From c248ed757beef1162c5b3d55c3f4a2ec76933dc7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Fri, 16 Jan 2009 14:54:25 +0000 Subject: [PATCH] * GuiGraphics.{cpp,h}: * GraphicsUi.ui: - polish UI for graphics groups. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28184 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiGraphics.cpp | 73 ++++-- src/frontends/qt4/GuiGraphics.h | 3 +- src/frontends/qt4/ui/GraphicsUi.ui | 401 +++++++++++++++++------------ 3 files changed, 300 insertions(+), 177 deletions(-) diff --git a/src/frontends/qt4/GuiGraphics.cpp b/src/frontends/qt4/GuiGraphics.cpp index ec28016235..020e2034ae 100644 --- a/src/frontends/qt4/GuiGraphics.cpp +++ b/src/frontends/qt4/GuiGraphics.cpp @@ -15,6 +15,7 @@ #include #include "GuiGraphics.h" +#include "frontends/alert.h" #include "qt_helpers.h" #include "Validator.h" @@ -246,10 +247,9 @@ GuiGraphics::GuiGraphics(GuiView & lv) connect(displayGB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor())); connect(displayscale, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor())); - connect(groupId, SIGNAL(currentIndexChanged (const QString&)), - this, SLOT(change_group(const QString&))); - connect(groupId, SIGNAL(editTextChanged(const QString&)), - this, SLOT(change_adaptor())); + connect(groupCO, SIGNAL(currentIndexChanged(int)), + this, SLOT(change_group(int))); + displayscale->setValidator(new QIntValidator(displayscale)); bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy); @@ -294,21 +294,58 @@ void GuiGraphics::change_adaptor() } -void GuiGraphics::change_group(const QString &text) +void GuiGraphics::change_group(int index) { - if (text.isEmpty()) + QString const group = groupCO->itemData( + groupCO->currentIndex()).toString(); + + if (group.isEmpty()) { + changed(); return; + } - groupId->blockSignals(true); + string grp = graphics::getGroupParams(buffer(), fromqstr(group)); + if (grp.empty()) { + // group does not exist yet + changed(); + return; + } + + // filename might have been changed + QString current_filename = filename->text(); - string grp = graphics::getGroupParams(buffer(), fromqstr(text)); + // group exists: load params into the dialog + groupCO->blockSignals(true); InsetGraphicsParams par; InsetGraphics::string2params(grp, buffer(), par); par.filename = params_.filename; params_ = par; paramsToDialog(par); + groupCO->blockSignals(false); + + // reset filename + filename->setText(current_filename); - groupId->blockSignals(false); + changed(); +} + + +void GuiGraphics::on_newGroupPB_clicked() +{ + docstring newgroup; + if (!Alert::askForText(newgroup, _("Enter unique group name:"))) + return; + if (newgroup.empty()) + return; + if (groupCO->findData(toqstr(newgroup), Qt::MatchExactly) != -1) { + Alert::warning(_("Group already defined!"), + bformat(_("A graphics group with the name '%1$s' already exists."), + newgroup)); + return; + } + groupCO->addItem(toqstr(newgroup), toqstr(newgroup)); + groupCO->setCurrentIndex( + groupCO->findData(toqstr(newgroup), Qt::MatchExactly)); } @@ -557,16 +594,17 @@ void GuiGraphics::paramsToDialog(InsetGraphicsParams const & igp) graphics::getGraphicsGroups(buffer(), grp); set::const_iterator it = grp.begin(); set::const_iterator end = grp.end(); - groupId->blockSignals(true); - groupId->clear(); - groupId->addItem(""); + groupCO->blockSignals(true); + groupCO->clear(); for (; it != end; it++) - groupId->addItem(toqstr(*it)); + groupCO->addItem(toqstr(*it), toqstr(*it)); + groupCO->insertItem(0, qt_("None"), QString()); if (igp.groupId.empty()) - groupId->setCurrentIndex(-1); + groupCO->setCurrentIndex(0); else - groupId->setCurrentIndex(groupId->findText(toqstr(igp.groupId), Qt::MatchExactly)); - groupId->blockSignals(false); + groupCO->setCurrentIndex( + groupCO->findData(toqstr(igp.groupId), Qt::MatchExactly)); + groupCO->blockSignals(false); if (igp.width.value() == 0) lengthToWidgets(Width, widthUnit, _(autostr), unitDefault); @@ -708,7 +746,8 @@ void GuiGraphics::applyView() // more latex options igp.special = fromqstr(latexoptions->text()); - igp.groupId = fromqstr(groupId->currentText()); + igp.groupId = fromqstr(groupCO->itemData( + groupCO->currentIndex()).toString()); } diff --git a/src/frontends/qt4/GuiGraphics.h b/src/frontends/qt4/GuiGraphics.h index 27e34ac916..3f91126d4e 100644 --- a/src/frontends/qt4/GuiGraphics.h +++ b/src/frontends/qt4/GuiGraphics.h @@ -40,8 +40,9 @@ public: private Q_SLOTS: void change_adaptor(); - void change_group(const QString &); + void change_group(int); void change_bb(); + void on_newGroupPB_clicked(); void on_browsePB_clicked(); void on_getPB_clicked(); void on_scaleCB_toggled(bool); diff --git a/src/frontends/qt4/ui/GraphicsUi.ui b/src/frontends/qt4/ui/GraphicsUi.ui index 624e6ff197..8092f39d4b 100644 --- a/src/frontends/qt4/ui/GraphicsUi.ui +++ b/src/frontends/qt4/ui/GraphicsUi.ui @@ -10,7 +10,9 @@ - + + 0 + 0 0 0 @@ -28,93 +30,6 @@ 6 - - - - 6 - - - 0 - - - - - &Restore - - - false - - - false - - - - - - - Qt::Horizontal - - - QSizePolicy::MinimumExpanding - - - - 20 - 20 - - - - - - - - &OK - - - true - - - true - - - - - - - - 0 - 0 - - - - &Apply - - - false - - - false - - - - - - - - 0 - 0 - - - - Close - - - false - - - - - @@ -171,7 +86,9 @@ true - + + 0 + 0 0 0 @@ -186,7 +103,7 @@ Qt::Horizontal - + 61 20 @@ -203,7 +120,9 @@ true - + + 0 + 0 0 0 @@ -310,7 +229,9 @@ - + + 0 + 0 0 0 @@ -374,7 +295,7 @@ Qt::Vertical - + 20 40 @@ -398,7 +319,9 @@ true - + + 0 + 0 0 0 @@ -500,7 +423,7 @@ Qt::Horizontal - + 181 20 @@ -525,23 +448,41 @@ LaTe&X and LyX options - - + + 9 + + + 6 + + + - Additional LaTeX options + Don't uncompress image before exporting to LaTeX - LaTeX &options: - - - latexoptions + Don't un&zip on export + + + + Qt::Horizontal + + + + 161 + 20 + + + + - + + 0 + 0 0 0 @@ -551,27 +492,33 @@ - - + + - Draft mode + Additional LaTeX options - &Draft mode + LaTeX &options: + + + latexoptions - - - - Don't uncompress image before exporting to LaTeX + + + + Qt::Vertical - - Don't un&zip on export + + + 354 + 81 + - + - + Qt::StrongFocus @@ -595,12 +542,43 @@ 6 - + + + + true + + + + 0 + 0 + 0 + 0 + + + + Percentage to scale by in LyX + + + + + + + Percentage to scale by in LyX + + + Sca&le on Screen (%): + + + displayscale + + + + Qt::Horizontal - + 40 20 @@ -608,84 +586,189 @@ - + + + + + + + Assign the graphic to a group of graphics that share the same settings + + + Graphics Group + + + true + + + + 9 + + + 6 + + + + + Qt::Horizontal + + + + 121 + 51 + + + + + - + + 0 + 0 0 0 - Graphics having the same group name will share the same parameters + - Grou&p Name: + Assigned to grou&p: - groupId - - - - - - - true - - - - 0 - 0 - - - - Percentage to scale by in LyX + groupCO - - + + - Percentage to scale by in LyX + Click to define a new graphics group - Sca&le on Screen (%): - - - displayscale + De&fine new group... - - + + - Group Name to be set up from the current parameters. Use context menu to assign the existing one. + Select an existing group for the current graphics. - true + false - - - - Qt::Vertical + + + + Draft mode - - - 354 - 81 - + + &Draft mode - + + + + + 0 + + + 6 + + + + + &Restore + + + false + + + false + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 20 + 20 + + + + + + + + &OK + + + true + + + true + + + + + + + + 0 + 0 + 0 + 0 + + + + &Apply + + + false + + + false + + + + + + + + 0 + 0 + 0 + 0 + + + + Close + + + false + + + + + -- 2.39.2