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 on 2016-01-11

prereq sync

1799. By Zsombor Egri on 2016-01-08

attachItem to accept UCThemingExtensions

1798. By Zsombor Egri on 2016-01-07

Popup added

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components.api'
2--- components.api 2015-12-19 10:06:24 +0000
3+++ components.api 2016-01-11 10:15:15 +0000
4@@ -935,6 +935,17 @@
5 function var show()
6 function var hide()
7 property Item pointerTarget
8+Ubuntu.Components.Popup 1.3 UCPopup: Window
9+ property Item caller
10+ property bool hasPointer
11+ signal aboutToOpen()
12+ signal opened()
13+ signal aboutToClose()
14+ signal closed()
15+ function open()
16+ function close()
17+ property PopupPositioning positioning
18+ property string styleName
19 Ubuntu.Components.Popups.PopupBase 1.0 0.1: OrientationHelper
20 property Item dismissArea
21 property PropertyAnimation fadingAnimation
22@@ -947,6 +958,12 @@
23 property bool grabDismissAreaEvents
24 function var show()
25 function var hide()
26+Ubuntu.Components.PopupPosition 1.3 UCPopupPosition: QtObject
27+ property Qt.Alignment align
28+ property QPointF distanceFromCaller
29+ property double pointerOffset
30+Ubuntu.Components.PopupPositioning 1.3 UCPopupPositioning: QtObject
31+ property list<PopupPosition> positions
32 Ubuntu.Components.Popups.PopupUtils 0.1 1.0 1.3
33 Ubuntu.Components.ProgressBar 1.0 0.1: AnimatedItem
34 property bool indeterminate
35
36=== modified file 'src/Ubuntu/Components/Themes/Ambiance/1.3/BottomEdgeStyle.qml'
37--- src/Ubuntu/Components/Themes/Ambiance/1.3/BottomEdgeStyle.qml 2015-12-10 16:39:45 +0000
38+++ src/Ubuntu/Components/Themes/Ambiance/1.3/BottomEdgeStyle.qml 2016-01-11 10:15:15 +0000
39@@ -118,6 +118,7 @@
40 target: bottomEdge
41 onCommitStarted: loader.asynchronous = false
42 onCommitCompleted: loader.asynchronous = true
43+ onStatusChanged: print("BottomEdge.status", bottomEdge.status)
44 }
45 }
46 }
47
48=== modified file 'src/Ubuntu/Components/plugin/plugin.cpp'
49--- src/Ubuntu/Components/plugin/plugin.cpp 2016-01-11 10:15:14 +0000
50+++ src/Ubuntu/Components/plugin/plugin.cpp 2016-01-11 10:15:15 +0000
51@@ -76,6 +76,7 @@
52 #include "ucbottomedgeregion.h"
53 #include "ucbottomedgestyle.h"
54 #include "ucpagetreenode.h"
55+#include "ucpopup.h"
56
57 // From UbuntuGestures
58 #include "private/ucswipearea_p.h"
59@@ -263,6 +264,9 @@
60 qmlRegisterType<UCBottomEdge>(uri, 1, 3, "BottomEdge");
61 qmlRegisterType<UCBottomEdgeRegion>(uri, 1, 3, "BottomEdgeRegion");
62 qmlRegisterType<UCPageTreeNode>(uri, 1, 3, "PageTreeNode");
63+ qmlRegisterType<UCPopup>(uri, 1, 3, "Popup");
64+ qmlRegisterType<UCPopupPositioning>(uri, 1, 3, "PopupPositioning");
65+ qmlRegisterType<UCPopupPosition>(uri, 1, 3, "PopupPosition");
66 }
67
68 void UbuntuComponentsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
69
70=== modified file 'src/Ubuntu/Components/plugin/plugin.pri'
71--- src/Ubuntu/Components/plugin/plugin.pri 2015-12-17 15:23:26 +0000
72+++ src/Ubuntu/Components/plugin/plugin.pri 2016-01-11 10:15:15 +0000
73@@ -106,7 +106,8 @@
74 $$PWD/ucbottomedgestyle.h \
75 $$PWD/ucbottomedgeregion.h \
76 $$PWD/ucpagetreenode.h \
77- $$PWD/ucpagetreenode_p.h
78+ $$PWD/ucpagetreenode_p.h \
79+ $$PWD/ucpopup.h
80
81 SOURCES += $$PWD/plugin.cpp \
82 $$PWD/uctheme.cpp \
83@@ -176,7 +177,8 @@
84 $$PWD/ucbottomedge.cpp \
85 $$PWD/ucbottomedgestyle.cpp \
86 $$PWD/ucbottomedgeregion.cpp \
87- $$PWD/ucpagetreenode.cpp
88+ $$PWD/ucpagetreenode.cpp \
89+ $$PWD/ucpopup.cpp
90
91 # adapters
92 SOURCES += $$PWD/adapters/alarmsadapter_organizer.cpp
93
94=== added file 'src/Ubuntu/Components/plugin/ucpopup.cpp'
95--- src/Ubuntu/Components/plugin/ucpopup.cpp 1970-01-01 00:00:00 +0000
96+++ src/Ubuntu/Components/plugin/ucpopup.cpp 2016-01-11 10:15:15 +0000
97@@ -0,0 +1,153 @@
98+/*
99+ * Copyright (C) 2015 Canonical, Ltd.
100+ *
101+ * This program is free software; you can redistribute it and/or modify
102+ * it under the terms of the GNU General Public License as published by
103+ * the Free Software Foundation; version 3.
104+ *
105+ * This program is distributed in the hope that it will be useful,
106+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
107+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
108+ * GNU General Public License for more details.
109+ *
110+ * You should have received a copy of the GNU General Public License
111+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
112+ *
113+ * Author: Zsombor Egri <zsombor.egri@canonical.com>
114+ */
115+
116+#include "ucpopup.h"
117+
118+UCPopupPosition::UCPopupPosition(QObject *parent)
119+ : QObject(parent)
120+{
121+}
122+
123+Qt::Alignment UCPopupPosition::align() const
124+{
125+ return m_align;
126+}
127+void UCPopupPosition::setAlign(Qt::Alignment align)
128+{
129+ if (m_align == align) {
130+ return;
131+ }
132+ m_align = align;
133+ Q_EMIT alignChanged();
134+}
135+
136+QPointF UCPopupPosition::distanceFromCaller() const
137+{
138+ return m_distanceFromCaller;
139+}
140+void UCPopupPosition::setDistanceFromCaller(const QPointF &distance)
141+{
142+ if (m_distanceFromCaller == distance) {
143+ return;
144+ }
145+ m_distanceFromCaller = distance;
146+ Q_EMIT distanceFromCallerChanged();
147+}
148+
149+qreal UCPopupPosition::pointerOffset() const
150+{
151+ return m_pointerOffset;
152+}
153+void UCPopupPosition::setPointerOffset(qreal offset)
154+{
155+ if (m_pointerOffset == offset) {
156+ return;
157+ }
158+ m_pointerOffset = offset;
159+ Q_EMIT pointerOffsetChanged();
160+}
161+
162+
163+UCPopupPositioning::UCPopupPositioning(QObject *parent)
164+ : QObject(parent)
165+{
166+}
167+
168+QList<UCPopupPosition*> UCPopupPositioning::positionsList()
169+{
170+ return m_positions;
171+}
172+
173+QQmlListProperty<UCPopupPosition> UCPopupPositioning::positions()
174+{
175+ return QQmlListProperty<UCPopupPosition>(this, m_positions);
176+}
177+
178+
179+UCPopup::UCPopup(QWindow *parent)
180+ : QQuickWindow(parent)
181+{
182+}
183+UCPopup::UCPopup(QQuickRenderControl *renderControl)
184+ : QQuickWindow(renderControl)
185+{
186+}
187+
188+QString UCPopup::styleName() const
189+{
190+ return m_styleName;
191+}
192+void UCPopup::setStyleName(const QString &name)
193+{
194+ if (m_styleName == name) {
195+ return;
196+ }
197+ m_styleName = name;
198+ Q_EMIT styleNameChanged();
199+}
200+
201+UCPopupPositioning *UCPopup::positioning() const
202+{
203+ return m_positioning;
204+}
205+void UCPopup::setPositioning(UCPopupPositioning *positioning)
206+{
207+ if (m_positioning == positioning) {
208+ return;
209+ }
210+ m_positioning = positioning;
211+ Q_EMIT positioningChanged();
212+}
213+
214+QQuickItem *UCPopup::caller() const
215+{
216+ return m_caller;
217+}
218+void UCPopup::setCaller(QQuickItem *caller)
219+{
220+ if (m_caller == caller) {
221+ return;
222+ }
223+ m_caller = caller;
224+ Q_EMIT callerChanged();
225+}
226+
227+bool UCPopup::hasPointer() const
228+{
229+ return m_hasPointer;
230+}
231+void UCPopup::setHasPointer(bool hasPointer)
232+{
233+ if (m_hasPointer == hasPointer) {
234+ return;
235+ }
236+ m_hasPointer = hasPointer;
237+ Q_EMIT hasPointerChanged();
238+}
239+
240+void UCPopup::open()
241+{
242+ setVisible(true);
243+}
244+
245+void UCPopup::close()
246+{
247+ setVisible(false);
248+}
249+
250+#include "moc_ucpopup.cpp"
251
252=== added file 'src/Ubuntu/Components/plugin/ucpopup.h'
253--- src/Ubuntu/Components/plugin/ucpopup.h 1970-01-01 00:00:00 +0000
254+++ src/Ubuntu/Components/plugin/ucpopup.h 2016-01-11 10:15:15 +0000
255@@ -0,0 +1,119 @@
256+/*
257+ * Copyright (C) 2015 Canonical, Ltd.
258+ *
259+ * This program is free software; you can redistribute it and/or modify
260+ * it under the terms of the GNU General Public License as published by
261+ * the Free Software Foundation; version 3.
262+ *
263+ * This program is distributed in the hope that it will be useful,
264+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
265+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
266+ * GNU General Public License for more details.
267+ *
268+ * You should have received a copy of the GNU General Public License
269+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
270+ *
271+ * Author: Zsombor Egri <zsombor.egri@canonical.com>
272+ */
273+
274+#ifndef UCPOPUP_H
275+#define UCPOPUP_H
276+
277+#include <QtCore/QObject>
278+#include <QtQuick/QQuickItem>
279+#include <QtQml/QQmlListProperty>
280+#include "ucthemingextension.h"
281+
282+class UCPopupPosition : public QObject
283+{
284+ Q_OBJECT
285+ Q_PROPERTY(Qt::Alignment align READ align WRITE setAlign NOTIFY alignChanged FINAL)
286+ Q_PROPERTY(QPointF distanceFromCaller READ distanceFromCaller WRITE setDistanceFromCaller NOTIFY distanceFromCallerChanged FINAL)
287+ Q_PROPERTY(qreal pointerOffset READ pointerOffset WRITE setPointerOffset NOTIFY pointerOffsetChanged FINAL)
288+public:
289+ explicit UCPopupPosition(QObject *parent = 0);
290+
291+ Qt::Alignment align() const;
292+ void setAlign(Qt::Alignment align);
293+ QPointF distanceFromCaller() const;
294+ void setDistanceFromCaller(const QPointF &distance);
295+ qreal pointerOffset() const;
296+ void setPointerOffset(qreal offset);
297+
298+
299+Q_SIGNALS:
300+ void alignChanged();
301+ void distanceFromCallerChanged();
302+ void pointerOffsetChanged();
303+
304+private:
305+ QPointF m_distanceFromCaller;
306+ qreal m_pointerOffset = -1;
307+ Qt::Alignment m_align = 0;
308+};
309+
310+class UCPopupPositioning : public QObject
311+{
312+ Q_OBJECT
313+ Q_PROPERTY(QQmlListProperty<UCPopupPosition> positions READ positions)
314+public:
315+ explicit UCPopupPositioning(QObject *parent = 0);
316+
317+ QList<UCPopupPosition*> positionsList();
318+ QQmlListProperty<UCPopupPosition> positions();
319+
320+private:
321+ QList<UCPopupPosition*> m_positions;
322+};
323+
324+// FIXME: when we move on Qt 5.5, make sure we derive from QQuickWindowQmlImpl!
325+class UCPopup : public QQuickWindow//, public UCThemingExtension
326+{
327+ Q_OBJECT
328+// Q_INTERFACES(UCThemingExtension)
329+// Q_PROPERTY(UCTheme theme READ getTheme WRITE setTheme NOTIFY themeChanged FINAL)
330+ Q_PROPERTY(QString styleName READ styleName WRITE setStyleName NOTIFY styleNameChanged FINAL)
331+ Q_PROPERTY(UCPopupPositioning *positioning READ positioning WRITE setPositioning NOTIFY positioningChanged FINAL)
332+ Q_PROPERTY(QQuickItem *caller READ caller WRITE setCaller NOTIFY callerChanged FINAL)
333+ Q_PROPERTY(bool hasPointer READ hasPointer WRITE setHasPointer NOTIFY hasPointerChanged FINAL)
334+public:
335+ UCPopup(QWindow *parent = 0);
336+ explicit UCPopup(QQuickRenderControl *renderControl);
337+
338+ QString styleName() const;
339+ void setStyleName(const QString &name);
340+ UCPopupPositioning *positioning() const;
341+ void setPositioning(UCPopupPositioning *positioning);
342+ QQuickItem *caller() const;
343+ void setCaller(QQuickItem *caller);
344+ bool hasPointer() const;
345+ void setHasPointer(bool hasPointer);
346+
347+protected:
348+// void preThemeChanged() override {}
349+// void postThemeChanged() override {}
350+
351+public Q_SLOTS:
352+ void open();
353+ void close();
354+
355+Q_SIGNALS:
356+ void themeChanged();
357+ void styleNameChanged();
358+ void positioningChanged();
359+ void callerChanged();
360+ void hasPointerChanged();
361+
362+ void aboutToOpen();
363+ void opened();
364+ void aboutToClose();
365+ void closed();
366+
367+private:
368+ QString m_styleName;
369+ UCPopupPositioning *m_positioning = nullptr;
370+ QQuickItem *m_caller = nullptr;
371+ bool m_hasPointer = true;
372+};
373+
374+#endif // UCPOPUP_H
375
376=== modified file 'src/Ubuntu/Components/plugin/uctheme.cpp'
377--- src/Ubuntu/Components/plugin/uctheme.cpp 2016-01-11 10:15:14 +0000
378+++ src/Ubuntu/Components/plugin/uctheme.cpp 2016-01-11 10:15:15 +0000
379@@ -641,7 +641,7 @@
380 listener, &ContextPropertyChangeListener::updateContextProperty);
381 }
382
383-void UCTheme::attachItem(QQuickItem *item, bool attach)
384+void UCTheme::attachItem(UCThemingExtension *item, bool attach)
385 {
386 if (attach) {
387 m_attachedItems.append(item);
388@@ -653,7 +653,7 @@
389 void UCTheme::updateThemedItems()
390 {
391 for (int i = 0; i < m_attachedItems.count(); i++) {
392- UCThemingExtension *extension = qobject_cast<UCThemingExtension*>(m_attachedItems[i]);
393+ UCThemingExtension *extension = m_attachedItems[i];
394 if (extension) {
395 extension->itemThemeReloaded(this);
396 }
397
398=== modified file 'src/Ubuntu/Components/plugin/uctheme.h'
399--- src/Ubuntu/Components/plugin/uctheme.h 2016-01-11 10:15:14 +0000
400+++ src/Ubuntu/Components/plugin/uctheme.h 2016-01-11 10:15:15 +0000
401@@ -35,6 +35,7 @@
402 class UCStyledItemBase;
403 class QQmlAbstractBinding;
404 class QQuickItem;
405+class UCThemingExtension;
406 class UCTheme : public QObject, public QQmlParserStatus
407 {
408 Q_OBJECT
409@@ -79,7 +80,7 @@
410 // internal, used by the deprecated Theme.createStyledComponent()
411 QQmlComponent* createStyleComponent(const QString& styleName, QObject* parent, quint16 version = 0);
412 static void createDefaultTheme(QQmlEngine* engine);
413- void attachItem(QQuickItem *item, bool attach);
414+ void attachItem(UCThemingExtension *item, bool attach);
415
416 // helper functions
417 QColor getPaletteColor(const char *profile, const char *color);
418@@ -160,7 +161,7 @@
419 QPointer<QObject> m_palette; // the palette might be from the default style if the theme doesn't define palette
420 QList<ThemeRecord> m_themePaths;
421 UCDefaultTheme m_defaultTheme;
422- QPODVector<QQuickItem*, 4> m_attachedItems;
423+ QPODVector<UCThemingExtension*, 4> m_attachedItems;
424 bool m_completed:1;
425
426 friend class UCDeprecatedTheme;
427
428=== modified file 'src/Ubuntu/Components/plugin/ucthemingextension.cpp'
429--- src/Ubuntu/Components/plugin/ucthemingextension.cpp 2016-01-11 10:15:14 +0000
430+++ src/Ubuntu/Components/plugin/ucthemingextension.cpp 2016-01-11 10:15:15 +0000
431@@ -159,7 +159,7 @@
432 UCThemingExtension::~UCThemingExtension()
433 {
434 if (theme) {
435- theme->attachItem(themedItem, false);
436+ theme->attachItem(this, false);
437 }
438 }
439
440@@ -240,14 +240,14 @@
441
442 // disconnect from the previous set
443 if (theme) {
444- theme->attachItem(themedItem, false);
445+ theme->attachItem(this, false);
446 }
447
448 theme = newTheme;
449
450 // connect to the new set
451 if (theme) {
452- theme->attachItem(themedItem, true);
453+ theme->attachItem(this, true);
454 // set the parent of the theme if custom
455 setParentTheme();
456 }

Subscribers

People subscribed via source and target branches