mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
show preview when cursor move to border
Change-Id: I5201e2fb3ba3f0ab9fa4c3881a501155662a66d6
This commit is contained in:
parent
028b57cdb3
commit
1ad9ac4c8d
Notes:
Deepin Code Review
2017-05-02 19:14:47 +08:00
Verified+1: Anonymous Coward #1000004 Code-Review+2: 石博文 <sbw@sbw.so> Submitted-by: 石博文 <sbw@sbw.so> Submitted-at: Tue, 02 May 2017 19:14:41 +0800 Reviewed-on: https://cr.deepin.io/22746 Project: dde/dde-dock Branch: refs/heads/master
@ -43,6 +43,7 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
|||||||
|
|
||||||
setAccessibleName(m_itemEntry->name());
|
setAccessibleName(m_itemEntry->name());
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
setMouseTracking(true);
|
||||||
setLayout(centralLayout);
|
setLayout(centralLayout);
|
||||||
|
|
||||||
m_itemView->setScene(m_itemScene);
|
m_itemView->setScene(m_itemScene);
|
||||||
@ -326,6 +327,10 @@ void AppItem::mouseMoveEvent(QMouseEvent *e)
|
|||||||
{
|
{
|
||||||
e->accept();
|
e->accept();
|
||||||
|
|
||||||
|
// handle preview
|
||||||
|
if (e->buttons() == Qt::NoButton)
|
||||||
|
return showPreview();
|
||||||
|
|
||||||
// handle drag
|
// handle drag
|
||||||
if (e->buttons() != Qt::LeftButton)
|
if (e->buttons() != Qt::LeftButton)
|
||||||
return;
|
return;
|
||||||
@ -335,10 +340,8 @@ void AppItem::mouseMoveEvent(QMouseEvent *e)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const QPoint distance = pos - MousePressPos;
|
const QPoint distance = pos - MousePressPos;
|
||||||
if (distance.manhattanLength() < APP_DRAG_THRESHOLD)
|
if (distance.manhattanLength() > APP_DRAG_THRESHOLD)
|
||||||
return;
|
return startDrag();
|
||||||
|
|
||||||
startDrag();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppItem::wheelEvent(QWheelEvent *e)
|
void AppItem::wheelEvent(QWheelEvent *e)
|
||||||
@ -390,24 +393,6 @@ void AppItem::dropEvent(QDropEvent *e)
|
|||||||
m_itemEntry->HandleDragDrop(uriList);
|
m_itemEntry->HandleDragDrop(uriList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppItem::showHoverTips()
|
|
||||||
{
|
|
||||||
// another model popup window is alread exists
|
|
||||||
// if (PopupWindow->isVisible() && PopupWindow->model())
|
|
||||||
// return;
|
|
||||||
|
|
||||||
// QWidget * const content = popupTips();
|
|
||||||
// if (!content)
|
|
||||||
// return;
|
|
||||||
|
|
||||||
// showPopupWindow(content);
|
|
||||||
|
|
||||||
if (m_titles.isEmpty())
|
|
||||||
return DockItem::showHoverTips();
|
|
||||||
|
|
||||||
showPreview();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AppItem::invokedMenuItem(const QString &itemId, const bool checked)
|
void AppItem::invokedMenuItem(const QString &itemId, const bool checked)
|
||||||
{
|
{
|
||||||
Q_UNUSED(checked);
|
Q_UNUSED(checked);
|
||||||
@ -495,13 +480,23 @@ void AppItem::activeChanged()
|
|||||||
|
|
||||||
void AppItem::showPreview()
|
void AppItem::showPreview()
|
||||||
{
|
{
|
||||||
// if (PopupWindow->isVisible())
|
if (m_titles.isEmpty())
|
||||||
// return hidePopup();
|
return;
|
||||||
|
|
||||||
|
// test cursor position
|
||||||
|
const QRect r = rect();
|
||||||
|
const QPoint p = mapFromGlobal(QCursor::pos());
|
||||||
|
|
||||||
|
switch (DockPosition)
|
||||||
|
{
|
||||||
|
case Top: if (p.y() != r.top()) return;
|
||||||
|
case Left: if (p.x() != r.left()) return;
|
||||||
|
case Right: if (p.x() != r.right()) return;
|
||||||
|
case Bottom: if (p.y() != r.bottom()) return;
|
||||||
|
}
|
||||||
|
|
||||||
m_appPreviewTips->updateLayoutDirection(DockPosition);
|
m_appPreviewTips->updateLayoutDirection(DockPosition);
|
||||||
// m_appPreviewTips->setWindowInfos(m_titles);
|
// m_appPreviewTips->setWindowInfos(m_titles);
|
||||||
|
|
||||||
qApp->processEvents();
|
|
||||||
|
|
||||||
showPopupWindow(m_appPreviewTips, true);
|
showPopupWindow(m_appPreviewTips, true);
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,6 @@ private:
|
|||||||
void dragMoveEvent(QDragMoveEvent *e);
|
void dragMoveEvent(QDragMoveEvent *e);
|
||||||
void dropEvent(QDropEvent *e);
|
void dropEvent(QDropEvent *e);
|
||||||
|
|
||||||
void showHoverTips();
|
|
||||||
void invokedMenuItem(const QString &itemId, const bool checked);
|
void invokedMenuItem(const QString &itemId, const bool checked);
|
||||||
const QString contextMenu() const;
|
const QString contextMenu() const;
|
||||||
QWidget *popupTips();
|
QWidget *popupTips();
|
||||||
|
@ -201,12 +201,14 @@ void DockItem::showPopupWindow(QWidget * const content, const bool model)
|
|||||||
case Right: popup->setArrowDirection(DockPopupWindow::ArrowRight); break;
|
case Right: popup->setArrowDirection(DockPopupWindow::ArrowRight); break;
|
||||||
}
|
}
|
||||||
popup->setContent(content);
|
popup->setContent(content);
|
||||||
popup->setMargin(5);
|
|
||||||
popup->setWidth(content->sizeHint().width());
|
popup->setWidth(content->sizeHint().width());
|
||||||
popup->setHeight(content->sizeHint().height());
|
popup->setHeight(content->sizeHint().height());
|
||||||
|
|
||||||
const QPoint p = popupMarkPoint();
|
const QPoint p = popupMarkPoint();
|
||||||
QMetaObject::invokeMethod(popup, "show", Qt::QueuedConnection, Q_ARG(QPoint, p), Q_ARG(bool, model));
|
if (!popup->isVisible())
|
||||||
|
QMetaObject::invokeMethod(popup, "show", Qt::QueuedConnection, Q_ARG(QPoint, p), Q_ARG(bool, model));
|
||||||
|
else
|
||||||
|
popup->show(p, model);
|
||||||
|
|
||||||
connect(popup, &DockPopupWindow::accept, this, &DockItem::popupWindowAccept);
|
connect(popup, &DockPopupWindow::accept, this, &DockItem::popupWindowAccept);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user