]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/selectiontoggle.h
- Fix crash found while investigating https://bugs.kde.org/show_bug.cgi?id=170927
[dolphin.git] / src / selectiontoggle.h
index 5815c5dae598a3026197d18e875e70f85433115a..e8f808562b15dde3b888082b6249d6acaa44dae3 100644 (file)
 #ifndef SELECTIONTOGGLE_H
 #define SELECTIONTOGGLE_H
 
+#include <kurl.h>
+
 #include <QAbstractButton>
 #include <QPixmap>
-#include <QTimer>
+
+class QTimeLine;
 
 /**
  * @brief Toggle button for changing the selection of an hovered item.
+ *
+ * The toggle button is visually invisible until it is displayed at least
+ * for one second.
+ *
  * @see SelectionManager
  */
 class SelectionToggle : public QAbstractButton
@@ -37,6 +44,15 @@ public:
     virtual ~SelectionToggle();
     virtual QSize sizeHint() const;
 
+    /**
+     * Resets the selection toggle so that it is hidden and stays
+     * visually invisible for at least one second after it is shown again.
+     */
+    void reset();
+
+    void setUrl(const KUrl& url);
+    KUrl url() const;
+
 public slots:
     virtual void setVisible(bool visible);
 
@@ -47,13 +63,25 @@ protected:
     virtual void paintEvent(QPaintEvent* event);
 
 private slots:
-    void showIcon();
+    /**
+     * Sets the alpha value for the fading animation and is
+     * connected with m_fadingTimeLine.
+     */
+    void setFadingValue(int value);
+
+    void setIconOverlay(bool checked);
+    void refreshIcon();
+
+private:
+    void startFading();
+    void stopFading();
 
 private:
-    bool m_showIcon;
     bool m_isHovered;
+    int m_fadingValue;
     QPixmap m_icon;
-    QTimer* m_timer;
+    QTimeLine* m_fadingTimeLine;
+    KUrl m_url;
 };
 
 #endif