mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-10-27 15:07:24 +00:00
Enable Qt tray icon in GNOME and derivatives.
As tested in Fedora Qt 5.6.2 tray icon works well in GNOME. Also add more logs about DE and tray icon. Fix #3175 #3188
This commit is contained in:
@@ -378,6 +378,8 @@ void MainWindow::LibsLoaded() {
|
||||
noQtTrayIcon = !DesktopEnvironment::TryQtTrayIcon();
|
||||
tryAppIndicator = !DesktopEnvironment::PreferAppIndicatorTrayIcon();
|
||||
|
||||
LOG(("Tray Icon: Try Qt = %1, Prefer appindicator = %2").arg(Logs::b(!noQtTrayIcon)).arg(Logs::b(tryAppIndicator)));
|
||||
|
||||
if (noQtTrayIcon) cSetSupportTray(false);
|
||||
|
||||
useGtkBase = (Libs::gtk_init_check != nullptr)
|
||||
@@ -438,6 +440,7 @@ void MainWindow::LibsLoaded() {
|
||||
|
||||
void MainWindow::psCreateTrayIcon() {
|
||||
if (!noQtTrayIcon) {
|
||||
LOG(("Tray Icon: Using Qt tray icon, available: %1").arg(Logs::b(QSystemTrayIcon::isSystemTrayAvailable())));
|
||||
cSetSupportTray(QSystemTrayIcon::isSystemTrayAvailable());
|
||||
return;
|
||||
}
|
||||
@@ -452,7 +455,7 @@ void MainWindow::psCreateTrayIcon() {
|
||||
QByteArray path = QFile::encodeName(iconFile.absoluteFilePath());
|
||||
_trayIndicator = Libs::app_indicator_new("Telegram Desktop", path.constData(), APP_INDICATOR_CATEGORY_APPLICATION_STATUS);
|
||||
if (_trayIndicator) {
|
||||
LOG(("Using appindicator tray icon."));
|
||||
LOG(("Tray Icon: Using appindicator tray icon."));
|
||||
} else {
|
||||
DEBUG_LOG(("Failed to app_indicator_new()!"));
|
||||
}
|
||||
@@ -485,7 +488,7 @@ void MainWindow::psCreateTrayIcon() {
|
||||
_trayIcon = Libs::gtk_status_icon_new_from_pixbuf(_trayPixbuf);
|
||||
}
|
||||
if (_trayIcon) {
|
||||
LOG(("Using GTK status tray icon."));
|
||||
LOG(("Tray Icon: Using GTK status tray icon."));
|
||||
|
||||
Libs::g_signal_connect_helper(_trayIcon, "popup-menu", GCallback(_trayIconPopup), _trayMenu);
|
||||
Libs::g_signal_connect_helper(_trayIcon, "activate", GCallback(_trayIconActivate), _trayMenu);
|
||||
@@ -505,10 +508,11 @@ void MainWindow::psCreateTrayIcon() {
|
||||
}
|
||||
}
|
||||
if (!useStatusIcon && !useAppIndicator) {
|
||||
LOG(("Tray Icon: Not able to use any tray icon :("));
|
||||
if (_trayMenu) {
|
||||
Libs::g_object_ref_sink(_trayMenu);
|
||||
Libs::g_object_unref(_trayMenu);
|
||||
_trayMenu = 0;
|
||||
_trayMenu = nullptr;
|
||||
}
|
||||
}
|
||||
cSetSupportTray(useAppIndicator);
|
||||
|
||||
Reference in New Issue
Block a user