From 85b5a29192b3991741f7985f864c1a0a622224b7 Mon Sep 17 00:00:00 2001 From: Hans Dijkema Date: Thu, 30 Apr 2026 13:42:57 +0200 Subject: [PATCH] handle tray menu myself instead by tray icon --- rktwebview_qt.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/rktwebview_qt.cpp b/rktwebview_qt.cpp index f3b9db9..b7a4a98 100644 --- a/rktwebview_qt.cpp +++ b/rktwebview_qt.cpp @@ -583,6 +583,9 @@ void Rktwebview_qt::processCommand(Command *cmd) } QMenu *menu = (has_menu) ? buildMenuFromJson(this, menu_json, tray_id) : nullptr; + _tray_menus[tray_id] = menu; + + /* if (menu == nullptr) { if (!has_menu) { INFO1("null menu, setting null menu on tray %d\n", tray_id); @@ -600,6 +603,7 @@ void Rktwebview_qt::processCommand(Command *cmd) _tray_menus[tray_id] = menu; _trays[tray_id]->setContextMenu(menu); } + */ cmd->result = true; cmd->done = true; @@ -616,19 +620,22 @@ void Rktwebview_qt::processCommand(Command *cmd) void Rktwebview_qt::handleTrayActivation(QSystemTrayIcon::ActivationReason reason) { QObject *obj = sender(); + int tray_wv = obj->property("tray-id").toInt(); QSystemTrayIcon *icn = qobject_cast(obj); // If a context menu has been set, pop it up and leave. - /*if (reason == QSystemTrayIcon::ActivationReason::Context) { - QMenu *mnu = icn->contextMenu(); + if (reason == QSystemTrayIcon::ActivationReason::Context) { + QMenu *mnu = nullptr; + if (_tray_menus.contains(tray_wv)) { + mnu = _tray_menus[tray_wv]; + } if (mnu != nullptr) { mnu->popup(QCursor::pos()); return; } - }*/ + } - int tray_wv = obj->property("tray-id").toInt(); QString evt = "tray-activated"; QString reason_str = activationReasonToString(reason);