Uwe Stöhr wrote:
While trying to fix bug 3420 I noticed that LyX 1.5 comes with a new delimiter dialog. This dialog is less clear to keep the overview about the different delimiters. The dialog of LyX 1.4.x is better and quicker to handle as you just need to click on the delimiter you want than scrolling down two comboboxes as in LyX 1.5's dialog.

What was the reason for this change? I would like to have LyX 1.4.x's dialog also in LyX 1.5. Does anybody agree with me in this case?

I've reworked a bit the dialog but I did not manage to expand the combos to the maximum... I shall ask our Designer expert... Edwin?

Abdel.


Author: younes
Date: Thu Apr  5 11:26:09 2007
New Revision: 17727

URL: http://www.lyx.org/trac/changeset/17727
Log:
Delimiter dilaog: Cleanup the code and rework the dialog a bit.
Most of the change is about using the new private member delimiters_ instead of the "delim" table. Also, we don't display an icon when the delimiter is one character.
I did not manage to let the combos expand to the maximum.

Modified:
    lyx-devel/trunk/src/frontends/qt4/QDelimiterDialog.C
    lyx-devel/trunk/src/frontends/qt4/QDelimiterDialog.h
    lyx-devel/trunk/src/frontends/qt4/ui/QDelimiterUi.ui

Modified: lyx-devel/trunk/src/frontends/qt4/QDelimiterDialog.C
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/qt4/QDelimiterDialog.C?rev=17727
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/QDelimiterDialog.C (original)
+++ lyx-devel/trunk/src/frontends/qt4/QDelimiterDialog.C Thu Apr 5 11:26:09 2007
@@ -49,7 +49,7 @@
        N_("bigg[[delimiter size]]"), N_("Bigg[[delimiter size]]"), ""};


-string do_match(const string & str)
+QString do_match(QString const & str)
 {
        if (str == "(") return ")";
        if (str == ")") return "(";
@@ -70,18 +70,18 @@
 }


-string fix_name(const string & str, bool big)
+string fix_name(QString const & str, bool big)
 {
        if (str == "slash")
                return "/";
        if (str == "backslash")
                return "\\";
-       if (str.empty())
+       if (str.isEmpty())
                return ".";
        if (!big || str == "(" || str == ")" || str == "[" || str == "]")
-               return str;
+               return fromqstr(str);

-       return "\\" + str;
+       return "\\" + fromqstr(str);
 }

 } // namespace anon
@@ -97,15 +97,24 @@

        setWindowTitle(qt_("LyX: Delimiters"));

-       for (int i = 0; *delim[i]; ++i) {
-               QPixmap pm = QPixmap(toqstr(find_xpm(delim[i])));
-               leftCO->addItem(QIcon(pm), "");
-               rightCO->addItem(QIcon(pm), "");
+       for (size_t i = 0; i != 21; ++i)
+               delimiters_.append(toqstr(delim[i]));
+
+       // The last element is the empty one.
+       size_t end = delimiters_.size() - 1;
+       for (size_t i = 0; i != end; ++i) {
+               if (delimiters_[i].size() == 1) {
+                       leftCO->addItem(delimiters_[i]);
+                       rightCO->addItem(delimiters_[i]);
+               } else {
+                       QPixmap pm = 
QPixmap(toqstr(find_xpm(fromqstr(delimiters_[i]))));
+                       leftCO->addItem(QIcon(pm), delimiters_[i]);
+                       rightCO->addItem(QIcon(pm), delimiters_[i]);
+               }
        }

-       string empty_xpm(find_xpm("empty"));
-       leftCO->addItem(QIcon(QPixmap(toqstr(empty_xpm))), qt_("(None)"));
-       rightCO->addItem(QIcon(QPixmap(toqstr(empty_xpm))), qt_("(None)"));
+       leftCO->addItem(qt_("(None)"));
+       rightCO->addItem(qt_("(None)"));

        sizeCO->addItem(qt_("Variable"));

@@ -118,8 +127,8 @@

 void QDelimiterDialog::insertClicked()
 {
-       string const left_ = delim[leftCO->currentIndex()];
-       string const right_ = delim[rightCO->currentIndex()];
+       QString const left_ = delimiters_[leftCO->currentIndex()];
+       QString const right_ = delimiters_[rightCO->currentIndex()];
        int const size_ = sizeCO->currentIndex();

        if (size_ == 0) {
@@ -141,11 +150,8 @@
 void QDelimiterDialog::on_leftCO_activated(int item)
 {
        if (matchCB->isChecked()) {
-               string const match = do_match(delim[item]);
-               int k = 0;
-               while (delim[k] && delim[k] != match)
-                       ++k;
-               rightCO->setCurrentIndex(k);
+               QString const match = do_match(delimiters_[item]);
+               rightCO->setCurrentIndex(delimiters_.indexOf(match));
        }
 }

@@ -153,11 +159,8 @@
 void QDelimiterDialog::on_rightCO_activated(int item)
 {
        if (matchCB->isChecked()) {
-               string const match = do_match(delim[item]);
-               int k = 0;
-               while (delim[k] && delim[k] != match)
-                       ++k;
-               leftCO->setCurrentIndex(k);
+               QString const match = do_match(delimiters_[item]);
+               leftCO->setCurrentIndex(delimiters_.indexOf(match));
        }
 }


Modified: lyx-devel/trunk/src/frontends/qt4/QDelimiterDialog.h
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/qt4/QDelimiterDialog.h?rev=17727
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/QDelimiterDialog.h (original)
+++ lyx-devel/trunk/src/frontends/qt4/QDelimiterDialog.h Thu Apr 5 11:26:09 2007
@@ -13,6 +13,9 @@
 #define QDELIMITERDIALOG_H

 #include "ui/QDelimiterUi.h"
+
+#include <QStringList>
+
 #include <string>

 namespace lyx {
@@ -32,6 +35,8 @@
 private:
        /// owning form
        QMathDelimiter * form_;
+       ///
+       QStringList delimiters_;
 };

 } // namespace frontend

Modified: lyx-devel/trunk/src/frontends/qt4/ui/QDelimiterUi.ui
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/qt4/ui/QDelimiterUi.ui?rev=17727
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/ui/QDelimiterUi.ui (original)
+++ lyx-devel/trunk/src/frontends/qt4/ui/QDelimiterUi.ui Thu Apr 5 11:26:09 2007
@@ -1,7 +1,4 @@
 <ui version="4.0" >
- <author></author>
- <comment></comment>
- <exportmacro></exportmacro>
  <class>QDelimiterUi</class>
  <widget class="QDialog" name="QDelimiterUi" >
   <property name="geometry" >
@@ -66,11 +63,25 @@
      </property>
      <item>
       <widget class="QComboBox" name="leftCO" >
+       <property name="sizePolicy" >
+        <sizepolicy>
+         <hsizetype>4</hsizetype>
+         <vsizetype>4</vsizetype>
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
        <property name="minimumSize" >
         <size>
          <width>42</width>
          <height>42</height>
         </size>
+       </property>
+       <property name="maxVisibleItems" >
+        <number>100</number>
+       </property>
+       <property name="sizeAdjustPolicy" >
+        <enum>QComboBox::AdjustToContents</enum>
        </property>
        <property name="iconSize" >
         <size>
@@ -82,11 +93,22 @@
      </item>
      <item>
       <widget class="QComboBox" name="rightCO" >
+       <property name="sizePolicy" >
+        <sizepolicy>
+         <hsizetype>4</hsizetype>
+         <vsizetype>4</vsizetype>
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
        <property name="minimumSize" >
         <size>
          <width>42</width>
          <height>42</height>
         </size>
+       </property>
+       <property name="maxVisibleItems" >
+        <number>100</number>
        </property>
        <property name="iconSize" >
         <size>
@@ -153,10 +175,6 @@
    </item>
   </layout>
  </widget>
- <pixmapfunction></pixmapfunction>
- <includes>
-  <include location="local" >qt_helpers.h</include>
- </includes>
  <tabstops>
   <tabstop>leftCO</tabstop>
   <tabstop>rightCO</tabstop>
@@ -165,6 +183,9 @@
   <tabstop>insertPB</tabstop>
   <tabstop>closePB</tabstop>
  </tabstops>
+ <includes>
+  <include location="local" >qt_helpers.h</include>
+ </includes>
  <resources/>
  <connections/>
 </ui>




Reply via email to