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"
30 QPreambleDialog::QPreambleDialog(QPreamble * form)
31 : QPreambleDialogBase(0, 0, false, 0),
34 connect(okPB, SIGNAL(clicked()),
35 form, SLOT(slotOK()));
36 connect(applyPB, SIGNAL(clicked()),
37 form, SLOT(slotApply()));
38 connect(closePB, SIGNAL(clicked()),
39 form, SLOT(slotClose()));
43 void QPreambleDialog::closeEvent(QCloseEvent * e)
50 void QPreambleDialog::change_adaptor()
56 void QPreambleDialog::editClicked()
59 string editor = GetEnv("EDITOR");
61 static string lastentry = "";
62 editor = QInputDialog::getText(
63 _("Enter editor program"), _("Editor"), QLineEdit::Normal,
64 lastentry.c_str()).latin1();
70 string const text(preambleLE->text().latin1());
71 string const filename(lyx::tempName("", "preamble"));
72 std::ofstream file(filename.c_str());
82 editor += " " + filename;
84 // FIXME: synchronous, ugh. Make async when moved to controllers ?
85 Systemcalls sys(Systemcalls::Wait, editor);
87 std::ifstream in(filename.c_str());
95 while (getline(in, line)) {
96 newtext += line + "\n";
100 lyx::unlink(filename);
101 preambleLE->setText(newtext.c_str());