int const end = nr_latex_delimiters - 1;
for (int i = 0; i < end; ++i) {
string const delim = latex_delimiters[i];
- MathSymbol const & ms = mathSymbol(delim);
+ MathSymbol const & ms = mathSymbol(delim);
QString symbol(ms.fontcode?
QChar(ms.fontcode) : toqstr(docstring(1, ms.unicode)));
QListWidgetItem * lwi = new QListWidgetItem(symbol);
}
for (int i = 0; i != leftLW->count(); ++i) {
- MathSymbol const & ms = mathSymbol(getDelimiterName(leftLW->item(i)));
+ MathSymbol const & ms = mathSymbol(getDelimiterName(leftLW->item(i)));
rightLW->addItem(list_items[doMatch(ms.unicode)]->clone());
}
}
texCodeL->setText(qt_("TeX Code: ") + toqstr(code_str));
+
+ // Enable the Swap button with non-matched pairs
+ bool const allow_swap =
+ (doMatch(mathSymbol(getDelimiterName(leftLW->currentItem())).unicode)
+ != mathSymbol(getDelimiterName(rightLW->currentItem())).unicode);
+ swapPB->setEnabled(allow_swap);
}
updateTeXCode(sizeCO->currentIndex());
}
+void GuiDelimiter::on_swapPB_clicked()
+{
+ // Get current math symbol for each side.
+ MathSymbol const & lms =
+ mathSymbol(getDelimiterName(leftLW->currentItem()));
+ MathSymbol const & rms =
+ mathSymbol(getDelimiterName(rightLW->currentItem()));
+
+ // Swap and match.
+ char_type const lc = doMatch(rms.unicode);
+ char_type const rc = doMatch(lms.unicode);
+
+ // Convert back to QString to locate them in the widget.
+ MathSymbol const & nlms = mathSymbol(texName(lc));
+ MathSymbol const & nrms = mathSymbol(texName(rc));
+ QString lqs(nlms.fontcode ?
+ QChar(nlms.fontcode) : toqstr(docstring(1, nlms.unicode)));
+ QString rqs(nrms.fontcode ?
+ QChar(nrms.fontcode) : toqstr(docstring(1, nrms.unicode)));
+
+ // Handle unencoded "symbol" of "(None)".
+ if (lqs.toStdString() == "?")
+ lqs = qt_("(None)");
+ if(rqs.toStdString() == "?")
+ rqs = qt_("(None)");
+
+ // Locate matching QListWidgetItem.
+ QList<QListWidgetItem *> lwi = leftLW->findItems(lqs, Qt::MatchExactly);
+ QList<QListWidgetItem *> rwi = rightLW->findItems(rqs, Qt::MatchExactly);
+
+ // Select.
+ leftLW->setCurrentItem(lwi.first());
+ rightLW->setCurrentItem(rwi.first());
+
+ updateTeXCode(sizeCO->currentIndex());
+}
+
Dialog * createGuiDelimiter(GuiView & lv) { return new GuiDelimiter(lv); }
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
<class>DelimiterUi</class>
- <widget class="QDialog" name="DelimiterUi" >
- <property name="geometry" >
+ <widget class="QDialog" name="DelimiterUi">
+ <property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<height>352</height>
</rect>
</property>
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>5</vsizetype>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="minimumSize" >
+ <property name="minimumSize">
<size>
<width>300</width>
<height>330</height>
</size>
</property>
- <property name="maximumSize" >
+ <property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
- <property name="windowTitle" >
+ <property name="windowTitle">
<string/>
</property>
- <property name="sizeGripEnabled" >
+ <property name="sizeGripEnabled">
<bool>true</bool>
</property>
- <layout class="QGridLayout" name="gridLayout" >
- <item row="0" column="0" >
- <layout class="QGridLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item row="0" column="0" >
- <layout class="QHBoxLayout" >
- <property name="spacing" >
- <number>6</number>
- </property>
- <property name="margin" >
- <number>0</number>
- </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <layout class="QGridLayout">
+ <item row="5" column="0">
+ <layout class="QHBoxLayout">
<item>
- <widget class="QListWidget" name="leftLW" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>5</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize" >
- <size>
- <width>60</width>
- <height>0</height>
- </size>
+ <spacer>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
</property>
- <property name="maximumSize" >
- <size>
- <width>140</width>
- <height>16777215</height>
- </size>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
</property>
- <property name="iconSize" >
+ <property name="sizeHint" stdset="0">
<size>
- <width>16</width>
- <height>16</height>
+ <width>50</width>
+ <height>28</height>
</size>
</property>
- <property name="resizeMode" >
- <enum>QListView::Adjust</enum>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="insertPB">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="spacing" >
- <number>2</number>
+ <property name="toolTip">
+ <string>Insert the delimiters</string>
</property>
- <property name="currentRow" >
- <number>-1</number>
+ <property name="text">
+ <string>&Insert</string>
</property>
</widget>
</item>
<item>
- <widget class="QListWidget" name="rightLW" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>5</vsizetype>
+ <widget class="QPushButton" name="closePB">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="minimumSize" >
- <size>
- <width>60</width>
- <height>0</height>
- </size>
- </property>
- <property name="maximumSize" >
- <size>
- <width>139</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="iconSize" >
- <size>
- <width>16</width>
- <height>16</height>
- </size>
- </property>
- <property name="resizeMode" >
- <enum>QListView::Adjust</enum>
- </property>
- <property name="spacing" >
- <number>2</number>
+ <property name="text">
+ <string>&Close</string>
</property>
</widget>
</item>
</layout>
</item>
- <item row="1" column="0" >
- <widget class="QLabel" name="texCodeL" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>3</hsizetype>
- <vsizetype>0</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text" >
- <string>TeX Code: </string>
- </property>
- <property name="textFormat" >
- <enum>Qt::AutoText</enum>
- </property>
- <property name="alignment" >
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- <property name="wordWrap" >
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="2" column="0" >
- <widget class="QCheckBox" name="matchCB" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>3</hsizetype>
- <vsizetype>0</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <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="3" column="0" >
- <layout class="QHBoxLayout" >
- <property name="spacing" >
- <number>6</number>
- </property>
- <property name="margin" >
- <number>0</number>
- </property>
+ <item row="4" column="0">
+ <layout class="QHBoxLayout">
<item>
- <widget class="QLabel" name="label" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>0</vsizetype>
+ <widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="text" >
- <string>&Size:</string>
+ <property name="text">
+ <string>Si&ze:</string>
</property>
- <property name="alignment" >
+ <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
- <property name="buddy" >
+ <property name="buddy">
<cstring>sizeCO</cstring>
</property>
</widget>
</item>
<item>
- <widget class="QComboBox" name="sizeCO" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>0</vsizetype>
+ <widget class="QComboBox" name="sizeCO">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</item>
<item>
<spacer>
- <property name="orientation" >
+ <property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
- <property name="sizeHint" stdset="0" >
+ <property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</item>
</layout>
</item>
- <item row="4" column="0" >
- <layout class="QHBoxLayout" >
- <property name="spacing" >
- <number>6</number>
+ <item row="1" column="0">
+ <widget class="QLabel" name="texCodeL">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="margin" >
- <number>0</number>
+ <property name="text">
+ <string>TeX Code: </string>
+ </property>
+ <property name="textFormat">
+ <enum>Qt::AutoText</enum>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <layout class="QHBoxLayout">
<item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
+ <widget class="QListWidget" name="leftLW">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="sizeType" >
- <enum>QSizePolicy::Expanding</enum>
+ <property name="minimumSize">
+ <size>
+ <width>60</width>
+ <height>0</height>
+ </size>
</property>
- <property name="sizeHint" stdset="0" >
+ <property name="maximumSize">
<size>
- <width>50</width>
- <height>28</height>
+ <width>140</width>
+ <height>16777215</height>
</size>
</property>
- </spacer>
+ <property name="iconSize">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ <property name="resizeMode">
+ <enum>QListView::Adjust</enum>
+ </property>
+ <property name="spacing">
+ <number>2</number>
+ </property>
+ <property name="currentRow">
+ <number>-1</number>
+ </property>
+ </widget>
</item>
<item>
- <widget class="QPushButton" name="insertPB" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>0</vsizetype>
+ <widget class="QListWidget" name="rightLW">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="toolTip" >
- <string>Insert the delimiters</string>
+ <property name="minimumSize">
+ <size>
+ <width>60</width>
+ <height>0</height>
+ </size>
</property>
- <property name="text" >
- <string>&Insert</string>
+ <property name="maximumSize">
+ <size>
+ <width>139</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ <property name="resizeMode">
+ <enum>QListView::Adjust</enum>
+ </property>
+ <property name="spacing">
+ <number>2</number>
</property>
</widget>
</item>
+ </layout>
+ </item>
+ <item row="2" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout">
<item>
- <widget class="QPushButton" name="closePB" >
- <property name="sizePolicy" >
- <sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>0</vsizetype>
+ <widget class="QCheckBox" name="matchCB">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="text" >
- <string>&Close</string>
+ <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>
+ <widget class="QPushButton" name="swapPB">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>Swap left and right delimiter type (while reversing to the appropriate direction)</string>
+ </property>
+ <property name="text">
+ <string>S&wap && Reverse</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
- <zorder>leftLW</zorder>
</widget>
- <layoutdefault spacing="6" margin="9" />
+ <layoutdefault spacing="6" margin="9"/>
<tabstops>
- <tabstop>matchCB</tabstop>
<tabstop>sizeCO</tabstop>
<tabstop>insertPB</tabstop>
<tabstop>closePB</tabstop>
</tabstops>
<includes>
- <include location="local" >qt_i18n.h</include>
+ <include location="local">qt_i18n.h</include>
</includes>
<resources/>
<connections/>