From 79f1b4a66b94e9262debce53b82ecd7da9f71d8b Mon Sep 17 00:00:00 2001 From: John Levon Date: Wed, 16 Oct 2002 21:26:35 +0000 Subject: [PATCH] Juergen's QSendto. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5429 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/ChangeLog | 12 +- src/frontends/qt2/Dialogs.C | 1 + src/frontends/qt2/Dialogs2.C | 4 +- src/frontends/qt2/Dialogs_impl.h | 7 +- src/frontends/qt2/Makefile.dialogs | 7 + src/frontends/qt2/QSendto.C | 101 ++++++++++ src/frontends/qt2/QSendto.h | 51 +++++ src/frontends/qt2/QSendtoDialog.C | 57 ++++++ src/frontends/qt2/QSendtoDialog.h | 42 ++++ src/frontends/qt2/ui/QSendtoDialog.ui | 267 ++++++++++++++++++++++++++ 10 files changed, 546 insertions(+), 3 deletions(-) create mode 100644 src/frontends/qt2/QSendto.C create mode 100644 src/frontends/qt2/QSendto.h create mode 100644 src/frontends/qt2/QSendtoDialog.C create mode 100644 src/frontends/qt2/QSendtoDialog.h create mode 100644 src/frontends/qt2/ui/QSendtoDialog.ui diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 462204f302..109d07fd78 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,13 @@ +2002-10-16 Juergen Spitzmueller + + * ui/QSendtoDialog.ui: + * QSendtoDialog.[Ch]: + * QSendto.[Ch]: + * Makefile.dialogs: + * Dialogs.C: + * Dialogs2.C: + * Dialogs_impl.h: Implement Sendto (Custom Export) dialog + 2002-10-16 Lars Gullik Bjønnes * qfont_loader.C (font_info): correct calculation of font size @@ -27,7 +37,7 @@ 2002-10-12 Dekel Tsur * qfont_loader.C (available): Implemented. - + 2002-10-09 Edwin Leuven * QDocument.C: Brand new document dialog diff --git a/src/frontends/qt2/Dialogs.C b/src/frontends/qt2/Dialogs.C index ec32c2ac41..bff0b0265c 100644 --- a/src/frontends/qt2/Dialogs.C +++ b/src/frontends/qt2/Dialogs.C @@ -65,6 +65,7 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d) print(lv, d), ref(lv, d), search(lv, d), + sendto(lv, d), spellchecker(lv, d), tabularcreate(lv, d), texinfo(lv, d), diff --git a/src/frontends/qt2/Dialogs2.C b/src/frontends/qt2/Dialogs2.C index e3190c7d0a..479dae737e 100644 --- a/src/frontends/qt2/Dialogs2.C +++ b/src/frontends/qt2/Dialogs2.C @@ -204,7 +204,9 @@ void Dialogs::showSearch() void Dialogs::showSendto() -{} +{ + pimpl_->sendto.controller().show(); +} void Dialogs::showSpellchecker() diff --git a/src/frontends/qt2/Dialogs_impl.h b/src/frontends/qt2/Dialogs_impl.h index 1af45e89f1..d91b502d66 100644 --- a/src/frontends/qt2/Dialogs_impl.h +++ b/src/frontends/qt2/Dialogs_impl.h @@ -96,7 +96,8 @@ #include "QRefDialog.h" #include "QSearch.h" #include "QSearchDialog.h" -//#include "QSendto.h" +#include "QSendto.h" +#include "QSendtoDialog.h" #include "QShowFile.h" #include "QShowFileDialog.h" #include "QSpellchecker.h" @@ -189,6 +190,9 @@ RefDialog; typedef GUI SearchDialog; +typedef GUI +SendtoDialog; + typedef GUI SpellcheckerDialog; @@ -240,6 +244,7 @@ struct Dialogs::Impl { PrintDialog print; RefDialog ref; SearchDialog search; + SendtoDialog sendto; SpellcheckerDialog spellchecker; TabularCreateDialog tabularcreate; TexinfoDialog texinfo; diff --git a/src/frontends/qt2/Makefile.dialogs b/src/frontends/qt2/Makefile.dialogs index 6ffb2a6365..a24279e122 100644 --- a/src/frontends/qt2/Makefile.dialogs +++ b/src/frontends/qt2/Makefile.dialogs @@ -23,6 +23,7 @@ DIALOGS = \ QPrint \ QRef \ QSearch \ + QSendto \ QShowFile \ QSpellchecker \ QTabularCreate \ @@ -77,6 +78,8 @@ DIALOGSOURCES = \ QRef.C QRefDialog.C \ QSearch.h QSearchDialog.h \ QSearch.C QSearchDialog.C \ + QSendto.h QSendtoDialog.h \ + QSendto.C QSendtoDialog.C \ QShowFile.h QShowFileDialog.h \ QShowFile.C QShowFileDialog.C \ QSpellchecker.h QSpellcheckerDialog.h \ @@ -119,6 +122,7 @@ MOCDIALOGS = \ QPrintDialog_moc.C \ QRefDialog_moc.C \ QSearchDialog_moc.C \ + QSendtoDialog_moc.C \ QShowFileDialog_moc.C \ QSpellcheckerDialog_moc.C \ QTabularCreateDialog_moc.C \ @@ -176,6 +180,8 @@ UIDIALOGS = \ QRefDialogBase.C \ QSearchDialogBase.h \ QSearchDialogBase.C \ + QSendtoDialogBase.h \ + QSendtoDialogBase.C \ QShowFileDialogBase.h \ QShowFileDialogBase.C \ QSpellcheckerDialogBase.h \ @@ -228,6 +234,7 @@ UIMOCDIALOGS = \ QPrintDialogBase_moc.C \ QRefDialogBase_moc.C \ QSearchDialogBase_moc.C \ + QSendtoDialogBase_moc.C \ QShowFileDialogBase_moc.C \ QSpellcheckerDialogBase_moc.C \ QTabularCreateDialogBase_moc.C \ diff --git a/src/frontends/qt2/QSendto.C b/src/frontends/qt2/QSendto.C new file mode 100644 index 0000000000..c0917d5412 --- /dev/null +++ b/src/frontends/qt2/QSendto.C @@ -0,0 +1,101 @@ +/** + * \file QSendto.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Juergen Spitzmueller + * + * Full author contact details are available in file CREDITS + */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "Qt2BC.h" +#include "ControlSendto.h" +#include "QSendtoDialog.h" +#include "QSendto.h" + +#include +#include +#include +#include + +#include "debug.h" +#include "gettext.h" +#include "converter.h" + +using std::vector; + +typedef Qt2CB > base_class; + +QSendto::QSendto() + : base_class(_("Send document to command")) +{ +} + + +void QSendto::build_dialog() +{ + dialog_.reset(new QSendtoDialog(this)); + + // Manage the ok, apply, restore and cancel/close buttons + bc().setOK(dialog_->okPB); + bc().setApply(dialog_->applyPB); + bc().setCancel(dialog_->closePB); +} + + +void QSendto::update_contents() +{ + all_formats_ = controller().allFormats(); + + // Check whether the current contents of the browser will be + // changed by loading the contents of formats + vector keys; + keys.resize(all_formats_.size()); + + vector::iterator result = keys.begin(); + vector::const_iterator it = all_formats_.begin(); + vector::const_iterator end = all_formats_.end(); + for (; it != end; ++it, ++result) { + *result = (*it)->prettyname(); + } + + // Reload the browser + dialog_->formatLB->clear(); + + for (vector::const_iterator it = keys.begin(); + it < keys.end(); ++it) { + dialog_->formatLB->insertItem(it->c_str()); + } + + dialog_->commandCO->insertItem(controller().getCommand().c_str()); +} + +void QSendto::apply() +{ + int const line(dialog_->formatLB->currentItem()); + + if (line < 0 || line > dialog_->formatLB->count()) + return; + + string const cmd(dialog_->commandCO->currentText().latin1()); + + controller().setFormat(all_formats_[line]); + controller().setCommand(cmd); +} + +bool QSendto::isValid() +{ + int const line(dialog_->formatLB->currentItem()); + + if (line < 0 || line > dialog_->formatLB->count()) + return false; + + else return dialog_->formatLB->count() != 0 && + !string(dialog_->commandCO->currentText()).empty(); +} diff --git a/src/frontends/qt2/QSendto.h b/src/frontends/qt2/QSendto.h new file mode 100644 index 0000000000..fc50d495ee --- /dev/null +++ b/src/frontends/qt2/QSendto.h @@ -0,0 +1,51 @@ +// -*- C++ -*- +/** + * \file QSendto.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Juergen Spitzmueller + * + * Full author contact details are available in file CREDITS + */ + +#ifndef QSENDTO_H +#define QSENDTO_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "Qt2Base.h" +#include + +class ControlSendto; +class QSendtoDialog; +class Format; + +/** This class provides a Qt implementation of the Custom Export Dialog. + */ +class QSendto + : public Qt2CB > +{ +public: + /// + friend class QSendtoDialog; + /// + QSendto(); + +protected: + virtual bool isValid(); + +private: + /// Apply from dialog + virtual void apply(); + /// Update the dialog + virtual void update_contents(); + /// Build the dialog + virtual void build_dialog(); + /// + std::vector all_formats_; +}; + +#endif // QSENDTO_H diff --git a/src/frontends/qt2/QSendtoDialog.C b/src/frontends/qt2/QSendtoDialog.C new file mode 100644 index 0000000000..19542aad3c --- /dev/null +++ b/src/frontends/qt2/QSendtoDialog.C @@ -0,0 +1,57 @@ +/** + * \file QSendtoDialog.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Juergen Spitzmueller + * + * Full author contact details are available in file CREDITS + */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include +#include "ControlSendto.h" +#include "gettext.h" +#include "debug.h" + +#include "converter.h" +#include "LString.h" + +#include +#include +#include +#include + +#include "QSendtoDialog.h" +#include "QSendto.h" + + +QSendtoDialog::QSendtoDialog(QSendto * form) + : QSendtoDialogBase(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 QSendtoDialog::changed_adaptor() +{ + form_->changed(); +} + + +void QSendtoDialog::closeEvent(QCloseEvent * e) +{ + form_->slotWMHide(); + e->accept(); +} diff --git a/src/frontends/qt2/QSendtoDialog.h b/src/frontends/qt2/QSendtoDialog.h new file mode 100644 index 0000000000..fff32b871f --- /dev/null +++ b/src/frontends/qt2/QSendtoDialog.h @@ -0,0 +1,42 @@ +// -*- C++ -*- +/** + * \file QSendtoDialog.h + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. + * + * \author Juergen Spitzmueller + * + * Full author contact details are available in file CREDITS + */ + +#ifndef QSENDTODIALOG_H +#define QSENDTODIALOG_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "ui/QSendtoDialogBase.h" + +class QSendto; + +class QSendtoDialog : public QSendtoDialogBase +{ + Q_OBJECT + +public: + QSendtoDialog(QSendto * form); + +protected slots: + virtual void changed_adaptor(); + virtual void slotFormatHighlighted(const QString&) {}; + virtual void slotFormatSelected(const QString&) {}; + +protected: + virtual void closeEvent(QCloseEvent * e); + +private: + QSendto * form_; +}; + +#endif // QSENDTODIALOG_H diff --git a/src/frontends/qt2/ui/QSendtoDialog.ui b/src/frontends/qt2/ui/QSendtoDialog.ui new file mode 100644 index 0000000000..f501a5bb29 --- /dev/null +++ b/src/frontends/qt2/ui/QSendtoDialog.ui @@ -0,0 +1,267 @@ + +QSendtoDialogBase +config.h +gettext.h + + QDialog + + name + QSendtoDialogBase + + + geometry + + 0 + 0 + 278 + 262 + + + + caption + Custom Export + + + sizeGripEnabled + true + + + QComboBox + + name + commandCO + + + geometry + + 15 + 185 + 245 + 22 + + + + sizePolicy + + 3 + 0 + + + + focusPolicy + StrongFocus + + + editable + true + + + sizeLimit + 10 + + + maxCount + 666 + + + insertionPolicy + AtTop + + + autoCompletion + true + + + duplicatesEnabled + false + + + toolTip + Process the converted file with this command ($$FName = file name) + + + + QLabel + + name + commandLA + + + geometry + + 15 + 165 + 126 + 16 + + + + text + &Command: + + + buddy + commandCO + + + + QLabel + + name + formatLA + + + geometry + + 15 + 10 + 115 + 16 + + + + text + &Export formats: + + + buddy + formatLB + + + + QListBox + + + text + New Item + + + + name + formatLB + + + geometry + + 15 + 30 + 245 + 125 + + + + maximumSize + + 32767 + 32767 + + + + toolTip + Available export converters + + + + QLayoutWidget + + name + Layout6 + + + geometry + + 11 + 225 + 256 + 24 + + + + + margin + 0 + + + spacing + 6 + + + QPushButton + + name + okPB + + + text + OK + + + autoDefault + true + + + default + false + + + + QPushButton + + name + applyPB + + + text + &Apply + + + + QPushButton + + name + closePB + + + text + Cancel + + + + + + + + formatLB + highlighted(const QString&) + QSendtoDialogBase + slotFormatHighlighted(const QString&) + + + formatLB + selected(const QString&) + QSendtoDialogBase + slotFormatSelected(const QString&) + + + formatLB + highlighted(const QString&) + QSendtoDialogBase + changed_adaptor() + + + commandCO + textChanged(const QString&) + QSendtoDialogBase + changed_adaptor() + + changed_adaptor() + slotFormatHighlighted(const QString&) + slotFormatSelected(const QString&) + + + formatLB + okPB + applyPB + closePB + + -- 2.39.5