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 <qpushbutton.h>
13 #include <qmultilineedit.h>
14 #include <qinputdialog.h>
16 #include "QPreambleDialog.h"
18 #include "QPreamble.h"
20 #include "support/lyxlib.h"
21 #include "support/syscall.h"
22 #include "support/filetools.h"
25 #include "QtLyXView.h"
26 #include "ControlPreamble.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"), lastentry.c_str()).latin1();
67 string const text(preambleLE->text().latin1());
68 string const filename(lyx::tempName("", "preamble"));
69 std::ofstream file(filename.c_str());
79 editor += " " + filename;
81 // FIXME: synchronous, ugh. Make async when moved to controllers ?
82 Systemcalls sys(Systemcalls::Wait, editor);
84 std::ifstream in(filename.c_str());
92 while (getline(in, line)) {
93 newtext += line + "\n";
97 lyx::unlink(filename);
98 preambleLE->setText(newtext.c_str());