mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
feat: 优化任务栏拖拽功能
1. 不过滤鼠标离开事件 2. 鼠标按下释放后隐藏菜单 3. 触摸屏下第一次获取手指按下的状态错误 Log: 优化任务栏拖拽功能 Task: https://pms.uniontech.com/zentao/task-view-90299.html Influence: 任务栏-插件区域-拖拽插件的功能 Change-Id: Ib13b0b36a7a4f1272f8b23b8c80a5499ecf576e6
This commit is contained in:
parent
5c83a78374
commit
f95055e0b9
@ -258,6 +258,7 @@ void DockItem::showContextMenu()
|
||||
void DockItem::menuActionClicked(QAction *action)
|
||||
{
|
||||
invokedMenuItem(action->data().toString(), true);
|
||||
m_contextMenu->hide();
|
||||
}
|
||||
|
||||
void DockItem::onContextMenuAccepted()
|
||||
|
@ -40,8 +40,8 @@ Menu::Menu(QWidget *dockItem, QWidget *parent)
|
||||
qApp->installEventFilter(this);
|
||||
m_dockItem->installEventFilter(this);
|
||||
|
||||
// 点击任务栏以外区域时,关闭右键菜单
|
||||
connect(m_eventInter, &XEventMonitor::ButtonPress, this, &Menu::onButtonPress);
|
||||
// 按下任务栏以外区域释放鼠标时,关闭右键菜单,否则会导致点击菜单项后无响应
|
||||
connect(m_eventInter, &XEventMonitor::ButtonRelease, this, &Menu::onButtonPress);
|
||||
}
|
||||
|
||||
void Menu::onButtonPress()
|
||||
@ -70,27 +70,6 @@ bool Menu::eventFilter(QObject *watched, QEvent *event)
|
||||
// 按下应用拖动,按下应用从菜单上方移动时,鼠标滚轮滚动时,隐藏右键菜单
|
||||
hide();
|
||||
}
|
||||
|
||||
// 当右键菜单显示时捕获鼠标的release事件,click=press+release,
|
||||
// 让click无效,从而让启动器窗口不关闭
|
||||
if (event->type() == QEvent::MouseButtonRelease) {
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
if (mouseEvent->source() == Qt::MouseEventSynthesizedByQt) {
|
||||
if (isVisible())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理当右键菜单显示时,esc按下,关闭右键菜单,保持和模态框一样的效果
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||
if (keyEvent->key() == Qt::Key_Escape) {
|
||||
if (isVisible()) {
|
||||
hide();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QMenu::eventFilter(watched, event);
|
||||
|
@ -42,13 +42,13 @@ DWIDGET_USE_NAMESPACE
|
||||
FashionTrayWidgetWrapper::FashionTrayWidgetWrapper(const QString &itemKey, AbstractTrayWidget *absTrayWidget, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_absTrayWidget(absTrayWidget)
|
||||
, m_touchSignalManager(TouchSignalManager::instance())
|
||||
, m_layout(new QVBoxLayout(this))
|
||||
, m_attention(false)
|
||||
, m_dragging(false)
|
||||
, m_hover(false)
|
||||
, m_pressed(false)
|
||||
, m_itemKey(itemKey)
|
||||
|
||||
{
|
||||
setStyleSheet("background: transparent;");
|
||||
setAcceptDrops(true);
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <com_deepin_daemon_gesture.h>
|
||||
|
||||
using Gesture = com::deepin::daemon::Gesture;
|
||||
class TouchSignalManager;
|
||||
|
||||
#define TRAY_ITEM_DRAG_MIMEDATA "TrayItemDragDrop"
|
||||
|
||||
@ -70,7 +71,10 @@ private:
|
||||
void onTrayWidgetClicked();
|
||||
|
||||
private:
|
||||
// 动态加载的插件内存空间与dock进程内存空间相互独立,创建手势服务,监听触摸按下动作
|
||||
QPointer<AbstractTrayWidget> m_absTrayWidget;
|
||||
|
||||
QPointer<TouchSignalManager> m_touchSignalManager;
|
||||
QVBoxLayout *m_layout;
|
||||
|
||||
bool m_attention;
|
||||
|
@ -94,6 +94,7 @@ SystemTrayItem::SystemTrayItem(PluginsItemInterface *const pluginInter, const QS
|
||||
m_contextMenu->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint | Qt::Dialog);
|
||||
m_contextMenu->setObjectName("trayMenu");
|
||||
qApp->installEventFilter(m_contextMenu);
|
||||
qApp->installEventFilter(this);
|
||||
}
|
||||
|
||||
SystemTrayItem::~SystemTrayItem()
|
||||
@ -276,25 +277,9 @@ bool SystemTrayItem::eventFilter(QObject *watched, QEvent *event)
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
if (mouseEvent->button() == Qt::LeftButton)
|
||||
m_contextMenu->hide();
|
||||
} else if (event->type() == QEvent::DragMove || event->type() == QEvent::Move || event->type() == QEvent::Leave) {
|
||||
} else if (event->type() == QEvent::DragMove || event->type() == QEvent::Move) {
|
||||
m_contextMenu->hide();
|
||||
}
|
||||
|
||||
// 让click无效,避免点击到插件上
|
||||
if (event->type() == QEvent::MouseButtonRelease) {
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
if (mouseEvent->source() == Qt::MouseEventSynthesizedByQt && isVisible())
|
||||
return true;
|
||||
}
|
||||
|
||||
// 处理当右键菜单显示时,esc按下,关闭右键菜单,保持和模态框一样的效果
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||
if (keyEvent->key() == Qt::Key_Escape && isVisible()) {
|
||||
m_contextMenu->hide();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QWidget::eventFilter(watched, event);
|
||||
@ -490,6 +475,7 @@ void SystemTrayItem::showContextMenu()
|
||||
void SystemTrayItem::menuActionClicked(QAction *action)
|
||||
{
|
||||
invokedMenuItem(action->data().toString(), true);
|
||||
m_contextMenu->hide();
|
||||
}
|
||||
|
||||
void SystemTrayItem::onContextMenuAccepted()
|
||||
|
Loading…
x
Reference in New Issue
Block a user