mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix: 解决点击桌面空白处不会将网络菜单隐藏问题
任务栏外区域事件使用XEventMonitor服务监听处理 Log: 解决插件右键菜单无法隐藏问题 Influence: 任务栏-插件右键隐藏问题 Bug: https://pms.uniontech.com/zentao/bug-view-101269.html Change-Id: I13aecf004928a07dff4a8638528c29878b733202
This commit is contained in:
parent
41deea756c
commit
f5d34f1560
@ -38,7 +38,9 @@ Menu::Menu(QWidget *dockItem, QWidget *parent)
|
||||
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint | Qt::Dialog);
|
||||
setObjectName("rightMenu");
|
||||
qApp->installEventFilter(this);
|
||||
m_dockItem->installEventFilter(this);
|
||||
|
||||
if (m_dockItem)
|
||||
m_dockItem->installEventFilter(this);
|
||||
|
||||
// 按下任务栏以外区域释放鼠标时,关闭右键菜单,否则会导致点击菜单项后无响应
|
||||
connect(m_eventInter, &XEventMonitor::ButtonRelease, this, &Menu::onButtonPress);
|
||||
|
@ -14,6 +14,7 @@ file(GLOB_RECURSE SRCS "*.h" "*.cpp" "../../widgets/*.h" "../../widgets/*.cpp"
|
||||
"../../frame/dbus/dbusmenumanager.h" "../../frame/dbus/dbusmenumanager.cpp"
|
||||
"../../widgets/*.h" "../../widgets/*.cpp"
|
||||
"../../frame/util/imageutil.h" "../../frame/util/imageutil.cpp"
|
||||
"../../frame/util/menudialog.h" "../../frame/util/menudialog.cpp"
|
||||
"../../frame/util/touchsignalmanager.h" "../../frame/util/touchsignalmanager.cpp")
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "systemtrayitem.h"
|
||||
#include "utils.h"
|
||||
#include "menudialog.h"
|
||||
|
||||
#include <QProcess>
|
||||
#include <QDebug>
|
||||
@ -35,9 +36,9 @@ SystemTrayItem::SystemTrayItem(PluginsItemInterface *const pluginInter, const QS
|
||||
: AbstractTrayWidget(parent)
|
||||
, m_popupShown(false)
|
||||
, m_tapAndHold(false)
|
||||
, m_contextMenu(new QMenu)
|
||||
, m_pluginInter(pluginInter)
|
||||
, m_centralWidget(m_pluginInter->itemWidget(itemKey))
|
||||
, m_contextMenu(new Menu)
|
||||
, m_popupTipsDelayTimer(new QTimer(this))
|
||||
, m_popupAdjustDelayTimer(new QTimer(this))
|
||||
, m_itemKey(itemKey)
|
||||
@ -90,11 +91,6 @@ SystemTrayItem::SystemTrayItem(PluginsItemInterface *const pluginInter, const QS
|
||||
connect(m_gsettings, &QGSettings::changed, this, &SystemTrayItem::onGSettingsChanged);
|
||||
|
||||
grabGesture(Qt::TapAndHoldGesture);
|
||||
|
||||
m_contextMenu->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint | Qt::Dialog);
|
||||
m_contextMenu->setObjectName("trayMenu");
|
||||
qApp->installEventFilter(m_contextMenu);
|
||||
qApp->installEventFilter(this);
|
||||
}
|
||||
|
||||
SystemTrayItem::~SystemTrayItem()
|
||||
@ -270,21 +266,6 @@ void SystemTrayItem::showEvent(QShowEvent *event)
|
||||
return AbstractTrayWidget::showEvent(event);
|
||||
}
|
||||
|
||||
bool SystemTrayItem::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (!watched->objectName().startsWith("trayMenu")) {
|
||||
if (event->type() == QEvent::MouseButtonPress) {
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
if (mouseEvent->button() == Qt::LeftButton)
|
||||
m_contextMenu->hide();
|
||||
} else if (event->type() == QEvent::DragMove || event->type() == QEvent::Move) {
|
||||
m_contextMenu->hide();
|
||||
}
|
||||
}
|
||||
|
||||
return QWidget::eventFilter(watched, event);
|
||||
}
|
||||
|
||||
const QPoint SystemTrayItem::popupMarkPoint() const
|
||||
{
|
||||
QPoint p(topleftPoint());
|
||||
|
@ -28,9 +28,9 @@
|
||||
#include "pluginsiteminterface.h"
|
||||
|
||||
#include <QGestureEvent>
|
||||
#include <QMenu>
|
||||
|
||||
class QGSettings;
|
||||
class Menu;
|
||||
class SystemTrayItem : public AbstractTrayWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -70,7 +70,6 @@ protected:
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
void showEvent(QShowEvent* event) override;
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
protected:
|
||||
const QPoint popupMarkPoint() const;
|
||||
@ -97,10 +96,10 @@ private:
|
||||
private:
|
||||
bool m_popupShown;
|
||||
bool m_tapAndHold;
|
||||
QMenu *m_contextMenu;
|
||||
|
||||
PluginsItemInterface* m_pluginInter;
|
||||
QWidget *m_centralWidget;
|
||||
Menu *m_contextMenu;
|
||||
|
||||
QTimer *m_popupTipsDelayTimer;
|
||||
QTimer *m_popupAdjustDelayTimer;
|
||||
|
Loading…
x
Reference in New Issue
Block a user