Abdelrazak Younes wrote:
It seems that Qt4 ui format doesn't support embedded icons like older
version did. I found similar xpm in "trunk/images". I have used those
for now but I am missing the one that should come with the style
PushButton. But the icons still do not show in the math panel under
Windows... Any idea?
no, had the same thing. haven't figured out yet how to solve this.
but these button images should probably be moved to lib/images?
moreover, i've been cleaning up the mathpanel a bit to get rid of some
qt3 convenience classes, see the attached patch (includes the missing
style.xpm).
(i don't really like the hardwired width setting of the iconpallete, but
iconpalette seems a bit misbehaved atm, try to detach or popup the delim
dialog)
it would be nice to have a widget iconpalette that we can hook on to a
toolbutton (as we use for the bullets in the qt2 frontend). it seems
that this can only be done with qmenu objects. we can however not add
widgets in qmenu's so for the moment am still pondering the question...
(ie lost)
comments welcome (also on the patch)
edwin
PS haven't added nicefrak yet, but that is easy
Index: src/frontends/qt4/ui/QMathUi.ui
===================================================================
--- src/frontends/qt4/ui/QMathUi.ui (revision 13551)
+++ src/frontends/qt4/ui/QMathUi.ui (working copy)
@@ -8,8 +8,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>322</width>
- <height>356</height>
+ <width>375</width>
+ <height>321</height>
</rect>
</property>
<property name="windowTitle" >
@@ -18,15 +18,15 @@
<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>
- <layout class="QHBoxLayout" >
+ <item rowspan="3" row="0" column="2" >
+ <layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
@@ -34,7 +34,7 @@
<number>6</number>
</property>
<item>
- <layout class="QVBoxLayout" >
+ <layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
@@ -42,461 +42,182 @@
<number>6</number>
</property>
<item>
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
+ <widget class="QComboBox" name="symbolsCO" >
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>3</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="spacing" >
- <number>6</number>
+ <property name="toolTip" >
+ <string>Select a page of symbols</string>
</property>
<item>
- <widget class="QPushButton" name="sqrtPB" >
- <property name="toolTip" >
- <string>Insert root</string>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="icon" >
- <iconset/>
- </property>
- </widget>
+ <property name="text" >
+ <string>Operators</string>
+ </property>
</item>
<item>
- <widget class="QPushButton" name="spacePB" >
- <property name="toolTip" >
- <string>Insert spacing</string>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="icon" >
- <iconset/>
- </property>
- </widget>
+ <property name="text" >
+ <string>Big operators</string>
+ </property>
</item>
<item>
- <widget class="QPushButton" name="stylePB" >
- <property name="toolTip" >
- <string>Set limits style</string>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="icon" >
- <iconset/>
- </property>
- </widget>
+ <property name="text" >
+ <string>Relations</string>
+ </property>
</item>
<item>
- <widget class="QPushButton" name="fontPB" >
- <property name="toolTip" >
- <string>Set math font</string>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="icon" >
- <iconset/>
- </property>
- </widget>
+ <property name="text" >
+ <string>Greek</string>
+ </property>
</item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
<item>
- <layout class="QGridLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item row="1" column="1" >
- <widget class="QPushButton" name="fracPB" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>1</hsizetype>
- <vsizetype>1</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip" >
- <string>Insert fraction</string>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="icon" >
- <iconset/>
- </property>
- </widget>
- </item>
- <item row="1" column="0" >
- <widget class="QPushButton" name="equationPB" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>1</hsizetype>
- <vsizetype>1</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip" >
- <string>Toggle between display and inline mode</string>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="icon" >
- <iconset/>
- </property>
- </widget>
- </item>
- <item row="0" column="1" >
- <widget class="QPushButton" name="matrixPB" >
- <property name="toolTip" >
- <string>Insert matrix</string>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="icon" >
- <iconset/>
- </property>
- </widget>
- </item>
- <item row="0" column="2" >
- <widget class="QPushButton" name="subscriptPB" >
- <property name="toolTip" >
- <string>Subscript</string>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="icon" >
- <iconset/>
- </property>
- </widget>
- </item>
- <item row="1" column="2" >
- <widget class="QPushButton" name="superscriptPB" >
- <property name="toolTip" >
- <string>Superscript</string>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="icon" >
- <iconset/>
- </property>
- </widget>
- </item>
- <item row="0" column="0" >
- <widget class="QPushButton" name="delimitersPB" >
- <property name="toolTip" >
- <string>Show delimiter and bracket dialog</string>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="icon" >
- <iconset/>
- </property>
- </widget>
- </item>
- </layout>
+ <property name="text" >
+ <string>Arrows</string>
+ </property>
</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>
+ <property name="text" >
+ <string>Dots</string>
+ </property>
</item>
- </layout>
- </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="functionsLA" >
- <property name="text" >
- <string>&Functions</string>
- </property>
- <property name="buddy" >
- <cstring>functionsLB</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="Q3ListBox" name="functionsLB" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>1</hsizetype>
- <vsizetype>7</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize" >
- <size>
- <width>100</width>
- <height>100</height>
- </size>
- </property>
- <property name="toolTip" >
- <string>Select a function or operator to insert</string>
- </property>
- </widget>
- </item>
- </layout>
+ <property name="text" >
+ <string>Frame decorations</string>
+ </property>
</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>
+ <property name="text" >
+ <string>Miscellaneous</string>
+ </property>
</item>
- </layout>
+ <item>
+ <property name="text" >
+ <string>AMS operators</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>AMS relations</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>AMS negated relations</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>AMS arrows</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>AMS Miscellaneous</string>
+ </property>
+ </item>
+ </widget>
</item>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>16</width>
+ <height>22</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</item>
<item>
- <widget class="QGroupBox" name="symbolsGB" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>7</hsizetype>
- <vsizetype>3</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
+ <widget class="QStackedWidget" name="symbolWS" >
+ <widget class="QWidget" name="page" />
+ <widget class="QWidget" name="page_2" />
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" >
+ <property name="margin" >
+ <number>0</number>
</property>
- <property name="minimumSize" >
- <size>
- <width>0</width>
- <height>0</height>
- </size>
+ <property name="spacing" >
+ <number>6</number>
</property>
- <property name="title" >
- <string>Symbols</string>
+ <item>
+ <widget class="QPushButton" name="tearoffPB" >
+ <property name="toolTip" >
+ <string>Open this panel as a separate window</string>
+ </property>
+ <property name="text" >
+ <string>&Detach panel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>81</width>
+ <height>51</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="1" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="0" >
+ <layout class="QVBoxLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="functionsLA" >
+ <property name="text" >
+ <string>&Functions</string>
</property>
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>11</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <widget class="QComboBox" name="symbolsCO" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>3</hsizetype>
- <vsizetype>0</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="toolTip" >
- <string>Select a page of symbols</string>
- </property>
- <item>
- <property name="text" >
- <string>Operators</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Big operators</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Relations</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Greek</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Arrows</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Dots</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Frame decorations</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>Miscellaneous</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>AMS operators</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>AMS relations</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>AMS negated relations</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>AMS arrows</string>
- </property>
- </item>
- <item>
- <property name="text" >
- <string>AMS Miscellaneous</string>
- </property>
- </item>
- </widget>
- </item>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::MinimumExpanding</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item>
- <widget class="Q3WidgetStack" name="symbolsWS" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>7</hsizetype>
- <vsizetype>7</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize" >
- <size>
- <width>0</width>
- <height>200</height>
- </size>
- </property>
- <property name="focusPolicy" >
- <enum>Qt::TabFocus</enum>
- </property>
- </widget>
- </item>
- <item>
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <widget class="QPushButton" name="tearoffPB" >
- <property name="toolTip" >
- <string>Open this panel as a separate window</string>
- </property>
- <property name="text" >
- <string>&Detach panel</string>
- </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>
- </layout>
- </item>
- </layout>
+ <property name="buddy" >
+ <cstring>functionsLW</cstring>
+ </property>
</widget>
</item>
+ <item>
+ <widget class="QListWidget" name="functionsLW" >
+ <property name="alternatingRowColors" >
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
</layout>
</item>
- <item>
+ <item row="3" column="0" colspan="3" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
@@ -514,8 +235,8 @@
</property>
<property name="sizeHint" >
<size>
- <width>20</width>
- <height>20</height>
+ <width>471</width>
+ <height>28</height>
</size>
</property>
</spacer>
@@ -529,25 +250,193 @@
</item>
</layout>
</item>
+ <item row="2" column="0" >
+ <spacer>
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" >
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="0" colspan="2" >
+ <layout class="QGridLayout" >
+ <property name="margin" >
+ <number>0</number>
+ </property>
+ <property name="spacing" >
+ <number>6</number>
+ </property>
+ <item row="2" column="1" >
+ <widget class="QPushButton" name="delimitersPB" >
+ <property name="toolTip" >
+ <string>Show delimiter and bracket dialog</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset>../../../../images/delim.xpm</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1" >
+ <widget class="QPushButton" name="fracPB" >
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip" >
+ <string>Insert fraction</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset>../../../../images/frac.xpm</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2" >
+ <widget class="QPushButton" name="subscriptPB" >
+ <property name="toolTip" >
+ <string>Subscript</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset>../../../../images/sub.xpm</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" >
+ <widget class="QPushButton" name="equationPB" >
+ <property name="sizePolicy" >
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip" >
+ <string>Toggle between display and inline mode</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset>../../../../images/equation.xpm</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" >
+ <widget class="QPushButton" name="spacePB" >
+ <property name="toolTip" >
+ <string>Insert spacing</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset>../../../../images/space.xpm</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" >
+ <widget class="QPushButton" name="matrixPB" >
+ <property name="toolTip" >
+ <string>Insert matrix</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset>../../../../images/matrix.xpm</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" >
+ <widget class="QPushButton" name="sqrtPB" >
+ <property name="toolTip" >
+ <string>Insert root</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset>../../../../images/sqrt.xpm</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2" >
+ <widget class="QPushButton" name="stylePB" >
+ <property name="toolTip" >
+ <string>Set limits style</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset>../../../../images/style.xpm</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3" >
+ <widget class="QPushButton" name="fontPB" >
+ <property name="toolTip" >
+ <string>Set math font</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset>../../../../images/font.xpm</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3" >
+ <widget class="QPushButton" name="superscriptPB" >
+ <property name="toolTip" >
+ <string>Superscript</string>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset>../../../../images/super.xpm</iconset>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
- <customwidgets>
- <customwidget>
- <class>Q3ListBox</class>
- <extends></extends>
- <header>q3listbox.h</header>
- <container>0</container>
- <pixmap></pixmap>
- </customwidget>
- <customwidget>
- <class>Q3WidgetStack</class>
- <extends></extends>
- <header>q3widgetstack.h</header>
- <container>1</container>
- <pixmap></pixmap>
- </customwidget>
- </customwidgets>
+ <tabstops>
+ <tabstop>symbolsCO</tabstop>
+ <tabstop>closePB</tabstop>
+ <tabstop>tearoffPB</tabstop>
+ <tabstop>delimitersPB</tabstop>
+ <tabstop>superscriptPB</tabstop>
+ <tabstop>subscriptPB</tabstop>
+ <tabstop>matrixPB</tabstop>
+ <tabstop>equationPB</tabstop>
+ <tabstop>fracPB</tabstop>
+ <tabstop>fontPB</tabstop>
+ <tabstop>stylePB</tabstop>
+ <tabstop>spacePB</tabstop>
+ <tabstop>sqrtPB</tabstop>
+ </tabstops>
<resources/>
<connections/>
</ui>
Index: src/frontends/qt4/iconpalette.C
===================================================================
--- src/frontends/qt4/iconpalette.C (revision 13551)
+++ src/frontends/qt4/iconpalette.C (working copy)
@@ -82,7 +82,7 @@
if (!layout_->isEmpty() && maxcol == maxcol_)
return;
- int cols(width() / button_size);
+ int cols = max(width() / button_size, 1);
int rows = max(int(buttons_.size() / cols), 1);
if (buttons_.size() % cols)
++rows;
Index: src/frontends/qt4/QMathDialog.C
===================================================================
--- src/frontends/qt4/QMathDialog.C (revision 13551)
+++ src/frontends/qt4/QMathDialog.C (working copy)
@@ -12,58 +12,27 @@
#include "QMathDialog.h"
#include "QMath.h"
-//Added by qt3to4:
+
#include <QPixmap>
#include <QResizeEvent>
+#include <QScrollArea>
+#include <QMenu>
+#include <QPushButton>
+#include <QListWidget>
+#include <QListWidgetItem>
+#include <QIcon>
#include "iconpalette.h"
#include "qt_helpers.h"
-
#include "controllers/ControlMath.h"
-
#include "frontends/lyx_gui.h"
-#include <q3widgetstack.h>
-#include <qpushbutton.h>
-#include <q3listbox.h>
-#include <q3popupmenu.h>
-
using std::string;
namespace lyx {
namespace frontend {
-class QScrollViewSingle : public Q3ScrollView {
-public:
- QScrollViewSingle(QWidget * p)
- : Q3ScrollView(p), w_(0) {
- setResizePolicy(Manual);
- setHScrollBarMode(AlwaysOff);
- setVScrollBarMode(AlwaysOn);
- setBackgroundMode(Qt::PaletteBackground);
- viewport()->setBackgroundMode(Qt::PaletteBackground);
- }
- void setChild(QWidget * w) {
- w_ = w;
- setMinimumWidth(verticalScrollBar()->width() + w_->width() + 4);
- addChild(w_);
- }
-protected:
- virtual void resizeEvent(QResizeEvent * e) {
- Q3ScrollView::resizeEvent(e);
- if (!w_)
- return;
-
- w_->resize(viewport()->width(), w_->height());
- // force the resize to get accurate scrollbar
- lyx_gui::sync_events();
- resizeContents(w_->width(), w_->height());
- }
-private:
- QWidget * w_;
-};
-
namespace {
char const ** panels[] = {
@@ -88,91 +57,89 @@
// enlarge the symbols ComboBox (no scrollbar)
//symbolsCO->setSizeLimit(13);
- connect(symbolsCO, SIGNAL(activated(int)), symbolsWS,
SLOT(raiseWidget(int)));
+ connect( tearoffPB, SIGNAL( clicked() ), this, SLOT( expandClicked() )
);
+ connect( closePB, SIGNAL( clicked() ), this, SLOT( accept() ) );
+ connect( fracPB, SIGNAL( clicked() ), this, SLOT( fracClicked() ) );
+ connect( superscriptPB, SIGNAL( clicked() ), this, SLOT(
superscriptClicked() ) );
+ connect( subscriptPB, SIGNAL( clicked() ), this, SLOT(
subscriptClicked() ) );
+ connect( delimitersPB, SIGNAL( clicked() ), this, SLOT(
delimiterClicked() ) );
+ connect( matrixPB, SIGNAL( clicked() ), this, SLOT( matrixClicked() ) );
+ connect( functionsLW, SIGNAL( itemActivated(QListWidgetItem *) ),
this, SLOT( functionSelected(QListWidgetItem *) ) );
+ connect( equationPB, SIGNAL( clicked() ), this, SLOT( equationClicked()
) );
+ connect( symbolsCO, SIGNAL(activated(int)), this,
SLOT(showingPanel(int)));
- connect( tearoffPB, SIGNAL( clicked() ), this, SLOT( expandClicked() ) );
- connect( closePB, SIGNAL( clicked() ), this, SLOT( accept() ) );
- connect( fracPB, SIGNAL( clicked() ), this, SLOT( fracClicked() ) );
- connect( superscriptPB, SIGNAL( clicked() ), this, SLOT(
superscriptClicked() ) );
- connect( subscriptPB, SIGNAL( clicked() ), this, SLOT( subscriptClicked()
) );
- connect( delimitersPB, SIGNAL( clicked() ), this, SLOT( delimiterClicked()
) );
- connect( matrixPB, SIGNAL( clicked() ), this, SLOT( matrixClicked() ) );
- connect( functionsLB, SIGNAL( selected(const QString&) ), this, SLOT(
functionSelected(const QString &) ) );
- connect( equationPB, SIGNAL( clicked() ), this, SLOT( equationClicked() )
);
-
+ // function list
for (int i = 0; *function_names[i]; ++i) {
- functionsLB->insertItem(function_names[i]);
+ functionsLW->addItem(function_names[i]);
}
+ functionsLW->setFixedWidth(functionsLW->sizeHint().width());
- for (int i = 0; i < nr_panels; ++i) {
- QScrollViewSingle * view = new QScrollViewSingle(symbolsWS);
- symbolsWS->addWidget(view, i);
- }
-
- // aboutToShow() only fires when != 0 in Qt 2 !
- symbolsWS->raiseWidget(0);
+ // add first symbol panel
addPanel(0);
- panel_initialised[0] = true;
+ showingPanel(0);
+ // 5 buttons + 2 margins + 1 scrollbar
+ symbolWS->setFixedWidth(5*40 + 2*10 + 15 );
- connect(symbolsWS, SIGNAL(aboutToShow(int)), this,
SLOT(showingPanel(int)));
+ // add menu's to the buttons
+ QMenu * m = new QMenu(spacePB);
+ m->setTitle(qt_("LyX: Math Spacing"));
+ m->setTearOffEnabled(true);
+ addMenuItem(m, qt_("Thin space \\,"), ",");
+ addMenuItem(m, qt_("Medium space \\:"), ":");
+ addMenuItem(m, qt_("Thick space \\;"), ";");
+ addMenuItem(m, qt_("Quadratin space \\quad"), "quad");
+ addMenuItem(m, qt_("Double quadratin space \\qquad"), "qquad");
+ addMenuItem(m, qt_("Negative space \\!"), "!");
+ spacePB->setMenu(m);
- Q3PopupMenu * m = new Q3PopupMenu(spacePB);
- m->setCaption(qt_("LyX: Math Spacing"));
- m->insertTearOffHandle();
- m->insertItem(qt_("Thin space \\,"), 1);
- m->insertItem(qt_("Medium space \\:"), 2);
- m->insertItem(qt_("Thick space \\;"), 3);
- m->insertItem(qt_("Quadratin space \\quad"), 4);
- m->insertItem(qt_("Double quadratin space \\qquad"), 5);
- m->insertItem(qt_("Negative space \\!"), 6);
- connect(m, SIGNAL(activated(int)), this, SLOT(insertSpace(int)));
- spacePB->setPopup(m);
-
- m = new Q3PopupMenu(sqrtPB);
- m->setCaption(qt_("LyX: Math Roots"));
- m->insertTearOffHandle();
- m->insertItem(qt_("Square root \\sqrt"), 1);
- m->insertItem(qt_("Cube root \\root"), 2);
- m->insertItem(qt_("Other root \\root"), 3);
- connect(m, SIGNAL(activated(int)), this, SLOT(insertRoot(int)));
+ m = new QMenu(sqrtPB);
+ m->setTitle(qt_("LyX: Math Roots"));
+ m->setTearOffEnabled(true);
+ addMenuItem(m, qt_("Square root \\sqrt"), "sqrt");
+ QAction * ma = new QAction(qt_("Cube root \\root"), this);
+ connect(ma, SIGNAL(triggered()), this, SLOT(insertCubeRoot()));
+ m->addAction(ma);
+ addMenuItem(m, qt_("Other root \\root"), "root");
sqrtPB->setPopup(m);
- m = new Q3PopupMenu(stylePB);
- m->setCaption(qt_("LyX: Math Styles"));
- m->insertTearOffHandle();
- m->insertItem(qt_("Display style \\displaystyle"), 1);
- m->insertItem(qt_("Normal text style \\textstyle"), 2);
- m->insertItem(qt_("Script (small) style \\scriptstyle"), 3);
- m->insertItem(qt_("Scriptscript (smaller) style \\scriptscriptstyle"),
4);
- connect(m, SIGNAL(activated(int)), this, SLOT(insertStyle(int)));
+ m = new QMenu(stylePB);
+ m->setTitle(qt_("LyX: Math Styles"));
+ m->setTearOffEnabled(true);
+ addMenuItem(m, qt_("Display style \\displaystyle"),
"displaystyle");
+ addMenuItem(m, qt_("Normal text style \\textstyle"), "textstyle");
+ addMenuItem(m, qt_("Script (small) style \\scriptstyle"),
"scriptstyle");
+ addMenuItem(m, qt_("Scriptscript (smaller) style
\\scriptscriptstyle"), "scriptscriptstyle");
stylePB->setPopup(m);
- m = new Q3PopupMenu(fontPB);
- m->setCaption(qt_("LyX: Math Fonts"));
- m->insertTearOffHandle();
- m->insertItem(qt_("Roman \\mathrm"), 1);
- m->insertItem(qt_("Bold \\mathbf"), 2);
- m->insertItem(qt_("Bold symbol \\boldsymbol"), 3);
- m->insertItem(qt_("Sans serif \\mathsf"), 4);
- m->insertItem(qt_("Italic \\mathit"), 5);
- m->insertItem(qt_("Typewriter \\mathtt"), 6);
- m->insertItem(qt_("Blackboard \\mathbb"), 7);
- m->insertItem(qt_("Fraktur \\mathfrak"), 8);
- m->insertItem(qt_("Calligraphic \\mathcal"), 9);
- m->insertItem(qt_("Normal text mode \\textrm"), 10);
- connect(m, SIGNAL(activated(int)), this, SLOT(insertFont(int)));
+ m = new QMenu(fontPB);
+ m->setTitle(qt_("LyX: Math Fonts"));
+ m->setTearOffEnabled(true);
+ addMenuItem(m, qt_("Roman \\mathrm"), "mathrm");
+ addMenuItem(m, qt_("Bold \\mathbf"), "mathbf");
+ addMenuItem(m, qt_("Bold symbol \\boldsymbol"), "boldsymbol");
+ addMenuItem(m, qt_("Sans serif \\mathsf"), "mathsf");
+ addMenuItem(m, qt_("Italic \\mathit"), "mathit");
+ addMenuItem(m, qt_("Typewriter \\mathtt"), "mathtt");
+ addMenuItem(m, qt_("Blackboard \\mathbb"), "mathbb");
+ addMenuItem(m, qt_("Fraktur \\mathfrak"), "mathfrak");
+ addMenuItem(m, qt_("Calligraphic \\mathcal"), "mathcal");
+ addMenuItem(m, qt_("Normal text mode \\textrm"), "textrm");
fontPB->setPopup(m);
}
+void QMathDialog::addMenuItem(QMenu * menu, const QString & label, const
std::string & action)
+{
+ QMAction * ma = new QMAction(label,action, this);
+ connect(ma, SIGNAL(action(const std::string &)), this,
SLOT(symbol_clicked(const std::string &)));
+ menu->addAction(ma);
+}
void QMathDialog::showingPanel(int num)
{
- if (panel_initialised[num])
- return;
+ if (!panel_initialised[num])
+ addPanel(num);
- addPanel(num);
-
- panel_initialised[num] = true;
+ symbolWS->setCurrentIndex(num);
}
@@ -192,9 +159,12 @@
void QMathDialog::addPanel(int num)
{
- QScrollViewSingle * view =
static_cast<QScrollViewSingle*>(symbolsWS->widget(num));
- IconPalette * p = makePanel(view->viewport(), panels[num]);
- view->setChild(p);
+ QScrollArea * sc = new QScrollArea(symbolWS);
+ IconPalette * p = makePanel(this, panels[num]);
+ p->resize(40 * 5, p->height());
+ sc->setWidget(p);
+ symbolWS->insertWidget(num,sc);
+ panel_initialised[num] = true;
}
@@ -218,10 +188,10 @@
void QMathDialog::expandClicked()
{
- int const id = symbolsWS->id(symbolsWS->visibleWidget());
+ int const id = symbolsCO->currentIndex();
IconPalette * p = makePanel(0, panels[id]);
string s = "LyX: ";
- s += fromqstr(symbolsCO->text(id));
+ s += fromqstr(symbolsCO->currentText());
p->setCaption(toqstr(s));
p->resize(40 * 5, p->height());
p->show();
@@ -229,9 +199,9 @@
}
-void QMathDialog::functionSelected(const QString & str)
+void QMathDialog::functionSelected(QListWidgetItem * item)
{
- form_->controller().dispatchInsert(fromqstr(str));
+ form_->controller().dispatchInsert(fromqstr(item->text()));
}
@@ -259,70 +229,11 @@
}
-void QMathDialog::insertSpace(int id)
+void QMathDialog::insertCubeRoot()
{
- string str;
- switch (id) {
- case 1: str = ","; break;
- case 2: str = ":"; break;
- case 3: str = ";"; break;
- case 4: str = "quad"; break;
- case 5: str = "qquad"; break;
- case 6: str = "!"; break;
- default: return;
- }
- form_->controller().dispatchInsert(str);
+ form_->controller().dispatchCubeRoot();
}
-void QMathDialog::insertRoot(int id)
-{
- switch (id) {
- case 1:
- form_->controller().dispatchInsert("sqrt");
- break;
- case 2:
- form_->controller().dispatchCubeRoot();
- break;
- case 3:
- form_->controller().dispatchInsert("root");
- break;
- }
-}
-
-
-void QMathDialog::insertStyle(int id)
-{
- string str;
- switch (id) {
- case 1: str = "displaystyle"; break;
- case 2: str = "textstyle"; break;
- case 3: str = "scriptstyle"; break;
- case 4: str = "scriptscriptstyle"; break;
- default: return;
- }
- form_->controller().dispatchInsert(str);
-}
-
-
-void QMathDialog::insertFont(int id)
-{
- string str;
- switch (id) {
- case 1: str = "mathrm"; break;
- case 2: str = "mathbf"; break;
- case 3: str = "boldsymbol"; break;
- case 4: str = "mathsf"; break;
- case 5: str = "mathit"; break;
- case 6: str = "mathtt"; break;
- case 7: str = "mathbb"; break;
- case 8: str = "mathfrak"; break;
- case 9: str = "mathcal"; break;
- case 10: str = "textrm"; break;
- default: return;
- }
- form_->controller().dispatchInsert(str);
-}
-
} // namespace frontend
} // namespace lyx
Index: src/frontends/qt4/QMathDialog.h
===================================================================
--- src/frontends/qt4/QMathDialog.h (revision 13551)
+++ src/frontends/qt4/QMathDialog.h (working copy)
@@ -18,10 +18,29 @@
#include <QDialog>
class IconPalette;
+class QListWidgetItem;
namespace lyx {
namespace frontend {
+class QMAction : public QAction {
+ Q_OBJECT
+public:
+ QMAction( const QString & text, const std::string & action, QObject *
parent)
+ : QAction(text,parent), action_(action) {
+ connect(this, SIGNAL(triggered()), this, SLOT(action()));
+ }
+signals:
+ void action(const std::string &);
+protected slots:
+ void action() {
+ emit action(action_);
+ }
+private:
+ std::string action_;
+};
+
+
class QMath;
class QMathDialog : public QDialog, public Ui::QMathUi
@@ -33,25 +52,23 @@
virtual void delimiterClicked();
virtual void expandClicked();
virtual void fracClicked();
- virtual void functionSelected(const QString &);
+ virtual void functionSelected(QListWidgetItem *);
virtual void matrixClicked();
virtual void subscriptClicked();
virtual void superscriptClicked();
virtual void equationClicked();
void symbol_clicked(const std::string &);
- void insertSpace(int id);
- void insertRoot(int id);
- void insertStyle(int id);
- void insertFont(int id);
+ void insertCubeRoot();
/// about to show a symbol panel
void showingPanel(int);
protected:
//needed ? virtual void closeEvent(QCloseEvent * e);
private:
+ /// add item to popup menu
+ void addMenuItem(QMenu * menu, const QString & label, const std::string
&);
/// make a symbol panel
IconPalette * makePanel(QWidget * parent, char const ** entries);
-
/// add a symbol panel
void addPanel(int num);
Index: images/style.xpm
===================================================================
--- images/style.xpm (revision 13551)
+++ images/style.xpm (working copy)
@@ -1,28 +1,26 @@
/* XPM */
-static char const * style_xpm[] = {
-"20 20 5 1",
+static char * delim2_xpm[] = {
+"20 20 3 1",
" c None",
-". c #0000ff",
-"X c #000000",
-"o c #0000ff",
-"Y c #0000ff",
+". c #0000FF",
+"+ c #000000",
" ",
-" ...... oooooo ",
-" ...... oo oo ",
-" .. .. oo oo ",
-" ...... ooooooo ",
-" ...... oo oo ",
-" .. .. oo oo ",
-" .. .. oo oo ",
-" .. .. oo oo ",
" ",
-" XX ",
-" XXXX YYYYY ",
-" XX XX Y Y ",
-" XX XX Y Y ",
-" XXXXXXXX YYYYYYY ",
-" XX XX Y Y ",
-" XX XX Y Y ",
-" XX XX Y Y ",
-" XX XX YYY YYY ",
+" .......... ++++++ ",
+" .......... ++++++ ",
+" .. . ++ ++ ",
+" .. ++ ++ ",
+" .. ++++++ ",
+" .. ++++++ ",
+" .. ",
+" .. ",
+" .. ",
+" .. ",
+" .. ++++++ ",
+" .. ++++++ ",
+" .. ++ ++ ",
+" .. . ++ ++ ",
+" .......... ++++++ ",
+" .......... ++++++ ",
+" ",
" "};
Index: images/font.xpm
===================================================================
--- images/font.xpm (revision 0)
+++ images/font.xpm (revision 0)
@@ -0,0 +1,28 @@
+/* XPM */
+static char const * style_xpm[] = {
+"20 20 5 1",
+" c None",
+". c #0000ff",
+"X c #000000",
+"o c #0000ff",
+"Y c #0000ff",
+" ",
+" ...... oooooo ",
+" ...... oo oo ",
+" .. .. oo oo ",
+" ...... ooooooo ",
+" ...... oo oo ",
+" .. .. oo oo ",
+" .. .. oo oo ",
+" .. .. oo oo ",
+" ",
+" XX ",
+" XXXX YYYYY ",
+" XX XX Y Y ",
+" XX XX Y Y ",
+" XXXXXXXX YYYYYYY ",
+" XX XX Y Y ",
+" XX XX Y Y ",
+" XX XX Y Y ",
+" XX XX YYY YYY ",
+" "};