From 614376ed64c47d7be112a9faa31e6ae34bdcdcbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kope=C4=87?= Date: Fri, 19 Feb 2021 16:11:52 +0100 Subject: [PATCH] Add an option to disable icons in menus --- src/app/main.cpp | 3 +++ src/base/preferences.cpp | 10 ++++++++++ src/base/preferences.h | 2 ++ src/gui/advancedsettings.cpp | 11 +++++++++++ src/gui/advancedsettings.h | 4 ++++ 5 files changed, 30 insertions(+) diff --git a/src/app/main.cpp b/src/app/main.cpp index bf0d5c5be..b9187c25d 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -251,6 +251,9 @@ int main(int argc, char *argv[]) // On OS X the standard is to not show icons in the menus app->setAttribute(Qt::AA_DontShowIconsInMenus); +#else + if (!Preferences::instance()->iconsInMenusEnabled()) + app->setAttribute(Qt::AA_DontShowIconsInMenus); #endif if (!firstTimeUser) diff --git a/src/base/preferences.cpp b/src/base/preferences.cpp index fa35f8f47..dd70c52a4 100644 --- a/src/base/preferences.cpp +++ b/src/base/preferences.cpp @@ -234,6 +234,16 @@ void Preferences::setCloseToTrayNotified(const bool b) { setValue("Preferences/General/CloseToTrayNotified", b); } + +bool Preferences::iconsInMenusEnabled() const +{ + return value("Preferences/Advanced/EnableIconsInMenus", true).toBool(); +} + +void Preferences::setIconsInMenusEnabled(const bool enable) +{ + setValue("Preferences/Advanced/EnableIconsInMenus", enable); +} #endif // Q_OS_MACOS bool Preferences::isToolbarDisplayed() const diff --git a/src/base/preferences.h b/src/base/preferences.h index 903d0008e..1235474ff 100644 --- a/src/base/preferences.h +++ b/src/base/preferences.h @@ -313,6 +313,8 @@ public: void setCloseToTrayNotified(bool b); TrayIcon::Style trayIconStyle() const; void setTrayIconStyle(TrayIcon::Style style); + bool iconsInMenusEnabled() const; + void setIconsInMenusEnabled(bool enable); #endif // Q_OS_MACOS // Stuff that don't appear in the Options GUI but are saved diff --git a/src/gui/advancedsettings.cpp b/src/gui/advancedsettings.cpp index dd9304157..57f2d89df 100644 --- a/src/gui/advancedsettings.cpp +++ b/src/gui/advancedsettings.cpp @@ -82,6 +82,9 @@ namespace DOWNLOAD_TRACKER_FAVICON, SAVE_PATH_HISTORY_LENGTH, ENABLE_SPEED_WIDGET, +#ifndef Q_OS_MACOS + ENABLE_ICONS_IN_MENUS, +#endif // embedded tracker TRACKER_STATUS, TRACKER_PORT, @@ -279,6 +282,9 @@ void AdvancedSettings::saveAdvancedSettings() mainWindow->setDownloadTrackerFavicon(m_checkBoxTrackerFavicon.isChecked()); AddNewTorrentDialog::setSavePathHistoryLength(m_spinBoxSavePathHistoryLength.value()); pref->setSpeedWidgetEnabled(m_checkBoxSpeedWidgetEnabled.isChecked()); +#ifndef Q_OS_MACOS + pref->setIconsInMenusEnabled(m_checkBoxIconsInMenusEnabled.isChecked()); +#endif // Tracker pref->setTrackerPort(m_spinBoxTrackerPort.value()); @@ -647,6 +653,11 @@ void AdvancedSettings::loadAdvancedSettings() // Enable speed graphs m_checkBoxSpeedWidgetEnabled.setChecked(pref->isSpeedWidgetEnabled()); addRow(ENABLE_SPEED_WIDGET, tr("Enable speed graphs"), &m_checkBoxSpeedWidgetEnabled); +#ifndef Q_OS_MACOS + // Enable icons in menus + m_checkBoxIconsInMenusEnabled.setChecked(pref->iconsInMenusEnabled()); + addRow(ENABLE_ICONS_IN_MENUS, tr("Enable icons in menus"), &m_checkBoxIconsInMenusEnabled); +#endif // Tracker State m_checkBoxTrackerStatus.setChecked(session->isTrackerEnabled()); addRow(TRACKER_STATUS, tr("Enable embedded tracker"), &m_checkBoxTrackerStatus); diff --git a/src/gui/advancedsettings.h b/src/gui/advancedsettings.h index 81035268e..5d3124362 100644 --- a/src/gui/advancedsettings.h +++ b/src/gui/advancedsettings.h @@ -84,4 +84,8 @@ private: #if defined(Q_OS_WIN) QComboBox m_comboBoxOSMemoryPriority; #endif + +#ifndef Q_OS_MACOS + QCheckBox m_checkBoxIconsInMenusEnabled; +#endif };