From 7927d71a08ee22ff43782e34ea9f4f94f65210e0 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Sun, 18 Mar 2018 12:11:26 +0100 Subject: [PATCH] Properly fix math packages table in Document Settings Fixes: #10777 (cherry picked from commit 3face5e119e27bf297bbaf647e8941bc6babd0c3) --- src/frontends/qt4/GuiDocument.cpp | 62 ++++-- src/frontends/qt4/ui/MathsUi.ui | 328 +++++++++++++++--------------- status.23x | 3 + 3 files changed, 215 insertions(+), 178 deletions(-) diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 7e40ff6cec..4020f17fa9 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -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 const & packages = BufferParams::auto_packages(); mathsModule->packagesTW->setRowCount(packages.size()); - int i = 0; + int packnum = 0; for (map::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); } } diff --git a/src/frontends/qt4/ui/MathsUi.ui b/src/frontends/qt4/ui/MathsUi.ui index 380d76a3a5..13f15dcc84 100644 --- a/src/frontends/qt4/ui/MathsUi.ui +++ b/src/frontends/qt4/ui/MathsUi.ui @@ -6,172 +6,15 @@ 0 0 - 500 + 569 367 - - - - - All packages: - - - - - - - Load A&utomatically - - - - - - - Load Alwa&ys - - - - - - - Do &Not Load - - - - - - - Indent displayed formulas instead of centering - - - Indent &Formulas - - - - - - - false - - - - 0 - 0 - - - - Size of the indentation - - - - - - - Qt::Horizontal - - - - 234 - 20 - - - - - - - - false - - - - - - - - - - - - - false - - - - 0 - 0 - - - - - - - - - - - Qt::Horizontal - - - - 153 - 20 - - - - - - - - - 0 - 0 - - - - - 115 - 18 - - - - Formula numbering side: - - - - - - - true - - - - 0 - 0 - - - - Side where formulas are numbered - - - - - - - Qt::Horizontal - - - - 234 - 17 - - - - - + + @@ -197,6 +40,171 @@ + + + + + + All packages: + + + + + + + Load A&utomatically + + + + + + + Load Alwa&ys + + + + + + + Do &Not Load + + + + + + + Indent displayed formulas instead of centering + + + Indent &Formulas + + + + + + + false + + + + 0 + 0 + + + + Size of the indentation + + + + + + + Qt::Horizontal + + + + 234 + 20 + + + + + + + + false + + + + + + + + + + + + + false + + + + 0 + 0 + + + + + + + + + + + Qt::Horizontal + + + + 153 + 20 + + + + + + + + + + + + + 0 + 0 + + + + + 115 + 18 + + + + Formula numbering side: + + + + + + + true + + + + 0 + 0 + + + + Side where formulas are numbered + + + + + + + Qt::Horizontal + + + + 234 + 17 + + + + + + diff --git a/status.23x b/status.23x index 59ef0bf921..ca88a24970 100644 --- a/status.23x +++ b/status.23x @@ -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 -- 2.39.5