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
=== modified file 'src/Ubuntu/Components/plugin/ucapplication.cpp'
--- src/Ubuntu/Components/plugin/ucapplication.cpp 2015-06-29 21:08:01 +0000
+++ src/Ubuntu/Components/plugin/ucapplication.cpp 2015-08-05 16:02:14 +0000
@@ -85,3 +85,23 @@
85void UCApplication::setInputMethod(QObject* inputMethod) {85void UCApplication::setInputMethod(QObject* inputMethod) {
86 m_inputMethod = inputMethod;86 m_inputMethod = inputMethod;
87}87}
88
89void UCApplication::showDeprecatedNote(QObject *onItem, const char *note)
90{
91 QQmlContext ctx(QQmlEngine::contextForObject(onItem));
92 // No warnings due to deprecated code used in the components themselves
93 if (ctx.baseUrl().toString().contains("/Ubuntu/Components/"))
94 return;
95 // Warnings without a filename are not helpful
96 if (ctx.baseUrl().isEmpty())
97 return;
98
99 QString noteId(QString("%1.%2").arg(note).arg(onItem->metaObject()->className()));
100 if (m_notes.contains(noteId))
101 return;
102 QByteArray suppressNote = qgetenv("SUPPRESS_DEPRECATED_NOTE");
103 if (suppressNote.isEmpty() || suppressNote != "yes") {
104 qmlInfo(onItem) << note;
105 m_notes.insert(noteId, true);
106 }
107}
88108
=== modified file 'src/Ubuntu/Components/plugin/ucapplication.h'
--- src/Ubuntu/Components/plugin/ucapplication.h 2015-06-29 17:48:58 +0000
+++ src/Ubuntu/Components/plugin/ucapplication.h 2015-08-05 16:02:14 +0000
@@ -20,6 +20,8 @@
20#define UBUNTU_COMPONENTS_APPLICATION_H20#define UBUNTU_COMPONENTS_APPLICATION_H
2121
22#include <QtCore/QObject>22#include <QtCore/QObject>
23#include <QtCore/QHash>
24#include <QtQml/qqmlinfo.h>
2325
24class QQmlContext;26class QQmlContext;
25class QQmlEngine;27class QQmlEngine;
@@ -49,11 +51,14 @@
49 void setContext(QQmlContext* context);51 void setContext(QQmlContext* context);
50 void setApplicationName(const QString& applicationName);52 void setApplicationName(const QString& applicationName);
51 void setInputMethod(QObject* inputMethod);53 void setInputMethod(QObject* inputMethod);
54 void showDeprecatedNote(QObject *onItem, const char *note);
5255
53private:56private:
54 QQmlContext* m_context;57 QQmlContext* m_context;
55 QObject* m_inputMethod;58 QObject* m_inputMethod;
5659
60 QHash<QString, bool> m_notes;
61
57Q_SIGNALS:62Q_SIGNALS:
58 void applicationNameChanged();63 void applicationNameChanged();
59 void inputMethodChanged();64 void inputMethodChanged();
6065
=== 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-05 16:02:14 +0000
@@ -18,12 +18,11 @@
1818
19#include "ucnamespace.h"19#include "ucnamespace.h"
20#include "ucdeprecatedtheme.h"20#include "ucdeprecatedtheme.h"
21#include "ucapplication.h"
21#include "uctheme.h"22#include "uctheme.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>
25#include <QtQml/QQmlInfo>
26#include <QtQml/QQmlEngine>
2726
28/*!27/*!
29 \qmltype Theme28 \qmltype Theme
@@ -66,33 +65,12 @@
66UCDeprecatedTheme::UCDeprecatedTheme(QObject *parent)65UCDeprecatedTheme::UCDeprecatedTheme(QObject *parent)
67 : QObject(parent)66 : QObject(parent)
68{67{
69 m_notes = QHash<QString, bool>();
70 connect(&UCTheme::defaultTheme(), &UCTheme::nameChanged,68 connect(&UCTheme::defaultTheme(), &UCTheme::nameChanged,
71 this, &UCDeprecatedTheme::nameChanged);69 this, &UCDeprecatedTheme::nameChanged);
72 connect(&UCTheme::defaultTheme(), &UCTheme::paletteChanged,70 connect(&UCTheme::defaultTheme(), &UCTheme::paletteChanged,
73 this, &UCDeprecatedTheme::paletteChanged);71 this, &UCDeprecatedTheme::paletteChanged);
74}72}
7573
76void UCDeprecatedTheme::showDeprecatedNote(QObject *onItem, const char *note)
77{
78 QQmlContext ctx(QQmlEngine::contextForObject(onItem));
79 // No warnings due to deprecated code used in the components themselves
80 if (ctx.baseUrl().toString().contains("/Ubuntu/Components/"))
81 return;
82 // Warnings without a filename are not helpful
83 if (ctx.baseUrl().isEmpty())
84 return;
85
86 QString noteId(QString("%1.%2").arg(note).arg(onItem->metaObject()->className()));
87 if (m_notes.contains(noteId))
88 return;
89 QByteArray suppressNote = qgetenv("SUPPRESS_DEPRECATED_NOTE");
90 if (suppressNote.isEmpty() || suppressNote != "yes") {
91 qmlInfo(onItem) << note;
92 m_notes.insert(noteId, true);
93 }
94}
95
96/*!74/*!
97 \qmlproperty string Theme::name75 \qmlproperty string Theme::name
9876
@@ -100,17 +78,17 @@
100*/78*/
101QString UCDeprecatedTheme::name()79QString UCDeprecatedTheme::name()
102{80{
103 showDeprecatedNote(this, "Theme.name is deprecated. Use ThemeSettings instead.");81 UCApplication::instance().showDeprecatedNote(this, "Theme.name is deprecated. Use ThemeSettings instead.");
104 return UCTheme::defaultTheme().name();82 return UCTheme::defaultTheme().name();
105}83}
106void UCDeprecatedTheme::setName(const QString& name)84void UCDeprecatedTheme::setName(const QString& name)
107{85{
108 showDeprecatedNote(this, "Theme.name is deprecated. Use ThemeSettings instead.");86 UCApplication::instance().showDeprecatedNote(this, "Theme.name is deprecated. Use ThemeSettings instead.");
109 UCTheme::defaultTheme().setName(name);87 UCTheme::defaultTheme().setName(name);
110}88}
111void UCDeprecatedTheme::resetName()89void UCDeprecatedTheme::resetName()
112{90{
113 showDeprecatedNote(this, "Theme.name is deprecated. Use ThemeSettings instead.");91 UCApplication::instance().showDeprecatedNote(this, "Theme.name is deprecated. Use ThemeSettings instead.");
114 UCTheme::defaultTheme().resetName();92 UCTheme::defaultTheme().resetName();
115}93}
11694
@@ -121,7 +99,7 @@
121*/99*/
122QObject* UCDeprecatedTheme::palette()100QObject* UCDeprecatedTheme::palette()
123{101{
124 showDeprecatedNote(this, "Theme.palette is deprecated. Use ThemeSettings instead.");102 UCApplication::instance().showDeprecatedNote(this, "Theme.palette is deprecated. Use ThemeSettings instead.");
125 return UCTheme::defaultTheme().palette();103 return UCTheme::defaultTheme().palette();
126}104}
127105
@@ -132,7 +110,7 @@
132*/110*/
133QQmlComponent* UCDeprecatedTheme::createStyleComponent(const QString& styleName, QObject* parent)111QQmlComponent* UCDeprecatedTheme::createStyleComponent(const QString& styleName, QObject* parent)
134{112{
135 showDeprecatedNote(parent, "Theme.createStyleComponent() is deprecated. Use ThemeSettings instead.");113 UCApplication::instance().showDeprecatedNote(parent, "Theme.createStyleComponent() is deprecated. Use ThemeSettings instead.");
136 return UCTheme::defaultTheme().createStyleComponent(styleName, parent, BUILD_VERSION(1, 2));114 return UCTheme::defaultTheme().createStyleComponent(styleName, parent, BUILD_VERSION(1, 2));
137}115}
138116
139117
=== modified file 'src/Ubuntu/Components/plugin/ucdeprecatedtheme.h'
--- src/Ubuntu/Components/plugin/ucdeprecatedtheme.h 2015-05-18 05:42:05 +0000
+++ src/Ubuntu/Components/plugin/ucdeprecatedtheme.h 2015-08-05 16:02:14 +0000
@@ -20,7 +20,6 @@
20#define UCDEPRECATEDTHEME_H20#define UCDEPRECATEDTHEME_H
2121
22#include <QtCore/QObject>22#include <QtCore/QObject>
23#include <QtCore/QHash>
2423
25class QQmlComponent;24class QQmlComponent;
26class QQmlContext;25class QQmlContext;
@@ -49,10 +48,6 @@
49Q_SIGNALS:48Q_SIGNALS:
50 void nameChanged();49 void nameChanged();
51 void paletteChanged();50 void paletteChanged();
52
53private:
54 void showDeprecatedNote(QObject *onItem, const char *note);
55 QHash<QString, bool> m_notes;
56};51};
5752
58#endif // UCDEPRECATEDTHEME_H53#endif // UCDEPRECATEDTHEME_H
5954
=== modified file 'src/Ubuntu/Components/plugin/ucubuntushape.cpp'
--- src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-07-31 09:40:26 +0000
+++ src/Ubuntu/Components/plugin/ucubuntushape.cpp 2015-08-05 16:02:14 +0000
@@ -35,8 +35,8 @@
35#include <QtQuick/QSGTextureProvider>35#include <QtQuick/QSGTextureProvider>
36#include <QtQuick/private/qquickimage_p.h>36#include <QtQuick/private/qquickimage_p.h>
37#include <QtQuick/private/qsgadaptationlayer_p.h>37#include <QtQuick/private/qsgadaptationlayer_p.h>
38#include <QtQml/qqmlinfo.h>
39#include <math.h>38#include <math.h>
39#include "ucapplication.h"
4040
41// Anti-aliasing distance of the contour in pixels.41// Anti-aliasing distance of the contour in pixels.
42const float distanceAApx = 1.75f;42const float distanceAApx = 1.75f;
@@ -794,8 +794,7 @@
794*/794*/
795void UCUbuntuShape::setColor(const QColor& color)795void UCUbuntuShape::setColor(const QColor& color)
796{796{
797 qmlInfo(this) << "'color' is deprecated. Use 'backgroundColor', 'secondaryBackgroundColor' and "797 UCApplication::instance().showDeprecatedNote(this, "'color' is deprecated. Use 'backgroundColor', 'secondaryBackgroundColor' and 'backgroundMode' instead.");
798 "'backgroundMode' instead.";
799798
800 if (!(m_flags & BackgroundApiSet)) {799 if (!(m_flags & BackgroundApiSet)) {
801 const QRgb colorRgb = qRgba(color.red(), color.green(), color.blue(), color.alpha());800 const QRgb colorRgb = qRgba(color.red(), color.green(), color.blue(), color.alpha());
@@ -823,8 +822,7 @@
823*/822*/
824void UCUbuntuShape::setGradientColor(const QColor& gradientColor)823void UCUbuntuShape::setGradientColor(const QColor& gradientColor)
825{824{
826 qmlInfo(this) << "'gradientColor' is deprecated. Use 'backgroundColor', "825 UCApplication::instance().showDeprecatedNote(this, "'gradientColor' is deprecated. Use 'backgroundColor', ");
827 "'secondaryBackgroundColor' and 'backgroundMode' instead.";
828826
829 if (!(m_flags & BackgroundApiSet)) {827 if (!(m_flags & BackgroundApiSet)) {
830 m_flags |= GradientColorSet;828 m_flags |= GradientColorSet;
@@ -850,7 +848,7 @@
850*/848*/
851void UCUbuntuShape::setImage(const QVariant& image)849void UCUbuntuShape::setImage(const QVariant& image)
852{850{
853 qmlInfo(this) << "'image' is deprecated. Use 'source' instead.";851 UCApplication::instance().showDeprecatedNote(this, "'image' is deprecated. Use 'source' instead.");
854852
855 if (!(m_flags & SourceApiSet)) {853 if (!(m_flags & SourceApiSet)) {
856 QQuickItem* newImage = qobject_cast<QQuickItem*>(qvariant_cast<QObject*>(image));854 QQuickItem* newImage = qobject_cast<QQuickItem*>(qvariant_cast<QObject*>(image));
@@ -879,7 +877,7 @@
879// maintain it for a while for compatibility reasons.877// maintain it for a while for compatibility reasons.
880void UCUbuntuShape::setStretched(bool stretched)878void UCUbuntuShape::setStretched(bool stretched)
881{879{
882 qmlInfo(this) << "'stretched' is deprecated. Use 'sourceFillMode' instead";880 UCApplication::instance().showDeprecatedNote(this, "'stretched' is deprecated. Use 'sourceFillMode' instead");
883881
884 if (!(m_flags & SourceApiSet)) {882 if (!(m_flags & SourceApiSet)) {
885 if (!!(m_flags & Stretched) != stretched) {883 if (!!(m_flags & Stretched) != stretched) {
@@ -898,7 +896,7 @@
898// Deprecation layer. Same comment as setStretched().896// Deprecation layer. Same comment as setStretched().
899void UCUbuntuShape::setHorizontalAlignment(HAlignment horizontalAlignment)897void UCUbuntuShape::setHorizontalAlignment(HAlignment horizontalAlignment)
900{898{
901 qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceHorizontalAlignment' instead";899 UCApplication::instance().showDeprecatedNote(this, "'horizontalAlignment' is deprecated. Use 'sourceHorizontalAlignment' instead");
902900
903 if (!(m_flags & SourceApiSet)) {901 if (!(m_flags & SourceApiSet)) {
904 if (m_imageHorizontalAlignment != horizontalAlignment) {902 if (m_imageHorizontalAlignment != horizontalAlignment) {
@@ -913,7 +911,7 @@
913// Deprecation layer. Same comment as setStretched().911// Deprecation layer. Same comment as setStretched().
914void UCUbuntuShape::setVerticalAlignment(VAlignment verticalAlignment)912void UCUbuntuShape::setVerticalAlignment(VAlignment verticalAlignment)
915{913{
916 qmlInfo(this) << "'horizontalAlignment' is deprecated. Use 'sourceVerticalAlignment' instead";914 UCApplication::instance().showDeprecatedNote(this, "'horizontalAlignment' is deprecated. Use 'sourceVerticalAlignment' instead");
917915
918 if (!(m_flags & SourceApiSet)) {916 if (!(m_flags & SourceApiSet)) {
919 if (m_imageVerticalAlignment != verticalAlignment) {917 if (m_imageVerticalAlignment != verticalAlignment) {

Subscribers

People subscribed via source and target branches