Merge lp:~zsombi/ubuntu-ui-toolkit/popup into lp:ubuntu-ui-toolkit/staging

Proposed by Zsombor Egri
Status: Work in progress
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/popup
Merge into: lp:ubuntu-ui-toolkit/staging
Prerequisite: lp:~zsombi/ubuntu-ui-toolkit/fixDefaultTheme
Diff against target: 456 lines (+306/-9)
9 files modified
components.api (+17/-0)
src/Ubuntu/Components/Themes/Ambiance/1.3/BottomEdgeStyle.qml (+1/-0)
src/Ubuntu/Components/plugin/plugin.cpp (+4/-0)
src/Ubuntu/Components/plugin/plugin.pri (+4/-2)
src/Ubuntu/Components/plugin/ucpopup.cpp (+153/-0)
src/Ubuntu/Components/plugin/ucpopup.h (+119/-0)
src/Ubuntu/Components/plugin/uctheme.cpp (+2/-2)
src/Ubuntu/Components/plugin/uctheme.h (+3/-2)
src/Ubuntu/Components/plugin/ucthemingextension.cpp (+3/-3)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/popup
Reviewer Review Type Date Requested Status
Ubuntu SDK team Pending
Review via email: mp+282152@code.launchpad.net

Commit message

New Popup component.

To post a comment you must log in.

Unmerged revisions

1800. By Zsombor Egri

prereq sync

1799. By Zsombor Egri

attachItem to accept UCThemingExtensions

1798. By Zsombor Egri

Popup added

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'components.api'
--- components.api 2015-12-19 10:06:24 +0000
+++ components.api 2016-01-11 10:15:15 +0000
@@ -935,6 +935,17 @@
935 function var show()935 function var show()
936 function var hide()936 function var hide()
937 property Item pointerTarget937 property Item pointerTarget
938Ubuntu.Components.Popup 1.3 UCPopup: Window
939 property Item caller
940 property bool hasPointer
941 signal aboutToOpen()
942 signal opened()
943 signal aboutToClose()
944 signal closed()
945 function open()
946 function close()
947 property PopupPositioning positioning
948 property string styleName
938Ubuntu.Components.Popups.PopupBase 1.0 0.1: OrientationHelper949Ubuntu.Components.Popups.PopupBase 1.0 0.1: OrientationHelper
939 property Item dismissArea950 property Item dismissArea
940 property PropertyAnimation fadingAnimation951 property PropertyAnimation fadingAnimation
@@ -947,6 +958,12 @@
947 property bool grabDismissAreaEvents958 property bool grabDismissAreaEvents
948 function var show()959 function var show()
949 function var hide()960 function var hide()
961Ubuntu.Components.PopupPosition 1.3 UCPopupPosition: QtObject
962 property Qt.Alignment align
963 property QPointF distanceFromCaller
964 property double pointerOffset
965Ubuntu.Components.PopupPositioning 1.3 UCPopupPositioning: QtObject
966 property list<PopupPosition> positions
950Ubuntu.Components.Popups.PopupUtils 0.1 1.0 1.3967Ubuntu.Components.Popups.PopupUtils 0.1 1.0 1.3
951Ubuntu.Components.ProgressBar 1.0 0.1: AnimatedItem968Ubuntu.Components.ProgressBar 1.0 0.1: AnimatedItem
952 property bool indeterminate969 property bool indeterminate
953970
=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/BottomEdgeStyle.qml'
--- src/Ubuntu/Components/Themes/Ambiance/1.3/BottomEdgeStyle.qml 2015-12-10 16:39:45 +0000
+++ src/Ubuntu/Components/Themes/Ambiance/1.3/BottomEdgeStyle.qml 2016-01-11 10:15:15 +0000
@@ -118,6 +118,7 @@
118 target: bottomEdge118 target: bottomEdge
119 onCommitStarted: loader.asynchronous = false119 onCommitStarted: loader.asynchronous = false
120 onCommitCompleted: loader.asynchronous = true120 onCommitCompleted: loader.asynchronous = true
121 onStatusChanged: print("BottomEdge.status", bottomEdge.status)
121 }122 }
122 }123 }
123 }124 }
124125
=== modified file 'src/Ubuntu/Components/plugin/plugin.cpp'
--- src/Ubuntu/Components/plugin/plugin.cpp 2016-01-11 10:15:14 +0000
+++ src/Ubuntu/Components/plugin/plugin.cpp 2016-01-11 10:15:15 +0000
@@ -76,6 +76,7 @@
76#include "ucbottomedgeregion.h"76#include "ucbottomedgeregion.h"
77#include "ucbottomedgestyle.h"77#include "ucbottomedgestyle.h"
78#include "ucpagetreenode.h"78#include "ucpagetreenode.h"
79#include "ucpopup.h"
7980
80// From UbuntuGestures81// From UbuntuGestures
81#include "private/ucswipearea_p.h"82#include "private/ucswipearea_p.h"
@@ -263,6 +264,9 @@
263 qmlRegisterType<UCBottomEdge>(uri, 1, 3, "BottomEdge");264 qmlRegisterType<UCBottomEdge>(uri, 1, 3, "BottomEdge");
264 qmlRegisterType<UCBottomEdgeRegion>(uri, 1, 3, "BottomEdgeRegion");265 qmlRegisterType<UCBottomEdgeRegion>(uri, 1, 3, "BottomEdgeRegion");
265 qmlRegisterType<UCPageTreeNode>(uri, 1, 3, "PageTreeNode");266 qmlRegisterType<UCPageTreeNode>(uri, 1, 3, "PageTreeNode");
267 qmlRegisterType<UCPopup>(uri, 1, 3, "Popup");
268 qmlRegisterType<UCPopupPositioning>(uri, 1, 3, "PopupPositioning");
269 qmlRegisterType<UCPopupPosition>(uri, 1, 3, "PopupPosition");
266}270}
267271
268void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)272void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
269273
=== modified file 'src/Ubuntu/Components/plugin/plugin.pri'
--- src/Ubuntu/Components/plugin/plugin.pri 2015-12-17 15:23:26 +0000
+++ src/Ubuntu/Components/plugin/plugin.pri 2016-01-11 10:15:15 +0000
@@ -106,7 +106,8 @@
106 $$PWD/ucbottomedgestyle.h \106 $$PWD/ucbottomedgestyle.h \
107 $$PWD/ucbottomedgeregion.h \107 $$PWD/ucbottomedgeregion.h \
108 $$PWD/ucpagetreenode.h \108 $$PWD/ucpagetreenode.h \
109 $$PWD/ucpagetreenode_p.h109 $$PWD/ucpagetreenode_p.h \
110 $$PWD/ucpopup.h
110111
111SOURCES += $$PWD/plugin.cpp \112SOURCES += $$PWD/plugin.cpp \
112 $$PWD/uctheme.cpp \113 $$PWD/uctheme.cpp \
@@ -176,7 +177,8 @@
176 $$PWD/ucbottomedge.cpp \177 $$PWD/ucbottomedge.cpp \
177 $$PWD/ucbottomedgestyle.cpp \178 $$PWD/ucbottomedgestyle.cpp \
178 $$PWD/ucbottomedgeregion.cpp \179 $$PWD/ucbottomedgeregion.cpp \
179 $$PWD/ucpagetreenode.cpp180 $$PWD/ucpagetreenode.cpp \
181 $$PWD/ucpopup.cpp
180182
181# adapters183# adapters
182SOURCES += $$PWD/adapters/alarmsadapter_organizer.cpp184SOURCES += $$PWD/adapters/alarmsadapter_organizer.cpp
183185
=== added file 'src/Ubuntu/Components/plugin/ucpopup.cpp'
--- src/Ubuntu/Components/plugin/ucpopup.cpp 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/plugin/ucpopup.cpp 2016-01-11 10:15:15 +0000
@@ -0,0 +1,153 @@
1/*
2 * Copyright (C) 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 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Zsombor Egri <zsombor.egri@canonical.com>
17 */
18
19#include "ucpopup.h"
20
21UCPopupPosition::UCPopupPosition(QObject *parent)
22 : QObject(parent)
23{
24}
25
26Qt::Alignment UCPopupPosition::align() const
27{
28 return m_align;
29}
30void UCPopupPosition::setAlign(Qt::Alignment align)
31{
32 if (m_align == align) {
33 return;
34 }
35 m_align = align;
36 Q_EMIT alignChanged();
37}
38
39QPointF UCPopupPosition::distanceFromCaller() const
40{
41 return m_distanceFromCaller;
42}
43void UCPopupPosition::setDistanceFromCaller(const QPointF &distance)
44{
45 if (m_distanceFromCaller == distance) {
46 return;
47 }
48 m_distanceFromCaller = distance;
49 Q_EMIT distanceFromCallerChanged();
50}
51
52qreal UCPopupPosition::pointerOffset() const
53{
54 return m_pointerOffset;
55}
56void UCPopupPosition::setPointerOffset(qreal offset)
57{
58 if (m_pointerOffset == offset) {
59 return;
60 }
61 m_pointerOffset = offset;
62 Q_EMIT pointerOffsetChanged();
63}
64
65
66UCPopupPositioning::UCPopupPositioning(QObject *parent)
67 : QObject(parent)
68{
69}
70
71QList<UCPopupPosition*> UCPopupPositioning::positionsList()
72{
73 return m_positions;
74}
75
76QQmlListProperty<UCPopupPosition> UCPopupPositioning::positions()
77{
78 return QQmlListProperty<UCPopupPosition>(this, m_positions);
79}
80
81
82UCPopup::UCPopup(QWindow *parent)
83 : QQuickWindow(parent)
84{
85}
86UCPopup::UCPopup(QQuickRenderControl *renderControl)
87 : QQuickWindow(renderControl)
88{
89}
90
91QString UCPopup::styleName() const
92{
93 return m_styleName;
94}
95void UCPopup::setStyleName(const QString &name)
96{
97 if (m_styleName == name) {
98 return;
99 }
100 m_styleName = name;
101 Q_EMIT styleNameChanged();
102}
103
104UCPopupPositioning *UCPopup::positioning() const
105{
106 return m_positioning;
107}
108void UCPopup::setPositioning(UCPopupPositioning *positioning)
109{
110 if (m_positioning == positioning) {
111 return;
112 }
113 m_positioning = positioning;
114 Q_EMIT positioningChanged();
115}
116
117QQuickItem *UCPopup::caller() const
118{
119 return m_caller;
120}
121void UCPopup::setCaller(QQuickItem *caller)
122{
123 if (m_caller == caller) {
124 return;
125 }
126 m_caller = caller;
127 Q_EMIT callerChanged();
128}
129
130bool UCPopup::hasPointer() const
131{
132 return m_hasPointer;
133}
134void UCPopup::setHasPointer(bool hasPointer)
135{
136 if (m_hasPointer == hasPointer) {
137 return;
138 }
139 m_hasPointer = hasPointer;
140 Q_EMIT hasPointerChanged();
141}
142
143void UCPopup::open()
144{
145 setVisible(true);
146}
147
148void UCPopup::close()
149{
150 setVisible(false);
151}
152
153#include "moc_ucpopup.cpp"
0154
=== added file 'src/Ubuntu/Components/plugin/ucpopup.h'
--- src/Ubuntu/Components/plugin/ucpopup.h 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/plugin/ucpopup.h 2016-01-11 10:15:15 +0000
@@ -0,0 +1,119 @@
1/*
2 * Copyright (C) 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 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 General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Author: Zsombor Egri <zsombor.egri@canonical.com>
17 */
18
19#ifndef UCPOPUP_H
20#define UCPOPUP_H
21
22#include <QtCore/QObject>
23#include <QtQuick/QQuickItem>
24#include <QtQml/QQmlListProperty>
25#include "ucthemingextension.h"
26
27class UCPopupPosition : public QObject
28{
29 Q_OBJECT
30 Q_PROPERTY(Qt::Alignment align READ align WRITE setAlign NOTIFY alignChanged FINAL)
31 Q_PROPERTY(QPointF distanceFromCaller READ distanceFromCaller WRITE setDistanceFromCaller NOTIFY distanceFromCallerChanged FINAL)
32 Q_PROPERTY(qreal pointerOffset READ pointerOffset WRITE setPointerOffset NOTIFY pointerOffsetChanged FINAL)
33public:
34 explicit UCPopupPosition(QObject *parent = 0);
35
36 Qt::Alignment align() const;
37 void setAlign(Qt::Alignment align);
38 QPointF distanceFromCaller() const;
39 void setDistanceFromCaller(const QPointF &distance);
40 qreal pointerOffset() const;
41 void setPointerOffset(qreal offset);
42
43
44Q_SIGNALS:
45 void alignChanged();
46 void distanceFromCallerChanged();
47 void pointerOffsetChanged();
48
49private:
50 QPointF m_distanceFromCaller;
51 qreal m_pointerOffset = -1;
52 Qt::Alignment m_align = 0;
53};
54
55class UCPopupPositioning : public QObject
56{
57 Q_OBJECT
58 Q_PROPERTY(QQmlListProperty<UCPopupPosition> positions READ positions)
59public:
60 explicit UCPopupPositioning(QObject *parent = 0);
61
62 QList<UCPopupPosition*> positionsList();
63 QQmlListProperty<UCPopupPosition> positions();
64
65private:
66 QList<UCPopupPosition*> m_positions;
67};
68
69// FIXME: when we move on Qt 5.5, make sure we derive from QQuickWindowQmlImpl!
70class UCPopup : public QQuickWindow//, public UCThemingExtension
71{
72 Q_OBJECT
73// Q_INTERFACES(UCThemingExtension)
74// Q_PROPERTY(UCTheme theme READ getTheme WRITE setTheme NOTIFY themeChanged FINAL)
75 Q_PROPERTY(QString styleName READ styleName WRITE setStyleName NOTIFY styleNameChanged FINAL)
76 Q_PROPERTY(UCPopupPositioning *positioning READ positioning WRITE setPositioning NOTIFY positioningChanged FINAL)
77 Q_PROPERTY(QQuickItem *caller READ caller WRITE setCaller NOTIFY callerChanged FINAL)
78 Q_PROPERTY(bool hasPointer READ hasPointer WRITE setHasPointer NOTIFY hasPointerChanged FINAL)
79public:
80 UCPopup(QWindow *parent = 0);
81 explicit UCPopup(QQuickRenderControl *renderControl);
82
83 QString styleName() const;
84 void setStyleName(const QString &name);
85 UCPopupPositioning *positioning() const;
86 void setPositioning(UCPopupPositioning *positioning);
87 QQuickItem *caller() const;
88 void setCaller(QQuickItem *caller);
89 bool hasPointer() const;
90 void setHasPointer(bool hasPointer);
91
92protected:
93// void preThemeChanged() override {}
94// void postThemeChanged() override {}
95
96public Q_SLOTS:
97 void open();
98 void close();
99
100Q_SIGNALS:
101 void themeChanged();
102 void styleNameChanged();
103 void positioningChanged();
104 void callerChanged();
105 void hasPointerChanged();
106
107 void aboutToOpen();
108 void opened();
109 void aboutToClose();
110 void closed();
111
112private:
113 QString m_styleName;
114 UCPopupPositioning *m_positioning = nullptr;
115 QQuickItem *m_caller = nullptr;
116 bool m_hasPointer = true;
117};
118
119#endif // UCPOPUP_H
0120
=== modified file 'src/Ubuntu/Components/plugin/uctheme.cpp'
--- src/Ubuntu/Components/plugin/uctheme.cpp 2016-01-11 10:15:14 +0000
+++ src/Ubuntu/Components/plugin/uctheme.cpp 2016-01-11 10:15:15 +0000
@@ -641,7 +641,7 @@
641 listener, &ContextPropertyChangeListener::updateContextProperty);641 listener, &ContextPropertyChangeListener::updateContextProperty);
642}642}
643643
644void UCTheme::attachItem(QQuickItem *item, bool attach)644void UCTheme::attachItem(UCThemingExtension *item, bool attach)
645{645{
646 if (attach) {646 if (attach) {
647 m_attachedItems.append(item);647 m_attachedItems.append(item);
@@ -653,7 +653,7 @@
653void UCTheme::updateThemedItems()653void UCTheme::updateThemedItems()
654{654{
655 for (int i = 0; i < m_attachedItems.count(); i++) {655 for (int i = 0; i < m_attachedItems.count(); i++) {
656 UCThemingExtension *extension = qobject_cast<UCThemingExtension*>(m_attachedItems[i]);656 UCThemingExtension *extension = m_attachedItems[i];
657 if (extension) {657 if (extension) {
658 extension->itemThemeReloaded(this);658 extension->itemThemeReloaded(this);
659 }659 }
660660
=== modified file 'src/Ubuntu/Components/plugin/uctheme.h'
--- src/Ubuntu/Components/plugin/uctheme.h 2016-01-11 10:15:14 +0000
+++ src/Ubuntu/Components/plugin/uctheme.h 2016-01-11 10:15:15 +0000
@@ -35,6 +35,7 @@
35class UCStyledItemBase;35class UCStyledItemBase;
36class QQmlAbstractBinding;36class QQmlAbstractBinding;
37class QQuickItem;37class QQuickItem;
38class UCThemingExtension;
38class UCTheme : public QObject, public QQmlParserStatus39class UCTheme : public QObject, public QQmlParserStatus
39{40{
40 Q_OBJECT41 Q_OBJECT
@@ -79,7 +80,7 @@
79 // internal, used by the deprecated Theme.createStyledComponent()80 // internal, used by the deprecated Theme.createStyledComponent()
80 QQmlComponent* createStyleComponent(const QString& styleName, QObject* parent, quint16 version = 0);81 QQmlComponent* createStyleComponent(const QString& styleName, QObject* parent, quint16 version = 0);
81 static void createDefaultTheme(QQmlEngine* engine);82 static void createDefaultTheme(QQmlEngine* engine);
82 void attachItem(QQuickItem *item, bool attach);83 void attachItem(UCThemingExtension *item, bool attach);
8384
84 // helper functions85 // helper functions
85 QColor getPaletteColor(const char *profile, const char *color);86 QColor getPaletteColor(const char *profile, const char *color);
@@ -160,7 +161,7 @@
160 QPointer<QObject> m_palette; // the palette might be from the default style if the theme doesn't define palette161 QPointer<QObject> m_palette; // the palette might be from the default style if the theme doesn't define palette
161 QList<ThemeRecord> m_themePaths;162 QList<ThemeRecord> m_themePaths;
162 UCDefaultTheme m_defaultTheme;163 UCDefaultTheme m_defaultTheme;
163 QPODVector<QQuickItem*, 4> m_attachedItems;164 QPODVector<UCThemingExtension*, 4> m_attachedItems;
164 bool m_completed:1;165 bool m_completed:1;
165166
166 friend class UCDeprecatedTheme;167 friend class UCDeprecatedTheme;
167168
=== modified file 'src/Ubuntu/Components/plugin/ucthemingextension.cpp'
--- src/Ubuntu/Components/plugin/ucthemingextension.cpp 2016-01-11 10:15:14 +0000
+++ src/Ubuntu/Components/plugin/ucthemingextension.cpp 2016-01-11 10:15:15 +0000
@@ -159,7 +159,7 @@
159UCThemingExtension::~UCThemingExtension()159UCThemingExtension::~UCThemingExtension()
160{160{
161 if (theme) {161 if (theme) {
162 theme->attachItem(themedItem, false);162 theme->attachItem(this, false);
163 }163 }
164}164}
165165
@@ -240,14 +240,14 @@
240240
241 // disconnect from the previous set241 // disconnect from the previous set
242 if (theme) {242 if (theme) {
243 theme->attachItem(themedItem, false);243 theme->attachItem(this, false);
244 }244 }
245245
246 theme = newTheme;246 theme = newTheme;
247247
248 // connect to the new set248 // connect to the new set
249 if (theme) {249 if (theme) {
250 theme->attachItem(themedItem, true);250 theme->attachItem(this, true);
251 // set the parent of the theme if custom251 // set the parent of the theme if custom
252 setParentTheme();252 setParentTheme();
253 }253 }

Subscribers

People subscribed via source and target branches