为右键菜单指定父类,修复右键菜单乱飞问题

This commit is contained in:
buxiaoqing 2023-03-07 10:33:48 +08:00
parent 72aa28e745
commit d3ae1e7c49
4 changed files with 7 additions and 7 deletions

View File

@ -128,7 +128,7 @@ CalendarButton::~CalendarButton()
void CalendarButton::contextMenuEvent(QContextMenuEvent *event)
{
m_menuCalender = new QMenu();
m_menuCalender = new QMenu(this);
m_menuCalender->setAttribute(Qt::WA_DeleteOnClose);
m_menuCalender->setGeometry(m_plugin->panel()->calculatePopupWindowPos
(mapToGlobal(event->pos()),

View File

@ -85,12 +85,12 @@ void StartMenuButton::mouseReleaseEvent(QMouseEvent* event)
void StartMenuButton::contextMenuEvent(QContextMenuEvent *event)
{
rightPressMenu=new QMenu();
rightPressMenu = new QMenu(this);
rightPressMenu->setAttribute(Qt::WA_DeleteOnClose);
QMenu *pUserAction=new QMenu(tr("User Action")); //用户操作
QMenu *pSleepHibernate=new QMenu(tr("Suspend or Hibernate")); //休眠或睡眠
QMenu *pPowerSupply=new QMenu(tr("Power Supply")); //电源
QMenu *pUserAction = new QMenu(tr("User Action"), this); //用户操作
QMenu *pSleepHibernate = new QMenu(tr("Suspend or Hibernate"), this); //休眠或睡眠
QMenu *pPowerSupply = new QMenu(tr("Power Supply"), this); //电源
rightPressMenu->addMenu(pUserAction);
if (QString::compare(getCanHibernateResult(),"yes") == 0 ||
QString::compare(getCanSuspendResult(),"yes") == 0) {

View File

@ -426,7 +426,7 @@ void StatusNotifierButton::updataItemMenu()
m_menu = m_menuImporter->menu();
if (m_menu && !m_menu->isEmpty()) {
m_plugin->willShowWindow(m_menu);
m_menu->exec(m_plugin->panel()->calculatePopupWindowPos(m_cursorLeftPos, m_menu->sizeHint()).topLeft()); //任务栏显示右键菜单
m_menu->exec(m_menuImporter->menu()->actions(), m_plugin->panel()->calculatePopupWindowPos(m_cursorLeftPos, m_menu->sizeHint()).topLeft(), nullptr, this); //任务栏显示右键菜单
} else {
m_interface->ContextMenu(m_cursorLeftPos.x(), m_cursorLeftPos.y()); //应用显示右键菜单
}

View File

@ -189,7 +189,7 @@ void UKUITaskGroup::contextMenuEvent(QContextMenuEvent *event)
{
setPopupVisible(false, true);
m_preventPopup = true;
QMenu * menu = new QMenu(tr("Group"));
QMenu * menu = new QMenu(tr("Group"), this);
menu->setAttribute(Qt::WA_DeleteOnClose);
//若应用卸载后主窗口仍为打开状态,则右键菜单只显示“退出”选项
XdgDesktopFile xdg;