From c248ed757beef1162c5b3d55c3f4a2ec76933dc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?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 | 429 +++++++++++++++++------------ 3 files changed, 314 insertions(+), 191 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,6 +448,50 @@ LaTe&X and LyX options + + 9 + + + 6 + + + + + Don't uncompress image before exporting to LaTeX + + + Don't un&zip on export + + + + + + + Qt::Horizontal + + + + 161 + 20 + + + + + + + + + 0 + 0 + 0 + 0 + + + + Additional LaTeX options + + + @@ -538,40 +505,20 @@ - - - - - 0 - 0 - + + + + Qt::Vertical - - Additional LaTeX options + + + 354 + 81 + - + - - - - Draft mode - - - &Draft mode - - - - - - - Don't uncompress image before exporting to LaTeX - - - Don't un&zip on export - - - - + Qt::StrongFocus @@ -595,45 +542,15 @@ 6 - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - Graphics having the same group name will share the same parameters - - - Grou&p Name: - - - groupId - - - true - + + 0 + 0 0 0 @@ -656,36 +573,202 @@ - - + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 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 + + - Group Name to be set up from the current parameters. Use context menu to assign the existing one. + + + + Assigned to grou&p: + + + groupCO + + + + + + + Click to define a new graphics group + + + De&fine new group... + + + + + + + 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 + + + + +