Skip to content

Commit

Permalink
Merge pull request #5372 from nextcloud/bugfix/revert-mono-config-delete
Browse files Browse the repository at this point in the history
Revert "Merge pull request #5366 from nextcloud/bugfix/remove-mono-icons-setting"
  • Loading branch information
claucambra authored Jan 27, 2023
2 parents e332929 + 68c785e commit 9cb1609
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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:"))) {
Expand Down
1 change: 1 addition & 0 deletions src/gui/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public slots:
protected slots:
void slotParseMessage(const QString &, QObject *);
void slotCheckConnection();
void slotUseMonoIconsChanged(bool);
void slotCleanup();
void slotAccountStateAdded(OCC::AccountState *accountState);
void slotAccountStateRemoved(OCC::AccountState *accountState);
Expand Down
10 changes: 10 additions & 0 deletions src/gui/generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &GeneralSettings::saveMiscSettings);
Expand Down Expand Up @@ -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);

Expand All @@ -241,6 +246,7 @@ void GeneralSettings::loadMiscSettings()
{
QScopedValueRollback<bool> 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());
Expand All @@ -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)
Expand Down Expand Up @@ -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(),
Expand Down
13 changes: 12 additions & 1 deletion src/gui/generalsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>556</width>
<height>573</height>
<height>563</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -66,6 +66,16 @@
<string>General Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QCheckBox" name="monoIconsCheckBox">
<property name="toolTip">
<string>For System Tray</string>
</property>
<property name="text">
<string>Use &amp;Monochrome Icons</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="autostartCheckBox">
<property name="text">
Expand Down Expand Up @@ -333,6 +343,7 @@
<tabstops>
<tabstop>autostartCheckBox</tabstop>
<tabstop>serverNotificationsCheckBox</tabstop>
<tabstop>monoIconsCheckBox</tabstop>
<tabstop>ignoredFilesButton</tabstop>
<tabstop>newFolderLimitCheckBox</tabstop>
<tabstop>newFolderLimitSpinBox</tabstop>
Expand Down
18 changes: 18 additions & 0 deletions src/libsync/configfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/libsync/configfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ class OWNCLOUDSYNC_EXPORT ConfigFile
*/
[[nodiscard]] std::chrono::milliseconds fullLocalDiscoveryInterval() const;

[[nodiscard]] bool monoIcons() const;
void setMonoIcons(bool);

[[nodiscard]] bool promptDeleteFiles() const;
void setPromptDeleteFiles(bool promptDeleteFiles);

Expand Down
17 changes: 17 additions & 0 deletions src/libsync/theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions src/libsync/theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,21 @@ class OWNCLOUDSYNC_EXPORT Theme : public QObject
*/
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.
*/
Expand Down Expand Up @@ -597,6 +612,7 @@ public slots:
Theme();

signals:
void systrayUseMonoIconsChanged(bool);
void systemPaletteChanged(const QPalette &palette);
void darkModeChanged();
void overrideServerUrlChanged();
Expand Down

0 comments on commit 9cb1609

Please sign in to comment.