~fboucault/unity-2d/opengl_switch

« back to all changes in this revision

Viewing changes to libunity-2d-private/Unity2d/blendedimageprovider.cpp

  • Committer: Aurelien Gateau
  • Author(s): Richard Dale
  • Date: 2011-04-28 13:09:25 UTC
  • Revision ID: aurelien.gateau@canonical.com-20110428130925-dfozimixq5usdvfv
Use libunity-2d logging methods.

Patch by Richard Dale

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
#include "blendedimageprovider.h"
18
18
#include <QPainter>
19
 
#include <QDebug>
 
19
#include <debug_p.h>
20
20
 
21
21
BlendedImageProvider::BlendedImageProvider() : QDeclarativeImageProvider(QDeclarativeImageProvider::Image)
22
22
{
31
31
    /* id is of the form [FILENAME]color=[COLORNAME]alpha=[FLOAT] */
32
32
    QRegExp rx("^(.+)color=(.+)alpha=(\\d+(?:\\.\\d+)?)$");
33
33
    if (rx.indexIn(id)) {
34
 
        qWarning() << "BlendedImageProvider: failed to match id:" << id;
 
34
        UQ_WARNING << "BlendedImageProvider: failed to match id:" << id;
35
35
        return QImage();
36
36
    }
37
37
    QStringList list = rx.capturedTexts();
38
38
 
39
39
    QString fileName = list[1];
40
40
    if (fileName.isEmpty()) {
41
 
        qWarning() << "BlendedImageProvider: filename can't be empty.";
 
41
        UQ_WARNING << "BlendedImageProvider: filename can't be empty.";
42
42
        return QImage();
43
43
    }
44
44
 
53
53
        */
54
54
        colorName.prepend("#");
55
55
        if (!QColor::isValidColor(colorName)) {
56
 
            qWarning() << "BlendedImageProvider: invalid color name:" << list[2];
 
56
            UQ_WARNING << "BlendedImageProvider: invalid color name:" << list[2];
57
57
            return QImage();
58
58
        }
59
59
    }
62
62
    bool valid = false;
63
63
    float alpha = list[3].toFloat(&valid);
64
64
    if (!valid) {
65
 
        qWarning() << "BlendedImageProvider: can't convert alpha to floating point:" << list[3];
 
65
        UQ_WARNING << "BlendedImageProvider: can't convert alpha to floating point:" << list[3];
66
66
        return QImage();
67
67
    }
68
68
    color.setAlphaF(alpha);
69
69
 
70
70
    QImage image(fileName);
71
71
    if (image.isNull()) {
72
 
        qWarning() << "BlendedImageProvider: failed to load image from file:" << fileName;
 
72
        UQ_WARNING << "BlendedImageProvider: failed to load image from file:" << fileName;
73
73
        return QImage();
74
74
    }
75
75