Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions plugins/application-tray/sniprotocolhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@ class DBusMenu : public DBusMenuImporter {
: DBusMenuImporter(service, path, parent)
{
QObject::connect(this, &DBusMenuImporter::menuUpdated, this, [this] (QMenu *menu) {
menu->setFixedSize(menu->sizeHint());
menu->adjustSize();
menu->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
menu->setMinimumHeight(menu->sizeHint().height());

// hide arrow
menu->setStyleSheet(
Comment thread
re2zero marked this conversation as resolved.
"QMenu::scroller { width: 0px; height: 0px; }"
"QMenu::down-arrow { image: none; }"
"QMenu::up-arrow { image: none; }"
);
Comment thread
re2zero marked this conversation as resolved.
}, Qt::QueuedConnection);
}
virtual QMenu *createMenu(QWidget *parent) override
Expand Down Expand Up @@ -272,7 +281,7 @@ bool SniTrayProtocolHandler::eventFilter(QObject *watched, QEvent *event)
pluginPopup->setItemKey(id());
pluginPopup->setPopupType(Plugin::PluginPopup::PopupTypeMenu);
const auto offset = mouseEvent->pos();
pluginPopup->setX(geometry.x() + offset.x());
pluginPopup->setX(geometry.x() + offset.x() + 2); // Add 2 offsets to avoid hovering to the menu
pluginPopup->setY(geometry.y() + offset.y());
menu->show();
}
Expand Down
6 changes: 6 additions & 0 deletions plugins/libdbusmenuqt/dbusmenuimporter.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* This file is part of the dbusmenu-qt library
SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
SPDX-FileCopyrightText: 2009 Canonical
SPDX-FileContributor: Aurelien Gateau <aurelien.gateau@canonical.com>

Expand Down Expand Up @@ -119,6 +120,8 @@ class DBusMenuImporterPrivate

if (map.take(QStringLiteral("children-display")).toString() == QLatin1String("submenu")) {
QMenu *menu = createMenu(parent);
// Set the ID of the menuAction of the submenu so that aboutToShow can correctly obtain the menu ID and refresh it
menu->menuAction()->setProperty(DBUSMENU_PROPERTY_ID, id);
Comment thread
re2zero marked this conversation as resolved.
action->setMenu(menu);
}

Expand Down Expand Up @@ -522,6 +525,9 @@ void DBusMenuImporter::slotMenuAboutToHide()

int id = action->property(DBUSMENU_PROPERTY_ID).toInt();
d->sendEvent(id, QStringLiteral("closed"));

// Clear id when the menu is closed to ensure that it can be refreshed normally next time hover
d->m_idsRefreshedByAboutToShow.remove(id);
}

void DBusMenuImporter::slotMenuAboutToShow()
Expand Down
Loading