add more spacing
[personal-kdebase.git] / apps / dolphin / src / dolphinstatusbar.h
blobe28c1c4f46121900c2df61fddd84f42bd03a8b52
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 ***************************************************************************/
21 #ifndef DOLPHINSTATUSBAR_H
22 #define DOLPHINSTATUSBAR_H
24 #include <khbox.h>
26 class DolphinView;
27 class KUrl;
28 class StatusBarMessageLabel;
29 class StatusBarSpaceInfo;
30 class QLabel;
31 class QProgressBar;
32 class QToolButton;
33 class QSlider;
34 class QTimer;
36 /**
37 * @brief Represents the statusbar of a Dolphin view.
39 * The statusbar allows to show messages and progress
40 * information.
42 class DolphinStatusBar : public KHBox
44 Q_OBJECT
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.
52 enum Type {
53 Default,
54 OperationCompleted,
55 Information,
56 Error
59 DolphinStatusBar(QWidget* parent, DolphinView* view);
61 virtual ~DolphinStatusBar();
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.
70 * If a progress is ongoing and a message
71 * with the type Type::Error is set, the progress
72 * is cleared automatically.
74 void setMessage(const QString& msg, Type type);
75 QString message() const;
77 Type type() const;
79 /**
80 * Sets the text for the progress information.
81 * The text is shown with a delay of 300 milliseconds:
82 * if the progress set by DolphinStatusBar::setProgress()
83 * does reach 100 % within 300 milliseconds,
84 * the progress text is not shown at all. This assures that
85 * no flickering occurs for showing a progress of fast
86 * operations.
88 void setProgressText(const QString& text);
89 QString progressText() const;
91 /**
92 * Sets the progress in percent (0 - 100). The
93 * progress is shown with a delay of 300 milliseconds:
94 * if the progress does reach 100 % within 300 milliseconds,
95 * the progress is not shown at all. This assures that
96 * no flickering occurs for showing a progress of fast
97 * operations.
99 void setProgress(int percent);
100 int progress() const
102 return m_progress;
106 * Clears the message text of the status bar by replacing
107 * the message with the default text, which can be set
108 * by DolphinStatusBar::setDefaultText(). The progress
109 * information is not cleared.
111 void clear();
114 * Sets the default text, which is shown if the status bar
115 * is cleared by DolphinStatusBar::clear().
117 void setDefaultText(const QString& text);
118 const QString& defaultText() const;
121 * Refreshes the status bar to get synchronized with the (updated) Dolphin settings.
123 void refresh();
125 protected:
126 /** @see QWidget::resizeEvent() */
127 virtual void resizeEvent(QResizeEvent* event);
129 private slots:
130 void updateProgressInfo();
133 * Is invoked, when the URL of the DolphinView, where the
134 * statusbar belongs too, has been changed. The space information
135 * content is updated.
137 void updateSpaceInfoContent(const KUrl& url);
140 * Sets the zoom level of the item view to \a zoomLevel.
142 void setZoomLevel(int zoomLevel);
145 * Assures that the text of the statusbar stays visible by hiding
146 * the space information widget or the zoom slider widget if not
147 * enough width is available.
149 void assureVisibleText();
151 void zoomOut();
152 void zoomIn();
153 void showZoomSliderToolTip(int zoomLevel);
155 private:
157 * Makes the space information widget and zoom slider widget
158 * visible, if \a visible is true and the settings allow to show
159 * the widgets. If \a visible is false, it is assured that both
160 * widgets are hidden.
162 void setExtensionsVisible(bool visible);
165 * Updates the text of the zoom slider tooltip to show
166 * the currently used size.
168 void updateZoomSliderToolTip(int zoomLevel);
170 private:
171 DolphinView* m_view;
172 StatusBarMessageLabel* m_messageLabel;
173 StatusBarSpaceInfo* m_spaceInfo;
175 QWidget* m_zoomWidget;
176 QToolButton* m_zoomOut;
177 QSlider* m_zoomSlider;
178 QToolButton* m_zoomIn;
180 QLabel* m_progressText;
181 QProgressBar* m_progressBar;
182 int m_progress;
185 #endif