Merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-ubuntushape-wrong-deprecation-log-fix into lp:ubuntu-ui-toolkit/staging

Proposed by Loïc Molinari
Status: Merged
Approved by: Zsombor Egri
Approved revision: 1727
Merged at revision: 1736
Proposed branch: lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-ubuntushape-wrong-deprecation-log-fix
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 178 lines (+33/-27)
2 files modified
src/Ubuntu/Components/plugin/ucubuntushape.cpp (+25/-23)
src/Ubuntu/Components/plugin/ucubuntushape.h (+8/-4)
To merge this branch: bzr merge lp:~loic.molinari/ubuntu-ui-toolkit/ubuntu-ui-toolkit-ubuntushape-wrong-deprecation-log-fix
Reviewer Review Type Date Requested Status
Zsombor Egri Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+278474@code.launchpad.net

Commit message

[UbuntuShape] Fixed deprecation logging issues.

This fix prevents logging a deprecation warning for "image", "color" and "gradientColor" properties when the import version is less than 1.3. The logging of properties used internally (through the old image wrapper) have been removed too since the user might not even have used them.

Description of the change

[UbuntuShape] Fixed deprecation logging issues.

This fix prevents logging a deprecation warning for "image", "color" and "gradientColor" properties when the import version is less than 1.3. The logging of properties used internally (through the old image wrapper) have been removed too since the user might not even have used them.

To post a comment you must log in.
Revision history for this message
Zsombor Egri (zsombi) wrote :

You may want to use http://bazaar.launchpad.net/~ubuntu-sdk-team/ubuntu-ui-toolkit/staging/view/head:/src/Ubuntu/Components/plugin/ucimportversionchecker_p.h to check in what version the UbuntuShape instance is used. Check UCListItem on how it is used.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1725. By Loïc Molinari

[UbuntuShape] Fixed wrong deprecation log info.

Revision history for this message
Loïc Molinari (loic.molinari) wrote :

> You may want to use http://bazaar.launchpad.net/~ubuntu-sdk-team/ubuntu-ui-too
> lkit/staging/view/head:/src/Ubuntu/Components/plugin/ucimportversionchecker_p.
> h to check in what version the UbuntuShape instance is used. Check UCListItem
> on how it is used.

Done, thanks.

Revision history for this message
Zsombor Egri (zsombi) wrote :

One more thing... I do not feel you'd need to introduce a different versioning definition just for this, you could use the version encoding we have right now, I do not think there is much performance implications using BUILD_VERSION(major, minor) vs. enums. Or even better, declaring constants with V13 = BUILD_VERSION(1, 3) then using that in the tests, i.e if (m_version - V13 && !loggedOnce) would even exclude the eventual overhead provided by the BUILD_VERSION (i.e. bit-shift + bit-or)

See comments inline.

Revision history for this message
Loïc Molinari (loic.molinari) wrote :

> One more thing... I do not feel you'd need to introduce a different versioning
> definition just for this, you could use the version encoding we have right
> now, I do not think there is much performance implications using
> BUILD_VERSION(major, minor) vs. enums. Or even better, declaring constants
> with V13 = BUILD_VERSION(1, 3) then using that in the tests, i.e if (m_version
> - V13 && !loggedOnce) would even exclude the eventual overhead provided by the
> BUILD_VERSION (i.e. bit-shift + bit-or)
>
> See comments inline.

Not that I don't like the encoding (and I don't force anyone to do the same) but I did that to avoid adding 16 bits (very likely to be 32 bits if the 4 bytes boundary is reached) per instance just for that, instead of 1 bit in the already allocated padding space. The shape being the item that's used the most by apps I try to make it as compact as possible. But I can store it as U16 if you think it's not worth it.

Yes, I'm a data torturer :)

Revision history for this message
Zsombor Egri (zsombi) wrote :

> > One more thing... I do not feel you'd need to introduce a different
> versioning
> > definition just for this, you could use the version encoding we have right
> > now, I do not think there is much performance implications using
> > BUILD_VERSION(major, minor) vs. enums. Or even better, declaring constants
> > with V13 = BUILD_VERSION(1, 3) then using that in the tests, i.e if
> (m_version
> > - V13 && !loggedOnce) would even exclude the eventual overhead provided by
> the
> > BUILD_VERSION (i.e. bit-shift + bit-or)
> >
> > See comments inline.
>
> Not that I don't like the encoding (and I don't force anyone to do the same)
> but I did that to avoid adding 16 bits (very likely to be 32 bits if the 4
> bytes boundary is reached) per instance just for that, instead of 1 bit in the
> already allocated padding space. The shape being the item that's used the most
> by apps I try to make it as compact as possible. But I can store it as U16 if
> you think it's not worth it.

Fair point!

>
> Yes, I'm a data torturer :)

I am glad you are, at least I can find my pair in this company ;)

Revision history for this message
Loïc Molinari (loic.molinari) wrote :

> > Yes, I'm a data torturer :)
>
> I am glad you are, at least I can find my pair in this company ;)

Hehe!

1726. By Loïc Molinari

trigger new jenkins pass.

1727. By Loïc Molinari

trigger new jenkins pass.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Zsombor Egri (zsombi) wrote :

Ok, finally :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Ubuntu/Components/plugin/ucubuntushape.cpp'
--- src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-10-21 12:54:54 +0000
+++ src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-12-02 09:22:46 +0000
@@ -28,6 +28,7 @@
28#include "ucubuntushape.h"28#include "ucubuntushape.h"
29#include "ucubuntushapetexture.h"29#include "ucubuntushapetexture.h"
30#include "ucunits.h"30#include "ucunits.h"
31#include "ucnamespace.h"
31#include "quickutils.h"32#include "quickutils.h"
32#include <QtCore/QPointer>33#include <QtCore/QPointer>
33#include <QtGui/QGuiApplication>34#include <QtGui/QGuiApplication>
@@ -307,6 +308,7 @@
307 , m_sourceFillMode(Stretch)308 , m_sourceFillMode(Stretch)
308 , m_sourceHorizontalWrapMode(Transparent)309 , m_sourceHorizontalWrapMode(Transparent)
309 , m_sourceVerticalWrapMode(Transparent)310 , m_sourceVerticalWrapMode(Transparent)
311 , m_version(Version12)
310 , m_sourceOpacity(255)312 , m_sourceOpacity(255)
311 , m_flags(Stretched)313 , m_flags(Stretched)
312{314{
@@ -328,6 +330,11 @@
328 || openglContext->hasExtension(QByteArrayLiteral("GL_OES_standard_derivatives")));330 || openglContext->hasExtension(QByteArrayLiteral("GL_OES_standard_derivatives")));
329}331}
330332
333bool UCUbuntuShape::isVersionGreaterThanOrEqual(Version version)
334{
335 return static_cast<int>(m_version) >= static_cast<int>(version);
336}
337
331/*! \qmlproperty string UbuntuShape::radius338/*! \qmlproperty string UbuntuShape::radius
332339
333 This property defines the corner radius. Three fixed values are supported: \c "small",340 This property defines the corner radius. Three fixed values are supported: \c "small",
@@ -808,7 +815,7 @@
808void UCUbuntuShape::setColor(const QColor& color)815void UCUbuntuShape::setColor(const QColor& color)
809{816{
810 static bool loggedOnce = false;817 static bool loggedOnce = false;
811 if (!loggedOnce) {818 if (isVersionGreaterThanOrEqual(Version13) && !loggedOnce) {
812 loggedOnce = true;819 loggedOnce = true;
813 qmlInfo(this) << "'color' is deprecated. Use 'backgroundColor', 'secondaryBackgroundColor' "820 qmlInfo(this) << "'color' is deprecated. Use 'backgroundColor', 'secondaryBackgroundColor' "
814 "and 'backgroundMode' instead.";821 "and 'backgroundMode' instead.";
@@ -841,7 +848,7 @@
841void UCUbuntuShape::setGradientColor(const QColor& gradientColor)848void UCUbuntuShape::setGradientColor(const QColor& gradientColor)
842{849{
843 static bool loggedOnce = false;850 static bool loggedOnce = false;
844 if (!loggedOnce) {851 if (isVersionGreaterThanOrEqual(Version13) && !loggedOnce) {
845 loggedOnce = true;852 loggedOnce = true;
846 qmlInfo(this) << "'gradientColor' is deprecated. Use 'backgroundColor', "853 qmlInfo(this) << "'gradientColor' is deprecated. Use 'backgroundColor', "
847 "'secondaryBackgroundColor' and 'backgroundMode' instead.";854 "'secondaryBackgroundColor' and 'backgroundMode' instead.";
@@ -872,7 +879,7 @@
872void UCUbuntuShape::setImage(const QVariant& image)879void UCUbuntuShape::setImage(const QVariant& image)
873{880{
874 static bool loggedOnce = false;881 static bool loggedOnce = false;
875 if (!loggedOnce) {882 if (isVersionGreaterThanOrEqual(Version13) && !loggedOnce) {
876 loggedOnce = true;883 loggedOnce = true;
877 qmlInfo(this) << "'image' is deprecated. Use 'source' instead.";884 qmlInfo(this) << "'image' is deprecated. Use 'source' instead.";
878 }885 }
@@ -904,12 +911,6 @@
904// maintain it for a while for compatibility reasons.911// maintain it for a while for compatibility reasons.
905void UCUbuntuShape::setStretched(bool stretched)912void 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 if (!(m_flags & SourceApiSet)) {914 if (!(m_flags & SourceApiSet)) {
914 if (!!(m_flags & Stretched) != stretched) {915 if (!!(m_flags & Stretched) != stretched) {
915 if (stretched) {916 if (stretched) {
@@ -927,13 +928,6 @@
927// Deprecation layer. Same comment as setStretched().928// Deprecation layer. Same comment as setStretched().
928void UCUbuntuShape::setHorizontalAlignment(HAlignment horizontalAlignment)929void 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 if (!(m_flags & SourceApiSet)) {931 if (!(m_flags & SourceApiSet)) {
938 if (m_imageHorizontalAlignment != horizontalAlignment) {932 if (m_imageHorizontalAlignment != horizontalAlignment) {
939 m_imageHorizontalAlignment = horizontalAlignment;933 m_imageHorizontalAlignment = horizontalAlignment;
@@ -947,13 +941,6 @@
947// Deprecation layer. Same comment as setStretched().941// Deprecation layer. Same comment as setStretched().
948void UCUbuntuShape::setVerticalAlignment(VAlignment verticalAlignment)942void 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 if (!(m_flags & SourceApiSet)) {944 if (!(m_flags & SourceApiSet)) {
958 if (m_imageVerticalAlignment != verticalAlignment) {945 if (m_imageVerticalAlignment != verticalAlignment) {
959 m_imageVerticalAlignment = verticalAlignment;946 m_imageVerticalAlignment = verticalAlignment;
@@ -1047,6 +1034,21 @@
1047 update();1034 update();
1048}1035}
10491036
1037QString UCUbuntuShape::propertyForVersion(quint16 version) const
1038{
1039 if (MINOR_VERSION(version) == 3) {
1040 return QStringLiteral("relativeRadius");
1041 } else {
1042 return QString();
1043 }
1044}
1045
1046void UCUbuntuShape::componentComplete()
1047{
1048 QQuickItem::componentComplete();
1049 m_version = MINOR_VERSION(importVersion(this)) == 3 ? Version13 : Version12;
1050}
1051
1050void UCUbuntuShape::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry)1052void UCUbuntuShape::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry)
1051{1053{
1052 QQuickItem::geometryChanged(newGeometry, oldGeometry);1054 QQuickItem::geometryChanged(newGeometry, oldGeometry);
10531055
=== modified file 'src/Ubuntu/Components/plugin/ucubuntushape.h'
--- src/Ubuntu/Components/plugin/ucubuntushape.h 2015-09-10 11:04:16 +0000
+++ src/Ubuntu/Components/plugin/ucubuntushape.h 2015-12-02 09:22:46 +0000
@@ -24,8 +24,7 @@
24#include <QtQuick/qsgtexture.h>24#include <QtQuick/qsgtexture.h>
25#include <QtQuick/qsgmaterial.h>25#include <QtQuick/qsgmaterial.h>
26#include <QtGui/QOpenGLFunctions>26#include <QtGui/QOpenGLFunctions>
2727#include "ucimportversionchecker_p.h"
28class UCUbuntuShape;
2928
30// --- Scene graph shader ---29// --- Scene graph shader ---
3130
@@ -121,7 +120,7 @@
121120
122// --- QtQuick item ---121// --- QtQuick item ---
123122
124class UCUbuntuShape : public QQuickItem123class UCUbuntuShape : public QQuickItem, public UCImportVersionChecker
125{124{
126 Q_OBJECT125 Q_OBJECT
127126
@@ -183,6 +182,7 @@
183182
184 static bool useDistanceFields(const QOpenGLContext* openglContext);183 static bool useDistanceFields(const QOpenGLContext* openglContext);
185184
185 enum Version { Version12 = 0 /* Or lesser */, Version13 = 1 };
186 enum Aspect { Flat = 0, Inset = 1, DropShadow = 2 }; // Don't forget to update private enum.186 enum Aspect { Flat = 0, Inset = 1, DropShadow = 2 }; // Don't forget to update private enum.
187 enum BackgroundMode { SolidColor = 0, VerticalGradient = 1 };187 enum BackgroundMode { SolidColor = 0, VerticalGradient = 1 };
188 enum HAlignment { AlignLeft = 0, AlignHCenter = 1, AlignRight = 2 };188 enum HAlignment { AlignLeft = 0, AlignHCenter = 1, AlignRight = 2 };
@@ -287,6 +287,8 @@
287 void verticalAlignmentChanged();287 void verticalAlignmentChanged();
288288
289protected:289protected:
290 virtual QString propertyForVersion(quint16 version) const;
291 virtual void componentComplete();
290 virtual QSGNode* updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData* data);292 virtual QSGNode* updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData* data);
291 virtual void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);293 virtual void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
292294
@@ -305,6 +307,7 @@
305 void _q_textureChanged();307 void _q_textureChanged();
306308
307private:309private:
310 bool isVersionGreaterThanOrEqual(Version version);
308 void updateFromImageProperties(QQuickItem* image);311 void updateFromImageProperties(QQuickItem* image);
309 void connectToPropertyChange(312 void connectToPropertyChange(
310 QObject* sender, const char* property, QObject* receiver, const char* slot);313 QObject* sender, const char* property, QObject* receiver, const char* slot);
@@ -344,7 +347,8 @@
344 FillMode m_sourceFillMode : 2;347 FillMode m_sourceFillMode : 2;
345 WrapMode m_sourceHorizontalWrapMode : 1;348 WrapMode m_sourceHorizontalWrapMode : 1;
346 WrapMode m_sourceVerticalWrapMode : 1;349 WrapMode m_sourceVerticalWrapMode : 1;
347 quint8 __explicit_padding : 6;350 Version m_version : 1;
351 quint8 __explicit_padding : 5;
348 quint8 m_sourceOpacity;352 quint8 m_sourceOpacity;
349 quint8 m_flags;353 quint8 m_flags;
350354

Subscribers

People subscribed via source and target branches