Jean-Marc Lasgouttes wrote:
> Pavel Sanda <sa...@lyx.org> writes:
> > Manveru schreef:
> >> I hadn't read this in manual, but from your explanations it seem to be
> >> very user not-friendly feature. It is not natural to users entering
> >> new name in that field every time they want new group. Without reading
> >> the manual, people like I who mostly not read manuals at all cannot
> >> understand how this feature works. But that is my private opinion.
> >
> > the group name is just part of the image settings, so filling up the name
> > is similar as filling the 'new' latex parameters for the image. i have
> > removed the confusing "Initialize" word and enriched the tooltips.
> > another proposals i have seen up to now are not so easy to implement.
> 
> Could we have an 'editable combox', that allows either to enter a new
> name or to click on the arrow and pick an already existing name?

attached is the patch which implements it.
pavel
diff --git a/src/frontends/qt4/GuiGraphics.cpp 
b/src/frontends/qt4/GuiGraphics.cpp
index f52c132..423b00a 100644
--- a/src/frontends/qt4/GuiGraphics.cpp
+++ b/src/frontends/qt4/GuiGraphics.cpp
@@ -243,7 +243,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(textChanged(const QString&)),
+       connect(groupId, SIGNAL(currentIndexChanged (const QString&)),
+               this, SLOT(change_group(const QString&)));
+       connect(groupId, SIGNAL(editTextChanged(const QString&)),
                this, SLOT(change_adaptor()));
        displayscale->setValidator(new QIntValidator(displayscale));
 
@@ -289,6 +291,24 @@ void GuiGraphics::change_adaptor()
 }
 
 
+void GuiGraphics::change_group(const QString &text)
+{
+       if (text.isEmpty())
+               return;
+
+       groupId->blockSignals(true);
+
+       string grp = graphics::getGroupParams(buffer(), fromqstr(text));
+       InsetGraphicsParams par;
+       InsetGraphics::string2params(grp, buffer(), par);
+       par.filename = params_.filename;
+       params_ = par;
+       paramsToDialog(par);
+
+       groupId->blockSignals(false);
+}
+
+
 void GuiGraphics::change_bb()
 {
        bbChanged = true;
@@ -530,7 +550,20 @@ void GuiGraphics::paramsToDialog(InsetGraphicsParams const 
& igp)
        Scale->setEnabled(scaleChecked);
        displayGB->setEnabled(lyxrc.display_graphics);
 
-       groupId->setText(toqstr(igp.groupId));
+       set<string> grp;
+       graphics::getGraphicsGroups(buffer(), grp);
+       set<string>::const_iterator it = grp.begin();
+       set<string>::const_iterator end = grp.end();
+       groupId->blockSignals(true);
+       groupId->clear();
+       groupId->addItem("");
+       for (; it != end; it++)
+               groupId->addItem(toqstr(*it));
+       if (igp.groupId.empty())
+               groupId->setCurrentIndex(-1);
+       else
+               groupId->setCurrentIndex(groupId->findText(toqstr(igp.groupId), 
Qt::MatchExactly));
+       groupId->blockSignals(false);
 
        lengthAutoToWidgets(Width, widthUnit, igp.width,
                unitDefault);
@@ -666,7 +699,7 @@ void GuiGraphics::applyView()
        // more latex options
        igp.special = fromqstr(latexoptions->text());
 
-       igp.groupId = fromqstr(groupId->text());
+       igp.groupId = fromqstr(groupId->currentText());
 }
 
 
diff --git a/src/frontends/qt4/GuiGraphics.h b/src/frontends/qt4/GuiGraphics.h
index a5dd3e6..27e34ac 100644
--- a/src/frontends/qt4/GuiGraphics.h
+++ b/src/frontends/qt4/GuiGraphics.h
@@ -40,6 +40,7 @@ public:
 
 private Q_SLOTS:
        void change_adaptor();
+       void change_group(const QString &);
        void change_bb();
        void on_browsePB_clicked();
        void on_getPB_clicked();
diff --git a/src/frontends/qt4/ui/GraphicsUi.ui 
b/src/frontends/qt4/ui/GraphicsUi.ui
index 697d143..704201a 100644
--- a/src/frontends/qt4/ui/GraphicsUi.ui
+++ b/src/frontends/qt4/ui/GraphicsUi.ui
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>480</width>
-    <height>348</height>
+    <width>482</width>
+    <height>383</height>
    </rect>
   </property>
   <property name="sizePolicy" >
@@ -124,14 +124,6 @@
       <number>0</number>
      </property>
      <widget class="QWidget" name="Graphics" >
-      <property name="geometry" >
-       <rect>
-        <x>0</x>
-        <y>0</y>
-        <width>458</width>
-        <height>272</height>
-       </rect>
-      </property>
       <attribute name="title" >
        <string>&amp;Graphics</string>
       </attribute>
@@ -367,14 +359,6 @@
       </layout>
      </widget>
      <widget class="QWidget" name="Clipping" >
-      <property name="geometry" >
-       <rect>
-        <x>0</x>
-        <y>0</y>
-        <width>458</width>
-        <height>272</height>
-       </rect>
-      </property>
       <attribute name="title" >
        <string>&amp;Clipping</string>
       </attribute>
@@ -537,14 +521,6 @@
       </layout>
      </widget>
      <widget class="QWidget" name="ExtraOptions" >
-      <property name="geometry" >
-       <rect>
-        <x>0</x>
-        <y>0</y>
-        <width>458</width>
-        <height>272</height>
-       </rect>
-      </property>
       <attribute name="title" >
        <string>LaTe&amp;X and LyX options</string>
       </attribute>
@@ -647,20 +623,7 @@
              <string>Grou&amp;p Name:</string>
             </property>
             <property name="buddy" >
-             <cstring>groupId</cstring>
-            </property>
-           </widget>
-          </item>
-          <item row="1" column="1" >
-           <widget class="QLineEdit" name="groupId" >
-            <property name="minimumSize" >
-             <size>
-              <width>87</width>
-              <height>0</height>
-             </size>
-            </property>
-            <property name="toolTip" >
-             <string>Group Name to be set up from the current parameters. Use 
context menu to assign the existing one.</string>
+             <cstring>grouId</cstring>
             </property>
            </widget>
           </item>
@@ -693,10 +656,20 @@
             </property>
            </widget>
           </item>
+          <item row="1" column="1" >
+           <widget class="QComboBox" name="groupId" >
+            <property name="toolTip" >
+             <string>Group Name to be set up from the current parameters. Use 
context menu to assign the existing one.</string>
+            </property>
+            <property name="editable" >
+             <bool>true</bool>
+            </property>
+           </widget>
+          </item>
          </layout>
         </widget>
        </item>
-       <item row="4" column="1" >
+       <item row="5" column="1" >
         <spacer>
          <property name="orientation" >
           <enum>Qt::Vertical</enum>

Reply via email to