+void GuiGraphics::changeGroup(int /* index */)
+{
+ QString const new_group = groupCO->itemData(
+ groupCO->currentIndex()).toString();
+
+ // check if the old group consisted only of this member
+ if (current_group_ != fromqstr(new_group)
+ && graphics::countGroupMembers(buffer(), current_group_) == 1) {
+ if (!new_group.isEmpty()) {
+ if (Alert::prompt(_("Dissolve previous group?"),
+ bformat(_("If you assign this graphic to group '%2$s',\n"
+ "the previously assigned group '%1$s' will be dissolved,\n"
+ "because this graphic was its only member.\n"
+ "How do you want to proceed?"),
+ from_utf8(current_group_), qstring_to_ucs4(new_group)),
+ 0, 0,
+ bformat(_("Stick with group '%1$s'"),
+ from_utf8(current_group_)),
+ bformat(_("Assign to group '%1$s' anyway"),
+ qstring_to_ucs4(new_group))) == 0) {
+ groupCO->setCurrentIndex(
+ groupCO->findData(toqstr(current_group_), Qt::MatchExactly));
+ return;
+ }
+ } else {
+ if (Alert::prompt(_("Dissolve previous group?"),
+ bformat(_("If you sign off this graphic from group '%1$s',\n"
+ "the group will be dissolved,\n"
+ "because this graphic was its only member.\n"
+ "How do you want to proceed?"),
+ from_utf8(current_group_)),
+ 0, 0,
+ bformat(_("Stick with group '%1$s'"),
+ from_utf8(current_group_)),
+ bformat(_("Sign off from group '%1$s'"),
+ from_utf8(current_group_))) == 0) {
+ groupCO->setCurrentIndex(
+ groupCO->findData(toqstr(current_group_), Qt::MatchExactly));
+ return;
+ }
+ }
+ }
+
+ if (new_group.isEmpty()) {
+ changed();
+ return;
+ }
+
+ string grp = graphics::getGroupParams(buffer(), fromqstr(new_group));
+ if (grp.empty()) {
+ // group does not exist yet
+ changed();
+ return;
+ }
+
+ // filename might have been changed
+ QString current_filename = filename->text();
+
+ // group exists: load params into the dialog
+ groupCO->blockSignals(true);
+ InsetGraphics::string2params(grp, buffer(), params_);
+ paramsToDialog(params_);
+ groupCO->blockSignals(false);
+
+ // reset filename
+ filename->setText(current_filename);
+
+ 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));
+}
+
+
+void GuiGraphics::changeBB()