Abdelrazak Younes wrote:
Abdelrazak Younes wrote:
Abdelrazak Younes wrote:
Uwe Stöhr wrote:
But anyway, the dialog of LyX 1.4.x is much simpler to work with as
 you see everything with one look.

Then I suggest that we switch to a wigdet list instead. With smaller icons it will fit nicely on screen.

Any objection if I do that?

OK, I've done that. The result is pretty good. Just need to map the 'enter' key and this dialog will be very usable.

I've done that now and committed the new dialog. Now you can insert matched delimiters without touching the mouse :-)

By the way, is there a short-cut to launch this dialog? If not I'd like to have one; any suggestion? I also think that we should put a new button in the math toolbar to launch the delimiter dialog without having to go first to the math panel. And we need a new menu item:

  Insert->Math->Delimiter

Any volunteer for these three items? I've spend too much time already on LyX this week :-(

Abdel.

PS: Edwin, the request for beautifying the dialog still stands.


Author: younes
Date: Thu Apr  5 14:12:07 2007
New Revision: 17731

URL: http://www.lyx.org/trac/changeset/17731
Log:
Rework the delimiter dialog:
- ListWidget instead of combo,
- matched delimiters on the same row,
- immediate insertion on "enter" or "double-click" if the 'match' option is checked.
- simplification of the code.

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=17731
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/QDelimiterDialog.C (original)
+++ lyx-devel/trunk/src/frontends/qt4/QDelimiterDialog.C Thu Apr 5 14:12:07 2007
@@ -20,7 +20,7 @@

 #include <QPixmap>
 #include <QCheckBox>
-
+#include <QListWidgetItem>

 #include <sstream>

@@ -31,7 +31,7 @@

 namespace {

-char const * delim[] = {
+string const delim[] = {
        "(", ")", "{", "}", "[", "]",
        "lceil", "rceil", "lfloor", "rfloor", "langle", "rangle",
        "uparrow", "Uparrow", "downarrow", "Downarrow",
@@ -96,39 +96,41 @@
        connect(insertPB, SIGNAL(clicked()), this, SLOT(insertClicked()));

        setWindowTitle(qt_("LyX: Delimiters"));
-
-       for (size_t i = 0; i != 21; ++i)
-               delimiters_.append(toqstr(delim[i]));
+       setFocusProxy(leftLW);

        // 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]);
+       for (size_t i = 0; !delim[i].empty(); ++i) {
+               QString const left_d = toqstr(delim[i]);
+               QString const right_d = do_match(left_d);
+               if (left_d.size() == 1) {
+                       leftLW->addItem(left_d);
+                       rightLW->addItem(right_d);
                } else {
-                       QPixmap pm = 
QPixmap(toqstr(find_xpm(fromqstr(delimiters_[i]))));
-                       leftCO->addItem(QIcon(pm), delimiters_[i]);
-                       rightCO->addItem(QIcon(pm), delimiters_[i]);
+                       QPixmap left_pm = 
QPixmap(toqstr(find_xpm(fromqstr(left_d))));
+                       leftLW->addItem(new QListWidgetItem(QIcon(left_pm), 
left_d));
+                       QPixmap right_pm = 
QPixmap(toqstr(find_xpm(fromqstr(right_d))));
+                       rightLW->addItem(new QListWidgetItem(QIcon(right_pm), 
right_d));
                }
        }

-       leftCO->addItem(qt_("(None)"));
-       rightCO->addItem(qt_("(None)"));
+       leftLW->addItem(qt_("(None)"));
+       rightLW->addItem(qt_("(None)"));

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

        for (int i = 0; *biggui[i]; ++i)
                sizeCO->addItem(qt_(biggui[i]));

-       on_leftCO_activated(0);
+       on_leftLW_currentRowChanged(0);
 }


 void QDelimiterDialog::insertClicked()
 {
-       QString const left_ = delimiters_[leftCO->currentIndex()];
-       QString const right_ = delimiters_[rightCO->currentIndex()];
+       QString const left_ = (leftLW->currentRow() < leftLW->count() - 1)?
+               leftLW->currentItem()->text(): QString();
+       QString const right_ = (rightLW->currentRow() < rightLW->count() - 1)?
+               rightLW->currentItem()->text(): QString();
        int const size_ = sizeCO->currentIndex();

        if (size_ == 0) {
@@ -143,32 +145,37 @@
                   << fix_name(right_, true) << '"';
                form_->controller().dispatchBigDelim(os.str());
        }
-
 }


-void QDelimiterDialog::on_leftCO_activated(int item)
+void QDelimiterDialog::on_leftLW_itemActivated(QListWidgetItem *)
 {
-       if (matchCB->isChecked()) {
-               QString const match = do_match(delimiters_[item]);
-               rightCO->setCurrentIndex(delimiters_.indexOf(match));
-       }
+       if (!matchCB->isChecked())
+               return;
+
+       insertClicked();
+       accept();
 }


-void QDelimiterDialog::on_rightCO_activated(int item)
+void QDelimiterDialog::on_leftLW_currentRowChanged(int item)
 {
-       if (matchCB->isChecked()) {
-               QString const match = do_match(delimiters_[item]);
-               leftCO->setCurrentIndex(delimiters_.indexOf(match));
-       }
+       if (matchCB->isChecked())
+               rightLW->setCurrentRow(item);
+}
+
+
+void QDelimiterDialog::on_rightLW_currentRowChanged(int item)
+{
+       if (matchCB->isChecked())
+               leftLW->setCurrentRow(item);
 }


 void QDelimiterDialog::on_matchCB_stateChanged(int state)
 {
        if (state == Qt::Checked)
-               on_leftCO_activated(leftCO->currentIndex());
+               on_leftLW_currentRowChanged(leftLW->currentRow());
 }



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=17731
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/QDelimiterDialog.h (original)
+++ lyx-devel/trunk/src/frontends/qt4/QDelimiterDialog.h Thu Apr 5 14:12:07 2007
@@ -14,9 +14,9 @@

 #include "ui/QDelimiterUi.h"

-#include <QStringList>
+#include <string>

-#include <string>
+class QListWidgetItem;

 namespace lyx {
 namespace frontend {
@@ -28,15 +28,14 @@
 public:
        QDelimiterDialog(QMathDelimiter * form);
 public Q_SLOTS:
-       void on_leftCO_activated(int);
-       void on_rightCO_activated(int);
+       void on_leftLW_itemActivated(QListWidgetItem *);
+       void on_leftLW_currentRowChanged(int);
+       void on_rightLW_currentRowChanged(int);
        void on_matchCB_stateChanged(int);
        void insertClicked();
 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=17731
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/ui/QDelimiterUi.ui (original)
+++ lyx-devel/trunk/src/frontends/qt4/ui/QDelimiterUi.ui Thu Apr 5 14:12:07 2007
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>206</width>
-    <height>153</height>
+    <width>193</width>
+    <height>430</height>
    </rect>
   </property>
   <property name="minimumSize" >
@@ -62,59 +62,62 @@
       <number>6</number>
      </property>
      <item>
-      <widget class="QComboBox" name="leftCO" >
+      <widget class="QListWidget" name="leftLW" >
        <property name="sizePolicy" >
         <sizepolicy>
-         <hsizetype>4</hsizetype>
-         <vsizetype>4</vsizetype>
+         <hsizetype>0</hsizetype>
+         <vsizetype>7</vsizetype>
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
-       <property name="minimumSize" >
+       <property name="maximumSize" >
         <size>
-         <width>42</width>
-         <height>42</height>
+         <width>110</width>
+         <height>16777215</height>
         </size>
-       </property>
-       <property name="maxVisibleItems" >
-        <number>100</number>
-       </property>
-       <property name="sizeAdjustPolicy" >
-        <enum>QComboBox::AdjustToContents</enum>
        </property>
        <property name="iconSize" >
         <size>
-         <width>32</width>
-         <height>32</height>
+         <width>16</width>
+         <height>16</height>
         </size>
+       </property>
+       <property name="resizeMode" >
+        <enum>QListView::Adjust</enum>
+       </property>
+       <property name="spacing" >
+        <number>1</number>
+       </property>
+       <property name="currentRow" >
+        <number>-1</number>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QComboBox" name="rightCO" >
+      <widget class="QListWidget" name="rightLW" >
        <property name="sizePolicy" >
         <sizepolicy>
-         <hsizetype>4</hsizetype>
-         <vsizetype>4</vsizetype>
+         <hsizetype>0</hsizetype>
+         <vsizetype>7</vsizetype>
          <horstretch>0</horstretch>
          <verstretch>0</verstretch>
         </sizepolicy>
        </property>
-       <property name="minimumSize" >
+       <property name="maximumSize" >
         <size>
-         <width>42</width>
-         <height>42</height>
+         <width>110</width>
+         <height>16777215</height>
         </size>
-       </property>
-       <property name="maxVisibleItems" >
-        <number>100</number>
        </property>
        <property name="iconSize" >
         <size>
-         <width>32</width>
-         <height>32</height>
+         <width>16</width>
+         <height>16</height>
         </size>
+       </property>
+       <property name="spacing" >
+        <number>1</number>
        </property>
       </widget>
      </item>
@@ -176,8 +179,6 @@
   </layout>
  </widget>
  <tabstops>
-  <tabstop>leftCO</tabstop>
-  <tabstop>rightCO</tabstop>
   <tabstop>matchCB</tabstop>
   <tabstop>sizeCO</tabstop>
   <tabstop>insertPB</tabstop>





Also, I've reordered the right list based on the matching pair.

I had to fix the list width cause I didn't manage to let it have a reasonable size. Edwin, please beautify this dialog for me.

Abdel.

------------------------------------------------------------------------


Reply via email to