]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinstatusbar.h
Update the FSF address to 51 Franklin Street (hopefully it is the right one)
[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
25 //Added by qt3to4:
26 #include <QLabel>
27 #include <khbox.h>
28 class QProgressBar;
29 class QLabel;
30 class QTimer;
31 class StatusBarMessageLabel;
32 class StatusBarSpaceInfo;
33 class DolphinView;
34 class KUrl;
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 KHBox {
43 Q_OBJECT
44
45 public:
46 /**
47 * Describes the type of the message text. Dependent
48 * from the type a corresponding icon and color is
49 * used for the message text.
50 */
51 enum Type {
52 Default,
53 OperationCompleted,
54 Information,
55 Error
56 };
57
58 DolphinStatusBar(DolphinView* parent = 0);
59 virtual ~DolphinStatusBar();
60
61 /**
62 * Sets the message text to \a msg. Dependant
63 * from the given type \a type an icon is shown and
64 * the color of the text is adjusted. The height of
65 * the statusbar is automatically adjusted in a way,
66 * that the full text fits into the available width.
67 *
68 * If a progress is ongoing and a message
69 * with the type Type::Error is set, the progress
70 * is cleared automatically.
71 */
72 void setMessage(const QString& msg, Type type);
73
74 QString message() const;
75 Type type() const;
76
77 /**
78 * Sets the text for the progress information.
79 * The text is shown with a delay of 300 milliseconds:
80 * if the progress set by DolphinStatusBar::setProgress()
81 * does reach 100 % within 300 milliseconds,
82 * the progress text is not shown at all. This assures that
83 * no flickering occurs for showing a progress of fast
84 * operations.
85 */
86 void setProgressText(const QString& text);
87 QString progressText() const;
88
89 /**
90 * Sets the progress in percent (0 - 100). The
91 * progress is shown with a delay of 300 milliseconds:
92 * if the progress does reach 100 % within 300 milliseconds,
93 * the progress is not shown at all. This assures that
94 * no flickering occurs for showing a progress of fast
95 * operations.
96 */
97 void setProgress(int percent);
98 int progress() const { return m_progress; }
99
100 /**
101 * Clears the message text of the status bar by replacing
102 * the message with the default text, which can be set
103 * by DolphinStatusBar::setDefaultText(). The progress
104 * information is not cleared.
105 */
106 void clear();
107
108 /**
109 * Sets the default text, which is shown if the status bar
110 * is cleared by DolphinStatusBar::clear().
111 */
112 void setDefaultText(const QString& text);
113 const QString& defaultText() const { return m_defaultText; }
114
115 private slots:
116 void slotProgressTimer();
117
118 /**
119 * Is invoked, when the Url of the DolphinView, where the
120 * statusbar belongs too, has been changed.
121 */
122 void slotUrlChanged(const KUrl& url);
123
124 private:
125 StatusBarMessageLabel* m_messageLabel;
126 StatusBarSpaceInfo* m_spaceInfo;
127 QLabel* m_progressText;
128 QProgressBar* m_progressBar;
129 QTimer* m_progressTimer;
130 int m_progress;
131 QString m_defaultText;
132 };
133
134 #endif