From a284a7c864b2aa1903a5789e728aaece6fdced5d Mon Sep 17 00:00:00 2001 From: nowrep Date: Tue, 25 Mar 2014 16:53:41 +0100 Subject: [PATCH] [SiteIcon] Don't set :pressed state when popup is not shown Popup will not be shown eg. on qupzilla: sites --- src/lib/navigation/siteicon.cpp | 16 +++++++++++----- src/lib/navigation/siteicon.h | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/lib/navigation/siteicon.cpp b/src/lib/navigation/siteicon.cpp index 0e3b74394..e03d76dc5 100644 --- a/src/lib/navigation/siteicon.cpp +++ b/src/lib/navigation/siteicon.cpp @@ -97,11 +97,15 @@ void SiteIcon::mouseReleaseEvent(QMouseEvent* e) // Mouse release event is restoring Down state // So we pause updates to prevent flicker - bool activated = e->button() == Qt::LeftButton && rect().contains(e->pos()); + bool activated = false; + + if (e->button() == Qt::LeftButton && rect().contains(e->pos())) { + // Popup may not be always shown, eg. on qupzilla: pages + activated = showPopup(); + } if (activated) { setUpdatesEnabled(false); - showPopup(); } ToolButton::mouseReleaseEvent(e); @@ -147,16 +151,16 @@ void SiteIcon::mouseMoveEvent(QMouseEvent* e) setDown(false); } -void SiteIcon::showPopup() +bool SiteIcon::showPopup() { if (!m_view || !m_window) { - return; + return false; } QUrl url = m_view->url(); if (url.isEmpty() || url.scheme() == QLatin1String("qupzilla")) { - return; + return false; } setDown(true); @@ -165,4 +169,6 @@ void SiteIcon::showPopup() info->showAt(parentWidget()); connect(info, SIGNAL(destroyed()), this, SLOT(popupClosed())); + + return true; } diff --git a/src/lib/navigation/siteicon.h b/src/lib/navigation/siteicon.h index e2daf3299..6482b4fa9 100644 --- a/src/lib/navigation/siteicon.h +++ b/src/lib/navigation/siteicon.h @@ -47,7 +47,7 @@ private: void mouseReleaseEvent(QMouseEvent* e); void mouseMoveEvent(QMouseEvent* e); - void showPopup(); + bool showPopup(); BrowserWindow* m_window; LocationBar* m_locationBar;