]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/statusbar/dolphinstatusbar.h
SVN_SILENT made messages (.desktop file) - always resolve ours
[dolphin.git] / src / statusbar / dolphinstatusbar.h
index 983f5b6dac1d99d5cad80b28cc9dc7c4264ce547..b4ddcd95efb273d754a87b616acf1f7359dbd1bf 100644 (file)
@@ -7,8 +7,11 @@
 #ifndef DOLPHINSTATUSBAR_H
 #define DOLPHINSTATUSBAR_H
 
+#include "animatedheightwidget.h"
+
+#include <KMessageWidget>
+
 #include <QTime>
-#include <QWidget>
 
 class QUrl;
 class StatusBarSpaceInfo;
@@ -18,6 +21,7 @@ class QToolButton;
 class QSlider;
 class QTimer;
 class KSqueezedTextLabel;
+class QHBoxLayout;
 
 /**
  * @brief Represents the statusbar of a Dolphin view.
@@ -25,7 +29,7 @@ class KSqueezedTextLabel;
  * The statusbar allows to show messages, progress
  * information and space-information of a disk.
  */
-class DolphinStatusBar : public QWidget
+class DolphinStatusBar : public AnimatedHeightWidget
 {
     Q_OBJECT
 
@@ -35,21 +39,26 @@ public:
 
     QString text() const;
 
+    enum class CancelLoading {
+        Allowed,
+        Disallowed
+    };
     /**
-     * Sets the text for the progress information.
-     * DolphinStatusBar::setProgress() should be invoked
-     * afterwards each time the progress changes.
+     * Shows progress for a task on the status bar.
+     *
+     * Allows us to inform the user about various tasks progressing in the background.
+     * This method can be called from various places in any order but only the most recent call will be displayed.
+     * @param currentlyRunningTaskTitle The task that is currently progressing.
+     * @param progressPercent           The percent value shown in a progress bar next to the @p currentlyRunningTaskTitle.
+     *                                  A negative @p progressPercent value will be interpreted as indeterminate/unknown progress.
+     *                                  The progress is shown delayed by 500 milliseconds: If the progress does reach 100 % within 500 milliseconds,
+     *                                  the progress is not shown at all.
+     * @param cancelLoading             Whether a "Stop" button for cancelling the task should be available next to the progress reporting.
+     *
+     * @note Make sure you also hide the progress information by calling this with a @p progressPercent equal or greater than 100.
      */
-    void setProgressText(const QString &text);
+    void showProgress(const QString &currentlyRunningTaskTitle, int progressPercent, CancelLoading cancelLoading = CancelLoading::Allowed);
     QString progressText() const;
-
-    /**
-     * Sets the progress in percent (0 - 100). The
-     * 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;
 
     /**
@@ -79,6 +88,22 @@ public:
      */
     void updateSpaceInfo();
 
+    /**
+     * Changes the statusbar between disabled, small, and full width
+     * depending on settings enabled.
+     */
+    void updateMode();
+
+    /**
+     * Updates the statusbar width to fit all content.
+     */
+    void updateWidthToContent();
+
+    /**
+     * @return The amount of clipping done to the small statusbar side and bottom.
+     */
+    int clippingAmount() const;
+
 public Q_SLOTS:
     void setText(const QString &text);
     void setUrl(const QUrl &url);
@@ -92,12 +117,33 @@ Q_SIGNALS:
 
     void zoomLevelChanged(int zoomLevel);
 
+    /**
+     * Requests for @p message with the given @p messageType to be shown to the user in a non-modal way.
+     */
+    void showMessage(const QString &message, KMessageWidget::MessageType messageType);
+
+    /**
+     * Emitted when statusbar mode is changed.
+     */
+    void modeUpdated();
+
+    /**
+     * Emitted when statusbar width is updated to fit content.
+     */
+    void widthUpdated();
+
+    /**
+     * Emitted when statusbar url has changed.
+     */
+    void urlChanged();
+
 protected:
     void contextMenuEvent(QContextMenuEvent *event) override;
     void paintEvent(QPaintEvent *paintEvent) override;
 
 private Q_SLOTS:
     void showZoomSliderToolTip(int zoomLevel);
+
     void updateProgressInfo();
 
     /**
@@ -121,6 +167,11 @@ private:
      */
     void setExtensionsVisible(bool visible);
 
+    void updateContentsMargins();
+
+    /** @see AnimatedHeightWidget::preferredHeight() */
+    int preferredHeight() const override;
+
 private:
     QString m_text;
     QString m_defaultText;
@@ -131,6 +182,7 @@ private:
     QSlider *m_zoomSlider;
 
     QLabel *m_progressTextLabel;
+    CancelLoading m_cancelLoading = CancelLoading::Allowed;
     QProgressBar *m_progressBar;
     QToolButton *m_stopButton;
     int m_progress;
@@ -138,6 +190,8 @@ private:
 
     QTimer *m_delayUpdateTimer;
     QTime m_textTimestamp;
+
+    QHBoxLayout *m_topLayout;
 };
 
 #endif