Use greyscale menubar icons on Mac OS X.

This commit is contained in:
Ian Langworth ☠ 2015-08-08 18:16:50 -07:00
parent 281cf3a733
commit 93ff0aa6d0
4 changed files with 85 additions and 2 deletions

View File

@ -119,6 +119,8 @@ macx {
QSYNERGY_ICON.path = Contents/Resources
QMAKE_BUNDLE_DATA += QSYNERGY_ICON
LIBS += $$MACX_LIBS
HEADERS += src/OSXHelpers.h
SOURCES += src/OSXHelpers.mm
}
unix:!macx:LIBS += -ldns_sd
debug {

View File

@ -35,6 +35,10 @@
#include "QUtility.h"
#include "ProcessorArch.h"
#if defined(Q_OS_MAC)
#include "OSXHelpers.h"
#endif
#include <QtCore>
#include <QtGui>
#include <QtNetwork>
@ -67,7 +71,21 @@ static const char synergyConfigName[] = "synergy.conf";
static const QString synergyConfigFilter(QObject::tr("Synergy Configurations (*.conf);;All files (*.*)"));
#endif
static const char* synergyIconFiles[] =
static const char* synergyLightIconFiles[] =
{
":/res/icons/64x64/synergy-light-disconnected.png",
":/res/icons/64x64/synergy-light-disconnected.png",
":/res/icons/64x64/synergy-light-connected.png",
":/res/icons/64x64/synergy-light-transfering.png"
};
static const char* synergyDarkIconFiles[] =
{
":/res/icons/64x64/synergy-dark-disconnected.png",
":/res/icons/64x64/synergy-dark-disconnected.png",
":/res/icons/64x64/synergy-dark-connected.png",
":/res/icons/64x64/synergy-dark-transfering.png"
};
static const char* synergyDefaultIconFiles[] =
{
":/res/icons/16x16/synergy-disconnected.png",
":/res/icons/16x16/synergy-disconnected.png",
@ -313,7 +331,15 @@ void MainWindow::saveSettings()
void MainWindow::setIcon(qSynergyState state)
{
QIcon icon;
icon.addFile(synergyIconFiles[state]);
#ifdef Q_OS_MAC
if (isOSXInterfaceStyleDark())
icon.addFile(synergyDarkIconFiles[state]);
else
icon.addFile(synergyLightIconFiles[state]);
#else
icon.addFile(synergyDefaultIconFiles[state]);
#endif
if (m_pTrayIcon)
m_pTrayIcon->setIcon(icon);

24
src/gui/src/OSXHelpers.h Normal file
View File

@ -0,0 +1,24 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2015 Synergy Si Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(OSXHELPERS__H)
#define OSXHELPERS__H
bool isOSXInterfaceStyleDark();
#endif

31
src/gui/src/OSXHelpers.mm Normal file
View File

@ -0,0 +1,31 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2015 Synergy Si Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import "OSXHelpers.h"
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import <Cocoa/Cocoa.h>
bool
isOSXInterfaceStyleDark()
{
// Implementation from http://stackoverflow.com/a/26472651
NSDictionary* dict = [[NSUserDefaults standardUserDefaults] persistentDomainForName:NSGlobalDomain];
id style = [dict objectForKey:@"AppleInterfaceStyle"];
return (style && [style isKindOfClass:[NSString class]] && NSOrderedSame == [style caseInsensitiveCompare:@"dark"]);
}