~zsombi/ubuntu-ui-toolkit/listitemSelectModeBugs

« back to all changes in this revision

Viewing changes to src/Ubuntu/Components/plugin/ucubuntushape.cpp

  • Committer: Zsombor Egri
  • Date: 2015-12-07 17:02:28 UTC
  • mfrom: (1662.2.80 staging)
  • Revision ID: zsombor.egri@canonical.com-20151207170228-coqv9fvqublui315
staging sync

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include "ucubuntushape.h"
29
29
#include "ucubuntushapetexture.h"
30
30
#include "ucunits.h"
 
31
#include "ucnamespace.h"
31
32
#include "quickutils.h"
32
33
#include <QtCore/QPointer>
33
34
#include <QtGui/QGuiApplication>
307
308
    , m_sourceFillMode(Stretch)
308
309
    , m_sourceHorizontalWrapMode(Transparent)
309
310
    , m_sourceVerticalWrapMode(Transparent)
 
311
    , m_version(Version12)
310
312
    , m_sourceOpacity(255)
311
313
    , m_flags(Stretched)
312
314
{
328
330
         || openglContext->hasExtension(QByteArrayLiteral("GL_OES_standard_derivatives")));
329
331
}
330
332
 
 
333
bool UCUbuntuShape::isVersionGreaterThanOrEqual(Version version)
 
334
{
 
335
    return static_cast<int>(m_version) >= static_cast<int>(version);
 
336
}
 
337
 
331
338
/*! \qmlproperty string UbuntuShape::radius
332
339
 
333
340
    This property defines the corner radius. Three fixed values are supported: \c "small",
808
815
void UCUbuntuShape::setColor(const QColor& color)
809
816
{
810
817
    static bool loggedOnce = false;
811
 
    if (!loggedOnce) {
 
818
    if (isVersionGreaterThanOrEqual(Version13) && !loggedOnce) {
812
819
        loggedOnce = true;
813
820
        qmlInfo(this) << "'color' is deprecated. Use 'backgroundColor', 'secondaryBackgroundColor' "
814
821
            "and 'backgroundMode' instead.";
841
848
void UCUbuntuShape::setGradientColor(const QColor& gradientColor)
842
849
{
843
850
    static bool loggedOnce = false;
844
 
    if (!loggedOnce) {
 
851
    if (isVersionGreaterThanOrEqual(Version13) && !loggedOnce) {
845
852
        loggedOnce = true;
846
853
        qmlInfo(this) << "'gradientColor' is deprecated. Use 'backgroundColor', "
847
854
            "'secondaryBackgroundColor' and 'backgroundMode' instead.";
872
879
void UCUbuntuShape::setImage(const QVariant& image)
873
880
{
874
881
    static bool loggedOnce = false;
875
 
    if (!loggedOnce) {
 
882
    if (isVersionGreaterThanOrEqual(Version13) && !loggedOnce) {
876
883
        loggedOnce = true;
877
884
        qmlInfo(this) << "'image' is deprecated. Use 'source' instead.";
878
885
    }
904
911
// maintain it for a while for compatibility reasons.
905
912
void UCUbuntuShape::setStretched(bool stretched)
906
913
{
907
 
    static bool loggedOnce = false;
908
 
    if (!loggedOnce) {
909
 
        loggedOnce = true;
910
 
        qmlInfo(this) << "'stretched' is deprecated. Use 'sourceFillMode' instead";
911
 
    }
912
 
 
913
914
    if (!(m_flags & SourceApiSet)) {
914
915
        if (!!(m_flags & Stretched) != stretched) {
915
916
            if (stretched) {
927
928
// Deprecation layer. Same comment as setStretched().
928
929
void UCUbuntuShape::setHorizontalAlignment(HAlignment horizontalAlignment)
929
930
{
930
 
    static bool loggedOnce = false;
931
 
    if (!loggedOnce) {
932
 
        loggedOnce = true;
933
 
        qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceHorizontalAlignment' "
934
 
            "instead";
935
 
    }
936
 
 
937
931
    if (!(m_flags & SourceApiSet)) {
938
932
        if (m_imageHorizontalAlignment != horizontalAlignment) {
939
933
            m_imageHorizontalAlignment = horizontalAlignment;
947
941
// Deprecation layer. Same comment as setStretched().
948
942
void UCUbuntuShape::setVerticalAlignment(VAlignment verticalAlignment)
949
943
{
950
 
    static bool loggedOnce = false;
951
 
    if (!loggedOnce) {
952
 
        loggedOnce = true;
953
 
        qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceVerticalAlignment' "
954
 
            "instead";
955
 
    }
956
 
 
957
944
    if (!(m_flags & SourceApiSet)) {
958
945
        if (m_imageVerticalAlignment != verticalAlignment) {
959
946
            m_imageVerticalAlignment = verticalAlignment;
1047
1034
    update();
1048
1035
}
1049
1036
 
 
1037
QString UCUbuntuShape::propertyForVersion(quint16 version) const
 
1038
{
 
1039
    if (MINOR_VERSION(version) == 3) {
 
1040
        return QStringLiteral("relativeRadius");
 
1041
    } else {
 
1042
        return QString();
 
1043
    }
 
1044
}
 
1045
 
 
1046
void UCUbuntuShape::componentComplete()
 
1047
{
 
1048
    QQuickItem::componentComplete();
 
1049
    m_version = MINOR_VERSION(importVersion(this)) == 3 ? Version13 : Version12;
 
1050
}
 
1051
 
1050
1052
void UCUbuntuShape::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry)
1051
1053
{
1052
1054
    QQuickItem::geometryChanged(newGeometry, oldGeometry);