From 56654bd0b9be78ef0f1ae322aef41a4e61c58111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=B3=E5=8D=9A=E6=96=87?= Date: Tue, 9 Aug 2016 10:58:47 +0800 Subject: [PATCH] hide popup when mouse press Change-Id: I057b43dd1698b775c79d71972519278da1d770ff --- frame/item/appitem.cpp | 6 +++--- frame/item/dockitem.cpp | 14 ++++++++------ frame/item/dockitem.h | 1 + 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/frame/item/appitem.cpp b/frame/item/appitem.cpp index b3baed502..acedbb7d6 100644 --- a/frame/item/appitem.cpp +++ b/frame/item/appitem.cpp @@ -231,9 +231,6 @@ void AppItem::paintEvent(QPaintEvent *e) painter.drawPixmap(itemRect.center() - pixmap.rect().center(), ImageFactory::lighterEffect(pixmap)); // Update the window icon geometry when the icon is changed. - if (m_updateIconGeometryTimer->isActive()) { - m_updateIconGeometryTimer->stop(); - } m_updateIconGeometryTimer->start(); } @@ -249,6 +246,9 @@ void AppItem::mouseReleaseEvent(QMouseEvent *e) void AppItem::mousePressEvent(QMouseEvent *e) { + m_updateIconGeometryTimer->stop(); + hidePopup(); + if (e->button() == Qt::RightButton) { if (perfectIconRect().contains(e->pos())) diff --git a/frame/item/dockitem.cpp b/frame/item/dockitem.cpp index d19c14be6..006247042 100644 --- a/frame/item/dockitem.cpp +++ b/frame/item/dockitem.cpp @@ -101,10 +101,7 @@ void DockItem::leaveEvent(QEvent *e) // auto hide if popup is not model window if (m_popupShown && !PopupWindow->model()) - { - m_popupShown = false; - PopupWindow->hide(); - } + hidePopup(); update(); } @@ -213,8 +210,7 @@ void DockItem::popupWindowAccept() disconnect(PopupWindow.get(), &DockPopupWindow::accept, this, &DockItem::popupWindowAccept); - m_popupShown = false; - PopupWindow->hide(); + hidePopup(); emit requestWindowAutoHide(true); } @@ -264,3 +260,9 @@ const QPoint DockItem::popupMarkPoint() return p; } + +void DockItem::hidePopup() +{ + m_popupShown = false; + PopupWindow->hide(); +} diff --git a/frame/item/dockitem.h b/frame/item/dockitem.h index c6d2e9306..7367e0a4f 100644 --- a/frame/item/dockitem.h +++ b/frame/item/dockitem.h @@ -49,6 +49,7 @@ protected: const QRect perfectIconRect() const; const QPoint popupMarkPoint(); + void hidePopup(); void showContextMenu(); void showHoverTips(); void popupWindowAccept();