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

Proposed by Christian Dywan on 2015-08-24
Status: Merged
Approved by: Zoltan Balogh on 2015-08-25
Approved revision: 1218
Merged at revision: 1220
Proposed branch: lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/optInDeprecationWarningsTrunk
Merge into: lp:ubuntu-ui-toolkit
Diff against target: 145 lines (+37/-12)
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/-4)
src/Ubuntu/Components/plugin/ucubuntushape.cpp (+21/-8)
To merge this branch: bzr merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/optInDeprecationWarningsTrunk
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration 2015-08-24 Approve on 2015-08-24
Ubuntu SDK team 2015-08-24 Pending
Review via email: mp+268909@code.launchpad.net

This proposal supersedes a proposal from 2015-08-24.

Commit Message

Make deprecation warnings from C++ opt-in

Description of the Change

Make deprecation warnings from C++ opt-in

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/plugin/quickutils.cpp'
2--- src/Ubuntu/Components/plugin/quickutils.cpp 2015-03-10 11:49:27 +0000
3+++ src/Ubuntu/Components/plugin/quickutils.cpp 2015-08-24 13:09:39 +0000
4@@ -196,3 +196,12 @@
5 delete component;
6 return result;
7 }
8+
9+bool QuickUtils::showDeprecationWarnings() {
10+ static int showWarnings = 0;
11+ if (showWarnings == 0) {
12+ QByteArray warningsFlag = qgetenv("SUPPRESS_DEPRECATED_NOTE");
13+ showWarnings = (warningsFlag.isEmpty() || warningsFlag == "yes") ? 1 : 2;
14+ }
15+ return showWarnings == 2;
16+}
17
18=== modified file 'src/Ubuntu/Components/plugin/quickutils.h'
19--- src/Ubuntu/Components/plugin/quickutils.h 2015-03-10 11:49:27 +0000
20+++ src/Ubuntu/Components/plugin/quickutils.h 2015-08-24 13:09:39 +0000
21@@ -46,6 +46,7 @@
22 Q_INVOKABLE static QString className(QObject *item);
23 Q_REVISION(1) Q_INVOKABLE static bool inherits(QObject *object, const QString &fromClass);
24 QObject* createQmlObject(const QUrl &url, QQmlEngine *engine);
25+ static bool showDeprecationWarnings();
26
27 Q_SIGNALS:
28 void rootObjectChanged();
29
30=== modified file 'src/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp'
31--- src/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp 2015-05-27 18:02:23 +0000
32+++ src/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp 2015-08-24 13:09:39 +0000
33@@ -19,6 +19,7 @@
34 #include "ucnamespace.h"
35 #include "ucdeprecatedtheme.h"
36 #include "uctheme.h"
37+#include "quickutils.h"
38 #include "listener.h"
39 #include <QtQml/QQmlComponent>
40 #include <QtQml/QQmlContext>
41@@ -75,6 +76,9 @@
42
43 void UCDeprecatedTheme::showDeprecatedNote(QObject *onItem, const char *note)
44 {
45+ if (!QuickUtils::showDeprecationWarnings())
46+ return;
47+
48 QQmlContext ctx(QQmlEngine::contextForObject(onItem));
49 // No warnings due to deprecated code used in the components themselves
50 if (ctx.baseUrl().toString().contains("/Ubuntu/Components/"))
51@@ -87,10 +91,8 @@
52 if (m_notes.contains(noteId))
53 return;
54 QByteArray suppressNote = qgetenv("SUPPRESS_DEPRECATED_NOTE");
55- if (suppressNote.isEmpty() || suppressNote != "yes") {
56- qmlInfo(onItem) << note;
57- m_notes.insert(noteId, true);
58- }
59+ qmlInfo(onItem) << note;
60+ m_notes.insert(noteId, true);
61 }
62
63 /*!
64
65=== modified file 'src/Ubuntu/Components/plugin/ucubuntushape.cpp'
66--- src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-08-06 13:16:24 +0000
67+++ src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-08-24 13:09:39 +0000
68@@ -28,6 +28,7 @@
69 #include "ucubuntushape.h"
70 #include "ucubuntushapetexture.h"
71 #include "ucunits.h"
72+#include "quickutils.h"
73 #include <QtCore/QPointer>
74 #include <QtGui/QGuiApplication>
75 #include <QtGui/QScreen>
76@@ -793,8 +794,10 @@
77 */
78 void UCUbuntuShape::setColor(const QColor& color)
79 {
80- qmlInfo(this) << "'color' is deprecated. Use 'backgroundColor', 'secondaryBackgroundColor' and "
81- "'backgroundMode' instead.";
82+ if (QuickUtils::showDeprecationWarnings()) {
83+ qmlInfo(this) << "'color' is deprecated. Use 'backgroundColor', 'secondaryBackgroundColor' and "
84+ "'backgroundMode' instead.";
85+ }
86
87 if (!(m_flags & BackgroundApiSet)) {
88 const QRgb colorRgb = qRgba(color.red(), color.green(), color.blue(), color.alpha());
89@@ -822,8 +825,10 @@
90 */
91 void UCUbuntuShape::setGradientColor(const QColor& gradientColor)
92 {
93- qmlInfo(this) << "'gradientColor' is deprecated. Use 'backgroundColor', "
94- "'secondaryBackgroundColor' and 'backgroundMode' instead.";
95+ if (QuickUtils::showDeprecationWarnings()) {
96+ qmlInfo(this) << "'gradientColor' is deprecated. Use 'backgroundColor', "
97+ "'secondaryBackgroundColor' and 'backgroundMode' instead.";
98+ }
99
100 if (!(m_flags & BackgroundApiSet)) {
101 m_flags |= GradientColorSet;
102@@ -849,7 +854,9 @@
103 */
104 void UCUbuntuShape::setImage(const QVariant& image)
105 {
106- qmlInfo(this) << "'image' is deprecated. Use 'source' instead.";
107+ if (QuickUtils::showDeprecationWarnings()) {
108+ qmlInfo(this) << "'image' is deprecated. Use 'source' instead.";
109+ }
110
111 if (!(m_flags & SourceApiSet)) {
112 QQuickItem* newImage = qobject_cast<QQuickItem*>(qvariant_cast<QObject*>(image));
113@@ -878,7 +885,9 @@
114 // maintain it for a while for compatibility reasons.
115 void UCUbuntuShape::setStretched(bool stretched)
116 {
117- qmlInfo(this) << "'stretched' is deprecated. Use 'sourceFillMode' instead";
118+ if (QuickUtils::showDeprecationWarnings()) {
119+ qmlInfo(this) << "'stretched' is deprecated. Use 'sourceFillMode' instead";
120+ }
121
122 if (!(m_flags & SourceApiSet)) {
123 if (!!(m_flags & Stretched) != stretched) {
124@@ -897,7 +906,9 @@
125 // Deprecation layer. Same comment as setStretched().
126 void UCUbuntuShape::setHorizontalAlignment(HAlignment horizontalAlignment)
127 {
128- qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceHorizontalAlignment' instead";
129+ if (QuickUtils::showDeprecationWarnings()) {
130+ qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceHorizontalAlignment' instead";
131+ }
132
133 if (!(m_flags & SourceApiSet)) {
134 if (m_imageHorizontalAlignment != horizontalAlignment) {
135@@ -912,7 +923,9 @@
136 // Deprecation layer. Same comment as setStretched().
137 void UCUbuntuShape::setVerticalAlignment(VAlignment verticalAlignment)
138 {
139- qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceVerticalAlignment' instead";
140+ if (QuickUtils::showDeprecationWarnings()) {
141+ qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceVerticalAlignment' instead";
142+ }
143
144 if (!(m_flags & SourceApiSet)) {
145 if (m_imageVerticalAlignment != verticalAlignment) {

Subscribers

People subscribed via source and target branches

to status/vote changes: