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