From 58dcb8523ce81544f663606a9eed911fec14b0cd Mon Sep 17 00:00:00 2001 From: John Levon Date: Mon, 27 Aug 2001 01:19:32 +0000 Subject: [PATCH] add external material dialog to Qt2 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2594 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/ChangeLog | 9 + src/frontends/qt2/Dialogs.C | 5 +- src/frontends/qt2/GUIRunTime.C | 1 - src/frontends/qt2/Makefile.am | 1 - src/frontends/qt2/Makefile.dialogs | 7 + src/frontends/qt2/QBibtexDialog.C | 11 +- src/frontends/qt2/QExternal.C | 90 ++++ src/frontends/qt2/QExternal.h | 41 ++ src/frontends/qt2/QExternalDialog.C | 86 ++++ src/frontends/qt2/QExternalDialog.h | 39 ++ src/frontends/qt2/ui/QErrorDialog.ui | 2 +- src/frontends/qt2/ui/QExternalDialog.ui | 619 ++++++++++++++++++++++++ 12 files changed, 903 insertions(+), 8 deletions(-) create mode 100644 src/frontends/qt2/QExternal.C create mode 100644 src/frontends/qt2/QExternal.h create mode 100644 src/frontends/qt2/QExternalDialog.C create mode 100644 src/frontends/qt2/QExternalDialog.h create mode 100644 src/frontends/qt2/ui/QExternalDialog.ui diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index b786c1d5b3..7f88ac9715 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,12 @@ +2001-08-27 John Levon + + * Dialogs.C: + * Makefile.am: + * Makefile.dialogs: + * QExternal.[Ch]: + * QExternalDialog.[Ch]: + * ui/QExternalDialog.ui: add external dialog + 2001-08-26 John Levon * Dialogs.C: diff --git a/src/frontends/qt2/Dialogs.C b/src/frontends/qt2/Dialogs.C index 3b29f453ea..96611ea716 100644 --- a/src/frontends/qt2/Dialogs.C +++ b/src/frontends/qt2/Dialogs.C @@ -19,6 +19,7 @@ #include "QCitationDialog.h" #include "QErrorDialog.h" #include "QERTDialog.h" +#include "QExternalDialog.h" #include "QIndexDialog.h" #include "QRefDialog.h" #include "QURLDialog.h" @@ -30,6 +31,7 @@ #include "QCitation.h" #include "QError.h" #include "QERT.h" +#include "QExternal.h" #include "QIndex.h" #include "QParagraph.h" #include "QPrint.h" @@ -53,6 +55,7 @@ #include "controllers/ControlCitation.h" #include "controllers/ControlError.h" #include "controllers/ControlERT.h" +#include "controllers/ControlExternal.h" #include "controllers/ControlIndex.h" #include "controllers/ControlRef.h" #include "controllers/ControlSplash.h" @@ -60,7 +63,6 @@ #if 0 #include "controllers/ControlButtons.h" #include "controllers/ControlCitation.h" -#include "controllers/ControlExternal.h" #include "controllers/ControlFloat.h" #include "controllers/ControlGraphics.h" #include "controllers/ControlInclude.h" @@ -96,6 +98,7 @@ Dialogs::Dialogs(LyXView * lv) add(new GUICharacter(*lv, *this)); add(new GUIError(*lv, *this)); add(new GUIERT(*lv, *this)); + add(new GUIExternal(*lv, *this)); add(new GUIIndex(*lv, *this)); add(new GUIRef(*lv, *this)); add(new GUIUrl(*lv, *this)); diff --git a/src/frontends/qt2/GUIRunTime.C b/src/frontends/qt2/GUIRunTime.C index 802a7379d7..842d80caa5 100644 --- a/src/frontends/qt2/GUIRunTime.C +++ b/src/frontends/qt2/GUIRunTime.C @@ -58,7 +58,6 @@ int GUIRunTime::initApplication(int argc, char * argv[]) // I belive this is done in the wrong place, imo this should // be done in lyx_gui.C similar to how/where xforms does it (Lgb) static QApplication a(argc, argv); - return 0; } diff --git a/src/frontends/qt2/Makefile.am b/src/frontends/qt2/Makefile.am index 5ea55f9767..c39d45a3fa 100644 --- a/src/frontends/qt2/Makefile.am +++ b/src/frontends/qt2/Makefile.am @@ -26,7 +26,6 @@ libqt2_la_OBJADD = \ ../xforms/FormBaseDeprecated.lo \ ../xforms/FormBrowser.lo \ ../xforms/FormDocument.lo \ - ../xforms/FormExternal.lo \ ../xforms/FormGraphics.lo \ ../xforms/FormInclude.lo \ ../xforms/FormIndex.lo \ diff --git a/src/frontends/qt2/Makefile.dialogs b/src/frontends/qt2/Makefile.dialogs index 5b8bec850f..0e169fd214 100644 --- a/src/frontends/qt2/Makefile.dialogs +++ b/src/frontends/qt2/Makefile.dialogs @@ -9,6 +9,7 @@ DIALOGS = \ QDocument \ QError \ QERT \ + QExternal \ QIndex \ QParagraph \ QPrint \ @@ -36,6 +37,8 @@ DIALOGSOURCES = \ QError.C QErrorDialog.C \ QERT.h QERTDialog.h \ QERT.C QERTDialog.C \ + QExternal.h QExternalDialog.h \ + QExternal.C QExternalDialog.C \ QIndex.h QIndexDialog.h \ QIndex.C QIndexDialog.C \ QParagraph.h QParagraphDialog.h \ @@ -64,6 +67,7 @@ MOCDIALOGS = \ QDocumentDialog_moc.C \ QErrorDialog_moc.C \ QERTDialog_moc.C \ + QExternalDialog_moc.C \ QIndexDialog_moc.C \ QParagraphDialog_moc.C \ QPrintDialog_moc.C \ @@ -91,6 +95,8 @@ UIDIALOGS = \ QErrorDialogBase.h \ QERTDialogBase.C \ QERTDialogBase.h \ + QExternalDialogBase.C \ + QExternalDialogBase.h \ QIndexDialogBase.h \ QIndexDialogBase.C \ QParagraphDialogBase.h \ @@ -117,6 +123,7 @@ UIMOCDIALOGS = \ QDocumentDialogBase_moc.C \ QErrorDialogBase_moc.C \ QERTDialogBase_moc.C \ + QExternalDialogBase_moc.C \ QIndexDialogBase_moc.C \ QParagraphDialogBase_moc.C \ QPrintDialogBase_moc.C \ diff --git a/src/frontends/qt2/QBibtexDialog.C b/src/frontends/qt2/QBibtexDialog.C index 41090aefeb..88a8f5bd4e 100644 --- a/src/frontends/qt2/QBibtexDialog.C +++ b/src/frontends/qt2/QBibtexDialog.C @@ -18,6 +18,7 @@ #include "Dialogs.h" #include "ControlBibtex.h" #include "gettext.h" +#include "debug.h" #include "support/filetools.h" @@ -40,10 +41,12 @@ void QBibtexDialog::change_adaptor() void QBibtexDialog::browsePressed() { - string file(QFileDialog::getOpenFileName(QString::null, - _("BibTeX style files (*.bst)"), this, 0, _("Select a BibTeX style")).latin1()); - if (!file.empty()) { - styleED->setText(ChangeExtension(OnlyFilename(file), "").c_str()); + QString file = QFileDialog::getOpenFileName(QString::null, + _("BibTeX style files (*.bst)"), this, 0, _("Select a BibTeX style")); + lyxerr << "HELLO" << std::endl; + if (!file.isNull()) { + lyxerr << "MONKEYS" << std::endl; + styleED->setText(ChangeExtension(OnlyFilename(file.latin1()), "").c_str()); form_->changed(); } } diff --git a/src/frontends/qt2/QExternal.C b/src/frontends/qt2/QExternal.C new file mode 100644 index 0000000000..28c3c31584 --- /dev/null +++ b/src/frontends/qt2/QExternal.C @@ -0,0 +1,90 @@ +/** + * \file QExternal.C + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#include +#include + +#include "LString.h" +#include "QExternalDialog.h" +#include "ControlExternal.h" +#include "QExternal.h" +#include "Qt2BC.h" +#include "gettext.h" + +#include +#include +#include +#include + +typedef Qt2CB > base_class; + +QExternal::QExternal(ControlExternal & c) + : base_class(c, _("External")) +{ +} + + +void QExternal::build_dialog() +{ + dialog_.reset(new QExternalDialog(this)); + + bc().setOK(dialog_->okPB); + bc().setApply(dialog_->applyPB); + bc().setCancel(dialog_->closePB); + bc().addReadOnly(dialog_->externalCO); + bc().addReadOnly(dialog_->fileED); + bc().addReadOnly(dialog_->browsePB); + + std::vector templates(controller().getTemplates()); + + for (std::vector::const_iterator cit = templates.begin(); + cit != templates.end(); ++cit) { + dialog_->externalCO->insertItem(cit->c_str(), -1); + } +} + + +void QExternal::update_contents() +{ + InsetExternal::Params const & params = controller().params(); + + dialog_->fileED->setText(params.filename.c_str()); + dialog_->paramsED->setText(params.parameters.c_str()); + + dialog_->externalCO->setCurrentItem(controller().getTemplateNumber(params.templ.lyxName)); + dialog_->externalTV->setText(controller().params().templ.helpText.c_str()); + isValid(); +} + + +string const & QExternal::helpText() +{ + controller().params().templ = controller().getTemplate(dialog_->externalCO->currentItem() + 1); + return controller().params().templ.helpText; +} + + +void QExternal::apply() +{ + controller().params().filename = + string(dialog_->fileED->text().latin1()); + controller().params().parameters = + string(dialog_->paramsED->text().latin1()); + + controller().params().templ = controller().getTemplate(dialog_->externalCO->currentItem() + 1); +} + + +bool QExternal::isValid() +{ + bool const valid = !string(dialog_->fileED->text()).empty(); + dialog_->viewPB->setEnabled(valid); + dialog_->editPB->setEnabled(valid); + dialog_->updatePB->setEnabled(valid); + return valid; +} diff --git a/src/frontends/qt2/QExternal.h b/src/frontends/qt2/QExternal.h new file mode 100644 index 0000000000..db81229615 --- /dev/null +++ b/src/frontends/qt2/QExternal.h @@ -0,0 +1,41 @@ +// -*- C++ -*- +/** + * \file QExternal.h + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#ifndef QEXTERNAL_H +#define QEXTERNAL_H + +#include "Qt2Base.h" + +class ControlExternal; +class QExternalDialog; + +class QExternal : + public Qt2CB > +{ + friend class QExternalDialog; + +public: + QExternal(ControlExternal &); + +protected: + virtual bool isValid(); + +private: + /// Apply changes + virtual void apply(); + /// update + virtual void update_contents(); + /// build the dialog + virtual void build_dialog(); + + /// get the right helptext + string const & helpText(); +}; + +#endif // QEXTERNAL_H diff --git a/src/frontends/qt2/QExternalDialog.C b/src/frontends/qt2/QExternalDialog.C new file mode 100644 index 0000000000..7fda93c980 --- /dev/null +++ b/src/frontends/qt2/QExternalDialog.C @@ -0,0 +1,86 @@ +/** + * \file QExternalDialog.C + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#include + +#include +#include +#include +#include +#include + + +#include "gettext.h" +#include "QExternalDialog.h" +#include "ControlExternal.h" +#include "Dialogs.h" +#include "QExternal.h" + +QExternalDialog::QExternalDialog(QExternal * form) + : QExternalDialogBase(0, 0, false, 0), + form_(form) +{ + connect(okPB, SIGNAL(clicked()), + form, SLOT(slotOK())); + connect(closePB, SIGNAL(clicked()), + form, SLOT(slotClose())); +} + + +void QExternalDialog::change_adaptor() +{ + form_->changed(); +} + + +void QExternalDialog::closeEvent(QCloseEvent * e) +{ + form_->slotWMHide(); + e->accept(); +} + + +void QExternalDialog::editClicked() +{ + form_->changed(); + form_->controller().editExternal(); +} + + +void QExternalDialog::viewClicked() +{ + form_->changed(); + form_->controller().viewExternal(); +} + + +void QExternalDialog::updateClicked() +{ + form_->changed(); + form_->controller().updateExternal(); +} + + +void QExternalDialog::browseClicked() +{ + string file(QFileDialog::getOpenFileName(QString::null, + _("External material (*)"), this, 0, _("Select external material")).latin1()); + if (!file.empty()) { + fileED->setText(file.c_str()); + form_->changed(); + } +} + + +void QExternalDialog::templateChanged() +{ + externalTV->setText(form_->helpText().c_str()); + + updatePB->setEnabled(!form_->controller().params().templ.automaticProduction); + form_->changed(); +} diff --git a/src/frontends/qt2/QExternalDialog.h b/src/frontends/qt2/QExternalDialog.h new file mode 100644 index 0000000000..f4581824bb --- /dev/null +++ b/src/frontends/qt2/QExternalDialog.h @@ -0,0 +1,39 @@ +/** + * \file QExternalDialog.h + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#ifndef QEXTERNALDIALOG_H +#define QEXTERNALDIALOG_H + +#include + +#include "ui/QExternalDialogBase.h" + +class QExternal; + +class QExternalDialog : public QExternalDialogBase +{ Q_OBJECT + +public: + QExternalDialog(QExternal * form); + +protected slots: + virtual void change_adaptor(); + virtual void editClicked(); + virtual void viewClicked(); + virtual void updateClicked(); + virtual void browseClicked(); + virtual void templateChanged(); + +protected: + virtual void closeEvent(QCloseEvent * e); + +private: + QExternal * form_; +}; + +#endif // QEXTERNALDIALOG_H diff --git a/src/frontends/qt2/ui/QErrorDialog.ui b/src/frontends/qt2/ui/QErrorDialog.ui index f06572a79b..cb3f590e9e 100644 --- a/src/frontends/qt2/ui/QErrorDialog.ui +++ b/src/frontends/qt2/ui/QErrorDialog.ui @@ -11,7 +11,7 @@ 0 0 - 368 + 360 236 diff --git a/src/frontends/qt2/ui/QExternalDialog.ui b/src/frontends/qt2/ui/QExternalDialog.ui new file mode 100644 index 0000000000..fc70a66aa6 --- /dev/null +++ b/src/frontends/qt2/ui/QExternalDialog.ui @@ -0,0 +1,619 @@ + +QExternalDialogBase + + QDialog + + name + QExternalDialogBase + + + geometry + + 0 + 0 + 432 + 417 + + + + caption + External Material + + + + margin + 11 + + + spacing + 6 + + + QLayoutWidget + + name + Layout14 + + + + margin + 0 + + + spacing + 6 + + + QLayoutWidget + + name + Layout5 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + templateLA + + + text + &Template + + + buddy + externalCO + + + toolTip + Available templates + + + + QComboBox + + name + externalCO + + + toolTip + Available templates + + + + + + + name + Spacer3_2 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + QLayoutWidget + + name + Layout11 + + + + margin + 0 + + + spacing + 6 + + + QTextView + + name + externalTV + + + toolTip + LaTeX error messages + + + + QLayoutWidget + + name + Layout9 + + + + margin + 0 + + + spacing + 6 + + + QPushButton + + name + editPB + + + text + &Edit file + + + toolTip + Edit the file externally + + + + QPushButton + + name + viewPB + + + text + &View file + + + toolTip + View the file + + + + QPushButton + + name + updatePB + + + text + &Update + + + toolTip + Update the material + + + + + name + Spacer2 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + + + QLayoutWidget + + name + Layout23 + + + + margin + 0 + + + spacing + 6 + + + QLayoutWidget + + name + Layout21 + + + + margin + 0 + + + spacing + 6 + + + QLayoutWidget + + name + Layout6 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + fileLA + + + text + &File + + + buddy + fileED + + + toolTip + Filename + + + + QLineEdit + + name + fileED + + + toolTip + Filename + + + + + + + name + Spacer5 + + + orientation + Vertical + + + sizeType + Minimum + + + sizeHint + + 20 + 20 + + + + + + + QLayoutWidget + + name + Layout20 + + + + margin + 0 + + + spacing + 6 + + + QPushButton + + name + browsePB + + + text + &Browse ... + + + + + name + Spacer4 + + + orientation + Vertical + + + sizeType + Minimum + + + sizeHint + + 20 + 20 + + + + + + + + name + Spacer2_2 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + QLayoutWidget + + name + Layout16 + + + + margin + 0 + + + spacing + 6 + + + QLayoutWidget + + name + Layout12 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + paramsLA + + + text + &Parameters + + + buddy + paramsED + + + toolTip + Parameters + + + + QLineEdit + + name + paramsED + + + toolTip + Parameters + + + + + + + name + Spacer1 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + QLayoutWidget + + name + Layout2 + + + + margin + 0 + + + spacing + 6 + + + + name + Spacer3 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QPushButton + + name + okPB + + + text + &OK + + + default + true + + + + QPushButton + + name + applyPB + + + text + &Apply + + + default + true + + + + QPushButton + + name + closePB + + + text + &Close + + + default + true + + + + + + + + + updatePB + clicked() + QExternalDialogBase + updateClicked() + + + viewPB + clicked() + QExternalDialogBase + viewClicked() + + + editPB + clicked() + QExternalDialogBase + editClicked() + + + externalCO + activated(const QString&) + QExternalDialogBase + templateChanged() + + + fileED + textChanged(const QString&) + QExternalDialogBase + change_adaptor() + + + browsePB + clicked() + QExternalDialogBase + browseClicked() + + + paramsED + textChanged(const QString&) + QExternalDialogBase + change_adaptor() + + browseClicked() + change_adaptor() + editClicked() + templateChanged() + updateClicked() + viewClicked() + + -- 2.39.2