Properly fix math packages table in Document Settings

Fixes: #10777
(cherry picked from commit 3face5e119)
This commit is contained in:
Juergen Spitzmueller 2018-03-18 12:11:26 +01:00
parent 91a15383f9
commit 7927d71a08
3 changed files with 215 additions and 178 deletions

View File

@ -1213,10 +1213,10 @@ GuiDocument::GuiDocument(GuiView & lv)
headers << qt_("Package") << qt_("Load automatically")
<< qt_("Load always") << qt_("Do not load");
mathsModule->packagesTW->setHorizontalHeaderLabels(headers);
setSectionResizeMode(mathsModule->packagesTW->horizontalHeader(), QHeaderView::ResizeToContents);
setSectionResizeMode(mathsModule->packagesTW->horizontalHeader(), QHeaderView::Stretch);
map<string, string> const & packages = BufferParams::auto_packages();
mathsModule->packagesTW->setRowCount(packages.size());
int i = 0;
int packnum = 0;
for (map<string, string>::const_iterator it = packages.begin();
it != packages.end(); ++it) {
docstring const package = from_ascii(it->first);
@ -1247,15 +1247,35 @@ GuiDocument::GuiDocument(GuiView & lv)
autoRB->setToolTip(autoTooltip);
alwaysRB->setToolTip(alwaysTooltip);
neverRB->setToolTip(neverTooltip);
// Pack the buttons in a layout in order to get proper alignment
QWidget * autoRBWidget = new QWidget();
QHBoxLayout * autoRBLayout = new QHBoxLayout(autoRBWidget);
autoRBLayout->addWidget(autoRB);
autoRBLayout->setAlignment(Qt::AlignCenter);
autoRBLayout->setContentsMargins(0, 0, 0, 0);
autoRBWidget->setLayout(autoRBLayout);
QWidget * alwaysRBWidget = new QWidget();
QHBoxLayout * alwaysRBLayout = new QHBoxLayout(alwaysRBWidget);
alwaysRBLayout->addWidget(alwaysRB);
alwaysRBLayout->setAlignment(Qt::AlignCenter);
alwaysRBLayout->setContentsMargins(0, 0, 0, 0);
alwaysRBWidget->setLayout(alwaysRBLayout);
QWidget * neverRBWidget = new QWidget();
QHBoxLayout * neverRBLayout = new QHBoxLayout(neverRBWidget);
neverRBLayout->addWidget(neverRB);
neverRBLayout->setAlignment(Qt::AlignCenter);
neverRBLayout->setContentsMargins(0, 0, 0, 0);
neverRBWidget->setLayout(neverRBLayout);
QTableWidgetItem * pack = new QTableWidgetItem(toqstr(package));
mathsModule->packagesTW->setItem(i, 0, pack);
mathsModule->packagesTW->setCellWidget(i, 1, autoRB);
mathsModule->packagesTW->setCellWidget(i, 2, alwaysRB);
mathsModule->packagesTW->setCellWidget(i, 3, neverRB);
//center the radio buttons
autoRB->setStyleSheet("margin-left:50%; margin-right:50%;");
alwaysRB->setStyleSheet("margin-left:50%; margin-right:50%;");
neverRB->setStyleSheet("margin-left:50%; margin-right:50%;");
mathsModule->packagesTW->setItem(packnum, 0, pack);
mathsModule->packagesTW->setCellWidget(packnum, 1, autoRBWidget);
mathsModule->packagesTW->setCellWidget(packnum, 2, alwaysRBWidget);
mathsModule->packagesTW->setCellWidget(packnum, 3, neverRBWidget);
connect(autoRB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
@ -1263,7 +1283,7 @@ GuiDocument::GuiDocument(GuiView & lv)
this, SLOT(change_adaptor()));
connect(neverRB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
++i;
++packnum;
}
connect(mathsModule->allPackagesAutoPB, SIGNAL(clicked()),
this, SLOT(allPackagesAuto()));
@ -3004,17 +3024,19 @@ void GuiDocument::applyView()
if (!item)
continue;
int row = mathsModule->packagesTW->row(item);
QRadioButton * rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 1);
QRadioButton * rb =
(QRadioButton*)mathsModule->packagesTW->cellWidget(row, 1)->layout()->itemAt(0)->widget();
if (rb->isChecked()) {
bp_.use_package(it->first, BufferParams::package_auto);
continue;
}
rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 2);
rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 2)->layout()->itemAt(0)->widget();
if (rb->isChecked()) {
bp_.use_package(it->first, BufferParams::package_on);
continue;
}
rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 3);
rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 3)->layout()->itemAt(0)->widget();
if (rb->isChecked())
bp_.use_package(it->first, BufferParams::package_off);
}
@ -3549,17 +3571,20 @@ void GuiDocument::paramsToDialog()
int row = mathsModule->packagesTW->row(item);
switch (bp_.use_package(it->first)) {
case BufferParams::package_off: {
QRadioButton * rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 3);
QRadioButton * rb =
(QRadioButton*)mathsModule->packagesTW->cellWidget(row, 3)->layout()->itemAt(0)->widget();
rb->setChecked(true);
break;
}
case BufferParams::package_on: {
QRadioButton * rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 2);
QRadioButton * rb =
(QRadioButton*)mathsModule->packagesTW->cellWidget(row, 2)->layout()->itemAt(0)->widget();
rb->setChecked(true);
break;
}
case BufferParams::package_auto: {
QRadioButton * rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, 1);
QRadioButton * rb =
(QRadioButton*)mathsModule->packagesTW->cellWidget(row, 1)->layout()->itemAt(0)->widget();
rb->setChecked(true);
break;
}
@ -4569,7 +4594,8 @@ void GuiDocument::allPackagesNot()
void GuiDocument::allPackages(int col)
{
for (int row = 0; row < mathsModule->packagesTW->rowCount(); ++row) {
QRadioButton * rb = (QRadioButton*)mathsModule->packagesTW->cellWidget(row, col);
QRadioButton * rb =
(QRadioButton*)mathsModule->packagesTW->cellWidget(row, col)->layout()->itemAt(0)->widget();
rb->setChecked(true);
}
}

View File

@ -6,172 +6,15 @@
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<width>569</width>
<height>367</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QLabel" name="allPakcagesLA">
<property name="text">
<string>All packages:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="allPackagesAutoPB">
<property name="text">
<string>Load A&amp;utomatically</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="allPackagesAlwaysPB">
<property name="text">
<string>Load Alwa&amp;ys</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="allPackagesNotPB">
<property name="text">
<string>Do &amp;Not Load</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="MathIndentCB">
<property name="toolTip">
<string>Indent displayed formulas instead of centering</string>
</property>
<property name="text">
<string>Indent &amp;Formulas</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="MathIndentCO">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Size of the indentation</string>
</property>
</widget>
</item>
<item row="2" column="2" colspan="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>234</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="MathIndentLE">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="lyx::frontend::LengthCombo" name="MathIndentLengthCO">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string/>
</property>
</widget>
</item>
<item row="3" column="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>153</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QLabel" name="MathNumberingPosL">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>115</width>
<height>18</height>
</size>
</property>
<property name="text">
<string>Formula numbering side:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="MathNumberingPosCO">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Side where formulas are numbered</string>
</property>
</widget>
</item>
<item row="4" column="2" colspan="2">
<spacer name="horizontalSpacer_1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>234</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="4">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QTableWidget" name="packagesTW">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@ -197,6 +40,171 @@
<column/>
</widget>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="allPakcagesLA">
<property name="text">
<string>All packages:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="allPackagesAutoPB">
<property name="text">
<string>Load A&amp;utomatically</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="allPackagesAlwaysPB">
<property name="text">
<string>Load Alwa&amp;ys</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="allPackagesNotPB">
<property name="text">
<string>Do &amp;Not Load</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="MathIndentCB">
<property name="toolTip">
<string>Indent displayed formulas instead of centering</string>
</property>
<property name="text">
<string>Indent &amp;Formulas</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="MathIndentCO">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Size of the indentation</string>
</property>
</widget>
</item>
<item row="1" column="2" colspan="2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>234</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="MathIndentLE">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="lyx::frontend::LengthCombo" name="MathIndentLengthCO">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string/>
</property>
</widget>
</item>
<item row="2" column="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>153</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="MathNumberingPosL">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>115</width>
<height>18</height>
</size>
</property>
<property name="text">
<string>Formula numbering side:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="MathNumberingPosCO">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Side where formulas are numbered</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>234</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>

View File

@ -66,6 +66,9 @@ What's new
- Allow unification of graphic groups inside marked block via context
menu.
- Cosmetic polishment of the "Math Options" pane of Document Settings
(bug 10777).
* DOCUMENTATION AND LOCALIZATION