diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 907d87fac..3a262a305 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -360,6 +360,9 @@ Application::Application(int &argc, char **argv) setQuitOnLastWindowClosed(false); + _theme->setSystrayUseMonoIcons(cfg.monoIcons()); + connect(_theme, &Theme::systrayUseMonoIconsChanged, this, &Application::slotUseMonoIconsChanged); + // Setting up the gui class will allow tray notifications for the // setup that follows, like folder setup _gui = new ownCloudGui(this); @@ -568,6 +571,11 @@ void Application::setupLogging() qCInfo(lcApplication) << "Arguments:" << qApp->arguments(); } +void Application::slotUseMonoIconsChanged(bool) +{ + _gui->slotComputeOverallSyncStatus(); +} + void Application::slotParseMessage(const QString &msg, QObject *) { if (msg.startsWith(QLatin1String("MSG_PARSEOPTIONS:"))) { diff --git a/src/gui/application.h b/src/gui/application.h index 67fd836e9..5bd412077 100644 --- a/src/gui/application.h +++ b/src/gui/application.h @@ -100,6 +100,7 @@ signals: protected slots: void slotParseMessage(const QString &, QObject *); void slotCheckConnection(); + void slotUseMonoIconsChanged(bool); void slotCleanup(); void slotAccountStateAdded(OCC::AccountState *accountState); void slotAccountStateRemoved(OCC::AccountState *accountState); diff --git a/src/gui/generalsettings.cpp b/src/gui/generalsettings.cpp index 429c75927..6a5164a26 100644 --- a/src/gui/generalsettings.cpp +++ b/src/gui/generalsettings.cpp @@ -182,6 +182,7 @@ GeneralSettings::GeneralSettings(QWidget *parent) //slotUpdateInfo(); // misc + connect(_ui->monoIconsCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::saveMiscSettings); connect(_ui->crashreporterCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::saveMiscSettings); connect(_ui->newFolderLimitCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::saveMiscSettings); connect(_ui->newFolderLimitSpinBox, static_cast(&QSpinBox::valueChanged), this, &GeneralSettings::saveMiscSettings); @@ -215,6 +216,10 @@ GeneralSettings::GeneralSettings(QWidget *parent) _ui->horizontalLayout_3->getContentsMargins(&m0, &m1, &m2, &m3); _ui->horizontalLayout_3->setContentsMargins(0, m1, m2, m3); + // OEM themes are not obliged to ship mono icons, so there + // is no point in offering an option + _ui->monoIconsCheckBox->setVisible(Theme::instance()->monoIconsAvailable()); + connect(_ui->ignoredFilesButton, &QAbstractButton::clicked, this, &GeneralSettings::slotIgnoreFilesEditor); connect(_ui->debugArchiveButton, &QAbstractButton::clicked, this, &GeneralSettings::slotCreateDebugArchive); @@ -241,6 +246,7 @@ void GeneralSettings::loadMiscSettings() { QScopedValueRollback scope(_currentlyLoading, true); ConfigFile cfgFile; + _ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons()); _ui->serverNotificationsCheckBox->setChecked(cfgFile.optionalServerNotifications()); _ui->callNotificationsCheckBox->setEnabled(_ui->serverNotificationsCheckBox->isEnabled()); _ui->callNotificationsCheckBox->setChecked(cfgFile.showCallNotifications()); @@ -250,6 +256,7 @@ void GeneralSettings::loadMiscSettings() _ui->newFolderLimitCheckBox->setChecked(newFolderLimit.first); _ui->newFolderLimitSpinBox->setValue(newFolderLimit.second); _ui->newExternalStorage->setChecked(cfgFile.confirmExternalStorage()); + _ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons()); } #if defined(BUILD_UPDATER) @@ -413,6 +420,9 @@ void GeneralSettings::saveMiscSettings() if (_currentlyLoading) return; ConfigFile cfgFile; + bool isChecked = _ui->monoIconsCheckBox->isChecked(); + cfgFile.setMonoIcons(isChecked); + Theme::instance()->setSystrayUseMonoIcons(isChecked); cfgFile.setCrashReporter(_ui->crashreporterCheckBox->isChecked()); cfgFile.setNewBigFolderSizeLimit(_ui->newFolderLimitCheckBox->isChecked(), diff --git a/src/gui/generalsettings.ui b/src/gui/generalsettings.ui index 2e61fc0c9..00cbeb149 100644 --- a/src/gui/generalsettings.ui +++ b/src/gui/generalsettings.ui @@ -7,7 +7,7 @@ 0 0 556 - 573 + 563 @@ -66,6 +66,16 @@ General Settings + + + + For System Tray + + + Use &Monochrome Icons + + + @@ -333,6 +343,7 @@ autostartCheckBox serverNotificationsCheckBox + monoIconsCheckBox ignoredFilesButton newFolderLimitCheckBox newFolderLimitSpinBox diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index 16cb45576..08064026f 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -56,6 +56,7 @@ static constexpr char remotePollIntervalC[] = "remotePollInterval"; static constexpr char forceSyncIntervalC[] = "forceSyncInterval"; static constexpr char fullLocalDiscoveryIntervalC[] = "fullLocalDiscoveryInterval"; static constexpr char notificationRefreshIntervalC[] = "notificationRefreshInterval"; +static constexpr char monoIconsC[] = "monoIcons"; static constexpr char promptDeleteC[] = "promptDeleteAllFiles"; static constexpr char crashReporterC[] = "crashReporter"; static constexpr char optionalServerNotificationsC[] = "optionalServerNotifications"; @@ -946,6 +947,23 @@ void ConfigFile::setPromptDeleteFiles(bool promptDeleteFiles) settings.setValue(QLatin1String(promptDeleteC), promptDeleteFiles); } +bool ConfigFile::monoIcons() const +{ + QSettings settings(configFile(), QSettings::IniFormat); + bool monoDefault = false; // On Mac we want bw by default +#ifdef Q_OS_MAC + // OEM themes are not obliged to ship mono icons + monoDefault = QByteArrayLiteral("Nextcloud") == QByteArrayLiteral(APPLICATION_NAME); +#endif + return settings.value(QLatin1String(monoIconsC), monoDefault).toBool(); +} + +void ConfigFile::setMonoIcons(bool useMonoIcons) +{ + QSettings settings(configFile(), QSettings::IniFormat); + settings.setValue(QLatin1String(monoIconsC), useMonoIcons); +} + bool ConfigFile::crashReporter() const { QSettings settings(configFile(), QSettings::IniFormat); diff --git a/src/libsync/configfile.h b/src/libsync/configfile.h index d7d6f4ebe..719cce083 100644 --- a/src/libsync/configfile.h +++ b/src/libsync/configfile.h @@ -83,6 +83,9 @@ public: */ [[nodiscard]] std::chrono::milliseconds fullLocalDiscoveryInterval() const; + [[nodiscard]] bool monoIcons() const; + void setMonoIcons(bool); + [[nodiscard]] bool promptDeleteFiles() const; void setPromptDeleteFiles(bool promptDeleteFiles); diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp index 732bd0948..caee23bc3 100644 --- a/src/libsync/theme.cpp +++ b/src/libsync/theme.cpp @@ -480,6 +480,23 @@ QString Theme::systrayIconFlavor(bool mono) const return flavor; } +void Theme::setSystrayUseMonoIcons(bool mono) +{ + _mono = mono; + emit systrayUseMonoIconsChanged(mono); +} + +bool Theme::systrayUseMonoIcons() const +{ + return _mono; +} + +bool Theme::monoIconsAvailable() const +{ + QString themeDir = QString(Theme::themePrefix) + QString::fromLatin1("%1/").arg(Theme::instance()->systrayIconFlavor(true)); + return QDir(themeDir).exists(); +} + QString Theme::updateCheckUrl() const { return APPLICATION_UPDATE_URL; diff --git a/src/libsync/theme.h b/src/libsync/theme.h index 7c6e42ba3..de721f71c 100644 --- a/src/libsync/theme.h +++ b/src/libsync/theme.h @@ -340,6 +340,21 @@ public: */ virtual QString aboutDetails() const; + /** + * Define if the systray icons should be using mono design + */ + void setSystrayUseMonoIcons(bool mono); + + /** + * Retrieve wether to use mono icons for systray + */ + bool systrayUseMonoIcons() const; + + /** + * Check if mono icons are available + */ + bool monoIconsAvailable() const; + /** * @brief Where to check for new Updates. */ @@ -597,6 +612,7 @@ protected: Theme(); signals: + void systrayUseMonoIconsChanged(bool); void systemPaletteChanged(const QPalette &palette); void darkModeChanged(); void overrideServerUrlChanged();