From f0f0be945242f10c37816a30326a09cb244b80f5 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 21 Jul 2015 15:29:38 +0200 Subject: [PATCH] fixed Qt tray icon for KDE, using Qt tray icon for all graphic envs, testing --- Telegram/SourceFiles/pspecific_linux.cpp | 17 ++++++++++++----- Telegram/SourceFiles/window.cpp | 15 +++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/Telegram/SourceFiles/pspecific_linux.cpp b/Telegram/SourceFiles/pspecific_linux.cpp index 73b656e08b..a59e15b8a7 100644 --- a/Telegram/SourceFiles/pspecific_linux.cpp +++ b/Telegram/SourceFiles/pspecific_linux.cpp @@ -68,7 +68,7 @@ namespace { bool frameless = true; bool finished = true; - bool noQtTrayIcon = false; + bool noQtTrayIcon = false, noTryUnity = false; bool useGtkBase = false, useAppIndicator = false, useStatusIcon = false, trayIconChecked = false, useUnityCount = false; AppIndicator *_trayIndicator = 0; @@ -351,10 +351,16 @@ namespace { class _PsInitializer { public: _PsInitializer() { + static bool inited = false; + if (inited) return; + inited = true; + QString cdesktop = QString(getenv("XDG_CURRENT_DESKTOP")).toLower(); - noQtTrayIcon = (cdesktop == qstr("unity")) || (cdesktop == qstr("pantheon")) || (cdesktop == qstr("gnome")); + noQtTrayIcon = false;//(cdesktop == qstr("pantheon")) || (cdesktop == qstr("gnome")); + noTryUnity = (cdesktop != qstr("unity")); if (noQtTrayIcon) cSetSupportTray(false); + std::cout << "libs init..\n"; setupGtk(); setupUnity(); @@ -458,9 +464,9 @@ namespace { } void setupUnity() { - if (!useGtkBase || !noQtTrayIcon) return; + if (noTryUnity) return; - QLibrary lib_unity(qstr("unity"), 9, 0); + QLibrary lib_unity(qstr("unity"), 9, 0); if (!loadLibrary(lib_unity, "unity", 9)) return; if (!loadFunction(lib_unity, "unity_launcher_entry_get_for_desktop_id", ps_unity_launcher_entry_get_for_desktop_id)) return; @@ -470,7 +476,6 @@ namespace { std::cout << "unity count api loaded\n"; } }; - _PsInitializer _psInitializer; class _PsEventFilter : public QAbstractNativeEventFilter { public: @@ -933,6 +938,8 @@ void PsMainWindow::psPlatformNotify(HistoryItem *item, int32 fwdCount) { } PsApplication::PsApplication(int &argc, char **argv) : QApplication(argc, argv) { + _PsInitializer _psInitializer; + Q_UNUSED(_psInitializer); } void PsApplication::psInstallEventFilter() { diff --git a/Telegram/SourceFiles/window.cpp b/Telegram/SourceFiles/window.cpp index c42a73ccd5..c83df1509c 100644 --- a/Telegram/SourceFiles/window.cpp +++ b/Telegram/SourceFiles/window.cpp @@ -429,16 +429,11 @@ void Window::init() { title = new TitleWidget(this); - psInitSize(); - psUpdateWorkmode(); -} - -void Window::firstShow() { #ifdef Q_OS_WIN trayIconMenu = new ContextMenu(this); #else - trayIconMenu = new QMenu(this); - trayIconMenu->setFont(QFont("Tahoma")); + trayIconMenu = new QMenu(this); + trayIconMenu->setFont(QFont("Tahoma")); #endif if (cPlatform() == dbipWindows || cPlatform() == dbipMac) { trayIconMenu->addAction(lang(lng_minimize_to_tray), this, SLOT(minimizeToTray()))->setEnabled(true); @@ -449,8 +444,12 @@ void Window::firstShow() { trayIconMenu->addAction(lang(lng_quit_from_tray), this, SLOT(quitFromTray()))->setEnabled(true); } - psFirstShow(); + psInitSize(); + psUpdateWorkmode(); +} +void Window::firstShow() { + psFirstShow(); updateTrayMenu(); }