Telegram: fix tray menu

This commit is contained in:
Gerasim Troeglazov
2020-03-05 20:46:11 +10:00
parent d6224c1ac0
commit 2d03aa73f2
2 changed files with 14 additions and 102 deletions

View File

@@ -1,6 +1,6 @@
From 22c5f614912e3254ee9fb8b4d1eb6ef5de97f2f3 Mon Sep 17 00:00:00 2001
From 65b27689f360e7bb125aabc4e5c371bc00145957 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 4 Mar 2020 20:20:54 +1000
Date: Thu, 5 Mar 2020 20:12:29 +1000
Subject: Add Haiku support
@@ -697,17 +697,17 @@ index 0000000..45d4cf8
+} // namespace Platform
diff --git a/Telegram/SourceFiles/platform/haiku/main_window_haiku.cpp b/Telegram/SourceFiles/platform/haiku/main_window_haiku.cpp
new file mode 100644
index 0000000..c603575
index 0000000..3fcfa02
--- /dev/null
+++ b/Telegram/SourceFiles/platform/haiku/main_window_haiku.cpp
@@ -0,0 +1,134 @@
@@ -0,0 +1,132 @@
+/*
+This file is part of Telegram Desktop for Haiku,
+
+For license and copyright information please follow this link:
+https://github.com/desktop-app/legal/blob/master/LEGAL
+
+Copyright (c) 2018-2019 Gerasim Troeglazov, 3dEyes@gmail.com
+Copyright (c) 2018-2020 Gerasim Troeglazov, 3dEyes@gmail.com
+*/
+
+#include "platform/haiku/main_window_haiku.h"
@@ -758,22 +758,20 @@ index 0000000..c603575
+}
+
+void MainWindow::psTrayMenuUpdated() {
+ if (trayIcon && trayIconMenu
+ && trayIcon->contextMenu() != trayIconMenu) {
+ trayIcon->setContextMenu(trayIconMenu);
+ }
+}
+
+void MainWindow::psSetupTrayIcon() {
+ if (!trayIcon) {
+ trayIcon = new QSystemTrayIcon(this);
+
+ auto icon = QIcon(App::pixmapFromImageInPlace(Core::App().logoNoMargin()));
+
+ trayIcon->setIcon(icon);
+ trayIcon->setToolTip(AppName.utf8());
+ connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(showFromTray()));
+ attachToTrayIcon(trayIcon);
+ App::wnd()->updateTrayMenu();
+ }
+ updateIconCounters();
+
+ trayIcon->show();
+}
+
@@ -837,22 +835,23 @@ index 0000000..c603575
+} // namespace Platform
diff --git a/Telegram/SourceFiles/platform/haiku/main_window_haiku.h b/Telegram/SourceFiles/platform/haiku/main_window_haiku.h
new file mode 100644
index 0000000..36ab559
index 0000000..5134cad
--- /dev/null
+++ b/Telegram/SourceFiles/platform/haiku/main_window_haiku.h
@@ -0,0 +1,69 @@
@@ -0,0 +1,70 @@
+/*
+This file is part of Telegram Desktop for Haiku,
+
+For license and copyright information please follow this link:
+https://github.com/desktop-app/legal/blob/master/LEGAL
+
+Copyright (c) 2018-2019 Gerasim Troeglazov, 3dEyes@gmail.com
+Copyright (c) 2018-2020 Gerasim Troeglazov, 3dEyes@gmail.com
+*/
+
+#pragma once
+
+#include "platform/platform_main_window.h"
+#include "ui/widgets/popup_menu.h"
+#include "base/flags.h"
+
+#include <QtCore/QTimer>
@@ -4634,90 +4633,3 @@ index 3c71216..891d428 100644
--
2.24.1
From d281bb0103254dd6ce94234780ceae101068ec08 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Wed, 4 Mar 2020 21:47:43 +1000
Subject: Fix tray menu
diff --git a/Telegram/SourceFiles/platform/haiku/main_window_haiku.cpp b/Telegram/SourceFiles/platform/haiku/main_window_haiku.cpp
index c603575..20eaf46 100644
--- a/Telegram/SourceFiles/platform/haiku/main_window_haiku.cpp
+++ b/Telegram/SourceFiles/platform/haiku/main_window_haiku.cpp
@@ -52,12 +52,18 @@ void MainWindow::psStatusIconCheck() {
}
void MainWindow::psShowTrayMenu() {
+ _trayIconMenuEmbed->popup(QCursor::pos());
}
void MainWindow::psTrayMenuUpdated() {
}
void MainWindow::psSetupTrayIcon() {
+ if (!_trayIconMenuEmbed) {
+ _trayIconMenuEmbed = new Ui::PopupMenu(nullptr, trayIconMenu);
+ _trayIconMenuEmbed->deleteOnHide(false);
+ }
+
if (!trayIcon) {
trayIcon = new QSystemTrayIcon(this);
@@ -75,13 +81,14 @@ void MainWindow::psSetupTrayIcon() {
}
void MainWindow::workmodeUpdated(DBIWorkMode mode) {
- psSetupTrayIcon();
if (mode == dbiwmWindowOnly) {
if (trayIcon) {
trayIcon->setContextMenu(0);
- delete trayIcon;
- trayIcon = nullptr;
+ trayIcon->deleteLater();
}
+ trayIcon = 0;
+ } else {
+ psSetupTrayIcon();
}
}
@@ -129,6 +136,7 @@ void MainWindow::psUpdateMargins() {
}
MainWindow::~MainWindow() {
+ delete _trayIconMenuEmbed;
}
} // namespace Platform
diff --git a/Telegram/SourceFiles/platform/haiku/main_window_haiku.h b/Telegram/SourceFiles/platform/haiku/main_window_haiku.h
index 36ab559..90940c3 100644
--- a/Telegram/SourceFiles/platform/haiku/main_window_haiku.h
+++ b/Telegram/SourceFiles/platform/haiku/main_window_haiku.h
@@ -4,12 +4,13 @@ This file is part of Telegram Desktop for Haiku,
For license and copyright information please follow this link:
https://github.com/desktop-app/legal/blob/master/LEGAL
-Copyright (c) 2018-2019 Gerasim Troeglazov, 3dEyes@gmail.com
+Copyright (c) 2018-2020 Gerasim Troeglazov, 3dEyes@gmail.com
*/
#pragma once
#include "platform/platform_main_window.h"
+#include "ui/widgets/popup_menu.h"
#include "base/flags.h"
#include <QtCore/QTimer>
@@ -60,6 +61,8 @@ private:
void updateIconCounters();
void psCreateTrayIcon();
+ Ui::PopupMenu *_trayIconMenuEmbed = nullptr;
+
QTimer _psCheckStatusIconTimer;
int _psCheckStatusIconLeft = 100;
--
2.24.1

View File

@@ -3,7 +3,7 @@ DESCRIPTION="Unofficial build of the original Telegram client for Haiku."
HOMEPAGE="https://www.telegram.org/"
COPYRIGHT="2013-2020 Telegram"
LICENSE="GNU GPL v3"
REVISION="1"
REVISION="2"
SOURCE_URI="https://github.com/telegramdesktop/tdesktop/releases/download/v$portVersion/tdesktop-$portVersion-full.tar.gz"
CHECKSUM_SHA256="d7bb9ad9e86d33333d733809e67daffc919d5dd32aeeaecd91c9ba9f5b3dfc22"