From 406c793cd89705f693eaa107b51c575f900313b8 Mon Sep 17 00:00:00 2001 From: Edwin Leuven Date: Fri, 3 Nov 2006 11:24:27 +0000 Subject: [PATCH] * reorganisation of graphics dialog git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15707 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/QGraphics.C | 100 +--- src/frontends/qt4/QGraphicsDialog.C | 133 +++-- src/frontends/qt4/QGraphicsDialog.h | 10 +- src/frontends/qt4/ui/QGraphicsUi.ui | 887 ++++++++++++---------------- 4 files changed, 492 insertions(+), 638 deletions(-) diff --git a/src/frontends/qt4/QGraphics.C b/src/frontends/qt4/QGraphics.C index bd904c81cc..6dab88e6f2 100644 --- a/src/frontends/qt4/QGraphics.C +++ b/src/frontends/qt4/QGraphics.C @@ -33,10 +33,10 @@ #include "support/lstrings.h" #include "support/lyxlib.h" -#include -#include -#include -#include +#include +#include +#include +#include #include @@ -70,38 +70,20 @@ void QGraphics::build_dialog() bcview().setRestore(dialog_->restorePB); bcview().setCancel(dialog_->closePB); - bcview().addReadOnly(dialog_->rotateGB); bcview().addReadOnly(dialog_->latexoptions); bcview().addReadOnly(dialog_->subfigure); - bcview().addReadOnly(dialog_->subcaption); bcview().addReadOnly(dialog_->filenameL); bcview().addReadOnly(dialog_->filename); bcview().addReadOnly(dialog_->browsePB); bcview().addReadOnly(dialog_->unzipCB); bcview().addReadOnly(dialog_->filename); - bcview().addReadOnly(dialog_->lbX); - bcview().addReadOnly(dialog_->lbY); - bcview().addReadOnly(dialog_->rtX); - bcview().addReadOnly(dialog_->rtY); - bcview().addReadOnly(dialog_->lbXunit); - bcview().addReadOnly(dialog_->lbYunit); - bcview().addReadOnly(dialog_->rtXunit); - bcview().addReadOnly(dialog_->rtYunit); + bcview().addReadOnly(dialog_->bbFrame); bcview().addReadOnly(dialog_->draftCB); bcview().addReadOnly(dialog_->clip); bcview().addReadOnly(dialog_->unzipCB); - bcview().addReadOnly(dialog_->subfigure); - bcview().addReadOnly(dialog_->subcaption); - bcview().addReadOnly(dialog_->showCB); - bcview().addReadOnly(dialog_->Width); - bcview().addReadOnly(dialog_->Height); - bcview().addReadOnly(dialog_->displayCB); - bcview().addReadOnly(dialog_->displayscale); - bcview().addReadOnly(dialog_->widthUnit); - bcview().addReadOnly(dialog_->heightUnit); - bcview().addReadOnly(dialog_->aspectratio); - bcview().addReadOnly(dialog_->angle); - bcview().addReadOnly(dialog_->origin); + bcview().addReadOnly(dialog_->displayGB); + bcview().addReadOnly(dialog_->sizeGB); + bcview().addReadOnly(dialog_->rotationGB); bcview().addReadOnly(dialog_->latexoptions); bcview().addReadOnly(dialog_->getPB); @@ -238,47 +220,25 @@ void QGraphics::update_contents() } dialog_->showCB->setCurrentIndex(item); dialog_->showCB->setEnabled(igp.display != graphics::NoDisplay && !readOnly()); - dialog_->displayCB->setChecked(igp.display != graphics::NoDisplay); + dialog_->displayGB->setChecked(igp.display != graphics::NoDisplay); dialog_->displayscale->setEnabled(igp.display != graphics::NoDisplay && !readOnly()); - dialog_->displayscaleL->setEnabled(igp.display != graphics::NoDisplay && !readOnly()); dialog_->displayscale->setText(toqstr(convert(igp.lyxscale))); - //// the output section (width/height) - // set the length combo boxes - // only the width has the possibility for scale%. The original - // units are defined in lengthcommon.C - // 1. the width (a listttype) - dialog_->widthUnit->clear(); - dialog_->widthUnit->addItem(qt_("Scale%")); - for (int i = 0; i < num_units; i++) - dialog_->widthUnit->addItem(unit_name_gui[i]); - - if (!igp.scale.empty() - && !float_equal(convert(igp.scale), 0.0, 0.05) - || igp.width.empty()) { - dialog_->Width->setText(toqstr(igp.scale)); - dialog_->widthUnit->setCurrentIndex(0); - } else { - // no scale means default width/height - dialog_->Width->setText(toqstr(convert(igp.width.value()))); - // the width cannot have a unitDefault, because - // it is a "Scale%" or another user defined unit! - // +1 instead of the "Scale%" option - int unit_ = igp.width.unit(); - dialog_->widthUnit->setCurrentIndex(unit_ + 1); - } - // 2. the height (a lengthgcombo type) + // the output section (width/height) + dialog_->Scale->setText(toqstr(igp.scale)); + + lengthToWidgets(dialog_->Width, dialog_->widthUnit, + igp.width.asString(), unitDefault); + lengthToWidgets(dialog_->Height, dialog_->heightUnit, igp.height.asString(), unitDefault); - // enable height input in case of non "Scale%" as width-unit - bool use_height = (dialog_->widthUnit->currentIndex() > 0); - dialog_->heightL->setEnabled(use_height); - dialog_->Height->setEnabled(use_height); - dialog_->heightUnit->setEnabled(use_height); - dialog_->aspectratio->setChecked(igp.keepAspectRatio); + dialog_->scaleCB->setChecked(!igp.scale.empty() || igp.width.empty()); + + dialog_->Scale->setEnabled(!igp.scale.empty() || igp.width.empty()); + dialog_->angle->setText(toqstr(igp.rotateAngle)); dialog_->origin->clear(); @@ -358,23 +318,19 @@ void QGraphics::apply() default:; } - if (!dialog_->displayCB->isChecked()) + if (!dialog_->displayGB->isChecked()) igp.display = graphics::NoDisplay; - string value = fromqstr(dialog_->Width->text()); - if (dialog_->widthUnit->currentIndex() > 0 || isValidLength(value)) { - // width/height combination - igp.width = - widgetsToLength(dialog_->Width, dialog_->widthUnit); - igp.scale = string(); + if (dialog_->scaleCB->isChecked() + && !dialog_->Scale->text().isEmpty()) { + igp.scale = fromqstr(dialog_->Scale->text()); } else { - // scaling instead of a width - igp.scale = value; - igp.width = LyXLength(); + igp.scale = string(); } - value = fromqstr(dialog_->Height->text()); - igp.height = - LyXLength(widgetsToLength(dialog_->Height, dialog_->heightUnit)); + + igp.width = LyXLength(widgetsToLength(dialog_->Width, dialog_->widthUnit)); + + igp.height = LyXLength(widgetsToLength(dialog_->Height, dialog_->heightUnit)); igp.keepAspectRatio = dialog_->aspectratio->isChecked(); diff --git a/src/frontends/qt4/QGraphicsDialog.C b/src/frontends/qt4/QGraphicsDialog.C index ce6641d3fd..2b79726e09 100644 --- a/src/frontends/qt4/QGraphicsDialog.C +++ b/src/frontends/qt4/QGraphicsDialog.C @@ -14,8 +14,6 @@ #include "QGraphicsDialog.h" #include "QGraphics.h" -//Added by qt3to4: -#include #include "lengthcombo.h" #include "validators.h" @@ -25,9 +23,10 @@ #include "controllers/ControlGraphics.h" -#include -#include -#include +#include +#include +#include +#include using std::string; @@ -48,41 +47,62 @@ QGraphicsDialog::QGraphicsDialog(QGraphics * form) form, SLOT(slotClose())); connect(restorePB, SIGNAL(clicked()), form, SLOT(slotRestore())); - connect(editPB, SIGNAL(clicked()), - this, SLOT(edit_clicked())); - - connect( subfigure, SIGNAL( toggled(bool) ), subcaption, SLOT( setEnabled(bool) ) ); - connect( browsePB, SIGNAL( clicked() ), this, SLOT( browse_clicked() ) ); - connect( filename, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) ); - connect( filename, SIGNAL( textChanged(const QString&) ), this, SLOT( filenameChanged(const QString&) ) ); - connect( subcaption, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) ); - connect( subfigure, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) ); - connect( latexoptions, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) ); - connect( clip, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) ); - connect( lbX, SIGNAL( textChanged(const QString&) ), this, SLOT( change_bb() ) ); - connect( showCB, SIGNAL( activated(int) ), this, SLOT( change_adaptor() ) ); - connect( displayscale, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) ); - connect( Width, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) ); - connect( widthUnit, SIGNAL( activated(int) ), this, SLOT( change_WUnit() ) ); - connect( aspectratio, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) ); - connect( displayCB, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) ); - connect( draftCB, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) ); - connect( unzipCB, SIGNAL( stateChanged(int) ), this, SLOT( change_adaptor() ) ); - connect( displayCB, SIGNAL( toggled(bool) ), showCB, SLOT( setEnabled(bool) ) ); - connect( displayCB, SIGNAL( toggled(bool) ), displayscale, SLOT( setEnabled(bool) ) ); - connect( Height, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) ); - connect( heightUnit, SIGNAL( selectionChanged(LyXLength::UNIT) ), this, SLOT( change_adaptor() ) ); - connect( angle, SIGNAL( textChanged(const QString&) ), this, SLOT( change_adaptor() ) ); - connect( origin, SIGNAL( activated(int) ), this, SLOT( change_adaptor() ) ); - connect( getPB, SIGNAL( clicked() ), this, SLOT( getBB_clicked() ) ); - connect( getPB, SIGNAL( clicked() ), this, SLOT( change_adaptor() ) ); - connect( lbY, SIGNAL( textChanged(const QString&) ), this, SLOT( change_bb() ) ); - connect( rtX, SIGNAL( textChanged(const QString&) ), this, SLOT( change_bb() ) ); - connect( rtY, SIGNAL( textChanged(const QString&) ), this, SLOT( change_bb() ) ); - connect( lbXunit, SIGNAL( activated(int) ), this, SLOT( change_bb() ) ); - connect( lbYunit, SIGNAL( activated(int) ), this, SLOT( change_bb() ) ); - connect( rtXunit, SIGNAL( activated(int) ), this, SLOT( change_bb() ) ); - connect( rtYunit, SIGNAL( activated(int) ), this, SLOT( change_bb() ) ); + connect(filename, SIGNAL( textChanged(const QString&) ), + this, SLOT( change_adaptor() ) ); + connect(subcaption, SIGNAL( textChanged(const QString&) ), + this, SLOT( change_adaptor() ) ); + connect(subfigure, SIGNAL( toggled(bool) ), + this, SLOT( change_adaptor() ) ); + connect(latexoptions, SIGNAL( textChanged(const QString&) ), + this, SLOT( change_adaptor() ) ); + connect(clip, SIGNAL( stateChanged(int) ), + this, SLOT( change_adaptor() ) ); + connect(showCB, SIGNAL( currentIndexChanged(int) ), + this, SLOT( change_adaptor() ) ); + connect(displayscale, SIGNAL( textChanged(const QString&) ), + this, SLOT( change_adaptor() ) ); + connect(Width, SIGNAL( textChanged(const QString&) ), + this, SLOT( change_adaptor() ) ); + connect(aspectratio, SIGNAL( stateChanged(int) ), + this, SLOT( change_adaptor() ) ); + connect(draftCB, SIGNAL( stateChanged(int) ), + this, SLOT( change_adaptor() ) ); + connect(unzipCB, SIGNAL( stateChanged(int) ), + this, SLOT( change_adaptor() ) ); + connect(Height, SIGNAL( textChanged(const QString&) ), + this, SLOT( change_adaptor() ) ); + connect(heightUnit, SIGNAL( selectionChanged(lyx::LyXLength::UNIT) ), + this, SLOT( change_adaptor() ) ); + connect(widthUnit, SIGNAL( selectionChanged(lyx::LyXLength::UNIT) ), + this, SLOT( change_adaptor() ) ); + connect(angle, SIGNAL( textChanged(const QString&) ), + this, SLOT( change_adaptor() ) ); + connect(origin, SIGNAL( activated(int) ), + this, SLOT( change_adaptor() ) ); + connect(getPB, SIGNAL( clicked() ), + this, SLOT( change_adaptor() ) ); + connect(scaleCB, SIGNAL(toggled(bool)), + this, SLOT(change_adaptor()) ); + connect(Scale, SIGNAL( textChanged(const QString&) ), + this, SLOT( change_adaptor() ) ); + + connect(lbY, SIGNAL( textChanged(const QString&) ), + this, SLOT( change_bb() ) ); + connect(lbYunit, SIGNAL( activated(int) ), + this, SLOT( change_bb() ) ); + connect(rtY, SIGNAL( textChanged(const QString&) ), + this, SLOT( change_bb() ) ); + connect(rtYunit, SIGNAL( activated(int) ), + this, SLOT( change_bb() ) ); + + connect(lbX, SIGNAL( textChanged(const QString&) ), + this, SLOT( change_bb() ) ); + connect(lbXunit, SIGNAL( activated(int) ), + this, SLOT( change_bb() ) ); + connect(rtX, SIGNAL( textChanged(const QString&) ), + this, SLOT( change_bb() ) ); + connect(rtXunit, SIGNAL( activated(int) ), + this, SLOT( change_bb() ) ); angle->setValidator(new QDoubleValidator(-360, 360, 2, angle)); @@ -121,16 +141,6 @@ void QGraphicsDialog::change_bb() } -void QGraphicsDialog::change_WUnit() -{ - bool useHeight = (widthUnit->currentIndex() > 0); - Height->setEnabled(useHeight); - heightUnit->setEnabled(useHeight); - heightL->setEnabled(useHeight); - form_->changed(); -} - - void QGraphicsDialog::closeEvent(QCloseEvent * e) { form_->slotWMHide(); @@ -138,7 +148,7 @@ void QGraphicsDialog::closeEvent(QCloseEvent * e) } -void QGraphicsDialog::browse_clicked() +void QGraphicsDialog::on_browsePB_clicked() { docstring const str = form_->controller().browse(qstring_to_ucs4(filename->text())); @@ -147,22 +157,37 @@ void QGraphicsDialog::browse_clicked() } -void QGraphicsDialog::getBB_clicked() +void QGraphicsDialog::on_getPB_clicked() { form_->getBB(); } -void QGraphicsDialog::edit_clicked() +void QGraphicsDialog::on_editPB_clicked() { form_->controller().editGraphics(); } -void QGraphicsDialog::filenameChanged(const QString & filename) + +void QGraphicsDialog::on_filename_textChanged(const QString & filename) { editPB->setDisabled(filename.isEmpty()); } + +void QGraphicsDialog::on_scaleCB_toggled(bool setscale) +{ + Scale->setEnabled(setscale); + widthL->setDisabled(setscale); + Width->setDisabled(setscale); + widthUnit->setDisabled(setscale); + aspectratio->setDisabled(setscale); + bool noheight = setscale || aspectratio->checkState()==Qt::Checked; + heightL->setDisabled(noheight); + Height->setDisabled(noheight); + heightUnit->setDisabled(noheight); +} + } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt4/QGraphicsDialog.h b/src/frontends/qt4/QGraphicsDialog.h index be98f8b5fd..396e99d0af 100644 --- a/src/frontends/qt4/QGraphicsDialog.h +++ b/src/frontends/qt4/QGraphicsDialog.h @@ -33,11 +33,11 @@ public: protected Q_SLOTS: virtual void change_adaptor(); virtual void change_bb(); - virtual void change_WUnit(); - virtual void browse_clicked(); - virtual void getBB_clicked(); - virtual void edit_clicked(); - virtual void filenameChanged(const QString &); + virtual void on_browsePB_clicked(); + virtual void on_getPB_clicked(); + virtual void on_editPB_clicked(); + virtual void on_filename_textChanged(const QString &); + virtual void on_scaleCB_toggled(bool); protected: virtual void closeEvent(QCloseEvent * e); private: diff --git a/src/frontends/qt4/ui/QGraphicsUi.ui b/src/frontends/qt4/ui/QGraphicsUi.ui index 0cadf3ef74..81ffd0a64f 100644 --- a/src/frontends/qt4/ui/QGraphicsUi.ui +++ b/src/frontends/qt4/ui/QGraphicsUi.ui @@ -8,8 +8,8 @@ 0 0 - 412 - 411 + 432 + 332 @@ -38,6 +38,9 @@ + + 0 + &Graphics @@ -49,10 +52,56 @@ 6 - - + + + + File name of image + + + + + + + File name of image + + + &File: + + + filename + + + + + + + Select an image file + + + &Browse... + + + + + + + &Edit + + + false + + + false + + + + + - LyX Display + Output Size + + + true @@ -61,189 +110,98 @@ 6 - - - - true - - - Qt::NoFocus - - - % - - + + - - - - Display image in LyX - - - &Show in LyX - - + + - - - - Screen display - - - &Display: - - - showCB - - - - - + + true - 5 + 1 0 0 0 - Percentage to scale by in LyX + Width of image in output - - - - Percentage to scale by in LyX - - - Sca&le: - - - displayscale + + + + Qt::Horizontal - - - - - - Screen display + + + 61 + 20 + - - - Default - - - - - Monochrome - - - - - Grayscale - - - - - Color - - - + - - - - - - - Output - - - - 9 - - - 6 - - - - - true - - - &Width: - - - Width - - + + - - + + true - - Width of image in output - - - - - - - - - 3 - 5 + 1 + 0 0 0 - - - 0 - 0 - - - - Qt::StrongFocus - - Units of height value + Height of image in output - - + + true - - Height of image in output + + &Height: + + + Height - - + + + + &Scale Graphics (%): + + + + + true - &Height: + &Width: - Height + Width - + true @@ -259,32 +217,35 @@ - - + + - Rotation + Rotate Graphics - + + true + + - 11 + 9 6 - + Angle to rotate image by - A&ngle: + A&ngle (Degrees): angle - + @@ -299,7 +260,7 @@ - + The origin of the rotation @@ -312,7 +273,7 @@ - + The origin of the rotation @@ -322,75 +283,6 @@ - - - - 0 - - - 6 - - - - - Qt::Horizontal - - - QSizePolicy::MinimumExpanding - - - - 20 - 20 - - - - - - - - &Edit - - - false - - - false - - - - - - - File name of image - - - - - - - Select an image file - - - &Browse... - - - - - - - File name of image - - - &File: - - - filename - - - - - @@ -404,8 +296,31 @@ 6 - - + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Clip to bounding box values + + + Clip to &bounding box + + + + + true @@ -430,7 +345,7 @@ 6 - + &Left bottom: @@ -440,7 +355,35 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Right &top: @@ -450,146 +393,59 @@ - - - - 0 + + + + y: - - 6 + + + + + + y: - - - - x - - - - - - - - - - - - - - - - - y - - - - - - - - - - + - - - 0 - - - 6 + + + x: - - - - x - - - - - - - - - - - - - y - - - - - - - - - - - - - - - - - - Clip to bounding box values - - - Clip to &bounding box - - - - - - - Get bounding box from the (EPS) file - - - &Get from File - - - - - - - Qt::Horizontal - - - - 261 - 20 - - - + + + + + + x: + + + + + - + Qt::Horizontal - - QSizePolicy::Expanding - - 20 + 181 20 - - - - Qt::Vertical + + + + Get bounding box from the (EPS) file - - - 20 - 40 - + + &Get from File - + @@ -599,32 +455,12 @@ - 11 + 9 6 - - - - Is this just one part of a figure float ? - - - Su&bfigure - - - - - - - Don't uncompress image before exporting to LaTeX - - - Don't un&zip on export - - - - + Additional LaTeX options @@ -637,112 +473,184 @@ - + + + + 3 + 0 + 0 + 0 + + Additional LaTeX options - - + + - Draft mode + Don't uncompress image before exporting to LaTeX - &Draft mode + Don't un&zip on export - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 20 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 20 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 20 - 20 - - - - - - - - false - + + - The caption for the sub-figure + Draft mode - Ca&ption: - - - subcaption + &Draft mode - - - - false + + + + Subfigure - - The caption for the sub-figure + + true + + + true + + false + + + + 9 + + + 6 + + + + + The caption for the sub-figure + + + Ca&ption: + + + subcaption + + + + + + + + 3 + 0 + 0 + 0 + + + + The caption for the sub-figure + + + + - - - - Qt::Vertical + + + + Show in LyX - - QSizePolicy::Expanding + + true - - - 20 - 20 - + + true - + + + 9 + + + 6 + + + + + Screen display + + + &Display: + + + showCB + + + + + + + Screen display + + + + Default + + + + + Monochrome + + + + + Grayscale + + + + + Color + + + + + + + + Percentage to scale by in LyX + + + Sca&le on Screen (%): + + + displayscale + + + + + + + true + + + + 1 + 0 + 0 + 0 + + + + Percentage to scale by in LyX + + + + + @@ -845,7 +753,7 @@ LengthCombo - + QComboBox
lengthcombo.h
0 @@ -856,18 +764,15 @@ filename browsePB editPB - showCB - displayscale - displayCB + scaleCB + Scale Width - widthUnit Height heightUnit aspectratio angle origin clip - getPB lbX lbXunit lbY @@ -876,11 +781,11 @@ rtXunit rtY rtYunit - subfigure - subcaption + getPB latexoptions draftCB unzipCB + subcaption restorePB okPB applyPB @@ -889,82 +794,50 @@ - displayCB + aspectratio toggled(bool) - TextLabel1 - setEnabled(bool) + heightL + setDisabled(bool) - 112 - 269 + 201 + 193 - 74 + 81 158 - displayCB - toggled(bool) - scaleLA - setEnabled(bool) - - - 125 - 269 - - - 91 - 212 - - - - - subfigure - toggled(bool) - CaptionLA - setEnabled(bool) - - - 56 - 56 - - - 44 - 62 - - - - - subfigure + aspectratio toggled(bool) - subcaption - setEnabled(bool) + Height + setDisabled(bool) - 69 - 54 + 315 + 193 - 110 - 62 + 275 + 169 - displayCB + aspectratio toggled(bool) - displayscaleL - setEnabled(bool) + heightUnit + setDisabled(bool) - 53 - 260 + 337 + 193 - 157 - 235 + 337 + 167 -- 2.39.2