mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
fix: 单指长按不能唤出右键菜单
单指长按时启用右键菜单进行处理,且关闭悬停提示 Log: 优化单指长按右键菜单 Bug: https://pms.uniontech.com/zentao/bug-view-41153.html Change-Id: Id1ddd263a78220de4e6d437afdd80d9327a961d9 Reviewed-on: http://gerrit.uniontech.com/c/dde-dock/+/1472 Reviewed-by: <mailman@uniontech.com> Reviewed-by: wangwei <wangwei@uniontech.com> Reviewed-by: niecheng <niecheng@uniontech.com> Tested-by: <mailman@uniontech.com>
This commit is contained in:
parent
60e629dbbb
commit
24ece545b5
@ -47,8 +47,12 @@ void AbstractTrayWidget::mousePressEvent(QMouseEvent *event)
|
||||
// when right button of mouse is pressed immediately in fashion mode
|
||||
|
||||
// here we hide the right button press event when it is click in the special area
|
||||
|
||||
//enterEvent事件会以计时器方式调起悬停窗口,在这里进行关闭
|
||||
m_popupTipsDelayTimer->stop();
|
||||
if (event->button() == Qt::RightButton && perfectIconRect().contains(event->pos(), true)) {
|
||||
event->accept();
|
||||
setMouseData(event);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -62,10 +66,7 @@ void AbstractTrayWidget::mouseReleaseEvent(QMouseEvent *e)
|
||||
// 由于 XWindowTrayWidget 中对 发送鼠标事件到X窗口的函数, 如 sendClick/sendHoverEvent 中
|
||||
// 使用了 setX11PassMouseEvent, 而每次调用 setX11PassMouseEvent 时都会导致产生 mousePress 和 mouseRelease 事件
|
||||
// 因此如果直接在这里处理事件会导致一些问题, 所以使用 Timer 来延迟处理 100 毫秒内的最后一个事件
|
||||
m_lastMouseReleaseData.first = e->pos();
|
||||
m_lastMouseReleaseData.second = e->button();
|
||||
|
||||
m_handleMouseReleaseTimer->start();
|
||||
setMouseData(e);
|
||||
|
||||
QWidget::mouseReleaseEvent(e);
|
||||
}
|
||||
@ -132,3 +133,11 @@ void AbstractTrayWidget::resizeEvent(QResizeEvent *event)
|
||||
setMaximumWidth(QWIDGETSIZE_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractTrayWidget::setMouseData(QMouseEvent *e)
|
||||
{
|
||||
m_lastMouseReleaseData.first = e->pos();
|
||||
m_lastMouseReleaseData.second = e->button();
|
||||
|
||||
m_handleMouseReleaseTimer->start();
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
virtual const QImage trayImage() = 0;
|
||||
virtual inline TrayType trayTyep() const { return TrayType::ApplicationTray; } // default is ApplicationTray
|
||||
virtual bool isValid() {return true;}
|
||||
virtual void setMouseData(QMouseEvent *e);
|
||||
|
||||
Q_SIGNALS:
|
||||
void iconChanged();
|
||||
@ -65,5 +66,8 @@ private:
|
||||
QTimer *m_handleMouseReleaseTimer;
|
||||
|
||||
QPair<QPoint, Qt::MouseButton> m_lastMouseReleaseData;
|
||||
|
||||
protected:
|
||||
QTimer *m_popupTipsDelayTimer;
|
||||
};
|
||||
|
||||
|
@ -46,9 +46,9 @@ SNITrayWidget::SNITrayWidget(const QString &sniServicePath, QWidget *parent)
|
||||
, m_updateOverlayIconTimer(new QTimer(this))
|
||||
, m_updateAttentionIconTimer(new QTimer(this))
|
||||
, m_sniServicePath(sniServicePath)
|
||||
, m_popupTipsDelayTimer(new QTimer(this))
|
||||
, m_tipsLabel(new TipsWidget)
|
||||
{
|
||||
m_popupTipsDelayTimer = new QTimer(this);
|
||||
m_popupTipsDelayTimer->setInterval(500);
|
||||
m_popupTipsDelayTimer->setSingleShot(true);
|
||||
|
||||
|
@ -136,7 +136,6 @@ private:
|
||||
QString m_sniOverlayIconName;
|
||||
DBusImageList m_sniOverlayIconPixmap;
|
||||
QString m_sniStatus;
|
||||
QTimer *m_popupTipsDelayTimer;
|
||||
static Dock::Position DockPosition;
|
||||
static QPointer<DockPopupWindow> PopupWindow;
|
||||
Dock::TipsWidget *m_tipsLabel;
|
||||
|
@ -36,12 +36,12 @@ SystemTrayItem::SystemTrayItem(PluginsItemInterface *const pluginInter, const QS
|
||||
, m_tapAndHold(false)
|
||||
, m_pluginInter(pluginInter)
|
||||
, m_centralWidget(m_pluginInter->itemWidget(itemKey))
|
||||
, m_popupTipsDelayTimer(new QTimer(this))
|
||||
, m_popupAdjustDelayTimer(new QTimer(this))
|
||||
, m_itemKey(itemKey)
|
||||
{
|
||||
qDebug() << "load tray plugins item: " << m_pluginInter->pluginName() << itemKey << m_centralWidget;
|
||||
|
||||
m_popupTipsDelayTimer = new QTimer(this);
|
||||
m_centralWidget->setParent(this);
|
||||
m_centralWidget->setVisible(true);
|
||||
m_centralWidget->installEventFilter(this);
|
||||
|
@ -102,10 +102,7 @@ private:
|
||||
|
||||
PluginsItemInterface* m_pluginInter;
|
||||
QWidget *m_centralWidget;
|
||||
|
||||
QTimer *m_popupTipsDelayTimer;
|
||||
QTimer *m_popupAdjustDelayTimer;
|
||||
|
||||
QPointer<QWidget> m_lastPopupWidget;
|
||||
QString m_itemKey;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user