Properly fix math packages table in Document Settings

Fixes: #10777
This commit is contained in:
Juergen Spitzmueller 2018-03-18 12:11:26 +01:00
parent 40c290ac27
commit 3face5e119
2 changed files with 208 additions and 175 deletions

View File

@ -1212,7 +1212,7 @@ 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 packnum = 0;
@ -1245,15 +1245,34 @@ 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(packnum, 0, pack);
mathsModule->packagesTW->setCellWidget(packnum, 1, autoRB);
mathsModule->packagesTW->setCellWidget(packnum, 2, alwaysRB);
mathsModule->packagesTW->setCellWidget(packnum, 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->setCellWidget(packnum, 1, autoRBWidget);
mathsModule->packagesTW->setCellWidget(packnum, 2, alwaysRBWidget);
mathsModule->packagesTW->setCellWidget(packnum, 3, neverRBWidget);
connect(autoRB, SIGNAL(clicked()),
this, SLOT(change_adaptor()));
@ -3000,17 +3019,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);
}
@ -3545,17 +3566,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;
}
@ -4565,7 +4589,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>