mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
feat: 任务栏单指长按支持拖动
任务栏图标拖动需要单指长按超过200ms后(后端提供判断信号),才可进行 Log: 根据后端长按信号,任务栏图标单指长按超过200ms后才可拖动 Task: https://pms.uniontech.com/zentao/task-view-30976.html Change-Id: Ia75e7b09b7ea2421089a0e5b8be4ff9a5049bae3 Reviewed-on: http://gerrit.uniontech.com/c/dde-dock/+/864 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
1a455503d9
commit
31663a9ded
@ -77,6 +77,8 @@ MainPanelControl::MainPanelControl(QWidget *parent)
|
||||
, m_isHover(false)
|
||||
, m_needRecoveryWin(false)
|
||||
, m_isEnableLaunch(true)
|
||||
, m_longPressed(false)
|
||||
, m_gestureInter(new Gesture("com.deepin.daemon.Gesture", "/com/deepin/daemon/Gesture", QDBusConnection::systemBus(), this))
|
||||
{
|
||||
init();
|
||||
updateMainPanelLayout();
|
||||
@ -95,6 +97,14 @@ MainPanelControl::MainPanelControl(QWidget *parent)
|
||||
m_fixedSpliter->setFixedSize(0,0);
|
||||
m_appSpliter ->setFixedSize(0,0);
|
||||
m_traySpliter->setFixedSize(0,0);
|
||||
|
||||
// 根据后端延迟触屏信号控制是否可进行图标拖动,收到延迟触屏信号可拖动,没有收到延迟触屏信号、点击松开就不可拖动
|
||||
connect(m_gestureInter, &Gesture::TouchSinglePressTimeout, this, [this]{
|
||||
m_longPressed = true;
|
||||
});
|
||||
connect(m_gestureInter, &Gesture::TouchUpOrCancel, this, [this]{
|
||||
m_longPressed = false;
|
||||
});
|
||||
}
|
||||
|
||||
MainPanelControl::~MainPanelControl()
|
||||
@ -611,7 +621,7 @@ bool MainPanelControl::eventFilter(QObject *watched, QEvent *event)
|
||||
if (event->type() != QEvent::MouseMove)
|
||||
return false;
|
||||
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
QMouseEvent *mouseEvent = dynamic_cast<QMouseEvent *>(event);
|
||||
if (!mouseEvent || mouseEvent->buttons() != Qt::LeftButton)
|
||||
return false;
|
||||
|
||||
@ -627,6 +637,11 @@ bool MainPanelControl::eventFilter(QObject *watched, QEvent *event)
|
||||
if (distance.manhattanLength() < QApplication::startDragDistance())
|
||||
return false;
|
||||
|
||||
// source为MouseEventSynthesizedByQt时,事件由触屏事件转换而来,触屏没有收到后端的延迟触屏信号时不进行拖动
|
||||
if (mouseEvent->source() == Qt::MouseEventSynthesizedByQt && !m_longPressed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
startDrag(item);
|
||||
|
||||
return QWidget::eventFilter(watched, event);
|
||||
|
@ -28,7 +28,10 @@
|
||||
#include <QBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
#include <com_deepin_daemon_gesture.h>
|
||||
|
||||
using namespace Dock;
|
||||
using Gesture = com::deepin::daemon::Gesture;
|
||||
|
||||
class TrayPluginItem;
|
||||
class PluginsItem;
|
||||
@ -142,6 +145,10 @@ private:
|
||||
bool m_isHover;//判断鼠标是否移到desktop区域
|
||||
bool m_needRecoveryWin; // 判断鼠标移出desktop区域是否恢复之前窗口
|
||||
bool m_isEnableLaunch;//判断是否使能了com.deepin.dde.dock.module.launcher
|
||||
|
||||
// 保存触控屏长按状态
|
||||
bool m_longPressed;
|
||||
Gesture* m_gestureInter;
|
||||
};
|
||||
|
||||
#endif // MAINPANELCONTROL_H
|
||||
|
@ -38,6 +38,12 @@
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
Gesture *FashionTrayWidgetWrapper::m_gestureInter = new Gesture("com.deepin.daemon.Gesture"
|
||||
, "/com/deepin/daemon/Gesture"
|
||||
, QDBusConnection::systemBus()
|
||||
, nullptr);
|
||||
bool FashionTrayWidgetWrapper::m_longPressed = false;
|
||||
|
||||
FashionTrayWidgetWrapper::FashionTrayWidgetWrapper(const QString &itemKey, AbstractTrayWidget *absTrayWidget, QWidget *parent)
|
||||
: QWidget(parent),
|
||||
m_absTrayWidget(absTrayWidget),
|
||||
@ -67,6 +73,14 @@ FashionTrayWidgetWrapper::FashionTrayWidgetWrapper(const QString &itemKey, Abstr
|
||||
setMinimumSize(PLUGIN_BACKGROUND_MIN_SIZE, PLUGIN_BACKGROUND_MIN_SIZE);
|
||||
|
||||
m_absTrayWidget->show();
|
||||
|
||||
// 根据后端信号,记录触屏长按状态
|
||||
connect(m_gestureInter, &Gesture::TouchSinglePressTimeout, m_gestureInter, []{
|
||||
m_longPressed = true;
|
||||
}, Qt::UniqueConnection);
|
||||
connect(m_gestureInter, &Gesture::TouchUpOrCancel, m_gestureInter, []{
|
||||
m_longPressed = false;
|
||||
}, Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
QPointer<AbstractTrayWidget> FashionTrayWidgetWrapper::absTrayWidget() const
|
||||
@ -221,6 +235,11 @@ void FashionTrayWidgetWrapper::handleMouseMove(QMouseEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果是触屏事件转换而来并且没有收到后端的延时触屏消息,不进行拖拽
|
||||
if (event->source() == Qt::MouseEventSynthesizedByQt && !m_longPressed) {
|
||||
return;
|
||||
}
|
||||
|
||||
event->accept();
|
||||
|
||||
QDrag drag(this);
|
||||
|
@ -28,6 +28,10 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QPointer>
|
||||
|
||||
#include <com_deepin_daemon_gesture.h>
|
||||
|
||||
using Gesture = com::deepin::daemon::Gesture;
|
||||
|
||||
#define TRAY_ITEM_DRAG_MIMEDATA "TrayItemDragDrop"
|
||||
|
||||
class FashionTrayWidgetWrapper : public QWidget
|
||||
@ -75,6 +79,9 @@ private:
|
||||
bool m_pressed;
|
||||
QString m_itemKey;
|
||||
QPoint MousePressPoint;
|
||||
|
||||
static Gesture *m_gestureInter;
|
||||
static bool m_longPressed;
|
||||
};
|
||||
|
||||
#endif //FASHIONTRAYWIDGETWRAPPER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user