~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kdm/kfrontend/themer/kdmpixmap.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (C) 2003 by Unai Garro <ugarro@users.sourceforge.net>
 
3
 *  Copyright (C) 2004 by Enrico Ros <rosenric@dei.unipd.it>
 
4
 *  Copyright (C) 2004 by Stephan Kulow <coolo@kde.org>
 
5
 *  Copyright (C) 2004 by Oswald Buddenhagen <ossi@kde.org>
 
6
 *
 
7
 *  This program is free software; you can redistribute it and/or modify
 
8
 *  it under the terms of the GNU General Public License as published by
 
9
 *  the Free Software Foundation; either version 2 of the License, or
 
10
 *  (at your option) any later version.
 
11
 *
 
12
 *  This program is distributed in the hope that it will be useful,
 
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 *  GNU General Public License for more details.
 
16
 *
 
17
 *  You should have received a copy of the GNU General Public License
 
18
 *  along with this program; if not, write to the Free Software
 
19
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
20
 */
 
21
 
 
22
#ifndef KDMPIXMAP_H
 
23
#define KDMPIXMAP_H
 
24
 
 
25
#include "kdmitem.h"
 
26
 
 
27
#include <QImage>
 
28
#include <QPixmap>
 
29
 
 
30
class QSignalMapper;
 
31
class QSvgRenderer;
 
32
 
 
33
/*
 
34
 * KdmPixmap. A pixmap element
 
35
 */
 
36
 
 
37
class KdmPixmap : public KdmItem {
 
38
    Q_OBJECT
 
39
 
 
40
public:
 
41
    KdmPixmap(QObject *parent, const QDomNode &node);
 
42
 
 
43
protected:
 
44
    // reimplemented; returns the size of loaded pixmap
 
45
    virtual QSize sizeHint();
 
46
 
 
47
    // draw the pixmap
 
48
    virtual void drawContents(QPainter *p, const QRect &r);
 
49
 
 
50
    // handle switching between normal / active / prelight configurations
 
51
    virtual void statusChanged(bool descend);
 
52
 
 
53
    virtual void setGeometry(QStack<QSize> &parentSizes, const QRect &newGeometry, bool force);
 
54
 
 
55
    struct PixmapStruct {
 
56
        struct PixmapClass {
 
57
            PixmapClass()
 
58
                : svgRenderer(0), present(false), svgImage(false), package(false),
 
59
                  aspectMode(Qt::IgnoreAspectRatio) {}
 
60
            QString fullpath;
 
61
            QImage image;
 
62
            QSvgRenderer *svgRenderer;
 
63
            QPixmap readyPixmap;
 
64
            QRect targetArea;
 
65
            QColor tint;
 
66
            bool present;
 
67
            bool svgImage;
 
68
            bool package;
 
69
            QString svgElement;
 
70
            QSize svgSizeHint;
 
71
            Qt::AspectRatioMode aspectMode;
 
72
        } normal, active, prelight;
 
73
    } pixmap;
 
74
 
 
75
    QSignalMapper *qsm;
 
76
 
 
77
private:
 
78
    // Method to load the image given by the theme
 
79
    void definePixmap(const QDomElement &el, PixmapStruct::PixmapClass &pc);
 
80
    QString findBestPixmap(const QString &dir, const QString &pat,
 
81
                           const QRect &area, Qt::AspectRatioMode aspectMode);
 
82
    bool loadPixmap(PixmapStruct::PixmapClass &pc);
 
83
    bool loadSvg(PixmapStruct::PixmapClass &pc);
 
84
    bool calcTargetArea(PixmapStruct::PixmapClass &pClass, const QSize &sh);
 
85
    void applyTint(PixmapStruct::PixmapClass &pClass, QImage &img);
 
86
    PixmapStruct::PixmapClass &getClass(ItemState sts);
 
87
    PixmapStruct::PixmapClass &getCurClass() { return getClass(state); }
 
88
 
 
89
private Q_SLOTS:
 
90
    void slotAnimate(int sts);
 
91
};
 
92
 
 
93
#endif