]> cloud.milkyroute.net Git - dolphin.git/blob - src/statusbar/dolphinstatusbar.h
Merge branch 'Applications/18.08'
[dolphin.git] / src / statusbar / dolphinstatusbar.h
1 /***************************************************************************
2 * Copyright (C) 2006-2012 by Peter Penz <peter.penz19@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef DOLPHINSTATUSBAR_H
21 #define DOLPHINSTATUSBAR_H
22
23 #include <QTime>
24 #include <QWidget>
25
26 class QUrl;
27 class StatusBarSpaceInfo;
28 class QLabel;
29 class QProgressBar;
30 class QToolButton;
31 class QSlider;
32 class QTimer;
33 class KSqueezedTextLabel;
34
35 /**
36 * @brief Represents the statusbar of a Dolphin view.
37 *
38 * The statusbar allows to show messages, progress
39 * information and space-information of a disk.
40 */
41 class DolphinStatusBar : public QWidget
42 {
43 Q_OBJECT
44
45 public:
46 explicit DolphinStatusBar(QWidget* parent);
47 ~DolphinStatusBar() override;
48
49 QString text() const;
50
51 /**
52 * Sets the text for the progress information.
53 * DolphinStatusBar::setProgress() should be invoked
54 * afterwards each time the progress changes.
55 */
56 void setProgressText(const QString& text);
57 QString progressText() const;
58
59 /**
60 * Sets the progress in percent (0 - 100). The
61 * progress is shown delayed by 500 milliseconds:
62 * If the progress does reach 100 % within 500 milliseconds,
63 * the progress is not shown at all.
64 */
65 void setProgress(int percent);
66 int progress() const;
67
68 /**
69 * Replaces the text set by setText() by the text that
70 * has been set by setDefaultText(). It is assured that the previous
71 * text will be shown for at least 1 second. DolphinStatusBar::text()
72 * will return an empty string after the reset has been done.
73 */
74 void resetToDefaultText();
75
76 /**
77 * Sets the default text, which is shown if the status bar
78 * is rest by DolphinStatusBar::resetToDefaultText().
79 */
80 void setDefaultText(const QString& text);
81 QString defaultText() const;
82
83 QUrl url() const;
84 int zoomLevel() const;
85
86 /**
87 * Refreshes the status bar to get synchronized with the (updated) Dolphin settings.
88 */
89 void readSettings();
90
91 /**
92 * Refreshes the disk space information.
93 */
94 void updateSpaceInfo();
95
96 public slots:
97 void setText(const QString& text);
98 void setUrl(const QUrl& url);
99 void setZoomLevel(int zoomLevel);
100
101 signals:
102 /**
103 * Is emitted if the stop-button has been pressed during showing a progress.
104 */
105 void stopPressed();
106
107 void zoomLevelChanged(int zoomLevel);
108
109 protected:
110 void contextMenuEvent(QContextMenuEvent* event) override;
111
112 private slots:
113 void showZoomSliderToolTip(int zoomLevel);
114 void updateProgressInfo();
115
116 /**
117 * Updates the text for m_label and does an eliding in
118 * case if the text does not fit into the available width.
119 */
120 void updateLabelText();
121
122 /**
123 * Is invoked by m_resetToDefaultTextTimer and clears
124 * m_text so that the default text will be shown. This
125 * prevents that information-messages will be cleared
126 * too fast.
127 */
128 void slotResetToDefaultText();
129
130 /**
131 * Updates the text of the zoom slider tooltip to show
132 * the currently used size.
133 */
134 void updateZoomSliderToolTip(int zoomLevel);
135
136 private:
137 /**
138 * Makes the space information widget and zoom slider widget
139 * visible, if \a visible is true and the settings allow to show
140 * the widgets. showUnknownProgressIf \a visible is false, it is assured that both
141 * widgets are hidden.
142 */
143 void setExtensionsVisible(bool visible);
144
145 private:
146 QString m_text;
147 QString m_defaultText;
148 KSqueezedTextLabel* m_label;
149 StatusBarSpaceInfo* m_spaceInfo;
150
151 QSlider* m_zoomSlider;
152
153 QLabel* m_progressTextLabel;
154 QProgressBar* m_progressBar;
155 QToolButton* m_stopButton;
156 int m_progress;
157 QTimer* m_showProgressBarTimer;
158
159 QTimer* m_resetToDefaultTextTimer;
160 QTime m_textTimestamp;
161 };
162
163 #endif