Warning, file /system/dolphin/src/statusbar/dolphinstatusbar.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  * SPDX-FileCopyrightText: 2006-2012 Peter Penz <peter.penz19@gmail.com>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef DOLPHINSTATUSBAR_H
0008 #define DOLPHINSTATUSBAR_H
0009 
0010 #include <QTime>
0011 #include <QWidget>
0012 
0013 class QUrl;
0014 class StatusBarSpaceInfo;
0015 class QLabel;
0016 class QProgressBar;
0017 class QToolButton;
0018 class QSlider;
0019 class QTimer;
0020 class KSqueezedTextLabel;
0021 
0022 /**
0023  * @brief Represents the statusbar of a Dolphin view.
0024  *
0025  * The statusbar allows to show messages, progress
0026  * information and space-information of a disk.
0027  */
0028 class DolphinStatusBar : public QWidget
0029 {
0030     Q_OBJECT
0031 
0032 public:
0033     explicit DolphinStatusBar(QWidget *parent);
0034     ~DolphinStatusBar() override;
0035 
0036     QString text() const;
0037 
0038     /**
0039      * Sets the text for the progress information.
0040      * DolphinStatusBar::setProgress() should be invoked
0041      * afterwards each time the progress changes.
0042      */
0043     void setProgressText(const QString &text);
0044     QString progressText() const;
0045 
0046     /**
0047      * Sets the progress in percent (0 - 100). The
0048      * progress is shown delayed by 500 milliseconds:
0049      * If the progress does reach 100 % within 500 milliseconds,
0050      * the progress is not shown at all.
0051      */
0052     void setProgress(int percent);
0053     int progress() const;
0054 
0055     /**
0056      * Replaces the text set by setText() by the text that
0057      * has been set by setDefaultText(). DolphinStatusBar::text()
0058      * will return an empty string after the reset has been done.
0059      */
0060     void resetToDefaultText();
0061 
0062     /**
0063      * Sets the default text, which is shown if the status bar
0064      * is rest by DolphinStatusBar::resetToDefaultText().
0065      */
0066     void setDefaultText(const QString &text);
0067     QString defaultText() const;
0068 
0069     QUrl url() const;
0070     int zoomLevel() const;
0071 
0072     /**
0073      * Refreshes the status bar to get synchronized with the (updated) Dolphin settings.
0074      */
0075     void readSettings();
0076 
0077     /**
0078      * Refreshes the disk space information.
0079      */
0080     void updateSpaceInfo();
0081 
0082 public Q_SLOTS:
0083     void setText(const QString &text);
0084     void setUrl(const QUrl &url);
0085     void setZoomLevel(int zoomLevel);
0086 
0087 Q_SIGNALS:
0088     /**
0089      * Is emitted if the stop-button has been pressed during showing a progress.
0090      */
0091     void stopPressed();
0092 
0093     void zoomLevelChanged(int zoomLevel);
0094 
0095 protected:
0096     void contextMenuEvent(QContextMenuEvent *event) override;
0097     void paintEvent(QPaintEvent *paintEvent) override;
0098 
0099 private Q_SLOTS:
0100     void showZoomSliderToolTip(int zoomLevel);
0101     void updateProgressInfo();
0102 
0103     /**
0104      * Updates the text for m_label and does an eliding in
0105      * case if the text does not fit into the available width.
0106      */
0107     void updateLabelText();
0108 
0109     /**
0110      * Updates the text of the zoom slider tooltip to show
0111      * the currently used size.
0112      */
0113     void updateZoomSliderToolTip(int zoomLevel);
0114 
0115 private:
0116     /**
0117      * Makes the space information widget and zoom slider widget
0118      * visible, if \a visible is true and the settings allow to show
0119      * the widgets. showUnknownProgressIf \a visible is false, it is assured that both
0120      * widgets are hidden.
0121      */
0122     void setExtensionsVisible(bool visible);
0123 
0124     void updateContentsMargins();
0125 
0126 private:
0127     QString m_text;
0128     QString m_defaultText;
0129     KSqueezedTextLabel *m_label;
0130     QLabel *m_zoomLabel;
0131     StatusBarSpaceInfo *m_spaceInfo;
0132 
0133     QSlider *m_zoomSlider;
0134 
0135     QLabel *m_progressTextLabel;
0136     QProgressBar *m_progressBar;
0137     QToolButton *m_stopButton;
0138     int m_progress;
0139     QTimer *m_showProgressBarTimer;
0140 
0141     QTimer *m_delayUpdateTimer;
0142     QTime m_textTimestamp;
0143 };
0144 
0145 #endif