From: John Levon Date: Mon, 7 Oct 2002 16:41:10 +0000 (+0000) Subject: Juergen's wrap dialog for Qt X-Git-Tag: 1.6.10~18211 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=c8f0a3516c1dcbdff3ecc035d086d30ddc541032;p=features.git Juergen's wrap dialog for Qt git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5366 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index b509b1bb3e..0ca4a5e654 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,13 @@ +2002-09-28 Juergen Spitzmueller + + * ui/QWrapDialog.ui: + * QWrapDialog.[Ch]: + * QWrap.[Ch]: + * Makefile.dialogs: + * Dialogs.C: + * Dialogs2.C: + * Dialogs_impl.h: Implement Wrap figure dialog + 2002-09-25 Angus Leeming * Dialogs2.C: diff --git a/src/frontends/qt2/Dialogs.C b/src/frontends/qt2/Dialogs.C index 6d7962e9f4..467b04938b 100644 --- a/src/frontends/qt2/Dialogs.C +++ b/src/frontends/qt2/Dialogs.C @@ -74,5 +74,6 @@ Dialogs::Impl::Impl(LyXView & lv, Dialogs & d) toc(lv, d), url(lv, d), - vclogfile(lv, d) + vclogfile(lv, d), + wrap(lv, d) {} diff --git a/src/frontends/qt2/Dialogs2.C b/src/frontends/qt2/Dialogs2.C index d803ee634a..e0f8cb7f47 100644 --- a/src/frontends/qt2/Dialogs2.C +++ b/src/frontends/qt2/Dialogs2.C @@ -276,7 +276,7 @@ void Dialogs::showVCLogFile() } -void Dialogs::showWrap(InsetWrap * i) +void Dialogs::showWrap(InsetWrap * iw) { - // FIXME -} + pimpl_->wrap.controller().showInset(iw); +} diff --git a/src/frontends/qt2/Dialogs_impl.h b/src/frontends/qt2/Dialogs_impl.h index 9d3446e352..ba61490317 100644 --- a/src/frontends/qt2/Dialogs_impl.h +++ b/src/frontends/qt2/Dialogs_impl.h @@ -117,6 +117,8 @@ #include "QURLDialog.h" #include "QVCLog.h" #include "QVCLogDialog.h" +#include "QWrap.h" +#include "QWrapDialog.h" #include "Qt2BC.h" @@ -205,6 +207,9 @@ UrlDialog; typedef GUI VCLogFileDialog; +typedef GUI +WrapDialog; + struct Dialogs::Impl { Impl(LyXView & lv, Dialogs & d); @@ -240,6 +245,7 @@ struct Dialogs::Impl { TocDialog toc; UrlDialog url; VCLogFileDialog vclogfile; + WrapDialog wrap; }; #endif // DIALOGS_IMPL_H diff --git a/src/frontends/qt2/Makefile.dialogs b/src/frontends/qt2/Makefile.dialogs index c20e3db1d7..722256ab25 100644 --- a/src/frontends/qt2/Makefile.dialogs +++ b/src/frontends/qt2/Makefile.dialogs @@ -29,7 +29,8 @@ DIALOGS = \ QThesaurus \ QToc \ QURL \ - QVCLog + QVCLog \ + QWrap DIALOGSOURCES = \ QAbout.h QAboutDialog.h \ @@ -88,7 +89,9 @@ DIALOGSOURCES = \ QURL.h QURLDialog.h \ QURL.C QURLDialog.C \ QVCLog.h QVCLogDialog.h \ - QVCLog.C QVCLogDialog.C + QVCLog.C QVCLogDialog.C \ + QWrap.h QWrapDialog.h \ + QWrap.C QWrapDialog.C MOCDIALOGS = \ QAboutDialog_moc.C \ @@ -119,7 +122,8 @@ MOCDIALOGS = \ QThesaurusDialog_moc.C \ QTocDialog_moc.C \ QURLDialog_moc.C \ - QVCLogDialog_moc.C + QVCLogDialog_moc.C \ + QWrapDialog_moc.C UIDIALOGS = \ QAboutDialogBase.h \ @@ -181,7 +185,9 @@ UIDIALOGS = \ QURLDialogBase.h \ QURLDialogBase.C \ QVCLogDialogBase.h \ - QVCLogDialogBase.C + QVCLogDialogBase.C \ + QWrapDialogBase.h \ + QWrapDialogBase.C UIMOCDIALOGS = \ QAboutDialogBase_moc.C \ @@ -213,4 +219,5 @@ UIMOCDIALOGS = \ QThesaurusDialogBase_moc.C \ QTocDialogBase_moc.C \ QURLDialogBase_moc.C \ - QVCLogDialogBase_moc.C + QVCLogDialogBase_moc.C \ + QWrapDialogBase_moc.C diff --git a/src/frontends/qt2/QWrap.C b/src/frontends/qt2/QWrap.C new file mode 100644 index 0000000000..458896226b --- /dev/null +++ b/src/frontends/qt2/QWrap.C @@ -0,0 +1,106 @@ +/** + * \file QWrap.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 "debug.h" +#include "gettext.h" +#include "support/lstrings.h" +#include "LyXView.h" +#include "ControlWrap.h" + +#include "QWrap.h" +#include "QWrapDialog.h" +#include "Qt2BC.h" +#include "lengthcombo.h" + +#include +#include +#include + +typedef Qt2CB > base_class; + +QWrap::QWrap() + : base_class(_("Wrap Options")) +{ +} + + +void QWrap::build_dialog() +{ + dialog_.reset(new QWrapDialog(this)); + + bc().setRestore(dialog_->restorePB); + bc().setOK(dialog_->okPB); + bc().setApply(dialog_->applyPB); + bc().setCancel(dialog_->closePB); + + bc().addReadOnly(dialog_->widthED); + bc().addReadOnly(dialog_->unitsLC); + bc().addReadOnly(dialog_->valignCO); +} + + +void QWrap::apply() +{ + double const value = strToDbl(dialog_->widthED->text().latin1()); + LyXLength::UNIT unit = dialog_->unitsLC->currentLengthItem(); + if (string(dialog_->widthED->text().latin1()).empty()) + unit = LyXLength::UNIT_NONE; + + controller().params().pageWidth = LyXLength(value, unit); + + switch (dialog_->valignCO->currentItem()) { + case 0: + controller().params().placement.erase(); + break; + case 1: + controller().params().placement = "l"; + break; + case 2: + controller().params().placement = "r"; + break; + case 3: + controller().params().placement = "p"; + break; + } +} + + +namespace { + string const numtostr(double val) { + string a(tostr(val)); + if (a == "0") + a = ""; + return a; + } +} // namespace anon + + +void QWrap::update_contents() +{ + LyXLength len(controller().params().pageWidth); + dialog_->widthED->setText(numtostr(len.value()).c_str()); + dialog_->unitsLC->setCurrentItem(len.unit()); + + int item = 0; + if (controller().params().placement == "l") + item = 1; + else if (controller().params().placement == "r") + item = 2; + else if (controller().params().placement == "p") + item = 3; + + dialog_->valignCO->setCurrentItem(item); +} diff --git a/src/frontends/qt2/QWrap.h b/src/frontends/qt2/QWrap.h new file mode 100644 index 0000000000..3fc085df11 --- /dev/null +++ b/src/frontends/qt2/QWrap.h @@ -0,0 +1,43 @@ +// -*- C++ -*- +/** + * \file QWrap.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 QWRAP_H +#define QWRAP_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "Qt2Base.h" + +class ControlWrap; +class QWrapDialog; + + +class QWrap + : public Qt2CB > +{ +public: + + friend class QWrapDialog; + + QWrap(); + +private: + /// Apply changes + virtual void apply(); + /// update + virtual void update_contents(); + /// build the dialog + virtual void build_dialog(); +}; + +#endif // QWRAP_H diff --git a/src/frontends/qt2/QWrapDialog.C b/src/frontends/qt2/QWrapDialog.C new file mode 100644 index 0000000000..ea0bef8ff9 --- /dev/null +++ b/src/frontends/qt2/QWrapDialog.C @@ -0,0 +1,53 @@ +/** + * \file QWrapDialog.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 "ControlWrap.h" + +#include "QWrap.h" +#include "QWrapDialog.h" + +#include +#include +#include "lengthcombo.h" + +QWrapDialog::QWrapDialog(QWrap * form) + : QWrapDialogBase(0, 0, false, 0), + form_(form) +{ + connect(restorePB, SIGNAL(clicked()), + form, SLOT(slotRestore())); + connect(okPB, SIGNAL(clicked()), + form, SLOT(slotOK())); + connect(applyPB, SIGNAL(clicked()), + form, SLOT(slotApply())); + connect(closePB, SIGNAL(clicked()), + form, SLOT(slotClose())); +} + + +void QWrapDialog::closeEvent(QCloseEvent * e) +{ + form_->slotWMHide(); + e->accept(); +} + + +void QWrapDialog::change_adaptor() +{ + form_->changed(); +} diff --git a/src/frontends/qt2/QWrapDialog.h b/src/frontends/qt2/QWrapDialog.h new file mode 100644 index 0000000000..def8301d0c --- /dev/null +++ b/src/frontends/qt2/QWrapDialog.h @@ -0,0 +1,39 @@ +// -*- C++ -*- +/** + * \file QWrapDialog.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 QWRAPDIALOG_H +#define QWRAPDIALOG_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "ui/QWrapDialogBase.h" + +class QWrap; + +class QWrapDialog : public QWrapDialogBase +{ Q_OBJECT + +public: + QWrapDialog(QWrap * form); + +protected slots: + virtual void change_adaptor(); + +protected: + virtual void closeEvent(QCloseEvent * e); + +private: + QWrap * form_; +}; + +#endif // QWRAPDIALOG_H diff --git a/src/frontends/qt2/ui/QWrapDialog.ui b/src/frontends/qt2/ui/QWrapDialog.ui new file mode 100644 index 0000000000..7b1ee9aa89 --- /dev/null +++ b/src/frontends/qt2/ui/QWrapDialog.ui @@ -0,0 +1,382 @@ + +QWrapDialogBase +config.h +gettext.h +vspace.h + + QDialog + + name + QWrapDialogBase + + + geometry + + 0 + 0 + 369 + 111 + + + + caption + Wrap Options + + + sizeGripEnabled + true + + + layoutMargin + + + layoutSpacing + + + + margin + 11 + + + spacing + 6 + + + QLayoutWidget + + name + Layout3 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + widthLA + + + frameShape + MShape + + + frameShadow + MShadow + + + text + &Width: + + + buddy + widthED + + + + QComboBox + + + text + Default (outer) + + + + + text + Left + + + + + text + Right + + + + + text + Outer + + + + name + valignCO + + + toolTip + Vertical alignment + + + + QLabel + + name + valignLA + + + text + &Placement: + + + buddy + valignCO + + + + LengthCombo + + name + unitsLC + + + sizePolicy + + 3 + 0 + + + + minimumSize + + 40 + 22 + + + + focusPolicy + StrongFocus + + + toolTip + Units of width value + + + + QLineEdit + + name + widthED + + + sizePolicy + + 1 + 0 + + + + toolTip + Width value + + + + QLabel + + name + unitsLA + + + text + &Units: + + + buddy + unitsLC + + + + + + + name + Spacer1_2 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout17 + + + + margin + 0 + + + spacing + 6 + + + QPushButton + + name + restorePB + + + text + &Restore + + + default + false + + + toolTip + + + + + + name + Spacer1 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QPushButton + + name + okPB + + + text + &OK + + + default + false + + + toolTip + + + + + QPushButton + + name + applyPB + + + text + &Apply + + + default + false + + + toolTip + + + + + QPushButton + + name + closePB + + + text + &Close + + + default + true + + + + + + + + + LengthCombo +
lengthcombo.h
+ + -1 + -1 + + 0 + + 5 + 5 + + image0 + selectionChanged(LyXLength::UNIT) +
+
+ + + image0 + 789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758 + + + + + widthED + textChanged(const QString&) + QWrapDialogBase + change_adaptor() + + + unitsLC + selectionChanged(LyXLength::UNIT) + QWrapDialogBase + change_adaptor() + + + valignCO + highlighted(const QString&) + QWrapDialogBase + change_adaptor() + + change_adaptor() + + + widthED + unitsLC + valignCO + restorePB + applyPB + okPB + closePB + +