2 * \file QPreambleDialog.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS
14 #pragma implementation
18 #include "support/lyxlib.h"
19 #include "support/forkedcall.h"
20 #include "support/filetools.h"
21 #include "qt_helpers.h"
23 #include "ControlPreamble.h"
25 #include "QPreamble.h"
26 #include "QPreambleDialog.h"
28 #include <qpushbutton.h>
29 #include <qmultilineedit.h>
30 #include <qinputdialog.h>
36 QPreambleDialog::QPreambleDialog(QPreamble * form)
37 : QPreambleDialogBase(0, 0, false, 0),
40 connect(okPB, SIGNAL(clicked()),
41 form, SLOT(slotOK()));
42 connect(applyPB, SIGNAL(clicked()),
43 form, SLOT(slotApply()));
44 connect(closePB, SIGNAL(clicked()),
45 form, SLOT(slotClose()));
49 void QPreambleDialog::closeEvent(QCloseEvent * e)
56 void QPreambleDialog::change_adaptor()
62 void QPreambleDialog::editClicked()
65 string editor = GetEnv("EDITOR");
67 static string lastentry;
68 editor = fromqstr(QInputDialog::getText(
69 qt_("Enter editor program"), qt_("Editor"), QLineEdit::Normal,
76 string const text(fromqstr(preambleLE->text()));
77 string const filename(lyx::tempName("", "preamble"));
78 std::ofstream file(filename.c_str());
88 editor += ' ' + filename;
93 if (call.startscript(Forkedcall::Wait, editor)) {
94 lyx::unlink(filename);
98 std::ifstream in(filename.c_str());
101 lyx::unlink(filename);
105 ostringstream newtext;
106 newtext << in.rdbuf();
108 // close the files before we delete the file
111 lyx::unlink(filename);
112 preambleLE->setText(toqstr(newtext.str()));