]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/statusbar/dolphinstatusbar.h
Fix 'show space' setting not being re-applied
[dolphin.git] / src / statusbar / dolphinstatusbar.h
index 2c1378372b62df2aa9b2bdc3efa47a2ef3f2bc50..2474732f503a5bdb727cd446cf026df07243c286 100644 (file)
@@ -1,6 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2006 by Peter Penz                                      *
- *   peter.penz@gmx.at                                                     *
+ *   Copyright (C) 2006-2012 by Peter Penz <peter.penz19@gmail.com>        *
  *                                                                         *
  *   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  *
 #ifndef DOLPHINSTATUSBAR_H
 #define DOLPHINSTATUSBAR_H
 
-#include "konq_statusbarmessagelabel.h"
 #include <QTime>
 #include <QWidget>
 
-class DolphinView;
-class KUrl;
+class QUrl;
 class StatusBarSpaceInfo;
 class QLabel;
 class QProgressBar;
 class QToolButton;
 class QSlider;
+class QTimer;
+class KSqueezedTextLabel;
 
 /**
  * @brief Represents the statusbar of a Dolphin view.
  *
- * The statusbar allows to show messages and progress
- * information.
+ * The statusbar allows to show messages, progress
+ * information and space-information of a disk.
  */
 class DolphinStatusBar : public QWidget
 {
     Q_OBJECT
 
 public:
-    /**
-     * Describes the type of the message text. Dependent
-     * from the type a corresponding icon and color is
-     * used for the message text.
-     */
-    enum Type {
-        Default = KonqStatusBarMessageLabel::Default,
-        OperationCompleted = KonqStatusBarMessageLabel::OperationCompleted,
-        Information = KonqStatusBarMessageLabel::Information,
-        Error = KonqStatusBarMessageLabel::Error
-    };
-
-    explicit DolphinStatusBar(QWidget* parent, DolphinView* view);
-
-    virtual ~DolphinStatusBar();
+    explicit DolphinStatusBar(QWidget* parent);
+    ~DolphinStatusBar() override;
 
-    /**
-     * Sets the message text to \a msg. Dependant
-     * from the given type \a type an icon is shown and
-     * the color of the text is adjusted. The height of
-     * the statusbar is automatically adjusted in a way,
-     * that the full text fits into the available width.
-     *
-     * If a progress is ongoing and a message
-     * with the type Type::Error is set, the progress
-     * is cleared automatically.
-     */
-    void setMessage(const QString& msg, Type type);
-    QString message() const;
-
-    Type type() const;
+    QString text() const;
 
     /**
      * Sets the text for the progress information.
@@ -86,34 +58,44 @@ public:
 
     /**
      * Sets the progress in percent (0 - 100). The
-     * progress is shown with a delay of 300 milliseconds:
-     * if the progress does reach 100 % within 300 milliseconds,
-     * the progress is not shown at all. This assures that
-     * no flickering occurs for showing a progress of fast
-     * operations.
+     * progress is shown delayed by 500 milliseconds:
+     * If the progress does reach 100 % within 500 milliseconds,
+     * the progress is not shown at all.
      */
     void setProgress(int percent);
     int progress() const;
 
     /**
-     * Clears the message text of the status bar by replacing
-     * the message with the default text, which can be set
-     * by DolphinStatusBar::setDefaultText(). The progress
-     * information is not cleared.
+     * Replaces the text set by setText() by the text that
+     * has been set by setDefaultText(). DolphinStatusBar::text()
+     * will return an empty string after the reset has been done.
      */
-    void clear();
+    void resetToDefaultText();
 
     /**
      * Sets the default text, which is shown if the status bar
-     * is cleared by DolphinStatusBar::clear().
+     * is rest by DolphinStatusBar::resetToDefaultText().
      */
     void setDefaultText(const QString& text);
     QString defaultText() const;
 
+    QUrl url() const;
+    int zoomLevel() const;
+
     /**
      * Refreshes the status bar to get synchronized with the (updated) Dolphin settings.
      */
-    void refresh();
+    void readSettings();
+
+    /**
+     * Refreshes the disk space information.
+     */
+    void updateSpaceInfo();
+
+public slots:
+    void setText(const QString& text);
+    void setUrl(const QUrl& url);
+    void setZoomLevel(int zoomLevel);
 
 signals:
     /**
@@ -121,30 +103,28 @@ signals:
      */
     void stopPressed();
 
+    void zoomLevelChanged(int zoomLevel);
+
 protected:
-    /** @see QWidget::contextMenuEvent() */
-    virtual void contextMenuEvent(QContextMenuEvent* event);
+    void contextMenuEvent(QContextMenuEvent* event) override;
 
 private slots:
+    void showZoomSliderToolTip(int zoomLevel);
+    void updateProgressInfo();
+
     /**
-     * Is invoked, when the URL of the DolphinView, where the
-     * statusbar belongs too, has been changed. The space information
-     * content is updated.
+     * Updates the text for m_label and does an eliding in
+     * case if the text does not fit into the available width.
      */
-    void updateSpaceInfoContent(const KUrl& url);
+    void updateLabelText();
 
     /**
-     * Sets the zoom level of the item view to \a zoomLevel.
+     * Updates the text of the zoom slider tooltip to show
+     * the currently used size.
      */
-    void setZoomLevel(int zoomLevel);
-
-    void zoomOut();
-    void zoomIn();
-    void showZoomSliderToolTip(int zoomLevel);
+    void updateZoomSliderToolTip(int zoomLevel);
 
 private:
-    void updateProgressInfo();
-
     /**
      * Makes the space information widget and zoom slider widget
      * visible, if \a visible is true and the settings allow to show
@@ -153,31 +133,22 @@ private:
      */
     void setExtensionsVisible(bool visible);
 
-    /**
-     * Updates the text of the zoom slider tooltip to show
-     * the currently used size.
-     */
-    void updateZoomSliderToolTip(int zoomLevel);
-
 private:
-    DolphinView* m_view;
-    KonqStatusBarMessageLabel* m_messageLabel;
+    QString m_text;
+    QString m_defaultText;
+    KSqueezedTextLabel* m_label;
     StatusBarSpaceInfo* m_spaceInfo;
 
-    QWidget* m_zoomWidget;
-    QToolButton* m_zoomOut;
     QSlider* m_zoomSlider;
-    QToolButton* m_zoomIn;
 
-    QLabel* m_progressText;
+    QLabel* m_progressTextLabel;
     QProgressBar* m_progressBar;
     QToolButton* m_stopButton;
     int m_progress;
+    QTimer* m_showProgressBarTimer;
 
-    // Timestamp when the last message has been set that has not the type
-    // 'Default'. The timestamp is used to prevent that default messages
-    // hide more important messages after a very short delay.
-    QTime m_messageTimeStamp;
+    QTimer* m_delayUpdateTimer;
+    QTime m_textTimestamp;
 };
 
 #endif