diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index bc8ba4571..4e8fdd703 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -11,6 +11,11 @@ file (GLOB LEGACY_GUI_UI_FILES src/*.ui) file (GLOB LEGACY_ACTIVATION_FILES src/*Activation* src/*License*) file (GLOB LEGACY_ZEROCONF_FILES src/Zeroconf*) +if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + file (GLOB LEGACY_GUI_MAC_SOURCE_FILES src/*.mm) + list (APPEND LEGACY_GUI_SOURCE_FILES ${LEGACY_GUI_MAC_SOURCE_FILES}) +endif() + if (SYNERGY_ENTERPRISE) list (REMOVE_ITEM LEGACY_GUI_SOURCE_FILES ${LEGACY_ACTIVATION_FILES}) list (REMOVE_ITEM LEGACY_GUI_UI_FILES ${LEGACY_ACTIVATION_FILES}) diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 176d68511..9aa5501b8 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -127,6 +127,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 { diff --git a/src/gui/res/Synergy.qrc b/src/gui/res/Synergy.qrc index 479b7a05a..8523d94bc 100644 --- a/src/gui/res/Synergy.qrc +++ b/src/gui/res/Synergy.qrc @@ -54,6 +54,11 @@ image/spinning-wheel.gif icons/16x16/padlock.png icons/16x16/synergy-transfering.png - icons/16x16/auto-config.png + icons/64x64/synergy-dark-transfering.png + icons/64x64/synergy-dark-disconnected.png + icons/64x64/synergy-dark-connected.png + icons/64x64/synergy-light-transfering.png + icons/64x64/synergy-light-disconnected.png + icons/64x64/synergy-light-connected.png diff --git a/src/gui/res/icons/256x256/synergy.ico b/src/gui/res/icons/256x256/synergy.ico index cf20e4bc8..be951b12d 100644 Binary files a/src/gui/res/icons/256x256/synergy.ico and b/src/gui/res/icons/256x256/synergy.ico differ diff --git a/src/gui/res/icons/64x64/synergy-dark-connected.png b/src/gui/res/icons/64x64/synergy-dark-connected.png new file mode 100644 index 000000000..c0ee3ecf9 Binary files /dev/null and b/src/gui/res/icons/64x64/synergy-dark-connected.png differ diff --git a/src/gui/res/icons/64x64/synergy-dark-disconnected.png b/src/gui/res/icons/64x64/synergy-dark-disconnected.png new file mode 100644 index 000000000..02e18cc93 Binary files /dev/null and b/src/gui/res/icons/64x64/synergy-dark-disconnected.png differ diff --git a/src/gui/res/icons/64x64/synergy-dark-transfering.png b/src/gui/res/icons/64x64/synergy-dark-transfering.png new file mode 100644 index 000000000..5e9e84122 Binary files /dev/null and b/src/gui/res/icons/64x64/synergy-dark-transfering.png differ diff --git a/src/gui/res/icons/64x64/synergy-light-connected.png b/src/gui/res/icons/64x64/synergy-light-connected.png new file mode 100644 index 000000000..821635375 Binary files /dev/null and b/src/gui/res/icons/64x64/synergy-light-connected.png differ diff --git a/src/gui/res/icons/64x64/synergy-light-disconnected.png b/src/gui/res/icons/64x64/synergy-light-disconnected.png new file mode 100644 index 000000000..67592e4c2 Binary files /dev/null and b/src/gui/res/icons/64x64/synergy-light-disconnected.png differ diff --git a/src/gui/res/icons/64x64/synergy-light-transfering.png b/src/gui/res/icons/64x64/synergy-light-transfering.png new file mode 100644 index 000000000..aa77b59b2 Binary files /dev/null and b/src/gui/res/icons/64x64/synergy-light-transfering.png differ diff --git a/src/gui/res/mac/Synergy.icns b/src/gui/res/mac/Synergy.icns new file mode 100644 index 000000000..2410e6f6f Binary files /dev/null and b/src/gui/res/mac/Synergy.icns differ diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index 33c89ae41..d8337d998 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -36,6 +36,10 @@ #include "SslCertificate.h" #include "Zeroconf.h" +#if defined(Q_OS_MAC) +#include "OSXHelpers.h" +#endif + #include #include #include @@ -63,7 +67,25 @@ static const char* tlsCheckString = "network encryption protocol: "; static const int debugLogLevel = 1; -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", + ":/res/icons/64x64/synergy-light-disconnected.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", + ":/res/icons/64x64/synergy-dark-disconnected.png" //synergyPendingRetry +}; + +static const char* synergyDefaultIconFiles[] = { ":/res/icons/16x16/synergy-disconnected.png", //synergyDisconnected ":/res/icons/16x16/synergy-disconnected.png", //synergyConnecting @@ -333,7 +355,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); @@ -528,7 +558,7 @@ void MainWindow::checkSecureSocket(const QString& line) //Get the protocol version from the line m_SecureSocketVersion = line.mid(index + strlen(tlsCheckString)); - } + } } QString MainWindow::getTimeStamp() { diff --git a/src/gui/src/OSXHelpers.h b/src/gui/src/OSXHelpers.h new file mode 100644 index 000000000..6b2b65bc0 --- /dev/null +++ b/src/gui/src/OSXHelpers.h @@ -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 . + */ + +#if !defined(OSXHELPERS__H) + +#define OSXHELPERS__H + +bool isOSXInterfaceStyleDark(); + +#endif diff --git a/src/gui/src/OSXHelpers.mm b/src/gui/src/OSXHelpers.mm new file mode 100644 index 000000000..de5debbee --- /dev/null +++ b/src/gui/src/OSXHelpers.mm @@ -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 . + */ + +#import "OSXHelpers.h" + +#import +#import +#import + +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"]); +}