From a49f156ce0326517bd3168b10c1c0d7c6ae5aab1 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 21 Aug 2023 15:51:49 +0300 Subject: [PATCH] Better control over toolbox icon size. --- .../preferencesconfigurationpage.cpp | 2 + .../preferencesconfigurationpage.ui | 54 ++++++++++++++++++- src/app/valentina/mainwindow.cpp | 21 ++++++++ src/app/valentina/mainwindow.h | 1 + src/libs/vmisc/vcommonsettings.cpp | 15 ++++++ src/libs/vmisc/vcommonsettings.h | 3 ++ 6 files changed, 94 insertions(+), 2 deletions(-) diff --git a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp index 9938ca272..e3151aea5 100644 --- a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp @@ -133,6 +133,7 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent) //----------------------- Toolbar ui->toolBarStyleCheck->setChecked(settings->GetToolBarStyle()); + ui->radioButtonToolboxIconSizeSmall->setChecked(settings->GetToolboxIconSizeSmall()); // Theme SetThemeModeComboBox(); @@ -195,6 +196,7 @@ auto PreferencesConfigurationPage::Apply() -> QStringList settings->SetOsSeparator(ui->osOptionCheck->isChecked()); settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked()); + settings->SetToolboxIconSizeSmall(ui->radioButtonToolboxIconSizeSmall->isChecked()); auto themeMode = static_cast(ui->comboBoxThemeMode->currentData().toInt()); if (settings->GetThemeMode() != themeMode) diff --git a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.ui b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.ui index 56766c638..c21796358 100644 --- a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.ui +++ b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.ui @@ -33,9 +33,9 @@ 0 - -70 + 0 624 - 873 + 904 @@ -284,6 +284,53 @@ + + + + + + Toolbox icon size: + + + + + + + Small + + + true + + + buttonGroupToolBoxIconSize + + + + + + + Normal + + + buttonGroupToolBoxIconSize + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + @@ -581,4 +628,7 @@ + + + diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 0651e00cc..39f0c31ad 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -5503,6 +5503,8 @@ void MainWindow::ReadSettings() // Text under tool buton icon ToolBarStyles(); + ToolboxIconSize(); + QFont f = ui->plainTextEditPatternMessages->font(); f.setPointSize(settings->GetPatternMessageFontSize(f.pointSize())); ui->plainTextEditPatternMessages->setFont(f); @@ -6419,6 +6421,24 @@ void MainWindow::ToolBarStyles() MainWindow::ToolBarStyle(ui->mainToolBar); } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolboxIconSize() +{ + auto SetIconSize = [](QToolBar *bar) + { + VCommonSettings *settings = VAbstractApplication::VApp()->Settings(); + QSize size = settings->GetToolboxIconSizeSmall() ? QSize(24, 24) : QSize(32, 32); + bar->setIconSize(size); + }; + + SetIconSize(ui->toolBarCurveTools); + SetIconSize(ui->toolBarDetailTools); + SetIconSize(ui->toolBarLineTools); + SetIconSize(ui->toolBarOperationTools); + SetIconSize(ui->toolBarPointTools); + SetIconSize(ui->toolBarSelectingTools); +} + //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ShowPaper(int index) { @@ -6450,6 +6470,7 @@ void MainWindow::Preferences() connect(dlg.data(), &DialogPreferences::UpdateProperties, m_toolOptions, &VToolOptionsPropertyBrowser::RefreshOptions); connect(dlg.data(), &DialogPreferences::UpdateProperties, this, &MainWindow::ToolBarStyles); + connect(dlg.data(), &DialogPreferences::UpdateProperties, this, &MainWindow::ToolboxIconSize); connect(dlg.data(), &DialogPreferences::UpdateProperties, this, [this]() { emit doc->FullUpdateFromFile(); }); connect(dlg.data(), &DialogPreferences::UpdateProperties, ui->view, &VMainGraphicsView::ResetScrollingAnimation); diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index e018d5b45..88da421ba 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -133,6 +133,7 @@ private slots: void PreviousPatternPiece(); void NextPatternPiece(); void ToolBarStyles(); + void ToolboxIconSize(); void ShowPaper(int index); void Preferences(); #if defined(Q_OS_MAC) diff --git a/src/libs/vmisc/vcommonsettings.cpp b/src/libs/vmisc/vcommonsettings.cpp index fe4773a3b..ed8e5522a 100644 --- a/src/libs/vmisc/vcommonsettings.cpp +++ b/src/libs/vmisc/vcommonsettings.cpp @@ -122,6 +122,9 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAskContinueIfLayout Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolBarStyle, (QLatin1String("configuration/tool_bar_style"))) // NOLINTNEXTLINE +Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolboxIconSizeSmall, + (QLatin1String("configuration/toolboxIconSizeSmall"))) +// NOLINTNEXTLINE Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationFreeCurveMode, (QLatin1String("configuration/freeCurveMode"))) // NOLINTNEXTLINE @@ -721,6 +724,18 @@ void VCommonSettings::SetToolBarStyle(const bool &value) setValue(*settingConfigurationToolBarStyle, value); } +//--------------------------------------------------------------------------------------------------------------------- +auto VCommonSettings::GetToolboxIconSizeSmall() const -> bool +{ + return value(*settingConfigurationToolboxIconSizeSmall, 1).toBool(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VCommonSettings::SetToolboxIconSizeSmall(bool value) +{ + setValue(*settingConfigurationToolboxIconSizeSmall, value); +} + //--------------------------------------------------------------------------------------------------------------------- auto VCommonSettings::GetThemeMode() const -> VThemeMode { diff --git a/src/libs/vmisc/vcommonsettings.h b/src/libs/vmisc/vcommonsettings.h index 47e203fa9..becfea2fa 100644 --- a/src/libs/vmisc/vcommonsettings.h +++ b/src/libs/vmisc/vcommonsettings.h @@ -128,6 +128,9 @@ public: auto GetToolBarStyle() const -> bool; void SetToolBarStyle(const bool &value); + auto GetToolboxIconSizeSmall() const -> bool; + void SetToolboxIconSizeSmall(bool value); + auto GetThemeMode() const -> VThemeMode; void SetThemeMode(VThemeMode mode);