mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Merge pull request #2393 from svkurowski/issue-2215
Switch monochrome systray icon color depending on systray brightness
This commit is contained in:
commit
ef16c409ef
@ -15,6 +15,7 @@
|
||||
#include "theme.h"
|
||||
#include "version.h"
|
||||
#include "config.h"
|
||||
#include "utility.h"
|
||||
|
||||
#include <QtCore>
|
||||
#ifndef TOKEN_AUTH_ONLY
|
||||
@ -184,11 +185,7 @@ QString Theme::systrayIconFlavor(bool mono) const
|
||||
{
|
||||
QString flavor;
|
||||
if (mono) {
|
||||
#ifdef Q_OS_MAC
|
||||
flavor = QLatin1String("black");
|
||||
#else
|
||||
flavor = QLatin1String("white");
|
||||
#endif
|
||||
flavor = Utility::hasDarkSystray() ? QLatin1String("white") : QLatin1String("black");
|
||||
} else {
|
||||
flavor = QLatin1String("colored");
|
||||
}
|
||||
|
||||
@ -335,6 +335,11 @@ QString Utility::timeToDescriptiveString(QList<QPair<QString,quint32> > &timeMap
|
||||
return retStr;
|
||||
}
|
||||
|
||||
bool Utility::hasDarkSystray()
|
||||
{
|
||||
return hasDarkSystray_private();
|
||||
}
|
||||
|
||||
|
||||
bool Utility::isWindows()
|
||||
{
|
||||
|
||||
@ -71,7 +71,19 @@ namespace Utility
|
||||
*/
|
||||
OWNCLOUDSYNC_EXPORT QString timeToDescriptiveString(QList<QPair<QString,quint32> > &timeMapping, quint64 msecs, quint8 precision, QString separator, bool specific);
|
||||
OWNCLOUDSYNC_EXPORT QString timeToDescriptiveString(quint64 msecs, quint8 precision, QString separator, bool specific);
|
||||
|
||||
|
||||
/**
|
||||
* @brief hasDarkSystray - determines whether the systray is dark or light.
|
||||
*
|
||||
* Use this to check if the OS has a dark or a light systray.
|
||||
*
|
||||
* The value might change during the execution of the program
|
||||
* (e.g. on OS X 10.10).
|
||||
*
|
||||
* @return bool which is true for systems with dark systray.
|
||||
*/
|
||||
OWNCLOUDSYNC_EXPORT bool hasDarkSystray();
|
||||
|
||||
// convinience OS detection methods
|
||||
OWNCLOUDSYNC_EXPORT bool isWindows();
|
||||
OWNCLOUDSYNC_EXPORT bool isMac();
|
||||
|
||||
@ -108,3 +108,18 @@ void setLaunchOnStartup_private(const QString &appName, const QString& guiName,
|
||||
CFRelease(urlRef);
|
||||
}
|
||||
|
||||
static bool hasDarkSystray_private()
|
||||
{
|
||||
bool returnValue = false;
|
||||
CFStringRef interfaceStyleKey = CFSTR("AppleInterfaceStyle");
|
||||
CFStringRef interfaceStyle = NULL;
|
||||
CFStringRef darkInterfaceStyle = CFSTR("Dark");
|
||||
interfaceStyle = (CFStringRef)CFPreferencesCopyAppValue(interfaceStyleKey,
|
||||
kCFPreferencesCurrentApplication);
|
||||
if (interfaceStyle != NULL) {
|
||||
returnValue = (kCFCompareEqualTo == CFStringCompare(interfaceStyle, darkInterfaceStyle, 0));
|
||||
CFRelease(interfaceStyle);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
@ -86,3 +86,8 @@ void setLaunchOnStartup_private(const QString &appName, const QString& guiName,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool hasDarkSystray_private()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -47,3 +47,8 @@ void setLaunchOnStartup_private(const QString &appName, const QString& guiName,
|
||||
settings.remove(appName);
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool hasDarkSystray_private()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user