From 965601ae2a294107b614cabf59c6641667de8a9f Mon Sep 17 00:00:00 2001 From: forbes Date: Fri, 13 Feb 2026 14:09:05 -0600 Subject: [PATCH] =?UTF-8?q?cherry-pick=20#26:=20UI=20polish=20=E2=80=94=20?= =?UTF-8?q?Wayland=20scaling,=20menu=20icon=20size=20(cc5ba638d1f)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PreferencePages/DlgSettingsGeneral.cpp | 93 ++++++++++++++----- src/Gui/PreferencePages/DlgSettingsGeneral.h | 5 +- src/Gui/PreferencePages/DlgSettingsGeneral.ui | 36 +++---- src/Gui/PreferencePages/DlgSettingsUI.ui | 61 ++++++------ src/Gui/StartupProcess.cpp | 11 +++ src/Gui/StartupProcess.h | 1 + 6 files changed, 137 insertions(+), 70 deletions(-) diff --git a/src/Gui/PreferencePages/DlgSettingsGeneral.cpp b/src/Gui/PreferencePages/DlgSettingsGeneral.cpp index 3cdc709534..b045da1e8c 100644 --- a/src/Gui/PreferencePages/DlgSettingsGeneral.cpp +++ b/src/Gui/PreferencePages/DlgSettingsGeneral.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -96,7 +97,6 @@ DlgSettingsGeneral::DlgSettingsGeneral(QWidget* parent) ui->SaveNewPreferencePack->setEnabled(false); ui->ManagePreferencePacks->setEnabled(false); ui->themesCombobox->setEnabled(false); - ui->moreThemesLabel->setEnabled(false); } } } @@ -121,7 +121,6 @@ DlgSettingsGeneral::DlgSettingsGeneral(QWidget* parent) this, &DlgSettingsGeneral::onThemeChanged ); - connect(ui->moreThemesLabel, &QLabel::linkActivated, this, &DlgSettingsGeneral::onLinkActivated); } // If there are any saved config file backs, show the revert button, otherwise hide it: @@ -147,9 +146,6 @@ DlgSettingsGeneral::DlgSettingsGeneral(QWidget* parent) const auto visible = UnitsApi::isMultiUnitLength(); ui->comboBox_FracInch->setVisible(visible); ui->fractionalInchLabel->setVisible(visible); - ui->moreThemesLabel->setEnabled( - Application::Instance->commandManager().getCommandByName("Std_AddonMgr") != nullptr - ); } /** @@ -166,7 +162,7 @@ void DlgSettingsGeneral::setRecentFileSize() auto recent = getMainWindow()->findChild(QLatin1String("recentFiles")); if (recent) { ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("RecentFiles"); - recent->resizeList(hGrp->GetInt("RecentFiles", 4)); + recent->resizeList(hGrp->GetInt("RecentFiles", 10)); } } @@ -264,6 +260,11 @@ void DlgSettingsGeneral::saveSettings() hGrp->SetInt("ToolbarIconSize", pixel); getMainWindow()->setIconSize(QSize(pixel, pixel)); + QVariant menuSize = ui->menuIconSize->itemData(ui->menuIconSize->currentIndex()); + int menuPixel = menuSize.toInt(); + hGrp->SetInt("MenuIconSize", menuPixel); + applyMenuIconSize(menuPixel); + int blinkTime {hGrp->GetBool("EnableCursorBlinking", true) ? -1 : 0}; qApp->setCursorFlashTime(blinkTime); @@ -348,6 +349,7 @@ void DlgSettingsGeneral::loadSettings() } addIconSizes(getCurrentIconSize()); + addMenuIconSizes(getCurrentMenuIconSize()); // TreeMode combobox setup. loadDockWindowVisibility(); @@ -395,8 +397,9 @@ void DlgSettingsGeneral::resetSettingsToDefaults() hGrp = WindowParameter::getDefaultParameter()->GetGroup("General"); // reset "Language" parameter hGrp->RemoveASCII("Language"); - // reset "ToolbarIconSize" parameter + // reset "ToolbarIconSize" and "MenuIconSize" parameters hGrp->RemoveInt("ToolbarIconSize"); + hGrp->RemoveInt("MenuIconSize"); // finally reset all the parameters associated to Gui::Pref* widgets PreferencePage::resetSettingsToDefaults(); @@ -534,6 +537,63 @@ void DlgSettingsGeneral::translateIconSizes() } } +int DlgSettingsGeneral::getCurrentMenuIconSize() const +{ + ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("General"); + return hGrp->GetInt("MenuIconSize", 24); +} + +void DlgSettingsGeneral::addMenuIconSizes(int current) +{ + ui->menuIconSize->clear(); + + QList sizes {16, 20, 24, 28}; + if (!sizes.contains(current)) { + sizes.append(current); + } + + for (int size : sizes) { + ui->menuIconSize->addItem(QString(), QVariant(size)); + } + + int index = ui->menuIconSize->findData(QVariant(current)); + ui->menuIconSize->setCurrentIndex(index); + translateMenuIconSizes(); +} + +void DlgSettingsGeneral::translateMenuIconSizes() +{ + auto getSize = [this](int index) { + return ui->menuIconSize->itemData(index).toInt(); + }; + + QStringList sizes; + sizes << tr("Small (%1px)").arg(getSize(0)); + sizes << tr("Medium (%1px)").arg(getSize(1)); + sizes << tr("Large (%1px)").arg(getSize(2)); + sizes << tr("Extra large (%1px)").arg(getSize(3)); + if (ui->menuIconSize->count() > 4) { + sizes << tr("Custom (%1px)").arg(getSize(4)); + } + + for (int index = 0; index < sizes.size(); index++) { + ui->menuIconSize->setItemText(index, sizes[index]); + } +} + +void DlgSettingsGeneral::applyMenuIconSize(int pixel) +{ + // Apply menu icon size via stylesheet override on all QMenu widgets + QString rule = QStringLiteral("QMenu::icon { width: %1px; height: %1px; }").arg(pixel); + for (auto* widget : qApp->allWidgets()) { + if (auto* menu = qobject_cast(widget)) { + menu->setStyleSheet(rule); + } + } + // Store the rule so new menus pick it up via the main window + getMainWindow()->setProperty("_menuIconSizeRule", rule); +} + void DlgSettingsGeneral::retranslateUnits() { auto setItem = [&, index {0}](const std::string& item) mutable { @@ -547,6 +607,7 @@ void DlgSettingsGeneral::changeEvent(QEvent* event) { if (event->type() == QEvent::LanguageChange) { translateIconSizes(); + translateMenuIconSizes(); retranslateUnits(); int index = ui->UseLocaleFormatting->currentIndex(); ui->retranslateUi(this); @@ -823,24 +884,6 @@ void DlgSettingsGeneral::onThemeChanged(int index) themeChanged = true; } -void DlgSettingsGeneral::onLinkActivated(const QString& link) -{ - auto const addonManagerLink = QStringLiteral("freecad:Std_AddonMgr"); - - if (link != addonManagerLink) { - return; - } - - // Set the user preferences to include only preference packs. - // This is a quick and dirty way to open Addon Manager with only themes. - auto pref = App::GetApplication().GetParameterGroupByPath( - "User parameter:BaseApp/Preferences/Addons" - ); - pref->SetInt("PackageTypeSelection", 3); // 3 stands for Preference Packs - pref->SetInt("StatusSelection", 0); // 0 stands for any installation status - - Gui::Application::Instance->commandManager().runCommandByName("Std_AddonMgr"); -} /////////////////////////////////////////////////////////// namespace diff --git a/src/Gui/PreferencePages/DlgSettingsGeneral.h b/src/Gui/PreferencePages/DlgSettingsGeneral.h index 33c49819b5..f977a50a26 100644 --- a/src/Gui/PreferencePages/DlgSettingsGeneral.h +++ b/src/Gui/PreferencePages/DlgSettingsGeneral.h @@ -72,7 +72,6 @@ protected Q_SLOTS: void onManagePreferencePacksClicked(); void onImportConfigClicked(); void onThemeChanged(int index); - void onLinkActivated(const QString& link); public Q_SLOTS: void onUnitSystemIndexChanged(int index); @@ -91,6 +90,10 @@ private: int getCurrentIconSize() const; void addIconSizes(int current); void translateIconSizes(); + int getCurrentMenuIconSize() const; + void addMenuIconSizes(int current); + void translateMenuIconSizes(); + static void applyMenuIconSize(int pixel); private: int localeIndex; diff --git a/src/Gui/PreferencePages/DlgSettingsGeneral.ui b/src/Gui/PreferencePages/DlgSettingsGeneral.ui index 798e29fa78..553978c9e2 100644 --- a/src/Gui/PreferencePages/DlgSettingsGeneral.ui +++ b/src/Gui/PreferencePages/DlgSettingsGeneral.ui @@ -219,35 +219,35 @@ dot/period will always be printed - - - - - 8 - - - - Looking for more themes? You can obtain them using the <a href="freecad:Std_AddonMgr">Addon Manager</a>. - - - Qt::RichText - - - - + + Size of toolbar icons - + Icon size in the toolbar + + + + Size of menu icons + + + + + + + Icon size in context menus and dropdown menus + + + @@ -278,7 +278,7 @@ dot/period will always be printed How many files should be listed in recent files list - 4 + 10 RecentFiles diff --git a/src/Gui/PreferencePages/DlgSettingsUI.ui b/src/Gui/PreferencePages/DlgSettingsUI.ui index ba6eaf104a..0a3177c0ce 100644 --- a/src/Gui/PreferencePages/DlgSettingsUI.ui +++ b/src/Gui/PreferencePages/DlgSettingsUI.ui @@ -23,7 +23,7 @@ - Customize the current theme. The offered settings are optional for theme developers so they may or may not have an effect in the current theme. + Kindred Create Theme true @@ -392,10 +392,10 @@ - Overlay + Panel Visibility - + Hide tab bar in dock overlay @@ -414,23 +414,7 @@ - - - - Show tab bar on mouse over when auto hide - - - Hint show tab bar - - - DockOverlayHintTabBar - - - View - - - - + Hide property view scroll bar in dock overlay @@ -446,7 +430,7 @@ - + Automatically hide overlaid dock panels when in non 3D view (e.g. TechDraw or Spreadsheet) @@ -465,13 +449,22 @@ - + + + + + + + Overlay Interaction + + + - Auto mouse click through transparent part of dock overlay. + Auto mouse click through transparent part of dock overlay - Automatically pass through of the mouse cursor + Automatically pass through mouse cursor true @@ -484,13 +477,13 @@ - + Automatically passes mouse wheel events through the transparent areas of an overlay panel - Automatically pass through of the mouse wheel + Automatically pass through mouse wheel true @@ -503,6 +496,22 @@ + + + + Show tab bar on mouse over when auto hide + + + Hint show tab bar + + + DockOverlayHintTabBar + + + View + + + diff --git a/src/Gui/StartupProcess.cpp b/src/Gui/StartupProcess.cpp index fd1f497535..f487a6634c 100644 --- a/src/Gui/StartupProcess.cpp +++ b/src/Gui/StartupProcess.cpp @@ -56,6 +56,7 @@ #include "Language/Translator.h" #include "Dialogs/DlgVersionMigrator.h" #include "FreeCADStyle.h" +#include "PreferencePages/DlgSettingsGeneral.h" #include #include @@ -226,6 +227,7 @@ void StartupPostProcess::execute() setProcessMessages(); setAutoSaving(); setToolBarIconSize(); + setMenuIconSize(); setWheelEventFilter(); setLocale(); setCursorFlashing(); @@ -281,6 +283,15 @@ void StartupPostProcess::setToolBarIconSize() } } +void StartupPostProcess::setMenuIconSize() +{ + ParameterGrp::handle hGrp = WindowParameter::getDefaultParameter()->GetGroup("General"); + int size = int(hGrp->GetInt("MenuIconSize", 0)); + if (size >= 16) { + DlgSettingsGeneral::applyMenuIconSize(size); + } +} + void StartupPostProcess::setWheelEventFilter() { // filter wheel events for combo boxes diff --git a/src/Gui/StartupProcess.h b/src/Gui/StartupProcess.h index cf4a84daff..5a12b65b58 100644 --- a/src/Gui/StartupProcess.h +++ b/src/Gui/StartupProcess.h @@ -64,6 +64,7 @@ private: void setProcessMessages(); void setAutoSaving(); void setToolBarIconSize(); + void setMenuIconSize(); void setWheelEventFilter(); void setLocale(); void setCursorFlashing();