]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/selectiontoggle.cpp
assure that the current index stays visible, when the user explicitly changed it...
[dolphin.git] / src / selectiontoggle.cpp
index fdae03e2b3b80e89292030a2e7f81fa58d9ffa31..b9b79def01af8f2834936e2e85909ccac59d03c7 100644 (file)
 
 #include "selectiontoggle.h"
 
+#include <kglobalsettings.h>
 #include <kicon.h>
 #include <kiconloader.h>
 #include <kiconeffect.h>
+#include <klocale.h>
 
 #include <QPainter>
 #include <QPaintEvent>
@@ -42,6 +44,8 @@ SelectionToggle::SelectionToggle(QWidget* parent) :
     setIconOverlay(isChecked());
     connect(this, SIGNAL(toggled(bool)),
             this, SLOT(setIconOverlay(bool)));
+    connect(KGlobalSettings::self(), SIGNAL(iconChanged(int)),
+            this, SLOT(refreshIcon()));
 }
 
 SelectionToggle::~SelectionToggle()
@@ -102,6 +106,8 @@ void SelectionToggle::enterEvent(QEvent* event)
         m_fadingTimeLine->stop();
     }
     m_fadingValue = 255;
+    setToolTip(isChecked() ? i18nc("@info:tooltip", "Deselect Item") :
+                             i18nc("@info:tooltip", "Select Item"));
     update();
 }
 
@@ -173,11 +179,19 @@ void SelectionToggle::setIconOverlay(bool checked)
     update();
 }
 
+void SelectionToggle::refreshIcon()
+{
+    setIconOverlay(isChecked());
+}
+
 void SelectionToggle::startFading()
 {
     Q_ASSERT(m_fadingTimeLine == 0);
 
-    m_fadingTimeLine = new QTimeLine(1500, this);
+    const bool animate = KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects;
+    const int duration = animate ? 600 : 1;
+
+    m_fadingTimeLine = new QTimeLine(duration, this);
     connect(m_fadingTimeLine, SIGNAL(frameChanged(int)),
             this, SLOT(setFadingValue(int)));
     m_fadingTimeLine->setFrameRange(0, 255);