From 3face5e119e27bf297bbaf647e8941bc6babd0c3 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 --- src/frontends/qt4/GuiDocument.cpp | 55 +++-- src/frontends/qt4/ui/MathsUi.ui | 328 +++++++++++++++--------------- 2 files changed, 208 insertions(+), 175 deletions(-) diff --git a/src/frontends/qt4/GuiDocument.cpp b/src/frontends/qt4/GuiDocument.cpp index 8149b5070f..b6f1f12698 100644 --- a/src/frontends/qt4/GuiDocument.cpp +++ b/src/frontends/qt4/GuiDocument.cpp @@ -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 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); } } 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 + + + + + + -- 2.39.5