~kubuntu-users/dolphin/hardy-fork

« back to all changes in this revision

Viewing changes to src/statusbarmessagelabel.h

  • Committer: Martin Böhm
  • Date: 2007-12-04 18:15:49 UTC
  • Revision ID: martin.bohm@kubuntu.org-20071204181549-2aqgnxrpbser3xww
Initial branch from 0.9.2

Show diffs side-by-side

added added

removed removed

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