]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/statusbar/dolphinstatusbar.h
Avoid wrapping text in the status bar
[dolphin.git] / src / statusbar / dolphinstatusbar.h
index 0b0004e47e1676bd61129493763b66599f60343b..75a2cdc6f0c3020520fbbea2ec6f0388f3284e05 100644 (file)
@@ -1,27 +1,15 @@
-/***************************************************************************
- *   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  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2006-2012 Peter Penz <peter.penz19@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #ifndef DOLPHINSTATUSBAR_H
 #define DOLPHINSTATUSBAR_H
 
+#include "animatedheightwidget.h"
+
 #include <QTime>
-#include <QWidget>
 
 class QUrl;
 class StatusBarSpaceInfo;
@@ -31,6 +19,7 @@ class QToolButton;
 class QSlider;
 class QTimer;
 class KSqueezedTextLabel;
+class QHBoxLayout;
 
 /**
  * @brief Represents the statusbar of a Dolphin view.
@@ -38,12 +27,12 @@ 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
 
 public:
-    DolphinStatusBar(QWidget* parent);
+    explicit DolphinStatusBar(QWidget *parent);
     ~DolphinStatusBar() override;
 
     QString text() const;
@@ -53,7 +42,7 @@ public:
      * DolphinStatusBar::setProgress() should be invoked
      * afterwards each time the progress changes.
      */
-    void setProgressText(const QStringtext);
+    void setProgressText(const QString &text);
     QString progressText() const;
 
     /**
@@ -67,8 +56,7 @@ public:
 
     /**
      * Replaces the text set by setText() by the text that
-     * has been set by setDefaultText(). It is assured that the previous
-     * text will be shown for at least 1 second. DolphinStatusBar::text()
+     * has been set by setDefaultText(). DolphinStatusBar::text()
      * will return an empty string after the reset has been done.
      */
     void resetToDefaultText();
@@ -77,7 +65,7 @@ public:
      * Sets the default text, which is shown if the status bar
      * is rest by DolphinStatusBar::resetToDefaultText().
      */
-    void setDefaultText(const QStringtext);
+    void setDefaultText(const QString &text);
     QString defaultText() const;
 
     QUrl url() const;
@@ -88,12 +76,17 @@ public:
      */
     void readSettings();
 
-public slots:
-    void setText(const QString& text);
-    void setUrl(const QUrl& url);
+    /**
+     * Refreshes the disk space information.
+     */
+    void updateSpaceInfo();
+
+public Q_SLOTS:
+    void setText(const QString &text);
+    void setUrl(const QUrl &url);
     void setZoomLevel(int zoomLevel);
 
-signals:
+Q_SIGNALS:
     /**
      * Is emitted if the stop-button has been pressed during showing a progress.
      */
@@ -102,9 +95,10 @@ signals:
     void zoomLevelChanged(int zoomLevel);
 
 protected:
-    void contextMenuEvent(QContextMenuEvent* event) override;
+    void contextMenuEvent(QContextMenuEvent *event) override;
+    void paintEvent(QPaintEvent *paintEvent) override;
 
-private slots:
+private Q_SLOTS:
     void showZoomSliderToolTip(int zoomLevel);
     void updateProgressInfo();
 
@@ -114,14 +108,6 @@ private slots:
      */
     void updateLabelText();
 
-    /**
-     * Is invoked by m_resetToDefaultTextTimer and clears
-     * m_text so that the default text will be shown. This
-     * prevents that information-messages will be cleared
-     * too fast.
-     */
-    void slotResetToDefaultText();
-
     /**
      * Updates the text of the zoom slider tooltip to show
      * the currently used size.
@@ -137,22 +123,30 @@ private:
      */
     void setExtensionsVisible(bool visible);
 
+    void updateContentsMargins();
+
+    /** @see AnimatedHeightWidget::preferredHeight() */
+    int preferredHeight() const override;
+
 private:
     QString m_text;
     QString m_defaultText;
-    KSqueezedTextLabel* m_label;
-    StatusBarSpaceInfo* m_spaceInfo;
+    KSqueezedTextLabel *m_label;
+    QLabel *m_zoomLabel;
+    StatusBarSpaceInfo *m_spaceInfo;
 
-    QSliderm_zoomSlider;
+    QSlider *m_zoomSlider;
 
-    QLabelm_progressTextLabel;
-    QProgressBarm_progressBar;
-    QToolButtonm_stopButton;
+    QLabel *m_progressTextLabel;
+    QProgressBar *m_progressBar;
+    QToolButton *m_stopButton;
     int m_progress;
-    QTimerm_showProgressBarTimer;
+    QTimer *m_showProgressBarTimer;
 
-    QTimer* m_resetToDefaultTextTimer;
+    QTimer *m_delayUpdateTimer;
     QTime m_textTimestamp;
+
+    QHBoxLayout *m_topLayout;
 };
 
 #endif