]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinstatusbar.h
Minor adjustments and cleanups in the statusbar:
[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 Q_OBJECT
42
43 public:
44 /**
45 * Describes the type of the message text. Dependent
46 * from the type a corresponding icon and color is
47 * used for the message text.
48 */
49 enum Type {
50 Default,
51 OperationCompleted,
52 Information,
53 Error
54 };
55
56 DolphinStatusBar(DolphinView* parent = 0);
57 virtual ~DolphinStatusBar();
58
59 /**
60 * Sets the message text to \a msg. Dependant
61 * from the given type \a type an icon is shown and
62 * the color of the text is adjusted. The height of
63 * the statusbar is automatically adjusted in a way,
64 * that the full text fits into the available width.
65 *
66 * If a progress is ongoing and a message
67 * with the type Type::Error is set, the progress
68 * is cleared automatically.
69 */
70 void setMessage(const QString& msg, Type type);
71 QString message() const;
72
73 Type type() const;
74
75 /**
76 * Sets the text for the progress information.
77 * The text is shown with a delay of 300 milliseconds:
78 * if the progress set by DolphinStatusBar::setProgress()
79 * does reach 100 % within 300 milliseconds,
80 * the progress text is not shown at all. This assures that
81 * no flickering occurs for showing a progress of fast
82 * operations.
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 { return m_progress; }
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 const QString& defaultText() const { return m_defaultText; }
112
113 private slots:
114 void updateProgressInfo();
115
116 /**
117 * Is invoked, when the URL of the DolphinView, where the
118 * statusbar belongs too, has been changed. The space information
119 * is updated.
120 */
121 void updateSpaceInfo(const KUrl& url);
122
123 private:
124 StatusBarMessageLabel* m_messageLabel;
125 StatusBarSpaceInfo* m_spaceInfo;
126
127 QLabel* m_progressText;
128 QProgressBar* m_progressBar;
129 int m_progress;
130
131 QString m_defaultText;
132 };
133
134 #endif