2 * \file QPreambleDialog.C
3 * Copyright 2001 the LyX Team
4 * Read the file COPYING
6 * \author John Levon <moz@compsoc.man.ac.uk>
12 #include "support/lyxlib.h"
13 #include "support/forkedcall.h"
14 #include "support/filetools.h"
17 #include "ControlPreamble.h"
19 #include "QPreamble.h"
20 #include "QPreambleDialog.h"
22 #include <qpushbutton.h>
23 #include <qmultilineedit.h>
24 #include <qinputdialog.h>
28 QPreambleDialog::QPreambleDialog(QPreamble * form)
29 : QPreambleDialogBase(0, 0, false, 0),
32 connect(okPB, SIGNAL(clicked()),
33 form, SLOT(slotOK()));
34 connect(applyPB, SIGNAL(clicked()),
35 form, SLOT(slotApply()));
36 connect(closePB, SIGNAL(clicked()),
37 form, SLOT(slotClose()));
41 void QPreambleDialog::closeEvent(QCloseEvent * e)
48 void QPreambleDialog::change_adaptor()
54 void QPreambleDialog::editClicked()
57 string editor = GetEnv("EDITOR");
59 static string lastentry = "";
60 editor = QInputDialog::getText(
61 _("Enter editor program"), _("Editor"), QLineEdit::Normal,
62 lastentry.c_str()).latin1();
68 string const text(preambleLE->text().latin1());
69 string const filename(lyx::tempName("", "preamble"));
70 std::ofstream file(filename.c_str());
80 editor += " " + filename;
85 if (call.startscript(Forkedcall::Wait, editor)) {
86 lyx::unlink(filename);
90 std::ifstream in(filename.c_str());
93 lyx::unlink(filename);
100 while (getline(in, line)) {
101 newtext += line + "\n";
105 lyx::unlink(filename);
106 preambleLE->setText(newtext.c_str());