Better control over toolbox icon size.

This commit is contained in:
Roman Telezhynskyi 2023-08-21 15:51:49 +03:00
parent 8476b50a24
commit a49f156ce0
6 changed files with 94 additions and 2 deletions

View File

@ -133,6 +133,7 @@ PreferencesConfigurationPage::PreferencesConfigurationPage(QWidget *parent)
//----------------------- Toolbar //----------------------- Toolbar
ui->toolBarStyleCheck->setChecked(settings->GetToolBarStyle()); ui->toolBarStyleCheck->setChecked(settings->GetToolBarStyle());
ui->radioButtonToolboxIconSizeSmall->setChecked(settings->GetToolboxIconSizeSmall());
// Theme // Theme
SetThemeModeComboBox(); SetThemeModeComboBox();
@ -195,6 +196,7 @@ auto PreferencesConfigurationPage::Apply() -> QStringList
settings->SetOsSeparator(ui->osOptionCheck->isChecked()); settings->SetOsSeparator(ui->osOptionCheck->isChecked());
settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked()); settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked());
settings->SetToolboxIconSizeSmall(ui->radioButtonToolboxIconSizeSmall->isChecked());
auto themeMode = static_cast<VThemeMode>(ui->comboBoxThemeMode->currentData().toInt()); auto themeMode = static_cast<VThemeMode>(ui->comboBoxThemeMode->currentData().toInt());
if (settings->GetThemeMode() != themeMode) if (settings->GetThemeMode() != themeMode)

View File

@ -33,9 +33,9 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>-70</y> <y>0</y>
<width>624</width> <width>624</width>
<height>873</height> <height>904</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
@ -284,6 +284,53 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_17">
<property name="text">
<string>Toolbox icon size:</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonToolboxIconSizeSmall">
<property name="text">
<string>Small</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupToolBoxIconSize</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonToolboxIconSizeNormal">
<property name="text">
<string>Normal</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupToolBoxIconSize</string>
</attribute>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -581,4 +628,7 @@
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>
<buttongroups>
<buttongroup name="buttonGroupToolBoxIconSize"/>
</buttongroups>
</ui> </ui>

View File

@ -5503,6 +5503,8 @@ void MainWindow::ReadSettings()
// Text under tool buton icon // Text under tool buton icon
ToolBarStyles(); ToolBarStyles();
ToolboxIconSize();
QFont f = ui->plainTextEditPatternMessages->font(); QFont f = ui->plainTextEditPatternMessages->font();
f.setPointSize(settings->GetPatternMessageFontSize(f.pointSize())); f.setPointSize(settings->GetPatternMessageFontSize(f.pointSize()));
ui->plainTextEditPatternMessages->setFont(f); ui->plainTextEditPatternMessages->setFont(f);
@ -6419,6 +6421,24 @@ void MainWindow::ToolBarStyles()
MainWindow::ToolBarStyle(ui->mainToolBar); 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) void MainWindow::ShowPaper(int index)
{ {
@ -6450,6 +6470,7 @@ void MainWindow::Preferences()
connect(dlg.data(), &DialogPreferences::UpdateProperties, m_toolOptions, connect(dlg.data(), &DialogPreferences::UpdateProperties, m_toolOptions,
&VToolOptionsPropertyBrowser::RefreshOptions); &VToolOptionsPropertyBrowser::RefreshOptions);
connect(dlg.data(), &DialogPreferences::UpdateProperties, this, &MainWindow::ToolBarStyles); 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, this, [this]() { emit doc->FullUpdateFromFile(); });
connect(dlg.data(), &DialogPreferences::UpdateProperties, ui->view, connect(dlg.data(), &DialogPreferences::UpdateProperties, ui->view,
&VMainGraphicsView::ResetScrollingAnimation); &VMainGraphicsView::ResetScrollingAnimation);

View File

@ -133,6 +133,7 @@ private slots:
void PreviousPatternPiece(); void PreviousPatternPiece();
void NextPatternPiece(); void NextPatternPiece();
void ToolBarStyles(); void ToolBarStyles();
void ToolboxIconSize();
void ShowPaper(int index); void ShowPaper(int index);
void Preferences(); void Preferences();
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)

View File

@ -122,6 +122,9 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationAskContinueIfLayout
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolBarStyle, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolBarStyle,
(QLatin1String("configuration/tool_bar_style"))) (QLatin1String("configuration/tool_bar_style")))
// NOLINTNEXTLINE // NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationToolboxIconSizeSmall,
(QLatin1String("configuration/toolboxIconSizeSmall")))
// NOLINTNEXTLINE
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationFreeCurveMode, Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingConfigurationFreeCurveMode,
(QLatin1String("configuration/freeCurveMode"))) (QLatin1String("configuration/freeCurveMode")))
// NOLINTNEXTLINE // NOLINTNEXTLINE
@ -721,6 +724,18 @@ void VCommonSettings::SetToolBarStyle(const bool &value)
setValue(*settingConfigurationToolBarStyle, 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 auto VCommonSettings::GetThemeMode() const -> VThemeMode
{ {

View File

@ -128,6 +128,9 @@ public:
auto GetToolBarStyle() const -> bool; auto GetToolBarStyle() const -> bool;
void SetToolBarStyle(const bool &value); void SetToolBarStyle(const bool &value);
auto GetToolboxIconSizeSmall() const -> bool;
void SetToolboxIconSizeSmall(bool value);
auto GetThemeMode() const -> VThemeMode; auto GetThemeMode() const -> VThemeMode;
void SetThemeMode(VThemeMode mode); void SetThemeMode(VThemeMode mode);