]> cloud.milkyroute.net Git - dolphin.git/blob - src/statusbar/dolphinstatusbar.h
Use KMessageWidget for error- and information-messages
[dolphin.git] / src / statusbar / dolphinstatusbar.h
1 /***************************************************************************
2 * Copyright (C) 2006-2012 by Peter Penz <peter.penz19@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef DOLPHINSTATUSBAR_H
21 #define DOLPHINSTATUSBAR_H
22
23 #include <QWidget>
24
25 class KUrl;
26 class StatusBarSpaceInfo;
27 class QLabel;
28 class QProgressBar;
29 class QToolButton;
30 class QSlider;
31 class QTimer;
32
33 /**
34 * @brief Represents the statusbar of a Dolphin view.
35 *
36 * The statusbar allows to show messages, progress
37 * information and space-information of a disk.
38 */
39 class DolphinStatusBar : public QWidget
40 {
41 Q_OBJECT
42
43 public:
44 DolphinStatusBar(QWidget* parent);
45 virtual ~DolphinStatusBar();
46
47 QString text() const;
48
49 /**
50 * Sets the text for the progress information.
51 * DolphinStatusBar::setProgress() should be invoked
52 * afterwards each time the progress changes.
53 */
54 void setProgressText(const QString& text);
55 QString progressText() const;
56
57 /**
58 * Sets the progress in percent (0 - 100). The
59 * progress is shown delayed by 1 second:
60 * If the progress does reach 100 % within 1 second,
61 * the progress is not shown at all.
62 */
63 void setProgress(int percent);
64 int progress() const;
65
66 /**
67 * Replaces the text set by setText() by the text that
68 * has been set by setDefaultText(). DolphinStatusBar::text()
69 * will return an empty string afterwards.
70 */
71 void resetToDefaultText();
72
73 /**
74 * Sets the default text, which is shown if the status bar
75 * is rest by DolphinStatusBar::resetToDefaultText().
76 */
77 void setDefaultText(const QString& text);
78 QString defaultText() const;
79
80 KUrl url() const;
81 int zoomLevel() const;
82
83 /**
84 * Refreshes the status bar to get synchronized with the (updated) Dolphin settings.
85 */
86 void readSettings();
87
88 public slots:
89 void setText(const QString& text);
90 void setUrl(const KUrl& url);
91 void setZoomLevel(int zoomLevel);
92
93 signals:
94 /**
95 * Is emitted if the stop-button has been pressed during showing a progress.
96 */
97 void stopPressed();
98
99 void zoomLevelChanged(int zoomLevel);
100
101 protected:
102 virtual void contextMenuEvent(QContextMenuEvent* event);
103 virtual bool eventFilter(QObject* obj, QEvent* event);
104
105 private slots:
106 void showZoomSliderToolTip(int zoomLevel);
107 void updateProgressInfo();
108
109 /**
110 * Updates the text for m_label and does an eliding in
111 * case if the text does not fit into the available width.
112 */
113 void updateLabelText();
114
115 private:
116 /**
117 * Makes the space information widget and zoom slider widget
118 * visible, if \a visible is true and the settings allow to show
119 * the widgets. showUnknownProgressIf \a visible is false, it is assured that both
120 * widgets are hidden.
121 */
122 void setExtensionsVisible(bool visible);
123
124 /**
125 * Updates the text of the zoom slider tooltip to show
126 * the currently used size.
127 */
128 void updateZoomSliderToolTip(int zoomLevel);
129
130 void applyFixedWidgetSize(QWidget* widget, const QSize& size);
131
132 private:
133 QString m_text;
134 QString m_defaultText;
135 QLabel* m_label;
136 StatusBarSpaceInfo* m_spaceInfo;
137
138 QSlider* m_zoomSlider;
139
140 QLabel* m_progressTextLabel;
141 QProgressBar* m_progressBar;
142 QToolButton* m_stopButton;
143 int m_progress;
144 QTimer* m_showProgressBarTimer;
145 };
146
147 #endif