]> cloud.milkyroute.net Git - dolphin.git/blob - src/statusbarmessagelabel.h
commited initial version of Dolphin
[dolphin.git] / src / statusbarmessagelabel.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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21 #ifndef STATUSBARMESSAGELABEL_H
22 #define STATUSBARMESSAGELABEL_H
23
24 #include <qwidget.h>
25 #include <qpixmap.h>
26 #include <qstring.h>
27 //Added by qt3to4:
28 #include <QPaintEvent>
29 #include <QResizeEvent>
30 #include <dolphinstatusbar.h>
31 class QTimer;
32
33 /**
34 * @brief Represents a message text label as part of the status bar.
35 *
36 * Dependant from the given type automatically a corresponding icon
37 * is shown in front of the text. For message texts having the type
38 * DolphinStatusBar::Error a dynamic color blending is done to get the
39 * attention from the user.
40 *
41 * @author Peter Penz
42 */
43 class StatusBarMessageLabel : public QWidget
44 {
45 Q_OBJECT
46
47 public:
48 StatusBarMessageLabel(QWidget* parent);
49 virtual ~StatusBarMessageLabel();
50
51 void setType(DolphinStatusBar::Type type);
52 DolphinStatusBar::Type type() const { return m_type; }
53
54 void setText(const QString& text);
55 const QString& text() const { return m_text; }
56
57 // TODO: maybe a better approach is possible with the size hint
58 void setMinimumTextHeight(int min);
59 int minimumTextHeight() const { return m_minTextHeight; }
60
61 protected:
62 /** @see QWidget::paintEvent */
63 virtual void paintEvent(QPaintEvent* event);
64
65 /** @see QWidget::resizeEvent */
66 virtual void resizeEvent(QResizeEvent* event);
67
68 private slots:
69 void timerDone();
70 void assureVisibleText();
71
72 private:
73 enum State {
74 Default,
75 Illuminate,
76 Illuminated,
77 Desaturate
78 };
79
80 DolphinStatusBar::Type m_type;
81 State m_state;
82 int m_illumination;
83 int m_minTextHeight;
84 QTimer* m_timer;
85 QString m_text;
86 QPixmap m_pixmap;
87
88 QColor mixColors(const QColor& c1,
89 const QColor& c2,
90 int percent) const;
91
92 int pixmapGap() const { return 3; }
93 };
94
95 #endif