mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
feat: touchscreen support
Change-Id: Ica912c5e672d0e02f6e9540fd95d12d916dd5d74
This commit is contained in:
parent
b689dbece2
commit
ca08567861
Notes:
gerrit
2018-11-16 09:58:47 +08:00
Verified+1: <jenkins@deepin.com> Code-Review+2: Hualet Wang <mr.asianwang@gmail.com> Submitted-by: Hualet Wang <mr.asianwang@gmail.com> Submitted-at: Fri, 16 Nov 2018 09:58:46 +0800 Reviewed-on: https://cr.deepin.io/39704 Project: dde/dde-dock Branch: refs/heads/master
@ -290,6 +290,11 @@ void AppItem::mouseReleaseEvent(QMouseEvent *e)
|
||||
if (e->button() == Qt::MiddleButton) {
|
||||
m_itemEntryInter->NewInstance(QX11Info::getTimestamp());
|
||||
} else if (e->button() == Qt::LeftButton) {
|
||||
if (checkAndResetTapHoldGestureState()) {
|
||||
qDebug() << "tap and hold gesture detected, ignore the synthesized mouse release event";
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "app item clicked, name:" << m_itemEntryInter->name()
|
||||
<< "id:" << m_itemEntryInter->id() << "my-id:" << m_id << "icon:" << m_itemEntryInter->icon();
|
||||
|
||||
|
@ -35,6 +35,7 @@ DockItem::DockItem(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
m_hover(false),
|
||||
m_popupShown(false),
|
||||
m_tapAndHold(false),
|
||||
|
||||
m_hoverEffect(new HoverHighlightEffect(this)),
|
||||
|
||||
@ -65,6 +66,8 @@ DockItem::DockItem(QWidget *parent)
|
||||
|
||||
connect(m_popupTipsDelayTimer, &QTimer::timeout, this, &DockItem::showHoverTips);
|
||||
connect(m_popupAdjustDelayTimer, &QTimer::timeout, this, &DockItem::updatePopupPosition, Qt::QueuedConnection);
|
||||
|
||||
grabGesture(Qt::TapAndHoldGesture);
|
||||
}
|
||||
|
||||
DockItem::~DockItem()
|
||||
@ -83,6 +86,21 @@ void DockItem::setDockDisplayMode(const DisplayMode mode)
|
||||
DockDisplayMode = mode;
|
||||
}
|
||||
|
||||
void DockItem::gestureEvent(QGestureEvent *event)
|
||||
{
|
||||
if (!event)
|
||||
return;
|
||||
|
||||
QGesture *gesture = event->gesture(Qt::TapAndHoldGesture);
|
||||
|
||||
if (!gesture)
|
||||
return;
|
||||
|
||||
qDebug() << "got TapAndHoldGesture";
|
||||
|
||||
m_tapAndHold = true;
|
||||
}
|
||||
|
||||
bool DockItem::event(QEvent *event)
|
||||
{
|
||||
if (m_popupShown)
|
||||
@ -97,6 +115,9 @@ bool DockItem::event(QEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
if (event->type() == QEvent::Gesture)
|
||||
gestureEvent(static_cast<QGestureEvent*>(event));
|
||||
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
@ -307,6 +328,18 @@ QWidget *DockItem::popupTips()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief DockItem::checkAndResetTapHoldGestureState checks if a QTapAndHoldGesture
|
||||
* happens during the mouse press and release event pair.
|
||||
* \return true if yes, otherwise false.
|
||||
*/
|
||||
bool DockItem::checkAndResetTapHoldGestureState()
|
||||
{
|
||||
bool ret = m_tapAndHold;
|
||||
m_tapAndHold = false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
const QPoint DockItem::popupMarkPoint() const
|
||||
{
|
||||
QPoint p(topleftPoint());
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include <QFrame>
|
||||
#include <QPointer>
|
||||
#include <QGestureEvent>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@ -88,6 +89,9 @@ protected:
|
||||
virtual const QString contextMenu() const;
|
||||
virtual QWidget *popupTips();
|
||||
|
||||
bool checkAndResetTapHoldGestureState();
|
||||
virtual void gestureEvent(QGestureEvent *event);
|
||||
|
||||
protected slots:
|
||||
void showContextMenu();
|
||||
void onContextMenuAccepted();
|
||||
@ -98,6 +102,7 @@ private:
|
||||
protected:
|
||||
bool m_hover;
|
||||
bool m_popupShown;
|
||||
bool m_tapAndHold;
|
||||
|
||||
QPointer<QWidget> m_lastPopupWidget;
|
||||
QPointer<HoverHighlightEffect> m_hoverEffect;
|
||||
|
@ -87,20 +87,17 @@ void LauncherItem::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
hidePopup();
|
||||
|
||||
if (e->button() == Qt::RightButton/* && !perfectIconRect().contains(e->pos())*/)
|
||||
return QWidget::mousePressEvent(e);
|
||||
return QWidget::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void LauncherItem::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
if (e->button() != Qt::LeftButton)
|
||||
return;
|
||||
|
||||
QProcess *proc = new QProcess;
|
||||
|
||||
connect(proc, static_cast<void (QProcess::*)(int)>(&QProcess::finished), proc, &QProcess::deleteLater);
|
||||
|
||||
if (!m_launcherInter->IsVisible()) {
|
||||
m_launcherInter->Show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QWidget *LauncherItem::popupTips()
|
||||
|
@ -44,6 +44,7 @@ private:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void mouseReleaseEvent(QMouseEvent *e);
|
||||
|
||||
QWidget *popupTips();
|
||||
|
||||
|
@ -150,6 +150,11 @@ void PluginsItem::mouseReleaseEvent(QMouseEvent *e)
|
||||
if (e->button() != Qt::LeftButton)
|
||||
return;
|
||||
|
||||
if (checkAndResetTapHoldGestureState()) {
|
||||
qDebug() << "tap and hold gesture detected, ignore the synthesized mouse release event";
|
||||
return;
|
||||
}
|
||||
|
||||
e->accept();
|
||||
|
||||
const QPoint distance = e->pos() - MousePressPoint;
|
||||
|
Loading…
x
Reference in New Issue
Block a user