From 697e355f07c377e7fc29f655b0f71f7824e4bc4c Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Wed, 14 Aug 2013 16:35:36 +0200 Subject: [PATCH] Hide mono icon options if the resource has no mono icons --- src/mirall/generalsettings.cpp | 11 +++++++++++ src/mirall/theme.cpp | 23 +++++++++++++++++------ src/mirall/theme.h | 2 ++ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/mirall/generalsettings.cpp b/src/mirall/generalsettings.cpp index aedab297e6..05912604ff 100644 --- a/src/mirall/generalsettings.cpp +++ b/src/mirall/generalsettings.cpp @@ -21,6 +21,7 @@ #include "mirall/mirallconfigfile.h" #include +#include namespace Mirall { @@ -49,6 +50,16 @@ GeneralSettings::GeneralSettings(QWidget *parent) : // misc connect(_ui->monoIconsCheckBox, SIGNAL(toggled(bool)), SLOT(saveMiscSettings())); + + // OEM themes are not obliged to ship mono icons, so there + // is no point in offering an option + QString themeDir = QString::fromLatin1(":/mirall/theme/1%1/") + .arg(Theme::instance()->systrayIconFlavor(true)); + if (QDir(themeDir).exists()) + { + _ui->monoIconsCheckBox->setVisible(false); + } + } GeneralSettings::~GeneralSettings() diff --git a/src/mirall/theme.cpp b/src/mirall/theme.cpp index 6d72952821..2ba8c413ea 100644 --- a/src/mirall/theme.cpp +++ b/src/mirall/theme.cpp @@ -94,12 +94,8 @@ QIcon Theme::trayFolderIcon( const QString& backend ) const QIcon Theme::themeIcon( const QString& name, bool sysTray ) const { QString flavor; - if (sysTray && _mono) { -#ifdef Q_OS_MAC - flavor = QLatin1String("black"); -#else - flavor = QLatin1String("white"); -#endif + if (sysTray) { + flavor = systrayIconFlavor(_mono); } else { flavor = QLatin1String("colored"); } @@ -158,6 +154,21 @@ QString Theme::defaultClientFolder() const return appName(); } +QString Theme::systrayIconFlavor(bool mono) const +{ + QString flavor; + if (mono) { +#ifdef Q_OS_MAC + flavor = QLatin1String("black"); +#else + flavor = QLatin1String("white"); +#endif + } else { + flavor = QLatin1String("colored"); + } + return flavor; +} + void Theme::setSystrayUseMonoIcons(bool mono) { _mono = mono; diff --git a/src/mirall/theme.h b/src/mirall/theme.h index 85376dfa09..92273bb76f 100644 --- a/src/mirall/theme.h +++ b/src/mirall/theme.h @@ -119,6 +119,8 @@ public: */ virtual QString enforcedLocale() const { return QString::null; } + /** colored, white or black */ + QString systrayIconFlavor(bool mono) const; /** * Override to use a string or a custom image name.