X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/e2b844437e9308a04ddf043ae9d2f5c8ffef97b0..747a86573feb65e2ffe57cdae7dedf6ad272e789:/src/views/selectiontoggle.cpp diff --git a/src/views/selectiontoggle.cpp b/src/views/selectiontoggle.cpp index 3ab40ebdc..d602600c5 100644 --- a/src/views/selectiontoggle.cpp +++ b/src/views/selectiontoggle.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008 by Peter Penz * + * Copyright (C) 2008 by Peter Penz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -19,11 +19,11 @@ #include "selectiontoggle.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include @@ -32,11 +32,12 @@ #include #include +#include + SelectionToggle::SelectionToggle(QWidget* parent) : QAbstractButton(parent), m_isHovered(false), m_leftMouseButtonPressed(false), - m_appliedArrowCursor(false), m_fadingValue(0), m_margin(0), m_icon(), @@ -106,25 +107,12 @@ void SelectionToggle::setVisible(bool visible) 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); @@ -134,15 +122,10 @@ void SelectionToggle::enterEvent(QEvent* event) { QAbstractButton::enterEvent(event); - if (!m_appliedArrowCursor) { - QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); - m_appliedArrowCursor = true; - } - // if the mouse cursor is above the selection toggle, display // it immediately without fading timer m_isHovered = true; - if (m_fadingTimeLine != 0) { + if (m_fadingTimeLine) { m_fadingTimeLine->stop(); } m_fadingValue = 255; @@ -155,11 +138,6 @@ void SelectionToggle::leaveEvent(QEvent* event) { QAbstractButton::leaveEvent(event); - if (m_appliedArrowCursor) { - QApplication::restoreOverrideCursor(); - m_appliedArrowCursor = false; - } - m_isHovered = false; update(); } @@ -214,7 +192,7 @@ void SelectionToggle::setFadingValue(int value) { m_fadingValue = value; if (m_fadingValue >= 255) { - Q_ASSERT(m_fadingTimeLine != 0); + Q_ASSERT(m_fadingTimeLine); m_fadingTimeLine->stop(); } update(); @@ -237,7 +215,7 @@ void SelectionToggle::refreshIcon() void SelectionToggle::startFading() { - Q_ASSERT(m_fadingTimeLine == 0); + Q_ASSERT(!m_fadingTimeLine); const bool animate = KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects; const int duration = animate ? 600 : 1; @@ -252,7 +230,7 @@ void SelectionToggle::startFading() void SelectionToggle::stopFading() { - if (m_fadingTimeLine != 0) { + if (m_fadingTimeLine) { m_fadingTimeLine->stop(); delete m_fadingTimeLine; m_fadingTimeLine = 0;