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

Proposed by Cris Dywan
Status: Rejected
Rejected by: Cris Dywan
Proposed branch: lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/shapeNotes
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 239 lines (+38/-42)
5 files modified
src/Ubuntu/Components/plugin/ucapplication.cpp (+20/-0)
src/Ubuntu/Components/plugin/ucapplication.h (+5/-0)
src/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp (+6/-28)
src/Ubuntu/Components/plugin/ucdeprecatedtheme.h (+0/-5)
src/Ubuntu/Components/plugin/ucubuntushape.cpp (+7/-9)
To merge this branch: bzr merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/shapeNotes
Reviewer Review Type Date Requested Status
Cris Dywan Disapprove
PS Jenkins bot continuous-integration Approve
Loïc Molinari Pending
Review via email: mp+267065@code.launchpad.net

Commit message

Share deprecation note logic through UCApplication

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

07:27 <loicm> kalikiana: the problem is with showDeprecatedNote(), QQmlContext constructor implies a bunch of mallocs, string handling too, there's a bunch of string manipulation, an env var retrieval, and a hash lookup, I think that's too much for each setter, especially since a single frame can have a bunch of these called for all the shapes in a scene when animated

review: Disapprove

Unmerged revisions

1592. By Cris Dywan

Share deprecation note logic through UCApplication

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/plugin/ucapplication.cpp'
2--- src/Ubuntu/Components/plugin/ucapplication.cpp 2015-06-29 21:08:01 +0000
3+++ src/Ubuntu/Components/plugin/ucapplication.cpp 2015-08-05 16:02:14 +0000
4@@ -85,3 +85,23 @@
5 void UCApplication::setInputMethod(QObject* inputMethod) {
6 m_inputMethod = inputMethod;
7 }
8+
9+void UCApplication::showDeprecatedNote(QObject *onItem, const char *note)
10+{
11+ QQmlContext ctx(QQmlEngine::contextForObject(onItem));
12+ // No warnings due to deprecated code used in the components themselves
13+ if (ctx.baseUrl().toString().contains("/Ubuntu/Components/"))
14+ return;
15+ // Warnings without a filename are not helpful
16+ if (ctx.baseUrl().isEmpty())
17+ return;
18+
19+ QString noteId(QString("%1.%2").arg(note).arg(onItem->metaObject()->className()));
20+ if (m_notes.contains(noteId))
21+ return;
22+ QByteArray suppressNote = qgetenv("SUPPRESS_DEPRECATED_NOTE");
23+ if (suppressNote.isEmpty() || suppressNote != "yes") {
24+ qmlInfo(onItem) << note;
25+ m_notes.insert(noteId, true);
26+ }
27+}
28
29=== modified file 'src/Ubuntu/Components/plugin/ucapplication.h'
30--- src/Ubuntu/Components/plugin/ucapplication.h 2015-06-29 17:48:58 +0000
31+++ src/Ubuntu/Components/plugin/ucapplication.h 2015-08-05 16:02:14 +0000
32@@ -20,6 +20,8 @@
33 #define UBUNTU_COMPONENTS_APPLICATION_H
34
35 #include <QtCore/QObject>
36+#include <QtCore/QHash>
37+#include <QtQml/qqmlinfo.h>
38
39 class QQmlContext;
40 class QQmlEngine;
41@@ -49,11 +51,14 @@
42 void setContext(QQmlContext* context);
43 void setApplicationName(const QString& applicationName);
44 void setInputMethod(QObject* inputMethod);
45+ void showDeprecatedNote(QObject *onItem, const char *note);
46
47 private:
48 QQmlContext* m_context;
49 QObject* m_inputMethod;
50
51+ QHash<QString, bool> m_notes;
52+
53 Q_SIGNALS:
54 void applicationNameChanged();
55 void inputMethodChanged();
56
57=== modified file 'src/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp'
58--- src/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp 2015-05-27 18:02:23 +0000
59+++ src/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp 2015-08-05 16:02:14 +0000
60@@ -18,12 +18,11 @@
61
62 #include "ucnamespace.h"
63 #include "ucdeprecatedtheme.h"
64+#include "ucapplication.h"
65 #include "uctheme.h"
66 #include "listener.h"
67 #include <QtQml/QQmlComponent>
68 #include <QtQml/QQmlContext>
69-#include <QtQml/QQmlInfo>
70-#include <QtQml/QQmlEngine>
71
72 /*!
73 \qmltype Theme
74@@ -66,33 +65,12 @@
75 UCDeprecatedTheme::UCDeprecatedTheme(QObject *parent)
76 : QObject(parent)
77 {
78- m_notes = QHash<QString, bool>();
79 connect(&UCTheme::defaultTheme(), &UCTheme::nameChanged,
80 this, &UCDeprecatedTheme::nameChanged);
81 connect(&UCTheme::defaultTheme(), &UCTheme::paletteChanged,
82 this, &UCDeprecatedTheme::paletteChanged);
83 }
84
85-void UCDeprecatedTheme::showDeprecatedNote(QObject *onItem, const char *note)
86-{
87- QQmlContext ctx(QQmlEngine::contextForObject(onItem));
88- // No warnings due to deprecated code used in the components themselves
89- if (ctx.baseUrl().toString().contains("/Ubuntu/Components/"))
90- return;
91- // Warnings without a filename are not helpful
92- if (ctx.baseUrl().isEmpty())
93- return;
94-
95- QString noteId(QString("%1.%2").arg(note).arg(onItem->metaObject()->className()));
96- if (m_notes.contains(noteId))
97- return;
98- QByteArray suppressNote = qgetenv("SUPPRESS_DEPRECATED_NOTE");
99- if (suppressNote.isEmpty() || suppressNote != "yes") {
100- qmlInfo(onItem) << note;
101- m_notes.insert(noteId, true);
102- }
103-}
104-
105 /*!
106 \qmlproperty string Theme::name
107
108@@ -100,17 +78,17 @@
109 */
110 QString UCDeprecatedTheme::name()
111 {
112- showDeprecatedNote(this, "Theme.name is deprecated. Use ThemeSettings instead.");
113+ UCApplication::instance().showDeprecatedNote(this, "Theme.name is deprecated. Use ThemeSettings instead.");
114 return UCTheme::defaultTheme().name();
115 }
116 void UCDeprecatedTheme::setName(const QString& name)
117 {
118- showDeprecatedNote(this, "Theme.name is deprecated. Use ThemeSettings instead.");
119+ UCApplication::instance().showDeprecatedNote(this, "Theme.name is deprecated. Use ThemeSettings instead.");
120 UCTheme::defaultTheme().setName(name);
121 }
122 void UCDeprecatedTheme::resetName()
123 {
124- showDeprecatedNote(this, "Theme.name is deprecated. Use ThemeSettings instead.");
125+ UCApplication::instance().showDeprecatedNote(this, "Theme.name is deprecated. Use ThemeSettings instead.");
126 UCTheme::defaultTheme().resetName();
127 }
128
129@@ -121,7 +99,7 @@
130 */
131 QObject* UCDeprecatedTheme::palette()
132 {
133- showDeprecatedNote(this, "Theme.palette is deprecated. Use ThemeSettings instead.");
134+ UCApplication::instance().showDeprecatedNote(this, "Theme.palette is deprecated. Use ThemeSettings instead.");
135 return UCTheme::defaultTheme().palette();
136 }
137
138@@ -132,7 +110,7 @@
139 */
140 QQmlComponent* UCDeprecatedTheme::createStyleComponent(const QString& styleName, QObject* parent)
141 {
142- showDeprecatedNote(parent, "Theme.createStyleComponent() is deprecated. Use ThemeSettings instead.");
143+ UCApplication::instance().showDeprecatedNote(parent, "Theme.createStyleComponent() is deprecated. Use ThemeSettings instead.");
144 return UCTheme::defaultTheme().createStyleComponent(styleName, parent, BUILD_VERSION(1, 2));
145 }
146
147
148=== modified file 'src/Ubuntu/Components/plugin/ucdeprecatedtheme.h'
149--- src/Ubuntu/Components/plugin/ucdeprecatedtheme.h 2015-05-18 05:42:05 +0000
150+++ src/Ubuntu/Components/plugin/ucdeprecatedtheme.h 2015-08-05 16:02:14 +0000
151@@ -20,7 +20,6 @@
152 #define UCDEPRECATEDTHEME_H
153
154 #include <QtCore/QObject>
155-#include <QtCore/QHash>
156
157 class QQmlComponent;
158 class QQmlContext;
159@@ -49,10 +48,6 @@
160 Q_SIGNALS:
161 void nameChanged();
162 void paletteChanged();
163-
164-private:
165- void showDeprecatedNote(QObject *onItem, const char *note);
166- QHash<QString, bool> m_notes;
167 };
168
169 #endif // UCDEPRECATEDTHEME_H
170
171=== modified file 'src/Ubuntu/Components/plugin/ucubuntushape.cpp'
172--- src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-07-31 09:40:26 +0000
173+++ src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-08-05 16:02:14 +0000
174@@ -35,8 +35,8 @@
175 #include <QtQuick/QSGTextureProvider>
176 #include <QtQuick/private/qquickimage_p.h>
177 #include <QtQuick/private/qsgadaptationlayer_p.h>
178-#include <QtQml/qqmlinfo.h>
179 #include <math.h>
180+#include "ucapplication.h"
181
182 // Anti-aliasing distance of the contour in pixels.
183 const float distanceAApx = 1.75f;
184@@ -794,8 +794,7 @@
185 */
186 void UCUbuntuShape::setColor(const QColor& color)
187 {
188- qmlInfo(this) << "'color' is deprecated. Use 'backgroundColor', 'secondaryBackgroundColor' and "
189- "'backgroundMode' instead.";
190+ UCApplication::instance().showDeprecatedNote(this, "'color' is deprecated. Use 'backgroundColor', 'secondaryBackgroundColor' and 'backgroundMode' instead.");
191
192 if (!(m_flags & BackgroundApiSet)) {
193 const QRgb colorRgb = qRgba(color.red(), color.green(), color.blue(), color.alpha());
194@@ -823,8 +822,7 @@
195 */
196 void UCUbuntuShape::setGradientColor(const QColor& gradientColor)
197 {
198- qmlInfo(this) << "'gradientColor' is deprecated. Use 'backgroundColor', "
199- "'secondaryBackgroundColor' and 'backgroundMode' instead.";
200+ UCApplication::instance().showDeprecatedNote(this, "'gradientColor' is deprecated. Use 'backgroundColor', ");
201
202 if (!(m_flags & BackgroundApiSet)) {
203 m_flags |= GradientColorSet;
204@@ -850,7 +848,7 @@
205 */
206 void UCUbuntuShape::setImage(const QVariant& image)
207 {
208- qmlInfo(this) << "'image' is deprecated. Use 'source' instead.";
209+ UCApplication::instance().showDeprecatedNote(this, "'image' is deprecated. Use 'source' instead.");
210
211 if (!(m_flags & SourceApiSet)) {
212 QQuickItem* newImage = qobject_cast<QQuickItem*>(qvariant_cast<QObject*>(image));
213@@ -879,7 +877,7 @@
214 // maintain it for a while for compatibility reasons.
215 void UCUbuntuShape::setStretched(bool stretched)
216 {
217- qmlInfo(this) << "'stretched' is deprecated. Use 'sourceFillMode' instead";
218+ UCApplication::instance().showDeprecatedNote(this, "'stretched' is deprecated. Use 'sourceFillMode' instead");
219
220 if (!(m_flags & SourceApiSet)) {
221 if (!!(m_flags & Stretched) != stretched) {
222@@ -898,7 +896,7 @@
223 // Deprecation layer. Same comment as setStretched().
224 void UCUbuntuShape::setHorizontalAlignment(HAlignment horizontalAlignment)
225 {
226- qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceHorizontalAlignment' instead";
227+ UCApplication::instance().showDeprecatedNote(this, "'horizontalAlignment' is deprecated. Use 'sourceHorizontalAlignment' instead");
228
229 if (!(m_flags & SourceApiSet)) {
230 if (m_imageHorizontalAlignment != horizontalAlignment) {
231@@ -913,7 +911,7 @@
232 // Deprecation layer. Same comment as setStretched().
233 void UCUbuntuShape::setVerticalAlignment(VAlignment verticalAlignment)
234 {
235- qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceVerticalAlignment' instead";
236+ UCApplication::instance().showDeprecatedNote(this, "'horizontalAlignment' is deprecated. Use 'sourceVerticalAlignment' instead");
237
238 if (!(m_flags & SourceApiSet)) {
239 if (m_imageVerticalAlignment != verticalAlignment) {

Subscribers

People subscribed via source and target branches