mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-24 04:36:34 +01:00
NavigationBarToolButton: Prevent down state flickering when showing popup
This commit is contained in:
parent
516bd92089
commit
80eb072bb1
@ -19,6 +19,7 @@
|
||||
#include "abstractbuttoninterface.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QMouseEvent>
|
||||
#include <QApplication>
|
||||
|
||||
NavigationBarToolButton::NavigationBarToolButton(AbstractButtonInterface *button, QWidget *parent)
|
||||
@ -45,7 +46,6 @@ NavigationBarToolButton::NavigationBarToolButton(AbstractButtonInterface *button
|
||||
connect(button, &AbstractButtonInterface::toolTipChanged, this, &NavigationBarToolButton::setToolTip);
|
||||
connect(button, &AbstractButtonInterface::badgeTextChanged, this, &NavigationBarToolButton::updateBadge);
|
||||
connect(button, &AbstractButtonInterface::visibleChanged, this, &NavigationBarToolButton::visibilityChangeRequested);
|
||||
connect(this, &ToolButton::clicked, this, &NavigationBarToolButton::clicked);
|
||||
}
|
||||
|
||||
void NavigationBarToolButton::updateVisibility()
|
||||
@ -97,3 +97,26 @@ void NavigationBarToolButton::updateBadge()
|
||||
m_badgeLabel->show();
|
||||
}
|
||||
}
|
||||
|
||||
void NavigationBarToolButton::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
// Prevent flickering due to mouse release event restoring Down state
|
||||
|
||||
bool popupOpened = false;
|
||||
|
||||
if (e->button() == Qt::LeftButton && rect().contains(e->pos())) {
|
||||
clicked();
|
||||
popupOpened = isDown();
|
||||
}
|
||||
|
||||
if (popupOpened) {
|
||||
setUpdatesEnabled(false);
|
||||
}
|
||||
|
||||
ToolButton::mouseReleaseEvent(e);
|
||||
|
||||
if (popupOpened) {
|
||||
setDown(true);
|
||||
setUpdatesEnabled(true);
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ private:
|
||||
void updateIcon();
|
||||
void updateBadge();
|
||||
|
||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||
|
||||
AbstractButtonInterface *m_button;
|
||||
QLabel *m_badgeLabel = nullptr;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user