~ubuntu-branches/ubuntu/wily/ubuntu-ui-toolkit/wily-proposed

« back to all changes in this revision

Viewing changes to src/Ubuntu/Components/plugin/ucdeprecatedtheme.cpp

  • Committer: Package Import Robot
  • Author(s): CI Train Bot, Florian Boucault, Loïc Molinari, Benjamin Zeller, Richard Huddie, Tim Peeters, Zsombor Egri, Timo Jyrinki, Christian Dywan, Albert Astals Cid
  • Date: 2015-07-30 13:04:18 UTC
  • mfrom: (1.1.126)
  • Revision ID: package-import@ubuntu.com-20150730130418-nxjr780u6wqcdqeh
Tags: 1.3.1584+15.10.20150730-0ubuntu1
[ Florian Boucault ]
* New BottomEdgeHint component to represent extra features available from the 
  bottom edge of an application.

[ Loïc Molinari ]
* [UbuntuShape] Added a big radius.
* [UbuntuShape] Added relative radius support. Fixes LP: #1478124.
* Ensured components, styles, examples and tests use the new UbuntuShape 
  properties (not deprecated). Fixes LP: #1437412.

[ Benjamin Zeller ]
* Make use of the official qt build macros to blend into the Qt buildprocess.
* Fix debug builds, optimization is always enabled by the system qt build.

[ Richard Huddie ]
* Fix for autopilot bug lp:1476715. Don't throw an exception if maliit-server
  is not found. Fixes LP: #1476715.

[ Tim Peeters ]
* Clean up the MainView docs.
* Set theme version for Sections component.
* Implement AdaptivePageLayout.

[ Zsombor Egri ]
* Fix width for trailing and leading actions of a ListItem. Fixes LP: #1465582.
* Button and Haptics import wrong toolkit versions, thus they break style 
  versioning. Moving Icon and ProgressBar to 1.0 and 1.1 version source folder.
* SuruDark theme for ListItem style. Fixes LP: #1451225.
* Swiping ListItem when no actions are defined for the gesture breaks 
  selectMode. Fixes LP: #1468100.
* Fixing selected connection with the ListItem's select mode checkbox state. 
  Fixes LP: #1461501, LP: #1469471.

[ Timo Jyrinki ]
* Fix ucstylehints.cpp compilation with Qt 5.5. Fixes LP: #1473873.
* Add PageHeadStyle 1.3 reference to fix install_plugins_qmltypes failure with 
  Qt 5.5. Fixes LP: #1466484.

[ Christian Dywan ]
* Avoid hard-coded skipping of members by name "type" can be a property name 
  regardless of also being a field in the JSON description of a property.
* Add apicheck unit test for QML and Javascript.
* Remove "do cleanup" comments. Fixes LP: #1369874.
* Initialize defaultTypes later to avoid bogus types.
* Implement Action.shortcut property. Fixes LP: #1202464.
* Update text handler to 3gu assert.
* Add a deprecated note to ListItems.ThinDivider. Fixes LP: #1470951.
* Don't include overridden properties in API.
* Clean-up API check wrapper scripts.
* Track version members were introduced.
* Implement ListItemPopover on right-click. Fixes LP: #1452676.
* Move delegate's chevron into the row and size it explicitly. 
  Fixes LP: #1474418.
* Enable (Shift)Tab via activeFocusOnTab. Fixes LP: #1276797.
* Only swipe with left button and block timer otherwise. 
  Fixes LP: #1476300, LP: #1476310.
* Include Javascript libraries in QML documentation. Fixes LP: #1466058.

[ Albert Astals Cid ]
* Fix warning if there's no __propagated
* TypeError: Cannot call method 'hasOwnProperty' of null.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2015 Canonical Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU Lesser General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authors: Zsombor Egri <zsombor.egri@canonical.com>
 
17
 */
 
18
 
 
19
#include "ucnamespace.h"
 
20
#include "ucdeprecatedtheme.h"
 
21
#include "uctheme.h"
 
22
#include "listener.h"
 
23
#include <QtQml/QQmlComponent>
 
24
#include <QtQml/QQmlContext>
 
25
#include <QtQml/QQmlInfo>
 
26
#include <QtQml/QQmlEngine>
 
27
 
 
28
/*!
 
29
    \qmltype Theme
 
30
    \instantiates UCTheme
 
31
    \inqmlmodule Ubuntu.Components 1.1
 
32
    \ingroup theming
 
33
    \brief The Theme class provides facilities to interact with the current theme.
 
34
 
 
35
    A global instance is exposed as the \b Theme context property.
 
36
 
 
37
    The theme defines the visual aspect of the Ubuntu components.
 
38
 
 
39
    Example changing the current theme:
 
40
 
 
41
    \qml
 
42
    import QtQuick 2.4
 
43
    import Ubuntu.Components 1.2
 
44
 
 
45
    Item {
 
46
        Button {
 
47
            onClicked: Theme.name = "Ubuntu.Components.Themes.Ambiance"
 
48
        }
 
49
    }
 
50
    \endqml
 
51
 
 
52
    Example creating a style component:
 
53
 
 
54
    \qml
 
55
    import QtQuick 2.4
 
56
    import Ubuntu.Components 1.2
 
57
 
 
58
    StyledItem {
 
59
        id: myItem
 
60
        style: Theme.createStyleComponent("MyItemStyle.qml", myItem)
 
61
    }
 
62
    \endqml
 
63
 
 
64
    \sa {StyledItem}
 
65
*/
 
66
UCDeprecatedTheme::UCDeprecatedTheme(QObject *parent)
 
67
    : QObject(parent)
 
68
{
 
69
    m_notes = QHash<QString, bool>();
 
70
    connect(&UCTheme::defaultTheme(), &UCTheme::nameChanged,
 
71
            this, &UCDeprecatedTheme::nameChanged);
 
72
    connect(&UCTheme::defaultTheme(), &UCTheme::paletteChanged,
 
73
            this, &UCDeprecatedTheme::paletteChanged);
 
74
}
 
75
 
 
76
void 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
/*!
 
97
    \qmlproperty string Theme::name
 
98
 
 
99
    The name of the current theme.
 
100
*/
 
101
QString UCDeprecatedTheme::name()
 
102
{
 
103
    showDeprecatedNote(this, "Theme.name is deprecated. Use ThemeSettings instead.");
 
104
    return UCTheme::defaultTheme().name();
 
105
}
 
106
void UCDeprecatedTheme::setName(const QString& name)
 
107
{
 
108
    showDeprecatedNote(this, "Theme.name is deprecated. Use ThemeSettings instead.");
 
109
    UCTheme::defaultTheme().setName(name);
 
110
}
 
111
void UCDeprecatedTheme::resetName()
 
112
{
 
113
    showDeprecatedNote(this, "Theme.name is deprecated. Use ThemeSettings instead.");
 
114
    UCTheme::defaultTheme().resetName();
 
115
}
 
116
 
 
117
/*!
 
118
    \qmlproperty Palette Theme::palette
 
119
 
 
120
    The palette of the current theme.
 
121
*/
 
122
QObject* UCDeprecatedTheme::palette()
 
123
{
 
124
    showDeprecatedNote(this, "Theme.palette is deprecated. Use ThemeSettings instead.");
 
125
    return UCTheme::defaultTheme().palette();
 
126
}
 
127
 
 
128
/*!
 
129
    \qmlmethod Component Theme::createStyleComponent(string styleName, object parent)
 
130
 
 
131
    Returns an instance of the style component named \a styleName.
 
132
*/
 
133
QQmlComponent* UCDeprecatedTheme::createStyleComponent(const QString& styleName, QObject* parent)
 
134
{
 
135
    showDeprecatedNote(parent, "Theme.createStyleComponent() is deprecated. Use ThemeSettings instead.");
 
136
    return UCTheme::defaultTheme().createStyleComponent(styleName, parent, BUILD_VERSION(1, 2));
 
137
}
 
138
 
 
139
void UCDeprecatedTheme::registerToContext(QQmlContext* context)
 
140
{
 
141
    UCTheme::defaultTheme().m_engine = context->engine();
 
142
    UCTheme::defaultTheme().updateEnginePaths();
 
143
    // register deprecated Theme property
 
144
    context->setContextProperty("Theme", this);
 
145
 
 
146
    ContextPropertyChangeListener *themeChangeListener =
 
147
        new ContextPropertyChangeListener(context, "Theme");
 
148
    QObject::connect(this, SIGNAL(nameChanged()),
 
149
                     themeChangeListener, SLOT(updateContextProperty()));
 
150
}