Enrico Forestieri wrote:
On Wed, Aug 16, 2006 at 12:05:47AM +0200, Abdelrazak Younes wrote:
Michael Gerz wrote:
> 5-b) I remember some work from Georg and Enrico about some math
> symbols. I thing Georg put a FIXME in qt4 for that.
Done by Edwin IIRC.
Nope. The FIXME is still there in QDelimiterDialog.C.
the attached patch adds this (and i changed the dialog while i was at
it... ;-)
snapshot attached, and gonna commit unless people object
regards, ed.

Index: QDelimiterDialog.C
===================================================================
--- QDelimiterDialog.C (revision 14699)
+++ QDelimiterDialog.C (working copy)
@@ -11,25 +11,24 @@
#include <config.h>
#include "QDelimiterDialog.h"
+#include "QMath.h"
-#include "iconpalette.h"
-#include "QMath.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 * 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 fix_name(const string & str)
+string fix_name(const string & str, bool big)
{
if (str == "slash")
return "/";
@@ -69,7 +78,10 @@
return "\\";
if (str == "empty")
return ".";
- return str;
+ if (!big || str == "(" || str == ")" || str == "[" || str == "]")
+ return str;
+
+ return "\\" + str;
}
} // namespace anon
@@ -80,69 +92,81 @@
{
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)"));
- 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(")");
+ for (int i = 0; *biggui[i]; ++i)
+ sizeCO->addItem(qt_(biggui[i]));
+
+ 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)
-{
- label->setUpdatesEnabled(false);
- label->setPixmap(QPixmap(toqstr(find_xpm(str))));
- label->setUpdatesEnabled(true);
- label->update();
}
-void QDelimiterDialog::ldelim_clicked(const string & str)
+void QDelimiterDialog::on_leftCO_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;
+ rightCO->setCurrentIndex(k);
}
}
-void QDelimiterDialog::rdelim_clicked(const string & str)
+void QDelimiterDialog::on_rightCO_activated(int item)
{
- right_ = str;
-
- set_label(rightPI, right_);
if (matchCB->isChecked()) {
- left_ = do_match(right_);
- set_label(leftPI, left_);
+ string const match = do_match(delim[item]);
+ int k = 0;
+ while (delim[k] && delim[k] != match)
+ ++k;
+ leftCO->setCurrentIndex(k);
}
}
+
+void QDelimiterDialog::on_matchCB_stateChanged(int state)
+{
+ if (state == Qt::Checked)
+ on_leftCO_activated(leftCO->currentIndex());
+}
+
+
} // namespace frontend
} // namespace lyx
Index: QDelimiterDialog.h
===================================================================
--- QDelimiterDialog.h (revision 14699)
+++ QDelimiterDialog.h (working copy)
@@ -15,12 +15,6 @@
#include "ui/QDelimiterUi.h"
#include <string>
-#include <QLabel>
-#include <QDialog>
-
-class IconPalette;
-class QLabel;
-
namespace lyx {
namespace frontend {
@@ -31,20 +25,11 @@
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: ui/QDelimiterUi.ui
===================================================================
--- ui/QDelimiterUi.ui (revision 14699)
+++ ui/QDelimiterUi.ui (working copy)
@@ -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>&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>
@@ -34,184 +65,50 @@
<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>&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>
@@ -220,19 +117,6 @@
<number>6</number>
</property>
<item>
- <widget class="QCheckBox" name="matchCB" >
- <property name="toolTip" >
- <string>Match delimiter types</string>
- </property>
- <property name="text" >
- <string>&Keep matched</string>
- </property>
- <property name="checked" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
@@ -242,22 +126,12 @@
</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" >
@@ -269,22 +143,6 @@
</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" >
<string>&Close</string>
@@ -296,15 +154,6 @@
</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>