mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 10:18:50 +00:00
added pre-amble dialog with icky $EDITOR support
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2612 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
eed0649017
commit
621c062434
@ -1,3 +1,12 @@
|
||||
2001-08-29 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* QPreamble.[Ch]:
|
||||
* QPreambleDialog.[Ch]:
|
||||
* ui/QPreambleDialog.ui:
|
||||
* Makefile.am:
|
||||
* Makefile.dialogs:
|
||||
* Dialogs.C: add pre-amble dialog
|
||||
|
||||
2001-08-29 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* ui/QIndexDialog.ui:
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "QIndexDialog.h"
|
||||
#include "QLogDialog.h"
|
||||
#include "QMinipageDialog.h"
|
||||
#include "QPreambleDialog.h"
|
||||
#include "QRefDialog.h"
|
||||
#include "QTabularCreateDialog.h"
|
||||
#include "QThesaurusDialog.h"
|
||||
@ -45,6 +46,7 @@
|
||||
#include "QLog.h"
|
||||
#include "QMinipage.h"
|
||||
#include "QParagraph.h"
|
||||
#include "QPreamble.h"
|
||||
#include "QPrint.h"
|
||||
#include "QRef.h"
|
||||
#include "QSearch.h"
|
||||
@ -74,6 +76,7 @@
|
||||
#include "controllers/ControlIndex.h"
|
||||
#include "controllers/ControlLog.h"
|
||||
#include "controllers/ControlMinipage.h"
|
||||
#include "controllers/ControlPreamble.h"
|
||||
#include "controllers/ControlRef.h"
|
||||
#include "controllers/ControlSplash.h"
|
||||
#include "controllers/ControlTabularCreate.h"
|
||||
@ -85,7 +88,6 @@
|
||||
#include "controllers/ControlCitation.h"
|
||||
#include "controllers/ControlFloat.h"
|
||||
#include "controllers/ControlLabel.h"
|
||||
#include "controllers/ControlPreamble.h"
|
||||
#include "controllers/ControlPrint.h"
|
||||
#include "controllers/ControlRef.h"
|
||||
#include "controllers/ControlSearch.h"
|
||||
@ -117,6 +119,7 @@ Dialogs::Dialogs(LyXView * lv)
|
||||
add(new GUIIndex<QIndex, Qt2BC>(*lv, *this));
|
||||
add(new GUILog<QLog, Qt2BC>(*lv, *this));
|
||||
add(new GUIMinipage<QMinipage, Qt2BC>(*lv, *this));
|
||||
add(new GUIPreamble<QPreamble, Qt2BC>(*lv, *this));
|
||||
add(new GUIRef<QRef, Qt2BC>(*lv, *this));
|
||||
add(new GUITabularCreate<QTabularCreate, Qt2BC>(*lv, *this));
|
||||
add(new GUIThesaurus<QThesaurus, Qt2BC>(*lv, *this));
|
||||
|
@ -27,7 +27,6 @@ libqt2_la_OBJADD = \
|
||||
../xforms/FormDocument.lo \
|
||||
../xforms/FormIndex.lo \
|
||||
../xforms/FormInset.lo \
|
||||
../xforms/FormPreamble.lo \
|
||||
../xforms/FormPreferences.lo \
|
||||
../xforms/FormRef.lo \
|
||||
../xforms/FormTabular.lo \
|
||||
|
@ -16,6 +16,7 @@ DIALOGS = \
|
||||
QLog \
|
||||
QMinipage \
|
||||
QParagraph \
|
||||
QPreamble \
|
||||
QPrint \
|
||||
QRef \
|
||||
QSearch \
|
||||
@ -57,6 +58,8 @@ DIALOGSOURCES = \
|
||||
QMinipage.C QMinipageDialog.C \
|
||||
QParagraph.h QParagraphDialog.h \
|
||||
QParagraph.C QParagraphDialog.C \
|
||||
QPreamble.h QPreambleDialog.h \
|
||||
QPreamble.C QPreambleDialog.C \
|
||||
QPrint.h QPrintDialog.h \
|
||||
QPrint.C QPrintDialog.C \
|
||||
QRef.h QRefDialog.h \
|
||||
@ -92,6 +95,7 @@ MOCDIALOGS = \
|
||||
QLogDialog_moc.C \
|
||||
QMinipageDialog_moc.C \
|
||||
QParagraphDialog_moc.C \
|
||||
QPreambleDialog_moc.C \
|
||||
QPrintDialog_moc.C \
|
||||
QRefDialog_moc.C \
|
||||
QSearchDialog_moc.C \
|
||||
@ -133,6 +137,8 @@ UIDIALOGS = \
|
||||
QMinipageDialogBase.C \
|
||||
QParagraphDialogBase.h \
|
||||
QParagraphDialogBase.C \
|
||||
QPreambleDialogBase.h \
|
||||
QPreambleDialogBase.C \
|
||||
QPrintDialogBase.h \
|
||||
QPrintDialogBase.C \
|
||||
QRefDialogBase.h \
|
||||
@ -166,6 +172,7 @@ UIMOCDIALOGS = \
|
||||
QLogDialogBase_moc.C \
|
||||
QMinipageDialogBase_moc.C \
|
||||
QParagraphDialogBase_moc.C \
|
||||
QPreambleDialogBase_moc.C \
|
||||
QPrintDialogBase_moc.C \
|
||||
QRefDialogBase_moc.C \
|
||||
QSearchDialogBase_moc.C \
|
||||
|
54
src/frontends/qt2/QPreamble.C
Normal file
54
src/frontends/qt2/QPreamble.C
Normal file
@ -0,0 +1,54 @@
|
||||
/**
|
||||
* \file QPreamble.C
|
||||
* Copyright 2001 the LyX Team
|
||||
* Read the file COPYING
|
||||
*
|
||||
* \author John Levon <moz@compsoc.man.ac.uk>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <fstream>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include <qmultilineedit.h>
|
||||
#include <qpushbutton.h>
|
||||
|
||||
#include "QPreambleDialog.h"
|
||||
#include "QPreamble.h"
|
||||
#include "Qt2BC.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#include "QtLyXView.h"
|
||||
#include "ControlPreamble.h"
|
||||
|
||||
typedef Qt2CB<ControlPreamble, Qt2DB<QPreambleDialog> > base_class;
|
||||
|
||||
QPreamble::QPreamble(ControlPreamble & c)
|
||||
: base_class(c, _("LaTeX Preamble"))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void QPreamble::build_dialog()
|
||||
{
|
||||
dialog_.reset(new QPreambleDialog(this));
|
||||
|
||||
bc().setOK(dialog_->okPB);
|
||||
bc().setApply(dialog_->applyPB);
|
||||
bc().setCancel(dialog_->closePB);
|
||||
}
|
||||
|
||||
|
||||
void QPreamble::update_contents()
|
||||
{
|
||||
dialog_->preambleLE->setText(controller().params().c_str());
|
||||
}
|
||||
|
||||
|
||||
void QPreamble::apply()
|
||||
{
|
||||
controller().params() = dialog_->preambleLE->text().latin1();
|
||||
}
|
41
src/frontends/qt2/QPreamble.h
Normal file
41
src/frontends/qt2/QPreamble.h
Normal file
@ -0,0 +1,41 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file QPreamble.h
|
||||
* Copyright 2001 the LyX Team
|
||||
* Read the file COPYING
|
||||
*
|
||||
* \author John Levon <moz@compsoc.man.ac.uk>
|
||||
*/
|
||||
|
||||
#ifndef QPREAMBLE_H
|
||||
#define QPREAMBLE_H
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "Qt2Base.h"
|
||||
|
||||
class ControlPreamble;
|
||||
class QPreambleDialog;
|
||||
|
||||
///
|
||||
class QPreamble
|
||||
: public Qt2CB<ControlPreamble, Qt2DB<QPreambleDialog> >
|
||||
{
|
||||
public:
|
||||
///
|
||||
friend class QPreambleDialog;
|
||||
///
|
||||
QPreamble(ControlPreamble &);
|
||||
|
||||
private:
|
||||
/// Apply changes
|
||||
virtual void apply();
|
||||
/// update
|
||||
virtual void update_contents();
|
||||
/// build the dialog
|
||||
virtual void build_dialog();
|
||||
};
|
||||
|
||||
#endif // QPREAMBLE_H
|
99
src/frontends/qt2/QPreambleDialog.C
Normal file
99
src/frontends/qt2/QPreambleDialog.C
Normal file
@ -0,0 +1,99 @@
|
||||
/**
|
||||
* \file QPreambleDialog.C
|
||||
* Copyright 2001 the LyX Team
|
||||
* Read the file COPYING
|
||||
*
|
||||
* \author John Levon <moz@compsoc.man.ac.uk>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <fstream>
|
||||
|
||||
#include <qpushbutton.h>
|
||||
#include <qmultilineedit.h>
|
||||
#include <qinputdialog.h>
|
||||
|
||||
#include "QPreambleDialog.h"
|
||||
#include "Dialogs.h"
|
||||
#include "QPreamble.h"
|
||||
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/syscall.h"
|
||||
#include "support/filetools.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#include "QtLyXView.h"
|
||||
#include "ControlPreamble.h"
|
||||
|
||||
QPreambleDialog::QPreambleDialog(QPreamble * form)
|
||||
: QPreambleDialogBase(0, 0, false, 0),
|
||||
form_(form)
|
||||
{
|
||||
connect(okPB, SIGNAL(clicked()),
|
||||
form, SLOT(slotOK()));
|
||||
connect(applyPB, SIGNAL(clicked()),
|
||||
form, SLOT(slotApply()));
|
||||
connect(closePB, SIGNAL(clicked()),
|
||||
form, SLOT(slotClose()));
|
||||
}
|
||||
|
||||
|
||||
void QPreambleDialog::closeEvent(QCloseEvent * e)
|
||||
{
|
||||
form_->slotWMHide();
|
||||
e->accept();
|
||||
}
|
||||
|
||||
|
||||
void QPreambleDialog::change_adaptor()
|
||||
{
|
||||
form_->changed();
|
||||
}
|
||||
|
||||
|
||||
void QPreambleDialog::editClicked()
|
||||
{
|
||||
// find an editor
|
||||
string editor = GetEnv("EDITOR");
|
||||
if (editor.empty()) {
|
||||
static string lastentry = "";
|
||||
editor = QInputDialog::getText(
|
||||
_("Enter editor program"), _("Editor"), lastentry.c_str()).latin1();
|
||||
if (editor.empty())
|
||||
return;
|
||||
lastentry = editor;
|
||||
}
|
||||
|
||||
string const text(preambleLE->text().latin1());
|
||||
string const filename(lyx::tempName("", "preamble"));
|
||||
std::ofstream file(filename.c_str());
|
||||
|
||||
// FIXME ?
|
||||
if (!file)
|
||||
return;
|
||||
|
||||
file << text;
|
||||
|
||||
file.close();
|
||||
|
||||
editor += " " + filename;
|
||||
|
||||
// FIXME: synchronous, ugh. Make async when moved to controllers ?
|
||||
Systemcalls sys(Systemcalls::Wait, editor);
|
||||
|
||||
std::ifstream in(filename.c_str());
|
||||
|
||||
if (!in)
|
||||
return;
|
||||
|
||||
string newtext;
|
||||
string line;
|
||||
|
||||
while (getline(in, line)) {
|
||||
newtext += line + "\n";
|
||||
}
|
||||
|
||||
in.close();
|
||||
lyx::unlink(filename);
|
||||
preambleLE->setText(newtext.c_str());
|
||||
}
|
35
src/frontends/qt2/QPreambleDialog.h
Normal file
35
src/frontends/qt2/QPreambleDialog.h
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* \file QPreambleDialog.h
|
||||
* Copyright 2001 the LyX Team
|
||||
* Read the file COPYING
|
||||
*
|
||||
* \author John Levon <moz@compsoc.man.ac.uk>
|
||||
*/
|
||||
|
||||
#ifndef QPreambleDIAPreamble_H
|
||||
#define QPreambleDIAPreamble_H
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "ui/QPreambleDialogBase.h"
|
||||
|
||||
class QPreamble;
|
||||
|
||||
class QPreambleDialog : public QPreambleDialogBase
|
||||
{ Q_OBJECT
|
||||
|
||||
public:
|
||||
QPreambleDialog(QPreamble * form);
|
||||
|
||||
protected slots:
|
||||
virtual void editClicked();
|
||||
virtual void change_adaptor();
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent * e);
|
||||
|
||||
private:
|
||||
QPreamble * form_;
|
||||
};
|
||||
|
||||
#endif // QPreambleDIAPreamble_H
|
175
src/frontends/qt2/ui/QPreambleDialog.ui
Normal file
175
src/frontends/qt2/ui/QPreambleDialog.ui
Normal file
@ -0,0 +1,175 @@
|
||||
<!DOCTYPE UI><UI>
|
||||
<class>QPreambleDialogBase</class>
|
||||
<include location="global">config.h</include>
|
||||
<include location="local">gettext.h</include>
|
||||
<widget>
|
||||
<class>QDialog</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>QPreambleDialogBase</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>geometry</name>
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>416</width>
|
||||
<height>328</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>caption</name>
|
||||
<string>LaTeX pre-amble</string>
|
||||
</property>
|
||||
<vbox>
|
||||
<property stdset="1">
|
||||
<name>margin</name>
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>spacing</name>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget>
|
||||
<class>QMultiLineEdit</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>preambleLE</cstring>
|
||||
</property>
|
||||
<property>
|
||||
<name>toolTip</name>
|
||||
<string>The LaTeX pre-amble</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget>
|
||||
<class>QLayoutWidget</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>Layout2</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property stdset="1">
|
||||
<name>margin</name>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>spacing</name>
|
||||
<number>6</number>
|
||||
</property>
|
||||
<widget>
|
||||
<class>QPushButton</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>editPB</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>&Edit ...</string>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>default</name>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property>
|
||||
<name>toolTip</name>
|
||||
<string>Edit the pre-amble in an external editor</string>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer>
|
||||
<property>
|
||||
<name>name</name>
|
||||
<cstring>Spacer3</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>orientation</name>
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>sizeType</name>
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property>
|
||||
<name>sizeHint</name>
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<widget>
|
||||
<class>QPushButton</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>okPB</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>&OK</string>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>default</name>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property>
|
||||
<name>toolTip</name>
|
||||
<string></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget>
|
||||
<class>QPushButton</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>applyPB</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>&Apply</string>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>default</name>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property>
|
||||
<name>toolTip</name>
|
||||
<string></string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget>
|
||||
<class>QPushButton</class>
|
||||
<property stdset="1">
|
||||
<name>name</name>
|
||||
<cstring>closePB</cstring>
|
||||
</property>
|
||||
<property stdset="1">
|
||||
<name>text</name>
|
||||
<string>&Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>preambleLE</sender>
|
||||
<signal>textChanged()</signal>
|
||||
<receiver>QPreambleDialogBase</receiver>
|
||||
<slot>change_adaptor()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>editPB</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>QPreambleDialogBase</receiver>
|
||||
<slot>editClicked()</slot>
|
||||
</connection>
|
||||
<slot access="public">change_adaptor()</slot>
|
||||
<slot access="public">editClicked()</slot>
|
||||
</connections>
|
||||
<tabstops>
|
||||
<tabstop>preambleLE</tabstop>
|
||||
<tabstop>editPB</tabstop>
|
||||
<tabstop>okPB</tabstop>
|
||||
<tabstop>applyPB</tabstop>
|
||||
<tabstop>closePB</tabstop>
|
||||
</tabstops>
|
||||
</UI>
|
Loading…
Reference in New Issue
Block a user