From c50a5db2770df34c03bbf1fa3904da713c3df0f4 Mon Sep 17 00:00:00 2001 From: Ilya Fedin <fedin-ilja2010@ya.ru> Date: Sun, 24 Oct 2021 04:31:12 +0400 Subject: [PATCH] Restore dbusmenu-qt dependent functionality with Qt 6 --- Telegram/CMakeLists.txt | 10 ++------- .../platform/linux/main_window_linux.cpp | 21 ++----------------- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index ac51d69d1..c4ce80268 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -1289,16 +1289,10 @@ elseif (APPLE) endif() else() if (NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION) - if (NOT DESKTOP_APP_QT6) - target_link_libraries(Telegram - PRIVATE - desktop-app::external_statusnotifieritem - desktop-app::external_dbusmenu_qt - ) - endif() - target_link_libraries(Telegram PRIVATE + desktop-app::external_statusnotifieritem + desktop-app::external_dbusmenu_qt desktop-app::external_glibmm desktop-app::external_glib ) diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index dd7919826..3bed68869 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -50,13 +50,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include <QtDBus/QDBusObjectPath> #include <QtDBus/QDBusMetaType> -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include <statusnotifieritem.h> #include <dbusmenuexporter.h> -#else // Qt < 6.0.0 -class StatusNotifierItem; -class DBusMenuExporter; -#endif // Qt >= 6.0.0 #include <glibmm.h> #include <giomm.h> @@ -394,7 +389,7 @@ void ForceDisabled(QAction *action, bool disabled) { } #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION -[[maybe_unused]] bool IsIndicatorApplication() { +bool IsIndicatorApplication() { // Hack for indicator-application, // which doesn't handle icons sent across D-Bus: // save the icon to a temp file @@ -422,7 +417,7 @@ void ForceDisabled(QAction *action, bool disabled) { return Result; } -[[maybe_unused]] std::unique_ptr<QTemporaryFile> TrayIconFile( +std::unique_ptr<QTemporaryFile> TrayIconFile( const QIcon &icon, QObject *parent = nullptr) { static const auto templateName = AppRuntimeDirectory() @@ -651,7 +646,6 @@ private: #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION void MainWindow::Private::setSNITrayIcon(int counter, bool muted) { -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) const auto iconName = GetTrayIconName(counter, muted); const auto panelIconName = GetPanelIconName(counter, muted); @@ -687,11 +681,9 @@ void MainWindow::Private::setSNITrayIcon(int counter, bool muted) { sniTrayIcon->setIconByPixmap(icon); sniTrayIcon->setToolTipIconByPixmap(icon); } -#endif // Qt < 6.0.0 } void MainWindow::Private::attachToSNITrayIcon() { -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) sniTrayIcon->setToolTipTitle(AppName.utf16()); connect(sniTrayIcon, &StatusNotifierItem::activateRequested, @@ -707,7 +699,6 @@ void MainWindow::Private::attachToSNITrayIcon() { _public->handleTrayIconActication(QSystemTrayIcon::MiddleClick); }); }); -#endif // Qt < 6.0.0 } void MainWindow::Private::handleSNIHostRegistered() { @@ -796,11 +787,9 @@ MainWindow::MainWindow(not_null<Window::Controller*> controller) : Window::MainWindow(controller) , _private(std::make_unique<Private>(this)) { #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) qDBusRegisterMetaType<ToolTip>(); qDBusRegisterMetaType<IconPixmap>(); qDBusRegisterMetaType<IconPixmapList>(); -#endif // Qt < 6.0.0 #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION } @@ -928,7 +917,6 @@ void MainWindow::psSetupTrayIcon() { const auto muted = Core::App().unreadBadgeMuted(); #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if (_sniAvailable) { LOG(("Using SNI tray icon.")); if (!_private->sniTrayIcon) { @@ -947,7 +935,6 @@ void MainWindow::psSetupTrayIcon() { return; } -#endif // Qt < 6.0.0 #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION LOG(("Using Qt tray icon.")); @@ -970,13 +957,11 @@ void MainWindow::workmodeUpdated(Core::Settings::WorkMode mode) { return; } else if (mode == WorkMode::WindowOnly) { #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if (_private->sniTrayIcon) { _private->sniTrayIcon->setContextMenu(0); _private->sniTrayIcon->deleteLater(); } _private->sniTrayIcon = nullptr; -#endif // Qt < 6.0.0 #endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION if (trayIcon) { @@ -1239,11 +1224,9 @@ void MainWindow::createGlobalMenu() { about->setMenuRole(QAction::AboutQtRole); #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) _private->mainMenuExporter = new DBusMenuExporter( kMainMenuObjectPath.utf16(), psMainMenu); -#endif // Qt < 6.0.0 if (_private->appMenuSupported) { RegisterAppMenu(windowHandle(), kMainMenuObjectPath.utf16());