]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinstatusbar.h
Adapt to new konsole api
[dolphin.git] / src / 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 <khbox.h>
25
26 class DolphinView;
27 class KUrl;
28 class StatusBarMessageLabel;
29 class StatusBarSpaceInfo;
30 class QProgressBar;
31 class QLabel;
32 class QTimer;
33
34 /**
35 * @brief Represents the statusbar of a Dolphin view.
36 *
37 * The statusbar allows to show messages and progress
38 * information.
39 */
40 class DolphinStatusBar : public KHBox
41 {
42 Q_OBJECT
43
44 public:
45 /**
46 * Describes the type of the message text. Dependent
47 * from the type a corresponding icon and color is
48 * used for the message text.
49 */
50 enum Type {
51 Default,
52 OperationCompleted,
53 Information,
54 Error
55 };
56
57 DolphinStatusBar(DolphinView* parent = 0);
58 virtual ~DolphinStatusBar();
59
60 /**
61 * Sets the message text to \a msg. Dependant
62 * from the given type \a type an icon is shown and
63 * the color of the text is adjusted. The height of
64 * the statusbar is automatically adjusted in a way,
65 * that the full text fits into the available width.
66 *
67 * If a progress is ongoing and a message
68 * with the type Type::Error is set, the progress
69 * is cleared automatically.
70 */
71 void setMessage(const QString& msg, Type type);
72 QString message() const;
73
74 Type type() const;
75
76 /**
77 * Sets the text for the progress information.
78 * The text is shown with a delay of 300 milliseconds:
79 * if the progress set by DolphinStatusBar::setProgress()
80 * does reach 100 % within 300 milliseconds,
81 * the progress text is not shown at all. This assures that
82 * no flickering occurs for showing a progress of fast
83 * operations.
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 with a delay of 300 milliseconds:
91 * if the progress does reach 100 % within 300 milliseconds,
92 * the progress is not shown at all. This assures that
93 * no flickering occurs for showing a progress of fast
94 * operations.
95 */
96 void setProgress(int percent);
97 int progress() const
98 {
99 return m_progress;
100 }
101
102 /**
103 * Clears the message text of the status bar by replacing
104 * the message with the default text, which can be set
105 * by DolphinStatusBar::setDefaultText(). The progress
106 * information is not cleared.
107 */
108 void clear();
109
110 /**
111 * Sets the default text, which is shown if the status bar
112 * is cleared by DolphinStatusBar::clear().
113 */
114 void setDefaultText(const QString& text);
115 const QString& defaultText() const;
116
117 protected:
118 /** @see QWidget::resizeEvent() */
119 virtual void resizeEvent(QResizeEvent* event);
120
121 private slots:
122 void updateProgressInfo();
123
124 /**
125 * Is invoked, when the URL of the DolphinView, where the
126 * statusbar belongs too, has been changed. The space information
127 * content is updated.
128 */
129 void updateSpaceInfoContent(const KUrl& url);
130
131 /**
132 * Shows the space information if there is enough room to show it
133 * without the need to clip the status bar text. If the progress
134 * bar is shown, the space information won't be shown.
135 */
136 void showSpaceInfo();
137
138 private:
139 StatusBarMessageLabel* m_messageLabel;
140 StatusBarSpaceInfo* m_spaceInfo;
141
142 QLabel* m_progressText;
143 QProgressBar* m_progressBar;
144 int m_progress;
145 };
146
147 #endif