]> cloud.milkyroute.net Git - dolphin.git/blob - src/statusbar/dolphinstatusbar.h
The &-shortcut from another action is not set until the action has been shown at...
[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
36 /**
37 * @brief Represents the statusbar of a Dolphin view.
38 *
39 * The statusbar allows to show messages and progress
40 * information.
41 */
42 class DolphinStatusBar : public QWidget
43 {
44 Q_OBJECT
45
46 public:
47 /**
48 * Describes the type of the message text. Dependent
49 * from the type a corresponding icon and color is
50 * used for the message text.
51 */
52 enum Type {
53 Default = KonqStatusBarMessageLabel::Default,
54 OperationCompleted = KonqStatusBarMessageLabel::OperationCompleted,
55 Information = KonqStatusBarMessageLabel::Information,
56 Error = KonqStatusBarMessageLabel::Error
57 };
58
59 explicit DolphinStatusBar(QWidget* parent, DolphinView* view);
60
61 virtual ~DolphinStatusBar();
62
63 /**
64 * Sets the message text to \a msg. Dependant
65 * from the given type \a type an icon is shown and
66 * the color of the text is adjusted. The height of
67 * the statusbar is automatically adjusted in a way,
68 * that the full text fits into the available width.
69 *
70 * If a progress is ongoing and a message
71 * with the type Type::Error is set, the progress
72 * is cleared automatically.
73 */
74 void setMessage(const QString& msg, Type type);
75 QString message() const;
76
77 Type type() const;
78
79 /**
80 * Sets the text for the progress information.
81 * DolphinStatusBar::setProgress() should be invoked
82 * afterwards each time the progress changes.
83 */
84 void setProgressText(const QString& text);
85 QString progressText() const;
86
87 /**
88 * Sets the progress in percent (0 - 100). The
89 * progress is shown with a delay of 300 milliseconds:
90 * if the progress does reach 100 % within 300 milliseconds,
91 * the progress is not shown at all. This assures that
92 * no flickering occurs for showing a progress of fast
93 * operations.
94 */
95 void setProgress(int percent);
96 int progress() const;
97
98 /**
99 * Clears the message text of the status bar by replacing
100 * the message with the default text, which can be set
101 * by DolphinStatusBar::setDefaultText(). The progress
102 * information is not cleared.
103 */
104 void clear();
105
106 /**
107 * Sets the default text, which is shown if the status bar
108 * is cleared by DolphinStatusBar::clear().
109 */
110 void setDefaultText(const QString& text);
111 QString defaultText() const;
112
113 /**
114 * Refreshes the status bar to get synchronized with the (updated) Dolphin settings.
115 */
116 void refresh();
117
118 protected:
119 /** @see QWidget::contextMenuEvent() */
120 virtual void contextMenuEvent(QContextMenuEvent* event);
121
122 private slots:
123 /**
124 * Is invoked, when the URL of the DolphinView, where the
125 * statusbar belongs too, has been changed. The space information
126 * content is updated.
127 */
128 void updateSpaceInfoContent(const KUrl& url);
129
130 /**
131 * Sets the zoom level of the item view to \a zoomLevel.
132 */
133 void setZoomLevel(int zoomLevel);
134
135 void zoomOut();
136 void zoomIn();
137 void showZoomSliderToolTip(int zoomLevel);
138
139 private:
140 void updateProgressInfo();
141
142 /**
143 * Makes the space information widget and zoom slider widget
144 * visible, if \a visible is true and the settings allow to show
145 * the widgets. showUnknownProgressIf \a visible is false, it is assured that both
146 * widgets are hidden.
147 */
148 void setExtensionsVisible(bool visible);
149
150 /**
151 * Updates the text of the zoom slider tooltip to show
152 * the currently used size.
153 */
154 void updateZoomSliderToolTip(int zoomLevel);
155
156 private:
157 DolphinView* m_view;
158 KonqStatusBarMessageLabel* m_messageLabel;
159 StatusBarSpaceInfo* m_spaceInfo;
160
161 QWidget* m_zoomWidget;
162 QToolButton* m_zoomOut;
163 QSlider* m_zoomSlider;
164 QToolButton* m_zoomIn;
165
166 QLabel* m_progressText;
167 QProgressBar* m_progressBar;
168 int m_progress;
169
170 // Timestamp when the last message has been set that has not the type
171 // 'Default'. The timestamp is used to prevent that default messages
172 // hide more important messages after a very short delay.
173 QTime m_messageTimeStamp;
174 };
175
176 #endif