Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/optInDeprecationWarnings into lp:ubuntu-ui-toolkit/staging

Proposed by Cris Dywan
Status: Merged
Merge reported by: Cris Dywan
Merged at revision: not available
Proposed branch: lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/optInDeprecationWarnings
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 165 lines (+49/-27)
4 files modified
src/Ubuntu/Components/plugin/quickutils.cpp (+9/-0)
src/Ubuntu/Components/plugin/quickutils.h (+1/-0)
src/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp (+6/-5)
src/Ubuntu/Components/plugin/ucubuntushape.cpp (+33/-22)
To merge this branch: bzr merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/optInDeprecationWarnings
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Zoltan Balogh Approve
Review via email: mp+268902@code.launchpad.net

Commit message

Make deprecation warnings from C++ opt-in

Description of the change

Make deprecation warnings from C++ opt-in

To post a comment you must log in.
Revision history for this message
Zoltan Balogh (bzoltan) wrote :

Good for me

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Ubuntu/Components/plugin/quickutils.cpp'
--- src/Ubuntu/Components/plugin/quickutils.cpp 2015-03-10 11:49:27 +0000
+++ src/Ubuntu/Components/plugin/quickutils.cpp 2015-08-24 11:39:27 +0000
@@ -196,3 +196,12 @@
196 delete component;196 delete component;
197 return result;197 return result;
198}198}
199
200bool QuickUtils::showDeprecationWarnings() {
201 static int showWarnings = 0;
202 if (showWarnings == 0) {
203 QByteArray warningsFlag = qgetenv("SUPPRESS_DEPRECATED_NOTE");
204 showWarnings = (warningsFlag.isEmpty() || warningsFlag == "yes") ? 1 : 2;
205 }
206 return showWarnings == 2;
207}
199208
=== modified file 'src/Ubuntu/Components/plugin/quickutils.h'
--- src/Ubuntu/Components/plugin/quickutils.h 2015-03-10 11:49:27 +0000
+++ src/Ubuntu/Components/plugin/quickutils.h 2015-08-24 11:39:27 +0000
@@ -46,6 +46,7 @@
46 Q_INVOKABLE static QString className(QObject *item);46 Q_INVOKABLE static QString className(QObject *item);
47 Q_REVISION(1) Q_INVOKABLE static bool inherits(QObject *object, const QString &fromClass);47 Q_REVISION(1) Q_INVOKABLE static bool inherits(QObject *object, const QString &fromClass);
48 QObject* createQmlObject(const QUrl &url, QQmlEngine *engine);48 QObject* createQmlObject(const QUrl &url, QQmlEngine *engine);
49 static bool showDeprecationWarnings();
4950
50Q_SIGNALS:51Q_SIGNALS:
51 void rootObjectChanged();52 void rootObjectChanged();
5253
=== modified file 'src/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp'
--- src/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp 2015-05-27 18:02:23 +0000
+++ src/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp 2015-08-24 11:39:27 +0000
@@ -19,6 +19,7 @@
19#include "ucnamespace.h"19#include "ucnamespace.h"
20#include "ucdeprecatedtheme.h"20#include "ucdeprecatedtheme.h"
21#include "uctheme.h"21#include "uctheme.h"
22#include "quickutils.h"
22#include "listener.h"23#include "listener.h"
23#include <QtQml/QQmlComponent>24#include <QtQml/QQmlComponent>
24#include <QtQml/QQmlContext>25#include <QtQml/QQmlContext>
@@ -75,6 +76,9 @@
7576
76void UCDeprecatedTheme::showDeprecatedNote(QObject *onItem, const char *note)77void UCDeprecatedTheme::showDeprecatedNote(QObject *onItem, const char *note)
77{78{
79 if (!QuickUtils::showDeprecationWarnings())
80 return;
81
78 QQmlContext ctx(QQmlEngine::contextForObject(onItem));82 QQmlContext ctx(QQmlEngine::contextForObject(onItem));
79 // No warnings due to deprecated code used in the components themselves83 // No warnings due to deprecated code used in the components themselves
80 if (ctx.baseUrl().toString().contains("/Ubuntu/Components/"))84 if (ctx.baseUrl().toString().contains("/Ubuntu/Components/"))
@@ -86,11 +90,8 @@
86 QString noteId(QString("%1.%2").arg(note).arg(onItem->metaObject()->className()));90 QString noteId(QString("%1.%2").arg(note).arg(onItem->metaObject()->className()));
87 if (m_notes.contains(noteId))91 if (m_notes.contains(noteId))
88 return;92 return;
89 QByteArray suppressNote = qgetenv("SUPPRESS_DEPRECATED_NOTE");93 qmlInfo(onItem) << note;
90 if (suppressNote.isEmpty() || suppressNote != "yes") {94 m_notes.insert(noteId, true);
91 qmlInfo(onItem) << note;
92 m_notes.insert(noteId, true);
93 }
94}95}
9596
96/*!97/*!
9798
=== modified file 'src/Ubuntu/Components/plugin/ucubuntushape.cpp'
--- src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-08-24 09:24:37 +0000
+++ src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-08-24 11:39:27 +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 "quickutils.h"
31#include <QtCore/QPointer>32#include <QtCore/QPointer>
32#include <QtGui/QGuiApplication>33#include <QtGui/QGuiApplication>
33#include <QtGui/QScreen>34#include <QtGui/QScreen>
@@ -790,11 +791,13 @@
790*/791*/
791void UCUbuntuShape::setColor(const QColor& color)792void UCUbuntuShape::setColor(const QColor& color)
792{793{
793 static bool deprecationNoteShown = false;794 if (QuickUtils::showDeprecationWarnings()) {
794 if (!deprecationNoteShown) {795 static bool deprecationNoteShown = false;
795 deprecationNoteShown = true;796 if (!deprecationNoteShown) {
796 qmlInfo(this) << "'color' is deprecated. Use 'backgroundColor', 'secondaryBackgroundColor' and "797 deprecationNoteShown = true;
797 "'backgroundMode' instead.";798 qmlInfo(this) << "'color' is deprecated. Use 'backgroundColor', 'secondaryBackgroundColor' and "
799 "'backgroundMode' instead.";
800 }
798 }801 }
799802
800 if (!(m_flags & BackgroundApiSet)) {803 if (!(m_flags & BackgroundApiSet)) {
@@ -823,11 +826,13 @@
823*/826*/
824void UCUbuntuShape::setGradientColor(const QColor& gradientColor)827void UCUbuntuShape::setGradientColor(const QColor& gradientColor)
825{828{
826 static bool deprecationNoteShown = false;829 if (QuickUtils::showDeprecationWarnings()) {
827 if (!deprecationNoteShown) {830 static bool deprecationNoteShown = false;
828 deprecationNoteShown = true;831 if (!deprecationNoteShown) {
829 qmlInfo(this) << "'gradientColor' is deprecated. Use 'backgroundColor', "832 deprecationNoteShown = true;
830 "'secondaryBackgroundColor' and 'backgroundMode' instead.";833 qmlInfo(this) << "'gradientColor' is deprecated. Use 'backgroundColor', "
834 "'secondaryBackgroundColor' and 'backgroundMode' instead.";
835 }
831 }836 }
832837
833 if (!(m_flags & BackgroundApiSet)) {838 if (!(m_flags & BackgroundApiSet)) {
@@ -854,10 +859,12 @@
854*/859*/
855void UCUbuntuShape::setImage(const QVariant& image)860void UCUbuntuShape::setImage(const QVariant& image)
856{861{
857 static bool deprecationNoteShown = false;862 if (QuickUtils::showDeprecationWarnings()) {
858 if (!deprecationNoteShown) {863 static bool deprecationNoteShown = false;
859 deprecationNoteShown = true;864 if (!deprecationNoteShown) {
860 qmlInfo(this) << "'image' is deprecated. Use 'source' instead.";865 deprecationNoteShown = true;
866 qmlInfo(this) << "'image' is deprecated. Use 'source' instead.";
867 }
861 }868 }
862869
863 if (!(m_flags & SourceApiSet)) {870 if (!(m_flags & SourceApiSet)) {
@@ -887,10 +894,12 @@
887// maintain it for a while for compatibility reasons.894// maintain it for a while for compatibility reasons.
888void UCUbuntuShape::setStretched(bool stretched)895void UCUbuntuShape::setStretched(bool stretched)
889{896{
890 static bool deprecationNoteShown = false;897 if (QuickUtils::showDeprecationWarnings()) {
891 if (!deprecationNoteShown) {898 static bool deprecationNoteShown = false;
892 deprecationNoteShown = true;899 if (!deprecationNoteShown) {
893 qmlInfo(this) << "'stretched' is deprecated. Use 'sourceFillMode' instead";900 deprecationNoteShown = true;
901 qmlInfo(this) << "'stretched' is deprecated. Use 'sourceFillMode' instead";
902 }
894 }903 }
895904
896 if (!(m_flags & SourceApiSet)) {905 if (!(m_flags & SourceApiSet)) {
@@ -910,10 +919,12 @@
910// Deprecation layer. Same comment as setStretched().919// Deprecation layer. Same comment as setStretched().
911void UCUbuntuShape::setHorizontalAlignment(HAlignment horizontalAlignment)920void UCUbuntuShape::setHorizontalAlignment(HAlignment horizontalAlignment)
912{921{
913 static bool deprecationNoteShown = false;922 if (QuickUtils::showDeprecationWarnings()) {
914 if (!deprecationNoteShown) {923 static bool deprecationNoteShown = false;
915 deprecationNoteShown = true;924 if (!deprecationNoteShown) {
916 qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceHorizontalAlignment' instead";925 deprecationNoteShown = true;
926 qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceHorizontalAlignment' instead";
927 }
917 }928 }
918929
919 if (!(m_flags & SourceApiSet)) {930 if (!(m_flags & SourceApiSet)) {

Subscribers

People subscribed via source and target branches