]> git.lyx.org Git - features.git/commitdiff
Improve usability of quotation mark selection (#12872)
authorJuergen Spitzmueller <spitz@lyx.org>
Tue, 15 Aug 2023 18:21:32 +0000 (20:21 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Tue, 15 Aug 2023 18:21:32 +0000 (20:21 +0200)
src/frontends/qt/GuiDocument.cpp

index 309b1d88fdfa8fe08dfef4713c0d83044f1eb9c9..f9fb19b331f6e2c5c15b5d0b1fe58a03108f635a 100644 (file)
@@ -2424,6 +2424,25 @@ void GuiDocument::updateQuoteStyles(bool const set)
                        langModule->quoteStyleCO->addItem(
                                toqstr(quoteparams.getGuiLabel(qs, langdef)), static_cast<int>(qs));
        }
+       // Use document serif font to assure quotation marks are distinguishable
+       QFont comboFont(toqstr(lyxrc.roman_font_name),
+                       langModule->quoteStyleCO->fontInfo().pointSize() * 1.4, -1, false);
+       QFontMetrics fm(comboFont);
+       // calculate width of the widest item in the set font
+       int qswidth = 0;
+       for (int i = 0; i < langModule->quoteStyleCO->count(); ++i) {
+               langModule->quoteStyleCO->setItemData(i, QVariant(comboFont), Qt::FontRole);
+               QString str = langModule->quoteStyleCO->itemText(i);
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
+               qswidth = max(qswidth, fm.horizontalAdvance(str));
+#else
+               qswidth = max(qswidth, fm.width(str));
+#endif
+       }
+       // add scrollbar width and margin to width
+       qswidth += langModule->quoteStyleCO->style()->pixelMetric(QStyle::PM_ScrollBarExtent);
+       qswidth += langModule->quoteStyleCO->view()->autoScrollMargin();
+       langModule->quoteStyleCO->view()->setMinimumWidth(qswidth);
        if (set && has_default)
                // (re)set to the default style
                langModule->quoteStyleCO->setCurrentIndex(0);