]> cloud.milkyroute.net Git - dolphin.git/blob - src/statusbar/dolphinstatusbar.h
Adapt to frame change in Breeze
[dolphin.git] / src / statusbar / dolphinstatusbar.h
1 /*
2 * SPDX-FileCopyrightText: 2006-2012 Peter Penz <peter.penz19@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7 #ifndef DOLPHINSTATUSBAR_H
8 #define DOLPHINSTATUSBAR_H
9
10 #include <QTime>
11 #include <QWidget>
12
13 class QUrl;
14 class StatusBarSpaceInfo;
15 class QLabel;
16 class QProgressBar;
17 class QToolButton;
18 class QSlider;
19 class QTimer;
20 class KSqueezedTextLabel;
21
22 /**
23 * @brief Represents the statusbar of a Dolphin view.
24 *
25 * The statusbar allows to show messages, progress
26 * information and space-information of a disk.
27 */
28 class DolphinStatusBar : public QWidget
29 {
30 Q_OBJECT
31
32 public:
33 explicit DolphinStatusBar(QWidget *parent);
34 ~DolphinStatusBar() override;
35
36 QString text() const;
37
38 /**
39 * Sets the text for the progress information.
40 * DolphinStatusBar::setProgress() should be invoked
41 * afterwards each time the progress changes.
42 */
43 void setProgressText(const QString &text);
44 QString progressText() const;
45
46 /**
47 * Sets the progress in percent (0 - 100). The
48 * progress is shown delayed by 500 milliseconds:
49 * If the progress does reach 100 % within 500 milliseconds,
50 * the progress is not shown at all.
51 */
52 void setProgress(int percent);
53 int progress() const;
54
55 /**
56 * Replaces the text set by setText() by the text that
57 * has been set by setDefaultText(). DolphinStatusBar::text()
58 * will return an empty string after the reset has been done.
59 */
60 void resetToDefaultText();
61
62 /**
63 * Sets the default text, which is shown if the status bar
64 * is rest by DolphinStatusBar::resetToDefaultText().
65 */
66 void setDefaultText(const QString &text);
67 QString defaultText() const;
68
69 QUrl url() const;
70 int zoomLevel() const;
71
72 /**
73 * Refreshes the status bar to get synchronized with the (updated) Dolphin settings.
74 */
75 void readSettings();
76
77 /**
78 * Refreshes the disk space information.
79 */
80 void updateSpaceInfo();
81
82 public Q_SLOTS:
83 void setText(const QString &text);
84 void setUrl(const QUrl &url);
85 void setZoomLevel(int zoomLevel);
86
87 Q_SIGNALS:
88 /**
89 * Is emitted if the stop-button has been pressed during showing a progress.
90 */
91 void stopPressed();
92
93 void zoomLevelChanged(int zoomLevel);
94
95 protected:
96 void contextMenuEvent(QContextMenuEvent *event) override;
97 void paintEvent(QPaintEvent *paintEvent) override;
98
99 private Q_SLOTS:
100 void showZoomSliderToolTip(int zoomLevel);
101 void updateProgressInfo();
102
103 /**
104 * Updates the text for m_label and does an eliding in
105 * case if the text does not fit into the available width.
106 */
107 void updateLabelText();
108
109 /**
110 * Updates the text of the zoom slider tooltip to show
111 * the currently used size.
112 */
113 void updateZoomSliderToolTip(int zoomLevel);
114
115 private:
116 /**
117 * Makes the space information widget and zoom slider widget
118 * visible, if \a visible is true and the settings allow to show
119 * the widgets. showUnknownProgressIf \a visible is false, it is assured that both
120 * widgets are hidden.
121 */
122 void setExtensionsVisible(bool visible);
123
124 private:
125 QString m_text;
126 QString m_defaultText;
127 KSqueezedTextLabel *m_label;
128 QLabel *m_zoomLabel;
129 StatusBarSpaceInfo *m_spaceInfo;
130
131 QSlider *m_zoomSlider;
132
133 QLabel *m_progressTextLabel;
134 QProgressBar *m_progressBar;
135 QToolButton *m_stopButton;
136 int m_progress;
137 QTimer *m_showProgressBarTimer;
138
139 QTimer *m_delayUpdateTimer;
140 QTime m_textTimestamp;
141 };
142
143 #endif