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