#include <kiconeffect.h>
#include <klocale.h>
+#include <QApplication>
#include <QPainter>
#include <QPaintEvent>
#include <QRect>
#include <QTimer>
#include <QTimeLine>
+#include <kdebug.h>
+
SelectionToggle::SelectionToggle(QWidget* parent) :
QAbstractButton(parent),
m_isHovered(false),
bool SelectionToggle::eventFilter(QObject* obj, QEvent* event)
{
- if (obj == parent()) {
- switch (event->type()) {
- case QEvent::Leave:
- hide();
- break;
-
- case QEvent::MouseMove:
- if (m_leftMouseButtonPressed) {
- // Don't forward mouse move events to the viewport,
- // otherwise a rubberband selection will be shown when
- // clicking on the selection toggle and moving the mouse
- // above the viewport.
- return true;
- }
- break;
-
- default:
- break;
- }
+ if ((obj == parent()) && (event->type() == QEvent::MouseMove) && m_leftMouseButtonPressed) {
+ // Don't forward mouse move events to the viewport,
+ // otherwise a rubberband selection will be shown when
+ // clicking on the selection toggle and moving the mouse
+ // above the viewport.
+ return true;
}
return QAbstractButton::eventFilter(obj, event);
void SelectionToggle::leaveEvent(QEvent* event)
{
QAbstractButton::leaveEvent(event);
+
m_isHovered = false;
update();
}