handle tray menu myself instead by tray icon
This commit is contained in:
+11
-4
@@ -583,6 +583,9 @@ void Rktwebview_qt::processCommand(Command *cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QMenu *menu = (has_menu) ? buildMenuFromJson(this, menu_json, tray_id) : nullptr;
|
QMenu *menu = (has_menu) ? buildMenuFromJson(this, menu_json, tray_id) : nullptr;
|
||||||
|
_tray_menus[tray_id] = menu;
|
||||||
|
|
||||||
|
/*
|
||||||
if (menu == nullptr) {
|
if (menu == nullptr) {
|
||||||
if (!has_menu) {
|
if (!has_menu) {
|
||||||
INFO1("null menu, setting null menu on tray %d\n", tray_id);
|
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;
|
_tray_menus[tray_id] = menu;
|
||||||
_trays[tray_id]->setContextMenu(menu);
|
_trays[tray_id]->setContextMenu(menu);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
cmd->result = true;
|
cmd->result = true;
|
||||||
cmd->done = true;
|
cmd->done = true;
|
||||||
@@ -616,19 +620,22 @@ void Rktwebview_qt::processCommand(Command *cmd)
|
|||||||
void Rktwebview_qt::handleTrayActivation(QSystemTrayIcon::ActivationReason reason)
|
void Rktwebview_qt::handleTrayActivation(QSystemTrayIcon::ActivationReason reason)
|
||||||
{
|
{
|
||||||
QObject *obj = sender();
|
QObject *obj = sender();
|
||||||
|
int tray_wv = obj->property("tray-id").toInt();
|
||||||
|
|
||||||
QSystemTrayIcon *icn = qobject_cast<QSystemTrayIcon *>(obj);
|
QSystemTrayIcon *icn = qobject_cast<QSystemTrayIcon *>(obj);
|
||||||
|
|
||||||
// If a context menu has been set, pop it up and leave.
|
// If a context menu has been set, pop it up and leave.
|
||||||
/*if (reason == QSystemTrayIcon::ActivationReason::Context) {
|
if (reason == QSystemTrayIcon::ActivationReason::Context) {
|
||||||
QMenu *mnu = icn->contextMenu();
|
QMenu *mnu = nullptr;
|
||||||
|
if (_tray_menus.contains(tray_wv)) {
|
||||||
|
mnu = _tray_menus[tray_wv];
|
||||||
|
}
|
||||||
if (mnu != nullptr) {
|
if (mnu != nullptr) {
|
||||||
mnu->popup(QCursor::pos());
|
mnu->popup(QCursor::pos());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
int tray_wv = obj->property("tray-id").toInt();
|
|
||||||
QString evt = "tray-activated";
|
QString evt = "tray-activated";
|
||||||
QString reason_str = activationReasonToString(reason);
|
QString reason_str = activationReasonToString(reason);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user