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);