]> cloud.milkyroute.net Git - dolphin.git/blob - src/statusbar/dolphinstatusbar.h
SVN_SILENT: Coding style updates
[dolphin.git] / src / statusbar / dolphinstatusbar.h
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz *
3 * peter.penz@gmx.at *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #ifndef DOLPHINSTATUSBAR_H
22 #define DOLPHINSTATUSBAR_H
23
24 #include "konq_statusbarmessagelabel.h"
25 #include <QTime>
26 #include <QWidget>
27
28 class DolphinView;
29 class KUrl;
30 class StatusBarSpaceInfo;
31 class QLabel;
32 class QProgressBar;
33 class QToolButton;
34 class QSlider;
35 class QTimer;
36
37 /**
38 * @brief Represents the statusbar of a Dolphin view.
39 *
40 * The statusbar allows to show messages and progress
41 * information.
42 */
43 class DolphinStatusBar : public QWidget
44 {
45 Q_OBJECT
46
47 public:
48 /**
49 * Describes the type of the message text. Dependent
50 * from the type a corresponding icon and color is
51 * used for the message text.
52 */
53 enum Type {
54 Default = KonqStatusBarMessageLabel::Default,
55 OperationCompleted = KonqStatusBarMessageLabel::OperationCompleted,
56 Information = KonqStatusBarMessageLabel::Information,
57 Error = KonqStatusBarMessageLabel::Error
58 };
59
60 DolphinStatusBar(QWidget* parent, DolphinView* view);
61
62 virtual ~DolphinStatusBar();
63
64 /**
65 * Sets the message text to \a msg. Dependant
66 * from the given type \a type an icon is shown and
67 * the color of the text is adjusted. The height of
68 * the statusbar is automatically adjusted in a way,
69 * that the full text fits into the available width.
70 *
71 * If a progress is ongoing and a message
72 * with the type Type::Error is set, the progress
73 * is cleared automatically.
74 */
75 void setMessage(const QString& msg, Type type);
76 QString message() const;
77
78 Type type() const;
79
80 /**
81 * Sets the text for the progress information.
82 * DolphinStatusBar::setProgress() should be invoked
83 * afterwards each time the progress changes.
84 */
85 void setProgressText(const QString& text);
86 QString progressText() const;
87
88 /**
89 * Sets the progress in percent (0 - 100). The
90 * progress is shown delayed by 1 second:
91 * If the progress does reach 100 % within 1 second,
92 * the progress is not shown at all.
93 */
94 void setProgress(int percent);
95 int progress() const;
96
97 /**
98 * Clears the message text of the status bar by replacing
99 * the message with the default text, which can be set
100 * by DolphinStatusBar::setDefaultText(). The progress
101 * information is not cleared.
102 */
103 void clear();
104
105 /**
106 * Sets the default text, which is shown if the status bar
107 * is cleared by DolphinStatusBar::clear().
108 */
109 void setDefaultText(const QString& text);
110 QString defaultText() const;
111
112 /**
113 * Refreshes the status bar to get synchronized with the (updated) Dolphin settings.
114 */
115 void refresh();
116
117 signals:
118 /**
119 * Is emitted if the stop-button has been pressed during showing a progress.
120 */
121 void stopPressed();
122
123 protected:
124 /** @see QWidget::contextMenuEvent() */
125 virtual void contextMenuEvent(QContextMenuEvent* event);
126
127 private slots:
128 /**
129 * Is invoked, when the URL of the DolphinView, where the
130 * statusbar belongs too, has been changed. The space information
131 * content is updated.
132 */
133 void updateSpaceInfoContent(const KUrl& url);
134
135 /**
136 * Sets the zoom level of the item view to \a zoomLevel.
137 */
138 void setZoomLevel(int zoomLevel);
139
140 void zoomOut();
141 void zoomIn();
142 void showZoomSliderToolTip(int zoomLevel);
143
144 void updateProgressInfo();
145
146 private:
147 /**
148 * Makes the space information widget and zoom slider widget
149 * visible, if \a visible is true and the settings allow to show
150 * the widgets. showUnknownProgressIf \a visible is false, it is assured that both
151 * widgets are hidden.
152 */
153 void setExtensionsVisible(bool visible);
154
155 /**
156 * Updates the text of the zoom slider tooltip to show
157 * the currently used size.
158 */
159 void updateZoomSliderToolTip(int zoomLevel);
160
161 private:
162 DolphinView* m_view;
163 KonqStatusBarMessageLabel* m_messageLabel;
164 StatusBarSpaceInfo* m_spaceInfo;
165
166 QWidget* m_zoomWidget;
167 QToolButton* m_zoomOut;
168 QSlider* m_zoomSlider;
169 QToolButton* m_zoomIn;
170
171 QLabel* m_progressText;
172 QProgressBar* m_progressBar;
173 QToolButton* m_stopButton;
174 int m_progress;
175 QTimer* m_showProgressBarTimer;
176
177 // Timestamp when the last message has been set that has not the type
178 // 'Default'. The timestamp is used to prevent that default messages
179 // hide more important messages after a very short delay.
180 QTime m_messageTimeStamp;
181 };
182
183 #endif