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
19 #include "support/lyxlib.h"
20 #include "support/forkedcall.h"
21 #include "support/filetools.h"
24 #include "ControlPreamble.h"
26 #include "QPreamble.h"
27 #include "QPreambleDialog.h"
29 #include <qpushbutton.h>
30 #include <qmultilineedit.h>
31 #include <qinputdialog.h>
35 QPreambleDialog::QPreambleDialog(QPreamble * form)
36 : QPreambleDialogBase(0, 0, false, 0),
39 connect(okPB, SIGNAL(clicked()),
40 form, SLOT(slotOK()));
41 connect(applyPB, SIGNAL(clicked()),
42 form, SLOT(slotApply()));
43 connect(closePB, SIGNAL(clicked()),
44 form, SLOT(slotClose()));
48 void QPreambleDialog::closeEvent(QCloseEvent * e)
55 void QPreambleDialog::change_adaptor()
61 void QPreambleDialog::editClicked()
64 string editor = GetEnv("EDITOR");
66 static string lastentry = "";
67 editor = QInputDialog::getText(
68 _("Enter editor program"), _("Editor"), QLineEdit::Normal,
69 lastentry.c_str()).latin1();
75 string const text(preambleLE->text().latin1());
76 string const filename(lyx::tempName("", "preamble"));
77 std::ofstream file(filename.c_str());
87 editor += " " + filename;
92 if (call.startscript(Forkedcall::Wait, editor)) {
93 lyx::unlink(filename);
97 std::ifstream in(filename.c_str());
100 lyx::unlink(filename);
107 while (getline(in, line)) {
108 newtext += line + "\n";
112 lyx::unlink(filename);
113 preambleLE->setText(newtext.c_str());