From: John Levon Date: Tue, 28 Aug 2001 03:35:17 +0000 (+0000) Subject: add graphics dialog - not quite working X-Git-Tag: 1.6.10~20743 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=db7cd3524deac2251fe70121c1398ec6fc5ace3e;p=features.git add graphics dialog - not quite working the controllers really do make this piss easy to do :)) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2602 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index bb4bd33d8a..ed2caa3e2c 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,15 @@ +2001-08-28 John Levon + + * ui/QCharacterDialog.ui: + * ui/QThesaurusDialog.ui: fix tab order + + * QGraphics.[Ch]: + * QGraphicsDialog.[Ch]: + * ui/QGraphicsDialog.ui: + * Makefile.am: + * Makefile.dialogs: + * Dialogs.C: add graphics dialog + 2001-08-28 John Levon * QThesaurus.C: clear selection on update diff --git a/src/frontends/qt2/Dialogs.C b/src/frontends/qt2/Dialogs.C index 6d57fcd392..3c313d843d 100644 --- a/src/frontends/qt2/Dialogs.C +++ b/src/frontends/qt2/Dialogs.C @@ -20,6 +20,7 @@ #include "QErrorDialog.h" #include "QERTDialog.h" #include "QExternalDialog.h" +#include "QGraphicsDialog.h" #include "QIncludeDialog.h" #include "QIndexDialog.h" #include "QRefDialog.h" @@ -34,6 +35,7 @@ #include "QError.h" #include "QERT.h" #include "QExternal.h" +#include "QGraphics.h" #include "QInclude.h" #include "QIndex.h" #include "QParagraph.h" @@ -60,6 +62,7 @@ #include "controllers/ControlError.h" #include "controllers/ControlERT.h" #include "controllers/ControlExternal.h" +#include "controllers/ControlGraphics.h" #include "controllers/ControlInclude.h" #include "controllers/ControlIndex.h" #include "controllers/ControlRef.h" @@ -70,7 +73,6 @@ #include "controllers/ControlButtons.h" #include "controllers/ControlCitation.h" #include "controllers/ControlFloat.h" -#include "controllers/ControlGraphics.h" #include "controllers/ControlLabel.h" #include "controllers/ControlLog.h" #include "controllers/ControlMinipage.h" @@ -103,6 +105,7 @@ Dialogs::Dialogs(LyXView * lv) add(new GUIError(*lv, *this)); add(new GUIERT(*lv, *this)); add(new GUIExternal(*lv, *this)); + add(new GUIGraphics(*lv, *this)); add(new GUIInclude(*lv, *this)); add(new GUIIndex(*lv, *this)); add(new GUIRef(*lv, *this)); diff --git a/src/frontends/qt2/Makefile.am b/src/frontends/qt2/Makefile.am index 20377d436a..37f17e1073 100644 --- a/src/frontends/qt2/Makefile.am +++ b/src/frontends/qt2/Makefile.am @@ -25,7 +25,6 @@ libqt2_la_OBJADD = \ ../xforms/FormBaseDeprecated.lo \ ../xforms/FormBrowser.lo \ ../xforms/FormDocument.lo \ - ../xforms/FormGraphics.lo \ ../xforms/FormIndex.lo \ ../xforms/FormInset.lo \ ../xforms/FormLog.lo \ diff --git a/src/frontends/qt2/Makefile.dialogs b/src/frontends/qt2/Makefile.dialogs index 1ff2358a10..15b80b36a6 100644 --- a/src/frontends/qt2/Makefile.dialogs +++ b/src/frontends/qt2/Makefile.dialogs @@ -10,6 +10,7 @@ DIALOGS = \ QError \ QERT \ QExternal \ + QGraphics \ QInclude \ QIndex \ QParagraph \ @@ -41,6 +42,8 @@ DIALOGSOURCES = \ QERT.C QERTDialog.C \ QExternal.h QExternalDialog.h \ QExternal.C QExternalDialog.C \ + QGraphics.h QGraphicsDialog.h \ + QGraphics.C QGraphicsDialog.C \ QInclude.h QIncludeDialog.h \ QInclude.C QIncludeDialog.C \ QIndex.h QIndexDialog.h \ @@ -74,6 +77,7 @@ MOCDIALOGS = \ QErrorDialog_moc.C \ QERTDialog_moc.C \ QExternalDialog_moc.C \ + QGraphicsDialog_moc.C \ QIncludeDialog_moc.C \ QIndexDialog_moc.C \ QParagraphDialog_moc.C \ @@ -105,6 +109,8 @@ UIDIALOGS = \ QERTDialogBase.h \ QExternalDialogBase.C \ QExternalDialogBase.h \ + QGraphicsDialogBase.C \ + QGraphicsDialogBase.h \ QIncludeDialogBase.h \ QIncludeDialogBase.C \ QIndexDialogBase.h \ @@ -136,6 +142,7 @@ UIMOCDIALOGS = \ QErrorDialogBase_moc.C \ QERTDialogBase_moc.C \ QExternalDialogBase_moc.C \ + QGraphicsDialogBase_moc.C \ QIncludeDialogBase_moc.C \ QIndexDialogBase_moc.C \ QParagraphDialogBase_moc.C \ diff --git a/src/frontends/qt2/QGraphics.C b/src/frontends/qt2/QGraphics.C new file mode 100644 index 0000000000..40a8bc4565 --- /dev/null +++ b/src/frontends/qt2/QGraphics.C @@ -0,0 +1,177 @@ +/** + * \file QGraphics.C + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#include + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "QGraphicsDialog.h" +#include "ControlGraphics.h" +#include "QGraphics.h" +#include "Qt2BC.h" +#include "gettext.h" +#include "debug.h" + +#include "support/lstrings.h" + +#include +#include +#include +#include +#include + +typedef Qt2CB > base_class; + +QGraphics::QGraphics(ControlGraphics & c) + : base_class(c, _("Graphics")) +{ +} + + +void QGraphics::build_dialog() +{ + dialog_.reset(new QGraphicsDialog(this)); + + bc().setOK(dialog_->okPB); + bc().setApply(dialog_->applyPB); + bc().setCancel(dialog_->closePB); + bc().addReadOnly(dialog_->filenameED); + bc().addReadOnly(dialog_->browsePB); + bc().addReadOnly(dialog_->widthED); + bc().addReadOnly(dialog_->widthCO); + bc().addReadOnly(dialog_->heightED); + bc().addReadOnly(dialog_->heightCO); + bc().addReadOnly(dialog_->scaleCB); + bc().addReadOnly(dialog_->rotateED); + bc().addReadOnly(dialog_->monochromeRB); + bc().addReadOnly(dialog_->grayscaleRB); + bc().addReadOnly(dialog_->colorRB); + bc().addReadOnly(dialog_->dontRB); + bc().addReadOnly(dialog_->subcaptionED); +} + + +namespace { + string const numtostr(double val) { + string a(tostr(val)); + if (a == "0") + a = ""; + return a; + } +} // namespace anon + +void QGraphics::update_contents() +{ + InsetGraphicsParams & igp = controller().params(); + + dialog_->filenameED->setText(igp.filename.c_str()); + + QRadioButton * button; + + switch (igp.display) { + case InsetGraphicsParams::COLOR: button = dialog_->colorRB; break; + case InsetGraphicsParams::GRAYSCALE: button = dialog_->grayscaleRB; break; + case InsetGraphicsParams::MONOCHROME: button = dialog_->monochromeRB; break; + case InsetGraphicsParams::NONE: button = dialog_->dontRB; break; + } + button->setChecked(true); + + int item = 0; + switch (igp.widthResize) { + case InsetGraphicsParams::INCH: item = 1; break; + case InsetGraphicsParams::PERCENT_PAGE: item = 2; break; + case InsetGraphicsParams::PERCENT_COLUMN: item = 3; break; + default: break; + } + + dialog_->widthCO->setCurrentItem(item); + + item = 0; + switch (igp.heightResize) { + case InsetGraphicsParams::INCH: item = 1; break; + case InsetGraphicsParams::PERCENT_PAGE: item = 2; break; + default: break; + } + + dialog_->heightCO->setCurrentItem(item); + + // FIXME: scale ??? + + dialog_->widthED->setText(numtostr(igp.widthSize).c_str()); + dialog_->heightED->setText(numtostr(igp.heightSize).c_str()); + dialog_->rotateED->setText(numtostr(igp.rotateAngle).c_str()); + + dialog_->subcaptionED->setText(igp.subcaptionText.c_str()); +} + + +void QGraphics::apply() +{ + InsetGraphicsParams & igp = controller().params(); + + if (dialog_->colorRB->isChecked()) + igp.display = InsetGraphicsParams::COLOR; + else if (dialog_->grayscaleRB->isChecked()) + igp.display = InsetGraphicsParams::GRAYSCALE; + else if (dialog_->monochromeRB->isChecked()) + igp.display = InsetGraphicsParams::MONOCHROME; + else + igp.display = InsetGraphicsParams::NONE; + + igp.subcaptionText = dialog_->subcaptionED->text().latin1(); + igp.subcaption = !igp.subcaptionText.empty(); + + switch (dialog_->widthCO->currentItem()) { + case 0: igp.widthResize = InsetGraphicsParams::CM; break; + case 1: igp.widthResize = InsetGraphicsParams::INCH; break; + case 2: igp.widthResize = InsetGraphicsParams::PERCENT_PAGE; break; + case 3: igp.widthResize = InsetGraphicsParams::PERCENT_COLUMN; break; + default:; + } + if (string(dialog_->widthED->text().latin1()).empty()) { + igp.widthResize = InsetGraphicsParams::DEFAULT_SIZE; + igp.widthSize = 0.0; + } else { + igp.widthSize = strToDbl(dialog_->widthED->text().latin1()); + } + + switch (dialog_->heightCO->currentItem()) { + case 0: igp.heightResize = InsetGraphicsParams::CM; break; + case 1: igp.heightResize = InsetGraphicsParams::INCH; break; + case 2: igp.heightResize = InsetGraphicsParams::PERCENT_PAGE; break; + default:; + } + if (string(dialog_->heightED->text().latin1()).empty()) { + igp.heightResize = InsetGraphicsParams::DEFAULT_SIZE; + igp.heightSize = 0.0; + } else { + igp.heightSize = strToDbl(dialog_->heightED->text().latin1()); + } + + // FIXME: scale ??? + + igp.rotateAngle = strToDbl(dialog_->rotateED->text().latin1()); + + igp.filename = dialog_->filenameED->text().latin1(); +} + + +void QGraphics::browse() +{ + string const & name = controller().Browse(dialog_->filenameED->text().latin1()); + if (!name.empty()) + dialog_->filenameED->setText(name.c_str()); +} + + +bool QGraphics::isValid() +{ + return !string(dialog_->filenameED->text().latin1()).empty(); +} diff --git a/src/frontends/qt2/QGraphics.h b/src/frontends/qt2/QGraphics.h new file mode 100644 index 0000000000..75253a7de8 --- /dev/null +++ b/src/frontends/qt2/QGraphics.h @@ -0,0 +1,48 @@ +// -*- C++ -*- +/** + * \file QGraphics.h + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#ifndef QGRAPHICS_H +#define QGRAPHICS_H + +#ifdef __GNUG__ +#pragma interface +#endif + +#include "Qt2Base.h" +#include "insets/insetgraphics.h" + +class ControlGraphics; +class QGraphicsDialog; + +/// +class QGraphics + : public Qt2CB > +{ +public: + /// + friend class QGraphicsDialog; + /// + QGraphics(ControlGraphics &); + +protected: + virtual bool isValid(); + +private: + /// Apply changes + virtual void apply(); + /// update + virtual void update_contents(); + /// build the dialog + virtual void build_dialog(); + + /// browse for a file + void browse(); +}; + +#endif // QGRAPHICS_H diff --git a/src/frontends/qt2/QGraphicsDialog.C b/src/frontends/qt2/QGraphicsDialog.C new file mode 100644 index 0000000000..51fc9510c7 --- /dev/null +++ b/src/frontends/qt2/QGraphicsDialog.C @@ -0,0 +1,53 @@ +/** + * \file QGraphicsDialog.C + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#include +#include + +#include +#include +#include + +#include "LString.h" + +#include "QGraphicsDialog.h" +#include "ControlGraphics.h" +#include "Dialogs.h" +#include "QGraphics.h" +#include "debug.h" + +QGraphicsDialog::QGraphicsDialog(QGraphics * form) + : QGraphicsDialogBase(0, 0, false, 0), + form_(form) +{ + connect(okPB, SIGNAL(clicked()), + form, SLOT(slotOK())); + connect(applyPB, SIGNAL(clicked()), + form, SLOT(slotOK())); + connect(closePB, SIGNAL(clicked()), + form, SLOT(slotClose())); +} + + +void QGraphicsDialog::change_adaptor() +{ + form_->changed(); +} + + +void QGraphicsDialog::closeEvent(QCloseEvent * e) +{ + form_->slotWMHide(); + e->accept(); +} + + +void QGraphicsDialog::browseClicked() +{ + form_->browse(); +} diff --git a/src/frontends/qt2/QGraphicsDialog.h b/src/frontends/qt2/QGraphicsDialog.h new file mode 100644 index 0000000000..1135c7fe19 --- /dev/null +++ b/src/frontends/qt2/QGraphicsDialog.h @@ -0,0 +1,35 @@ +/** + * \file QGraphicsDialog.h + * Copyright 2001 the LyX Team + * Read the file COPYING + * + * \author John Levon + */ + +#ifndef QGRAPHICSDIALOG_H +#define QGRAPHICSDIALOG_H + +#include + +#include "ui/QGraphicsDialogBase.h" + +class QGraphics; + +class QGraphicsDialog : public QGraphicsDialogBase +{ Q_OBJECT + +public: + QGraphicsDialog(QGraphics * form); + +protected slots: + virtual void change_adaptor(); + virtual void browseClicked(); + +protected: + virtual void closeEvent(QCloseEvent * e); + +private: + QGraphics * form_; +}; + +#endif // QGRAPHICSDIALOG_H diff --git a/src/frontends/qt2/ui/QCharacterDialog.ui b/src/frontends/qt2/ui/QCharacterDialog.ui index e9180c97fa..99afb11d2c 100644 --- a/src/frontends/qt2/ui/QCharacterDialog.ui +++ b/src/frontends/qt2/ui/QCharacterDialog.ui @@ -13,7 +13,7 @@ 0 0 - 372 + 368 256 @@ -576,8 +576,9 @@ toggleallCB sizeCO miscCO - applyPB + autoapplyCB okPB + applyPB closePB diff --git a/src/frontends/qt2/ui/QGraphicsDialog.ui b/src/frontends/qt2/ui/QGraphicsDialog.ui new file mode 100644 index 0000000000..f617ea86bc --- /dev/null +++ b/src/frontends/qt2/ui/QGraphicsDialog.ui @@ -0,0 +1,1022 @@ + +QGraphicsDialogBase +config.h +gettext.h + + QDialog + + name + QGraphicsDialogBase + + + geometry + + 0 + 0 + 348 + 368 + + + + caption + Graphics + + + + margin + 11 + + + spacing + 6 + + + QLayoutWidget + + name + Layout12 + + + + margin + 0 + + + spacing + 6 + + + QLayoutWidget + + name + Layout7 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + filenameLA + + + text + &Filename + + + buddy + filenameED + + + toolTip + + + + + QLineEdit + + name + filenameED + + + toolTip + File name to include + + + + + name + Spacer10 + + + orientation + Vertical + + + sizeType + Minimum + + + sizeHint + + 20 + 20 + + + + + + + QLayoutWidget + + name + Layout11 + + + + margin + 0 + + + spacing + 6 + + + QPushButton + + name + browsePB + + + text + &Browse ... + + + toolTip + Select a file + + + + + name + Spacer11 + + + orientation + Vertical + + + sizeType + Minimum + + + sizeHint + + 20 + 20 + + + + + + + + + QLayoutWidget + + name + Layout10 + + + + margin + 0 + + + spacing + 6 + + + QGroupBox + + name + parametersGB + + + title + Graphics parameters + + + + margin + 11 + + + spacing + 6 + + + + name + Spacer3_2 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout4 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + widthLA + + + text + &Width + + + buddy + widthED + + + toolTip + Width of graphics + + + + QLineEdit + + name + widthED + + + toolTip + Width of graphics + + + + QComboBox + + + text + cm + + + + + text + inches + + + + + text + % of page + + + + + text + % of column + + + + name + widthCO + + + sizePolicy + + 3 + 0 + + + + toolTip + Width units + + + + + + + name + Spacer4_2 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout6 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + heightLA + + + text + &Height + + + buddy + heightED + + + toolTip + Height of graphics + + + + QLineEdit + + name + heightED + + + toolTip + Height of graphics + + + + QComboBox + + + text + cm + + + + + text + inches + + + + + text + % of page + + + + name + heightCO + + + sizePolicy + + 3 + 0 + + + + toolTip + Height units + + + + + + + name + Spacer5_2 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout14 + + + + margin + 0 + + + spacing + 6 + + + QCheckBox + + name + scaleCB + + + text + Sca&le Height + + + toolTip + FIXME + + + + + name + Spacer11_2 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + + name + Spacer10_2 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout9 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + rotateLA + + + text + &Rotation + + + buddy + rotateED + + + toolTip + FIXME + + + + QLineEdit + + name + rotateED + + + toolTip + FIXME + + + + + name + Spacer2 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + + name + Spacer6_2 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QLayoutWidget + + name + Layout7 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + subcaptionLA + + + text + &Subcaption + + + buddy + subcaptionED + + + toolTip + The sub-caption of the figure + + + + QLineEdit + + name + subcaptionED + + + toolTip + The sub-caption for the figure + + + + + + + + QButtonGroup + + name + displayBG + + + title + LyX display + + + sizePolicy + + 5 + 7 + + + + + margin + 11 + + + spacing + 6 + + + + name + Spacer7 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QRadioButton + + name + monochromeRB + + + text + &Monochrome + + + toolTip + FIXME + + + + + name + Spacer4 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QRadioButton + + name + grayscaleRB + + + text + &Grayscale + + + toolTip + FIXME + + + + + name + Spacer5 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QRadioButton + + name + colorRB + + + text + &Color + + + toolTip + FIXME + + + + + name + Spacer6 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QRadioButton + + name + dontRB + + + text + &Don't display + + + toolTip + FIXME + + + + + name + Spacer1 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + + + + QLayoutWidget + + name + Layout13 + + + + 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 + + + + + + + + + grayscaleRB + toggled(bool) + QGraphicsDialogBase + change_adaptor() + + + colorRB + toggled(bool) + QGraphicsDialogBase + change_adaptor() + + + filenameED + textChanged(const QString&) + QGraphicsDialogBase + change_adaptor() + + + browsePB + clicked() + QGraphicsDialogBase + browseClicked() + + + monochromeRB + toggled(bool) + QGraphicsDialogBase + change_adaptor() + + + dontRB + toggled(bool) + QGraphicsDialogBase + change_adaptor() + + + heightCO + highlighted(int) + QGraphicsDialogBase + change_adaptor() + + + heightED + textChanged(const QString&) + QGraphicsDialogBase + change_adaptor() + + + widthED + textChanged(const QString&) + QGraphicsDialogBase + change_adaptor() + + + widthCO + highlighted(int) + QGraphicsDialogBase + change_adaptor() + + + rotateED + textChanged(const QString&) + QGraphicsDialogBase + change_adaptor() + + + subcaptionED + textChanged(const QString&) + QGraphicsDialogBase + change_adaptor() + + browseClicked() + change_adaptor() + + + filenameED + browsePB + widthED + widthCO + heightED + heightCO + scaleCB + rotateED + subcaptionED + monochromeRB + grayscaleRB + colorRB + dontRB + okPB + applyPB + closePB + + diff --git a/src/frontends/qt2/ui/QThesaurusDialog.ui b/src/frontends/qt2/ui/QThesaurusDialog.ui index 501c4b1174..0f3b3e4cbc 100644 --- a/src/frontends/qt2/ui/QThesaurusDialog.ui +++ b/src/frontends/qt2/ui/QThesaurusDialog.ui @@ -13,7 +13,7 @@ 0 0 - 482 + 478 442 @@ -80,6 +80,13 @@ name Spacer2 + + sizePolicy + + 7 + 1 + + orientation Horizontal @@ -474,8 +481,8 @@ selectionChanged(const QString &) - TabWidget2 entryED + TabWidget2 nounsLB verbsLB adjectivesLB