]> git.lyx.org Git - features.git/commitdiff
rework mathdelimiter dialog and add size combo...
authorEdwin Leuven <e.leuven@gmail.com>
Wed, 16 Aug 2006 14:22:47 +0000 (14:22 +0000)
committerEdwin Leuven <e.leuven@gmail.com>
Wed, 16 Aug 2006 14:22:47 +0000 (14:22 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14703 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/QDelimiterDialog.C
src/frontends/qt4/QDelimiterDialog.h
src/frontends/qt4/ui/QDelimiterUi.ui

index 8ba79ba5cc3c34b9c7124fc3ce3996cba387bf57..06aa96298dec7b10236bf1d10a21f60cb45b05ff 100644 (file)
 #include <config.h>
 
 #include "QDelimiterDialog.h"
-
-#include "iconpalette.h"
 #include "QMath.h"
-#include "qt_helpers.h"
 
+#include "qt_helpers.h"
 #include "controllers/ControlMath.h"
 
-#include <qlabel.h>
-#include <qpixmap.h>
-#include <qcheckbox.h>
+#include "gettext.h"
 
+#include <QPixmap>
+#include <QCheckBox>
+
+
+#include <sstream>
 
 using std::string;
 
 namespace lyx {
 namespace frontend {
 
-// FIXME: Implement fixed size delimiters (see qt3 frontend)
-
 namespace {
 
 char const * delim[] = {
@@ -40,6 +39,16 @@ char const * delim[] = {
 };
 
 
+char const * const bigleft[]  = {"bigl", "Bigl", "biggl", "Biggl", ""};
+
+
+char const * const bigright[] = {"bigr", "Bigr", "biggr", "Biggr", ""};
+
+
+char const * const biggui[]   = {N_("big size"), N_("Big size"),
+       N_("bigg size"), N_("Bigg size"), ""};
+
+
 string do_match(const string & str)
 {
        if (str == "(") return ")";
@@ -61,7 +70,7 @@ string do_match(const string & str)
 }
 
 
-string fix_name(const string & str)
+string fix_name(const string & str, bool big)
 {
        if (str == "slash")
                return "/";
@@ -69,7 +78,10 @@ string fix_name(const string & str)
                return "\\";
        if (str == "empty")
                return ".";
-       return str;
+       if (!big || str == "(" || str == ")" || str == "[" || str == "]")
+               return str;
+
+       return "\\" + str;
 }
 
 } // namespace anon
@@ -80,69 +92,81 @@ QDelimiterDialog::QDelimiterDialog(QMathDelimiter * form)
 {
        setupUi(this);
 
-    connect( closePB, SIGNAL( clicked() ), this, SLOT( accept() ) );
-    connect( insertPB, SIGNAL( clicked() ), this, SLOT( insertClicked() ) );
+       connect(closePB, SIGNAL(clicked()), this, SLOT(accept()));
+       connect(insertPB, SIGNAL(clicked()), this, SLOT(insertClicked()));
 
        setCaption(qt_("LyX: Delimiters"));
 
        for (int i = 0; *delim[i]; ++i) {
-               string xpm(find_xpm(delim[i]));
-               leftIP->add(QPixmap(toqstr(xpm)), delim[i], delim[i]);
-               rightIP->add(QPixmap(toqstr(xpm)), delim[i], delim[i]);
+               QPixmap pm = QPixmap(toqstr(find_xpm(delim[i])));
+               leftCO->addItem(QIcon(pm), "");
+               rightCO->addItem(QIcon(pm), "");
        }
 
        string empty_xpm(find_xpm("empty"));
+       leftCO->addItem(QIcon(QPixmap(toqstr(empty_xpm))), qt_("(None)"));
+       rightCO->addItem(QIcon(QPixmap(toqstr(empty_xpm))), qt_("(None)"));
+
+       for (int i = 0; *biggui[i]; ++i)
+               sizeCO->addItem(qt_(biggui[i]));
 
-       leftIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
-       rightIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
-       // Leave these std:: qualifications alone !
-       connect(leftIP, SIGNAL(button_clicked(const std::string &)),
-               this, SLOT(ldelim_clicked(const std::string &)));
-       connect(rightIP, SIGNAL(button_clicked(const std::string &)),
-               this, SLOT(rdelim_clicked(const std::string &)));
-       ldelim_clicked("(");
-       rdelim_clicked(")");
+       on_leftCO_activated(0);
 }
 
 
 void QDelimiterDialog::insertClicked()
 {
-       form_->controller().dispatchDelim(fix_name(left_) + ' ' + fix_name(right_));
+       string const left_ = delim[leftCO->currentIndex()];
+       string const right_ = delim[rightCO->currentIndex()];
+       int const size_ = sizeCO->currentIndex();
+
+       if (size_ == 0) {
+               form_->controller().dispatchDelim(
+                       fix_name(left_, false) + ' ' +
+                       fix_name(right_, false));
+       } else {
+               std::ostringstream os;
+               os << '"' << bigleft[size_ - 1] << "\" \""
+                  << fix_name(left_, true) << "\" \""
+                  << bigright[size_ - 1] << "\" \""
+                  << fix_name(right_, true) << '"';
+               form_->controller().dispatchBigDelim(os.str());
+       }
+
 }
 
 
-void QDelimiterDialog::set_label(QLabel * label, const string & str)
+void QDelimiterDialog::on_leftCO_activated(int item)
 {
-       label->setUpdatesEnabled(false);
-       label->setPixmap(QPixmap(toqstr(find_xpm(str))));
-       label->setUpdatesEnabled(true);
-       label->update();
+       if (matchCB->isChecked()) {
+               string const match = do_match(delim[item]);
+               int k = 0;
+               while (delim[k] && delim[k] != match)
+                       ++k;
+               rightCO->setCurrentIndex(k);
+       }
 }
 
 
-void QDelimiterDialog::ldelim_clicked(const string & str)
+void QDelimiterDialog::on_rightCO_activated(int item)
 {
-       left_ = str;
-
-       set_label(leftPI, left_);
        if (matchCB->isChecked()) {
-               right_ = do_match(left_);
-               set_label(rightPI, right_);
+               string const match = do_match(delim[item]);
+               int k = 0;
+               while (delim[k] && delim[k] != match)
+                       ++k;
+               leftCO->setCurrentIndex(k);
        }
 }
 
 
-void QDelimiterDialog::rdelim_clicked(const string & str)
+void QDelimiterDialog::on_matchCB_stateChanged(int state)
 {
-       right_ = str;
-
-       set_label(rightPI, right_);
-       if (matchCB->isChecked()) {
-               left_ = do_match(right_);
-               set_label(leftPI, left_);
-       }
+       if (state == Qt::Checked)
+               on_leftCO_activated(leftCO->currentIndex());
 }
 
+
 } // namespace frontend
 } // namespace lyx
 
index 6c18d2d48f1e4f8313b9913564bab7b40ac255a5..c11264d2237671f1d843526604b8fe3e2df10a9f 100644 (file)
 #include "ui/QDelimiterUi.h"
 #include <string>
 
-#include <QLabel>
-#include <QDialog>
-
-class IconPalette;
-class QLabel;
-
 namespace lyx {
 namespace frontend {
 
@@ -31,20 +25,11 @@ class QDelimiterDialog : public QDialog, public Ui::QDelimiterUi {
 public:
        QDelimiterDialog(QMathDelimiter * form);
 public Q_SLOTS:
-       void ldelim_clicked(const std::string & str);
-       void rdelim_clicked(const std::string & str);
+       void on_leftCO_activated(int);
+       void on_rightCO_activated(int);
+       void on_matchCB_stateChanged(int);
        void insertClicked();
-protected:
-       //needed ? virtual void closeEvent(QCloseEvent * e);
 private:
-       void set_label(QLabel * label, const std::string & str);
-
-       /// symbol of left delimiter
-       std::string left_;
-
-       /// symbol of right delimiter
-       std::string right_;
-
        /// owning form
        QMathDelimiter * form_;
 };
index 635749e3e6c8e3c34bfee4387b67fd266da66161..f77cb6d41a2e62a97af0c203960da49e782ed7a0 100644 (file)
@@ -8,24 +8,55 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>260</width>
-    <height>595</height>
+    <width>206</width>
+    <height>153</height>
    </rect>
   </property>
+  <property name="minimumSize" >
+   <size>
+    <width>42</width>
+    <height>42</height>
+   </size>
+  </property>
   <property name="windowTitle" >
    <string/>
   </property>
   <property name="sizeGripEnabled" >
    <bool>true</bool>
   </property>
-  <layout class="QVBoxLayout" >
+  <layout class="QGridLayout" >
    <property name="margin" >
-    <number>11</number>
+    <number>9</number>
    </property>
    <property name="spacing" >
     <number>6</number>
    </property>
-   <item>
+   <item row="2" column="1" >
+    <widget class="QComboBox" name="sizeCO" >
+     <property name="sizePolicy" >
+      <sizepolicy>
+       <hsizetype>7</hsizetype>
+       <vsizetype>0</vsizetype>
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="0" colspan="2" >
+    <widget class="QCheckBox" name="matchCB" >
+     <property name="toolTip" >
+      <string>Match delimiter types</string>
+     </property>
+     <property name="text" >
+      <string>&amp;Keep matched</string>
+     </property>
+     <property name="checked" >
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="0" colspan="2" >
     <layout class="QHBoxLayout" >
      <property name="margin" >
       <number>0</number>
       <number>6</number>
      </property>
      <item>
-      <layout class="QVBoxLayout" >
-       <property name="margin" >
-        <number>0</number>
+      <widget class="QComboBox" name="leftCO" >
+       <property name="minimumSize" >
+        <size>
+         <width>42</width>
+         <height>42</height>
+        </size>
        </property>
-       <property name="spacing" >
-        <number>6</number>
+       <property name="iconSize" >
+        <size>
+         <width>32</width>
+         <height>32</height>
+        </size>
        </property>
-       <item>
-        <widget class="IconPalette" name="leftIP" >
-         <property name="sizePolicy" >
-          <sizepolicy>
-           <hsizetype>5</hsizetype>
-           <vsizetype>7</vsizetype>
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <layout class="QHBoxLayout" >
-         <property name="margin" >
-          <number>0</number>
-         </property>
-         <property name="spacing" >
-          <number>6</number>
-         </property>
-         <item>
-          <spacer>
-           <property name="orientation" >
-            <enum>Qt::Horizontal</enum>
-           </property>
-           <property name="sizeType" >
-            <enum>QSizePolicy::Expanding</enum>
-           </property>
-           <property name="sizeHint" >
-            <size>
-             <width>20</width>
-             <height>20</height>
-            </size>
-           </property>
-          </spacer>
-         </item>
-         <item>
-          <layout class="QVBoxLayout" >
-           <property name="margin" >
-            <number>0</number>
-           </property>
-           <property name="spacing" >
-            <number>6</number>
-           </property>
-           <item>
-            <widget class="QLabel" name="leftPI" >
-             <property name="sizePolicy" >
-              <sizepolicy>
-               <hsizetype>1</hsizetype>
-               <vsizetype>1</vsizetype>
-               <horstretch>0</horstretch>
-               <verstretch>0</verstretch>
-              </sizepolicy>
-             </property>
-             <property name="minimumSize" >
-              <size>
-               <width>5</width>
-               <height>5</height>
-              </size>
-             </property>
-             <property name="maximumSize" >
-              <size>
-               <width>40</width>
-               <height>40</height>
-              </size>
-             </property>
-             <property name="toolTip" >
-              <string>Left delimiter</string>
-             </property>
-             <property name="scaledContents" >
-              <bool>true</bool>
-             </property>
-            </widget>
-           </item>
-          </layout>
-         </item>
-        </layout>
-       </item>
-      </layout>
+      </widget>
      </item>
      <item>
-      <layout class="QVBoxLayout" >
-       <property name="margin" >
-        <number>0</number>
+      <widget class="QComboBox" name="rightCO" >
+       <property name="minimumSize" >
+        <size>
+         <width>42</width>
+         <height>42</height>
+        </size>
        </property>
-       <property name="spacing" >
-        <number>6</number>
+       <property name="iconSize" >
+        <size>
+         <width>32</width>
+         <height>32</height>
+        </size>
        </property>
-       <item>
-        <widget class="IconPalette" name="rightIP" >
-         <property name="sizePolicy" >
-          <sizepolicy>
-           <hsizetype>5</hsizetype>
-           <vsizetype>7</vsizetype>
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <layout class="QHBoxLayout" >
-         <property name="margin" >
-          <number>0</number>
-         </property>
-         <property name="spacing" >
-          <number>6</number>
-         </property>
-         <item>
-          <layout class="QVBoxLayout" >
-           <property name="margin" >
-            <number>0</number>
-           </property>
-           <property name="spacing" >
-            <number>6</number>
-           </property>
-           <item>
-            <widget class="QLabel" name="rightPI" >
-             <property name="sizePolicy" >
-              <sizepolicy>
-               <hsizetype>1</hsizetype>
-               <vsizetype>1</vsizetype>
-               <horstretch>0</horstretch>
-               <verstretch>0</verstretch>
-              </sizepolicy>
-             </property>
-             <property name="minimumSize" >
-              <size>
-               <width>5</width>
-               <height>5</height>
-              </size>
-             </property>
-             <property name="maximumSize" >
-              <size>
-               <width>40</width>
-               <height>40</height>
-              </size>
-             </property>
-             <property name="toolTip" >
-              <string>Right delimiter</string>
-             </property>
-             <property name="scaledContents" >
-              <bool>true</bool>
-             </property>
-            </widget>
-           </item>
-          </layout>
-         </item>
-         <item>
-          <spacer>
-           <property name="orientation" >
-            <enum>Qt::Horizontal</enum>
-           </property>
-           <property name="sizeType" >
-            <enum>QSizePolicy::Expanding</enum>
-           </property>
-           <property name="sizeHint" >
-            <size>
-             <width>20</width>
-             <height>20</height>
-            </size>
-           </property>
-          </spacer>
-         </item>
-        </layout>
-       </item>
-      </layout>
+      </widget>
      </item>
     </layout>
    </item>
-   <item>
+   <item row="2" column="0" >
+    <widget class="QLabel" name="label" >
+     <property name="text" >
+      <string>&amp;Size:</string>
+     </property>
+     <property name="buddy" >
+      <cstring>sizeCO</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="0" colspan="2" >
     <layout class="QHBoxLayout" >
      <property name="margin" >
       <number>0</number>
      <property name="spacing" >
       <number>6</number>
      </property>
-     <item>
-      <widget class="QCheckBox" name="matchCB" >
-       <property name="toolTip" >
-        <string>Match delimiter types</string>
-       </property>
-       <property name="text" >
-        <string>&amp;Keep matched</string>
-       </property>
-       <property name="checked" >
-        <bool>true</bool>
-       </property>
-      </widget>
-     </item>
      <item>
       <spacer>
        <property name="orientation" >
        </property>
        <property name="sizeHint" >
         <size>
-         <width>20</width>
-         <height>20</height>
+         <width>50</width>
+         <height>28</height>
         </size>
        </property>
       </spacer>
      </item>
-    </layout>
-   </item>
-   <item>
-    <layout class="QHBoxLayout" >
-     <property name="margin" >
-      <number>0</number>
-     </property>
-     <property name="spacing" >
-      <number>6</number>
-     </property>
      <item>
       <widget class="QPushButton" name="insertPB" >
        <property name="toolTip" >
        </property>
       </widget>
      </item>
-     <item>
-      <spacer>
-       <property name="orientation" >
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeType" >
-        <enum>QSizePolicy::Expanding</enum>
-       </property>
-       <property name="sizeHint" >
-        <size>
-         <width>20</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
      <item>
       <widget class="QPushButton" name="closePB" >
        <property name="text" >
   </layout>
  </widget>
  <pixmapfunction></pixmapfunction>
- <customwidgets>
-  <customwidget>
-   <class>IconPalette</class>
-   <extends></extends>
-   <header>iconpalette.h</header>
-   <container>0</container>
-   <pixmap></pixmap>
-  </customwidget>
- </customwidgets>
  <resources/>
  <connections/>
 </ui>