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

Proposed by Zsombor Egri
Status: Merged
Approved by: Cris Dywan
Approved revision: 1759
Merged at revision: 1757
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/iseeprivates
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 1523 lines (+580/-310)
16 files modified
src/Ubuntu/Components/plugin/plugin.pri (+3/-0)
src/Ubuntu/Components/plugin/ucabstractbutton.cpp (+76/-38)
src/Ubuntu/Components/plugin/ucabstractbutton.h (+9/-11)
src/Ubuntu/Components/plugin/ucabstractbutton_p.h (+50/-0)
src/Ubuntu/Components/plugin/ucaction.h (+1/-0)
src/Ubuntu/Components/plugin/ucactionitem.cpp (+162/-125)
src/Ubuntu/Components/plugin/ucactionitem.h (+8/-23)
src/Ubuntu/Components/plugin/ucactionitem_p.h (+63/-0)
src/Ubuntu/Components/plugin/ucbottomedge.cpp (+13/-13)
src/Ubuntu/Components/plugin/ucbottomedge.h (+0/-1)
src/Ubuntu/Components/plugin/ucbottomedge_p.h (+2/-0)
src/Ubuntu/Components/plugin/ucbottomedgehint.cpp (+130/-82)
src/Ubuntu/Components/plugin/ucbottomedgehint.h (+9/-14)
src/Ubuntu/Components/plugin/ucbottomedgehint_p.h (+46/-0)
src/Ubuntu/Components/plugin/ucstyleditembase.cpp (+7/-2)
src/Ubuntu/Components/plugin/ucstyleditembase_p.h (+1/-1)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/iseeprivates
Reviewer Review Type Date Requested Status
Cris Dywan Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+280280@code.launchpad.net

Commit message

Add private implementations to ActionItem, AbstractButton, BottomEdgeHint and BottomEdge.

Description of the change

Prerequisite work for proper action triggering, required by AbstractButton and BottomEdgeHint especially.

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 :

The changes look sensible. No change in functionality expected and so the existing unit tests should already cover it. Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Components/plugin/plugin.pri'
2--- src/Ubuntu/Components/plugin/plugin.pri 2015-12-07 17:02:28 +0000
3+++ src/Ubuntu/Components/plugin/plugin.pri 2015-12-11 12:19:41 +0000
4@@ -86,8 +86,10 @@
5 $$PWD/livetimer_p.h \
6 $$PWD/timeutils_p.h \
7 $$PWD/ucactionitem.h \
8+ $$PWD/ucactionitem_p.h \
9 $$PWD/uchaptics.h \
10 $$PWD/ucabstractbutton.h \
11+ $$PWD/ucabstractbutton_p.h \
12 $$PWD/ucthemingextension.h \
13 $$PWD/ucheader.h \
14 $$PWD/uclabel.h \
15@@ -95,6 +97,7 @@
16 $$PWD/privates/threelabelsslot_p.h \
17 $$PWD/ucimportversionchecker_p.h \
18 $$PWD/ucbottomedgehint.h \
19+ $$PWD/ucbottomedgehint_p.h \
20 $$PWD/gestures/ucswipearea.h \
21 $$PWD/gestures/ucswipearea_p.h \
22 $$PWD/gestures/damper.h \
23
24=== modified file 'src/Ubuntu/Components/plugin/ucabstractbutton.cpp'
25--- src/Ubuntu/Components/plugin/ucabstractbutton.cpp 2015-12-05 05:59:07 +0000
26+++ src/Ubuntu/Components/plugin/ucabstractbutton.cpp 2015-12-11 12:19:41 +0000
27@@ -15,11 +15,26 @@
28 */
29
30 #include "ucabstractbutton.h"
31+#include "ucabstractbutton_p.h"
32 #include "uchaptics.h"
33 #include <QtQuick/private/qquickitem_p.h>
34 #include <QtQuick/private/qquickmousearea_p.h>
35 #include <QtQml/private/qqmlglobal_p.h>
36
37+UCAbstractButtonPrivate::UCAbstractButtonPrivate()
38+ : UCActionItemPrivate()
39+ , mouseArea(new QQuickMouseArea)
40+ , acceptEvents(true)
41+ , pressAndHoldConnected(false)
42+{
43+}
44+void UCAbstractButtonPrivate::init()
45+{
46+ Q_Q(UCAbstractButton);
47+ q->setActiveFocusOnPress(true);
48+ q->setActiveFocusOnTab(true);
49+}
50+
51 /*!
52 \qmltype AbstractButton
53 \instantiates UCAbstractButton
54@@ -49,18 +64,20 @@
55 */
56
57 UCAbstractButton::UCAbstractButton(QQuickItem *parent)
58- : UCActionItem(parent)
59- , m_mouseArea(new QQuickMouseArea)
60- , m_acceptEvents(true)
61- , m_pressAndHoldConnected(false)
62-{
63- setActiveFocusOnPress(true);
64- setActiveFocusOnTab(true);
65+ : UCActionItem(*(new UCAbstractButtonPrivate), parent)
66+{
67+ d_func()->init();
68+}
69+UCAbstractButton::UCAbstractButton(UCAbstractButtonPrivate &&dd, QQuickItem *parent)
70+ : UCActionItem(dd, parent)
71+{
72+ d_func()->init();
73 }
74
75-bool UCAbstractButton::isPressAndHoldConnected()
76+bool UCAbstractButtonPrivate::isPressAndHoldConnected()
77 {
78- IS_SIGNAL_CONNECTED(this, UCAbstractButton, pressAndHold, ());
79+ Q_Q(UCAbstractButton);
80+ IS_SIGNAL_CONNECTED(q, UCAbstractButton, pressAndHold, ());
81 }
82
83 void UCAbstractButton::classBegin()
84@@ -71,63 +88,68 @@
85 HapticsProxy::instance().initialize();
86
87 // set up mouse area
88- QQml_setParent_noEvent(m_mouseArea, this);
89- m_mouseArea->setParentItem(this);
90- QQuickAnchors *anchors = QQuickItemPrivate::get(m_mouseArea)->anchors();
91+ Q_D(UCAbstractButton);
92+ QQml_setParent_noEvent(d->mouseArea, this);
93+ d->mouseArea->setParentItem(this);
94+ QQuickAnchors *anchors = QQuickItemPrivate::get(d->mouseArea)->anchors();
95 anchors->setFill(this);
96- m_mouseArea->setHoverEnabled(true);
97+ d->mouseArea->setHoverEnabled(true);
98 }
99
100-void UCAbstractButton::componentComplete()
101+void UCAbstractButtonPrivate::completeComponentInitialization()
102 {
103- UCActionItem::componentComplete();
104+ UCActionItemPrivate::completeComponentInitialization();
105+ Q_Q(UCAbstractButton);
106 // connect to the right slot, using macros so we get the proper slot
107- connect(m_mouseArea, SIGNAL(clicked(QQuickMouseEvent*)), this, SLOT(trigger()));
108+ QObject::connect(mouseArea, SIGNAL(clicked(QQuickMouseEvent*)), q, SLOT(trigger()));
109
110 // bind mouse area
111- connect(m_mouseArea, &QQuickMouseArea::pressedChanged, this, &UCAbstractButton::pressedChanged);
112- connect(m_mouseArea, &QQuickMouseArea::hoveredChanged, this, &UCAbstractButton::hoveredChanged);
113- connect(m_mouseArea, SIGNAL(clicked(QQuickMouseEvent*)), this, SLOT(_q_mouseAreaClicked()));
114- connect(m_mouseArea, SIGNAL(pressed(QQuickMouseEvent*)), this, SLOT(_q_mouseAreaPressed()));
115+ QObject::connect(mouseArea, &QQuickMouseArea::pressedChanged, q, &UCAbstractButton::pressedChanged);
116+ QObject::connect(mouseArea, &QQuickMouseArea::hoveredChanged, q, &UCAbstractButton::hoveredChanged);
117+ QObject::connect(mouseArea, SIGNAL(clicked(QQuickMouseEvent*)), q, SLOT(_q_mouseAreaClicked()));
118+ QObject::connect(mouseArea, SIGNAL(pressed(QQuickMouseEvent*)), q, SLOT(_q_mouseAreaPressed()));
119 }
120
121 // check the pressAndHold connection on runtime, as Connections
122 // may not be available on compoennt completion
123-void UCAbstractButton::_q_mouseAreaPressed()
124+void UCAbstractButtonPrivate::_q_mouseAreaPressed()
125 {
126 bool longPressConnected = isPressAndHoldConnected();
127- if (longPressConnected && !m_pressAndHoldConnected) {
128+ Q_Q(UCAbstractButton);
129+ if (longPressConnected && !pressAndHoldConnected) {
130 // do not use UniqueConnection as that has huge impact on performance
131- connect(m_mouseArea, SIGNAL(pressAndHold(QQuickMouseEvent*)),
132- this, SLOT(_q_mouseAreaPressAndHold()));
133- m_pressAndHoldConnected = true;
134- } else if (!longPressConnected && m_pressAndHoldConnected) {
135- disconnect(m_mouseArea, SIGNAL(pressAndHold(QQuickMouseEvent*)),
136- this, SLOT(_q_mouseAreaPressAndHold()));
137- m_pressAndHoldConnected = false;
138+ QObject::connect(mouseArea, SIGNAL(pressAndHold(QQuickMouseEvent*)),
139+ q, SLOT(_q_mouseAreaPressAndHold()));
140+ pressAndHoldConnected = true;
141+ } else if (!longPressConnected && pressAndHoldConnected) {
142+ QObject::disconnect(mouseArea, SIGNAL(pressAndHold(QQuickMouseEvent*)),
143+ q, SLOT(_q_mouseAreaPressAndHold()));
144+ pressAndHoldConnected = false;
145 }
146 }
147
148 // handle mouseClicked with Haptics
149-void UCAbstractButton::_q_mouseAreaClicked()
150+void UCAbstractButtonPrivate::_q_mouseAreaClicked()
151 {
152 // required by the deprecated ListItem module
153- if (!m_acceptEvents) {
154+ Q_Q(UCAbstractButton);
155+ if (!acceptEvents) {
156 return;
157 }
158 // play haptics
159 HapticsProxy::instance().play(QVariant());
160- Q_EMIT clicked();
161+ Q_EMIT q->clicked();
162 }
163
164 // handle pressAndHold
165-void UCAbstractButton::_q_mouseAreaPressAndHold()
166+void UCAbstractButtonPrivate::_q_mouseAreaPressAndHold()
167 {
168 // required by the deprecated ListItem module
169- if (!m_acceptEvents) {
170+ Q_Q(UCAbstractButton);
171+ if (!acceptEvents) {
172 return;
173 }
174- Q_EMIT pressAndHold();
175+ Q_EMIT q->pressAndHold();
176 }
177
178 // emit clicked when Enter/Return is pressed
179@@ -153,7 +175,8 @@
180 */
181 bool UCAbstractButton::pressed() const
182 {
183- return m_mouseArea ? m_mouseArea->pressed() : false;
184+ Q_D(const UCAbstractButton);
185+ return d->mouseArea ? d->mouseArea->pressed() : false;
186 }
187
188 /*!
189@@ -162,10 +185,25 @@
190 */
191 bool UCAbstractButton::hovered() const
192 {
193- return m_mouseArea ? m_mouseArea->hovered() : false;
194+ Q_D(const UCAbstractButton);
195+ return d->mouseArea ? d->mouseArea->hovered() : false;
196+}
197+
198+bool UCAbstractButton::acceptEvents() const
199+{
200+ Q_D(const UCAbstractButton);
201+ return d->acceptEvents;
202+}
203+void UCAbstractButton::setAcceptEvents(bool value)
204+{
205+ Q_D(UCAbstractButton);
206+ d->acceptEvents = value;
207 }
208
209 QQuickMouseArea *UCAbstractButton::privateMouseArea() const
210 {
211- return m_mouseArea;
212+ Q_D(const UCAbstractButton);
213+ return d->mouseArea;
214 }
215+
216+#include "moc_ucabstractbutton.cpp"
217
218=== modified file 'src/Ubuntu/Components/plugin/ucabstractbutton.h'
219--- src/Ubuntu/Components/plugin/ucabstractbutton.h 2015-09-30 18:55:20 +0000
220+++ src/Ubuntu/Components/plugin/ucabstractbutton.h 2015-12-11 12:19:41 +0000
221@@ -21,6 +21,7 @@
222
223 class QQuickMouseArea;
224 class QQuickMouseEvent;
225+class UCAbstractButtonPrivate;
226 class UCAbstractButton : public UCActionItem
227 {
228 Q_OBJECT
229@@ -28,7 +29,7 @@
230 Q_PROPERTY(bool hovered READ hovered NOTIFY hoveredChanged)
231
232 // internal, declared to support the deprecated ListItem module
233- Q_PROPERTY(bool __acceptEvents MEMBER m_acceptEvents)
234+ Q_PROPERTY(bool __acceptEvents READ acceptEvents WRITE setAcceptEvents)
235 Q_PROPERTY(QQuickMouseArea *__mouseArea READ privateMouseArea CONSTANT)
236 public:
237 explicit UCAbstractButton(QQuickItem *parent = 0);
238@@ -38,11 +39,12 @@
239
240 bool privateAcceptEvents() const;
241 void setPrivateAcceptEvents(bool accept);
242+ bool acceptEvents() const;
243+ void setAcceptEvents(bool value);
244 QQuickMouseArea *privateMouseArea() const;
245
246 protected:
247 void classBegin();
248- void componentComplete();
249 void keyPressEvent(QKeyEvent *key);
250
251 Q_SIGNALS:
252@@ -51,17 +53,13 @@
253 void clicked();
254 void pressAndHold();
255
256-protected Q_SLOTS:
257- void _q_mouseAreaPressed();
258- void _q_mouseAreaClicked();
259- void _q_mouseAreaPressAndHold();
260-
261 protected:
262- QQuickMouseArea *m_mouseArea;
263- bool m_acceptEvents:1;
264- bool m_pressAndHoldConnected:1;
265+ UCAbstractButton(UCAbstractButtonPrivate &&, QQuickItem *parent = 0);
266
267- bool isPressAndHoldConnected();
268+ Q_DECLARE_PRIVATE(UCAbstractButton)
269+ Q_PRIVATE_SLOT(d_func(), void _q_mouseAreaPressed())
270+ Q_PRIVATE_SLOT(d_func(), void _q_mouseAreaClicked())
271+ Q_PRIVATE_SLOT(d_func(), void _q_mouseAreaPressAndHold())
272 };
273
274 #endif // UCABSTRACTBUTTON_H
275
276=== added file 'src/Ubuntu/Components/plugin/ucabstractbutton_p.h'
277--- src/Ubuntu/Components/plugin/ucabstractbutton_p.h 1970-01-01 00:00:00 +0000
278+++ src/Ubuntu/Components/plugin/ucabstractbutton_p.h 2015-12-11 12:19:41 +0000
279@@ -0,0 +1,50 @@
280+/*
281+ * Copyright 2015 Canonical Ltd.
282+ *
283+ * This program is free software; you can redistribute it and/or modify
284+ * it under the terms of the GNU Lesser General Public License as published by
285+ * the Free Software Foundation; version 3.
286+ *
287+ * This program is distributed in the hope that it will be useful,
288+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
289+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
290+ * GNU Lesser General Public License for more details.
291+ *
292+ * You should have received a copy of the GNU Lesser General Public License
293+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
294+ */
295+
296+#ifndef UCABSTRACTBUTTON_P
297+#define UCABSTRACTBUTTON_P
298+
299+#include "ucabstractbutton.h"
300+#include "ucactionitem_p.h"
301+
302+class UCAbstractButtonPrivate : public UCActionItemPrivate
303+{
304+ Q_DECLARE_PUBLIC(UCAbstractButton)
305+public:
306+ static UCAbstractButtonPrivate *get(UCAbstractButton *item)
307+ {
308+ return item->d_func();
309+ }
310+
311+ UCAbstractButtonPrivate();
312+ void init();
313+
314+ void completeComponentInitialization() override;
315+
316+ bool isPressAndHoldConnected();
317+
318+ // private slots
319+ void _q_mouseAreaPressed();
320+ void _q_mouseAreaClicked();
321+ void _q_mouseAreaPressAndHold();
322+
323+ QQuickMouseArea *mouseArea;
324+ bool acceptEvents:1;
325+ bool pressAndHoldConnected:1;
326+};
327+
328+#endif // UCABSTRACTBUTTON_P
329+
330
331=== modified file 'src/Ubuntu/Components/plugin/ucaction.h'
332--- src/Ubuntu/Components/plugin/ucaction.h 2015-12-08 15:13:49 +0000
333+++ src/Ubuntu/Components/plugin/ucaction.h 2015-12-11 12:19:41 +0000
334@@ -101,6 +101,7 @@
335
336 friend class UCActionContext;
337 friend class UCActionItem;
338+ friend class UCActionItemPrivate;
339 friend class UCListItemPrivate;
340 friend class UCListItemAttached;
341 friend class UCListItemActionsPrivate;
342
343=== modified file 'src/Ubuntu/Components/plugin/ucactionitem.cpp'
344--- src/Ubuntu/Components/plugin/ucactionitem.cpp 2015-09-16 05:26:36 +0000
345+++ src/Ubuntu/Components/plugin/ucactionitem.cpp 2015-12-11 12:19:41 +0000
346@@ -15,12 +15,26 @@
347 */
348
349 #include "ucactionitem.h"
350+#include "ucactionitem_p.h"
351 #include "ucaction.h"
352 #include "ucstyleditembase_p.h"
353 #define foreach Q_FOREACH
354 #include <QtQml/private/qqmlbinding_p.h>
355 #undef foreach
356
357+UCActionItemPrivate::UCActionItemPrivate()
358+ : action(Q_NULLPTR)
359+ , flags(0)
360+{
361+}
362+
363+void UCActionItemPrivate::init()
364+{
365+ Q_Q(UCActionItem);
366+ QObject::connect(q, &UCActionItem::enabledChanged, q, &UCActionItem::enabledChanged2);
367+ QObject::connect(q, &UCActionItem::visibleChanged, q, &UCActionItem::visibleChanged2);
368+}
369+
370 /*!
371 * \qmltype ActionItem
372 * \instantiates UCActionItem
373@@ -40,57 +54,61 @@
374 * Called when the actionItem is triggered.
375 */
376 UCActionItem::UCActionItem(QQuickItem *parent)
377- : UCStyledItemBase(parent)
378- , m_action(Q_NULLPTR)
379- , m_flags(0)
380-{
381- connect(this, &UCActionItem::enabledChanged, this, &UCActionItem::enabledChanged2);
382- connect(this, &UCActionItem::visibleChanged, this, &UCActionItem::visibleChanged2);
383-}
384-
385-bool UCActionItem::hasBindingOnProperty(const QString &name)
386-{
387- QQmlProperty property(this, name, qmlContext(this));
388+ : UCStyledItemBase(*(new UCActionItemPrivate), parent)
389+{
390+ d_func()->init();
391+}
392+
393+UCActionItem::UCActionItem(UCActionItemPrivate &dd, QQuickItem *parent)
394+ : UCStyledItemBase(dd, parent)
395+{
396+ d_func()->init();
397+}
398+
399+bool UCActionItemPrivate::hasBindingOnProperty(const QString &name)
400+{
401+ Q_Q(UCActionItem);
402+ QQmlProperty property(q, name, qmlContext(q));
403 return QQmlPropertyPrivate::binding(property) != Q_NULLPTR;
404 }
405
406-void UCActionItem::componentComplete()
407+void UCActionItemPrivate::completeComponentInitialization()
408 {
409- UCStyledItemBase::componentComplete();
410+ UCStyledItemBasePrivate::completeComponentInitialization();
411 // make sure we connect to the right signals, so we detach and re-attach actions
412 // to make sure the SLOT macro picks up the custom trigger() slot
413- if (m_action) {
414+ if (action) {
415 attachAction(false);
416 attachAction(true);
417 }
418 }
419
420 // update visible property
421-void UCActionItem::_q_visibleBinding()
422+void UCActionItemPrivate::_q_visibleBinding()
423 {
424- if (m_flags & CustomVisible) {
425+ if (flags & CustomVisible) {
426 return;
427 }
428 if (hasBindingOnProperty(QStringLiteral("visible"))) {
429- m_flags |= CustomEnabled;
430+ flags |= CustomEnabled;
431 return;
432 }
433- bool visible = m_action ? m_action->m_visible : true;
434- setVisible(visible);
435+ bool visible = action ? action->m_visible : true;
436+ q_func()->setVisible(visible);
437 }
438
439 // update enabled property
440-void UCActionItem::_q_enabledBinding()
441+void UCActionItemPrivate::_q_enabledBinding()
442 {
443- if (m_flags & CustomEnabled) {
444+ if (flags & CustomEnabled) {
445 return;
446 }
447 if (hasBindingOnProperty(QStringLiteral("enabled"))) {
448- m_flags |= CustomEnabled;
449+ flags |= CustomEnabled;
450 return;
451 }
452- bool enabled = m_action ? m_action->m_enabled : true;
453- setEnabled(enabled);
454+ bool enabled = action ? action->m_enabled : true;
455+ q_func()->setEnabled(enabled);
456 }
457
458 // setter called when bindings from QML set the value. Internal functions will
459@@ -99,75 +117,77 @@
460 void UCActionItem::setVisible2(bool visible)
461 {
462 // set the custom flag and forward the value to the original proepry setter
463- m_flags |= CustomVisible;
464+ d_func()->flags |= UCActionItemPrivate::CustomVisible;
465 setVisible(visible);
466 }
467 void UCActionItem::setEnabled2(bool enabled)
468 {
469- m_flags |= CustomEnabled;
470+ d_func()->flags |= UCActionItemPrivate::CustomEnabled;
471 setEnabled(enabled);
472 }
473
474-void UCActionItem::updateProperties()
475+void UCActionItemPrivate::updateProperties()
476 {
477- if (!(m_flags & CustomText)) {
478- Q_EMIT textChanged();
479- }
480- if (!(m_flags & CustomIconSource)) {
481- Q_EMIT iconSourceChanged();
482- }
483- if (!(m_flags & CustomIconName)) {
484- Q_EMIT iconNameChanged();
485+ Q_Q(UCActionItem);
486+ if (!(flags & CustomText)) {
487+ Q_EMIT q->textChanged();
488+ }
489+ if (!(flags & CustomIconSource)) {
490+ Q_EMIT q->iconSourceChanged();
491+ }
492+ if (!(flags & CustomIconName)) {
493+ Q_EMIT q->iconNameChanged();
494 }
495 }
496
497-void UCActionItem::attachAction(bool attach)
498+void UCActionItemPrivate::attachAction(bool attach)
499 {
500+ Q_Q(UCActionItem);
501 if (attach) {
502- connect(this, SIGNAL(triggered(QVariant)),
503- m_action, SLOT(trigger(QVariant)), Qt::DirectConnection);
504- if (!(m_flags & CustomVisible)) {
505- connect(m_action, &UCAction::visibleChanged,
506- this, &UCActionItem::_q_visibleBinding, Qt::DirectConnection);
507- }
508- if (!(m_flags & CustomEnabled)) {
509- connect(m_action, &UCAction::enabledChanged,
510- this, &UCActionItem::_q_enabledBinding, Qt::DirectConnection);
511- }
512- if (!(m_flags & CustomText)) {
513- connect(m_action, &UCAction::textChanged,
514- this, &UCActionItem::textChanged, Qt::DirectConnection);
515- }
516- if (!(m_flags & CustomIconSource)) {
517- connect(m_action, &UCAction::iconSourceChanged,
518- this, &UCActionItem::iconSourceChanged, Qt::DirectConnection);
519- }
520- if (!(m_flags & CustomIconName)) {
521- connect(m_action, &UCAction::iconNameChanged,
522- this, &UCActionItem::iconNameChanged, Qt::DirectConnection);
523+ QObject::connect(q, SIGNAL(triggered(QVariant)),
524+ action, SLOT(trigger(QVariant)), Qt::DirectConnection);
525+ if (!(flags & CustomVisible)) {
526+ QObject::connect(action, SIGNAL(visibleChanged()),
527+ q, SLOT(_q_visibleBinding()), Qt::DirectConnection);
528+ }
529+ if (!(flags & CustomEnabled)) {
530+ QObject::connect(action, SIGNAL(enabledChanged()),
531+ q, SLOT(_q_enabledBinding()), Qt::DirectConnection);
532+ }
533+ if (!(flags & CustomText)) {
534+ QObject::connect(action, &UCAction::textChanged,
535+ q, &UCActionItem::textChanged, Qt::DirectConnection);
536+ }
537+ if (!(flags & CustomIconSource)) {
538+ QObject::connect(action, &UCAction::iconSourceChanged,
539+ q, &UCActionItem::iconSourceChanged, Qt::DirectConnection);
540+ }
541+ if (!(flags & CustomIconName)) {
542+ QObject::connect(action, &UCAction::iconNameChanged,
543+ q, &UCActionItem::iconNameChanged, Qt::DirectConnection);
544 }
545 } else {
546- disconnect(this, SIGNAL(triggered(QVariant)),
547- m_action, SLOT(trigger(QVariant)));
548- if (!(m_flags & CustomVisible)) {
549- disconnect(m_action, &UCAction::visibleChanged,
550- this, &UCActionItem::_q_visibleBinding);
551- }
552- if (!(m_flags & CustomEnabled)) {
553- disconnect(m_action, &UCAction::enabledChanged,
554- this, &UCActionItem::_q_enabledBinding);
555- }
556- if (!(m_flags & CustomText)) {
557- disconnect(m_action, &UCAction::textChanged,
558- this, &UCActionItem::textChanged);
559- }
560- if (!(m_flags & CustomIconSource)) {
561- disconnect(m_action, &UCAction::iconSourceChanged,
562- this, &UCActionItem::iconSourceChanged);
563- }
564- if (!(m_flags & CustomIconName)) {
565- disconnect(m_action, &UCAction::iconNameChanged,
566- this, &UCActionItem::iconNameChanged);
567+ QObject::disconnect(q, SIGNAL(triggered(QVariant)),
568+ action, SLOT(trigger(QVariant)));
569+ if (!(flags & CustomVisible)) {
570+ QObject::disconnect(action, SIGNAL(visibleChanged()),
571+ q, SLOT(_q_visibleBinding()));
572+ }
573+ if (!(flags & CustomEnabled)) {
574+ QObject::disconnect(action, SIGNAL(enabledChanged()),
575+ q, SLOT(_q_enabledBinding()));
576+ }
577+ if (!(flags & CustomText)) {
578+ QObject::disconnect(action, &UCAction::textChanged,
579+ q, &UCActionItem::textChanged);
580+ }
581+ if (!(flags & CustomIconSource)) {
582+ QObject::disconnect(action, &UCAction::iconSourceChanged,
583+ q, &UCActionItem::iconSourceChanged);
584+ }
585+ if (!(flags & CustomIconName)) {
586+ QObject::disconnect(action, &UCAction::iconNameChanged,
587+ q, &UCActionItem::iconNameChanged);
588 }
589 }
590 }
591@@ -178,23 +198,29 @@
592 * of the \l Action properties are copied to the values of the ActionItem
593 * properties, unless those were previously overridden.
594 */
595+UCAction* UCActionItem::action() const
596+{
597+ Q_D(const UCActionItem);
598+ return d->action;
599+}
600 void UCActionItem::setAction(UCAction *action)
601 {
602- if (m_action == action) {
603+ Q_D(UCActionItem);
604+ if (d->action == action) {
605 return;
606 }
607- if (m_action) {
608- attachAction(false);
609+ if (d->action) {
610+ d->attachAction(false);
611 }
612- m_action = action;
613+ d->action = action;
614 Q_EMIT actionChanged();
615
616- if (m_action) {
617- attachAction(true);
618+ if (d->action) {
619+ d->attachAction(true);
620 }
621- _q_visibleBinding();
622- _q_enabledBinding();
623- updateProperties();
624+ d->_q_visibleBinding();
625+ d->_q_enabledBinding();
626+ d->updateProperties();
627 }
628
629 /*!
630@@ -203,32 +229,35 @@
631 */
632 QString UCActionItem::text()
633 {
634- if (m_flags & CustomText) {
635- return m_text;
636+ Q_D(UCActionItem);
637+ if (d->flags & UCActionItemPrivate::CustomText) {
638+ return d->text;
639 }
640- return m_action ? m_action->m_text : QString();
641+ return d->action ? d->action->m_text : QString();
642 }
643 void UCActionItem::setText(const QString &text)
644 {
645- if (m_text == text) {
646+ Q_D(UCActionItem);
647+ if (d->text == text) {
648 return;
649 }
650- m_text = text;
651- if (m_action && !(m_flags & CustomText)) {
652+ d->text = text;
653+ if (d->action && !(d->flags & UCActionItemPrivate::CustomText)) {
654 // disconnect change signal from Action
655- disconnect(m_action, &UCAction::textChanged,
656+ disconnect(d->action, &UCAction::textChanged,
657 this, &UCActionItem::textChanged);
658 }
659- m_flags |= CustomText;
660+ d->flags |= UCActionItemPrivate::CustomText;
661 Q_EMIT textChanged();
662 }
663 void UCActionItem::resetText()
664 {
665- m_text.clear();
666- m_flags &= ~CustomText;
667- if (m_action) {
668+ Q_D(UCActionItem);
669+ d->text.clear();
670+ d->flags &= ~UCActionItemPrivate::CustomText;
671+ if (d->action) {
672 // re-connect change signal from Action
673- connect(m_action, &UCAction::textChanged,
674+ connect(d->action, &UCAction::textChanged,
675 this, &UCActionItem::textChanged, Qt::DirectConnection);
676 }
677 Q_EMIT textChanged();
678@@ -243,35 +272,38 @@
679 */
680 QUrl UCActionItem::iconSource()
681 {
682- if (m_flags & CustomIconSource) {
683- return m_iconSource;
684+ Q_D(UCActionItem);
685+ if (d->flags & UCActionItemPrivate::CustomIconSource) {
686+ return d->iconSource;
687 }
688- if (m_action) {
689- return m_action->m_iconSource;
690+ if (d->action) {
691+ return d->action->m_iconSource;
692 }
693 return !iconName().isEmpty() ? QUrl(QString("image://theme/%1").arg(iconName())) : QUrl();
694 }
695 void UCActionItem::setIconSource(const QUrl &iconSource)
696 {
697- if (m_iconSource == iconSource) {
698+ Q_D(UCActionItem);
699+ if (d->iconSource == iconSource) {
700 return;
701 }
702- m_iconSource = iconSource;
703- if (m_action && !(m_flags & CustomIconSource)) {
704+ d->iconSource = iconSource;
705+ if (d->action && !(d->flags & UCActionItemPrivate::CustomIconSource)) {
706 // disconnect change signal from Action
707- disconnect(m_action, &UCAction::iconSourceChanged,
708+ disconnect(d->action, &UCAction::iconSourceChanged,
709 this, &UCActionItem::iconSourceChanged);
710 }
711- m_flags |= CustomIconSource;
712+ d->flags |= UCActionItemPrivate::CustomIconSource;
713 Q_EMIT iconSourceChanged();
714 }
715 void UCActionItem::resetIconSource()
716 {
717- m_iconSource.clear();
718- m_flags &= ~CustomIconSource;
719- if (m_action) {
720+ Q_D(UCActionItem);
721+ d->iconSource.clear();
722+ d->flags &= ~UCActionItemPrivate::CustomIconSource;
723+ if (d->action) {
724 // re-connect change signal from Action
725- connect(m_action, &UCAction::iconSourceChanged,
726+ connect(d->action, &UCAction::iconSourceChanged,
727 this, &UCActionItem::iconSourceChanged, Qt::DirectConnection);
728 }
729 Q_EMIT iconSourceChanged();
730@@ -294,36 +326,39 @@
731 */
732 QString UCActionItem::iconName()
733 {
734- if (m_flags & CustomIconName) {
735- return m_iconName;
736+ Q_D(UCActionItem);
737+ if (d->flags & UCActionItemPrivate::CustomIconName) {
738+ return d->iconName;
739 }
740- return m_action ? m_action->m_iconName : QString();
741+ return d->action ? d->action->m_iconName : QString();
742 }
743 void UCActionItem::setIconName(const QString &iconName)
744 {
745- if (m_iconName == iconName) {
746+ Q_D(UCActionItem);
747+ if (d->iconName == iconName) {
748 return;
749 }
750- m_iconName = iconName;
751- if (m_action && !(m_flags & CustomIconName)) {
752+ d->iconName = iconName;
753+ if (d->action && !(d->flags & UCActionItemPrivate::CustomIconName)) {
754 // disconnect change signal from Action
755- disconnect(m_action, &UCAction::iconNameChanged,
756+ disconnect(d->action, &UCAction::iconNameChanged,
757 this, &UCActionItem::iconNameChanged);
758 }
759- m_flags |= CustomIconName;
760+ d->flags |= UCActionItemPrivate::CustomIconName;
761 Q_EMIT iconNameChanged();
762 // also sync iconSource if that is not a custom one or taken from action
763- if (!m_action || (m_flags & CustomIconSource)) {
764+ if (!d->action || (d->flags & UCActionItemPrivate::CustomIconSource)) {
765 Q_EMIT iconSourceChanged();
766 }
767 }
768 void UCActionItem::resetIconName()
769 {
770- m_iconName.clear();
771- m_flags &= ~CustomIconName;
772- if (m_action) {
773+ Q_D(UCActionItem);
774+ d->iconName.clear();
775+ d->flags &= ~UCActionItemPrivate::CustomIconName;
776+ if (d->action) {
777 // re-connect change signal from Action
778- connect(m_action, &UCAction::iconNameChanged,
779+ connect(d->action, &UCAction::iconNameChanged,
780 this, &UCActionItem::iconNameChanged, Qt::DirectConnection);
781 }
782 Q_EMIT iconNameChanged();
783@@ -339,3 +374,5 @@
784 Q_EMIT triggered(value);
785 }
786 }
787+
788+#include "moc_ucactionitem.cpp"
789
790=== modified file 'src/Ubuntu/Components/plugin/ucactionitem.h'
791--- src/Ubuntu/Components/plugin/ucactionitem.h 2015-09-16 05:26:36 +0000
792+++ src/Ubuntu/Components/plugin/ucactionitem.h 2015-12-11 12:19:41 +0000
793@@ -19,10 +19,11 @@
794 #include "ucstyleditembase.h"
795
796 class UCAction;
797+class UCActionItemPrivate;
798 class UCActionItem : public UCStyledItemBase
799 {
800 Q_OBJECT
801- Q_PROPERTY(UCAction *action MEMBER m_action WRITE setAction NOTIFY actionChanged FINAL)
802+ Q_PROPERTY(UCAction *action READ action WRITE setAction NOTIFY actionChanged FINAL)
803 Q_PROPERTY(QString text READ text WRITE setText RESET resetText NOTIFY textChanged)
804 Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource RESET resetIconSource NOTIFY iconSourceChanged)
805 Q_PROPERTY(QString iconName READ iconName WRITE setIconName RESET resetIconName NOTIFY iconNameChanged)
806@@ -33,6 +34,7 @@
807 public:
808 explicit UCActionItem(QQuickItem *parent = 0);
809
810+ UCAction *action() const;
811 void setAction(UCAction *action);
812 QString text();
813 void setText(const QString &text);
814@@ -60,29 +62,12 @@
815 public Q_SLOTS:
816 void trigger(const QVariant &value = QVariant());
817
818-protected Q_SLOTS:
819- void _q_visibleBinding();
820- void _q_enabledBinding();
821-
822 protected:
823- enum {
824- CustomText = 0x01,
825- CustomIconSource = 0x02,
826- CustomIconName = 0x04,
827- CustomVisible = 0x40,
828- CustomEnabled = 0x80
829- };
830- QString m_text;
831- QString m_iconName;
832- QUrl m_iconSource;
833- UCAction *m_action;
834- quint8 m_flags;
835-
836- void componentComplete();
837-
838- bool hasBindingOnProperty(const QString &name);
839- void updateProperties();
840- void attachAction(bool attach);
841+ UCActionItem(UCActionItemPrivate &, QQuickItem *parent);
842+
843+ Q_DECLARE_PRIVATE(UCActionItem)
844+ Q_PRIVATE_SLOT(d_func(), void _q_visibleBinding())
845+ Q_PRIVATE_SLOT(d_func(), void _q_enabledBinding())
846 };
847
848 #endif // UCACTIONITEM_H
849
850=== added file 'src/Ubuntu/Components/plugin/ucactionitem_p.h'
851--- src/Ubuntu/Components/plugin/ucactionitem_p.h 1970-01-01 00:00:00 +0000
852+++ src/Ubuntu/Components/plugin/ucactionitem_p.h 2015-12-11 12:19:41 +0000
853@@ -0,0 +1,63 @@
854+/*
855+ * Copyright 2015 Canonical Ltd.
856+ *
857+ * This program is free software; you can redistribute it and/or modify
858+ * it under the terms of the GNU Lesser General Public License as published by
859+ * the Free Software Foundation; version 3.
860+ *
861+ * This program is distributed in the hope that it will be useful,
862+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
863+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
864+ * GNU Lesser General Public License for more details.
865+ *
866+ * You should have received a copy of the GNU Lesser General Public License
867+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
868+ *
869+ * Author: Zsombor Egri <zsombor.egri@canonical.com>
870+ */
871+
872+#ifndef UCACTIONITEM_P
873+#define UCACTIONITEM_P
874+
875+#include "ucactionitem.h"
876+#include "ucstyleditembase_p.h"
877+
878+class UCActionItemPrivate : public UCStyledItemBasePrivate
879+{
880+ Q_DECLARE_PUBLIC(UCActionItem)
881+public:
882+ static UCActionItemPrivate* get(UCActionItem *item)
883+ {
884+ return item->d_func();
885+ }
886+
887+ UCActionItemPrivate();
888+ void init();
889+
890+ bool hasBindingOnProperty(const QString &name);
891+ void updateProperties();
892+ void attachAction(bool attach);
893+
894+ // overrides
895+ void completeComponentInitialization() override;
896+
897+ // private slots
898+ void _q_visibleBinding();
899+ void _q_enabledBinding();
900+
901+ enum {
902+ CustomText = 0x01,
903+ CustomIconSource = 0x02,
904+ CustomIconName = 0x04,
905+ CustomVisible = 0x40,
906+ CustomEnabled = 0x80
907+ };
908+ QString text;
909+ QString iconName;
910+ QUrl iconSource;
911+ UCAction *action;
912+ quint8 flags;
913+};
914+
915+#endif // UCACTIONITEM_P
916+
917
918=== modified file 'src/Ubuntu/Components/plugin/ucbottomedge.cpp'
919--- src/Ubuntu/Components/plugin/ucbottomedge.cpp 2015-12-02 15:31:53 +0000
920+++ src/Ubuntu/Components/plugin/ucbottomedge.cpp 2015-12-11 12:19:41 +0000
921@@ -19,7 +19,7 @@
922 #include "ucbottomedge_p.h"
923 #include "ucbottomedgestyle.h"
924 #include "ucbottomedgeregion.h"
925-#include "ucbottomedgehint.h"
926+#include "ucbottomedgehint_p.h"
927 #include "ucstyleditembase_p.h"
928 #include <QtQml/QQmlEngine>
929 #include <QtGui/QScreen>
930@@ -737,26 +737,26 @@
931 initializeComponent();
932 }
933
934-void UCBottomEdge::componentComplete()
935+void UCBottomEdgePrivate::completeComponentInitialization()
936 {
937- UCStyledItemBase::componentComplete();
938- Q_D(UCBottomEdge);
939+ UCStyledItemBasePrivate::completeComponentInitialization();
940+ Q_Q(UCBottomEdge);
941 // fix the hint's style version as that has no qmlContext of its own
942 // and thus import version check will fail; setting the context for
943 // the hint using this component's hint won't work either as this
944 // component's context does not contain the properties from the hint.
945- UCStyledItemBasePrivate *hintPrivate = UCStyledItemBasePrivate::get(d->hint);
946- hintPrivate->styleVersion = d->styleVersion;
947- // also set the qml data as hitn does not have that either
948- QQmlData::get(d->hint, true);
949- QQmlEngine::setContextForObject(d->hint, new QQmlContext(qmlContext(this), d->hint));
950+ UCBottomEdgeHintPrivate *hintPrivate = UCBottomEdgeHintPrivate::get(hint);
951+ hintPrivate->styleVersion = styleVersion;
952+ // also set the qml data as hint does not have that either
953+ QQmlData::get(hint, true);
954+ QQmlEngine::setContextForObject(hint, new QQmlContext(qmlContext(q), hint));
955 // finally complete hint creation
956- hintPrivate->completeStyledItem();
957+ hintPrivate->completeComponentInitialization();
958 // and validate regions, leave out the first one as that supposed to be added first
959 // mimic the top limit of the regions list like we would add them one by one
960- for (int i = 1; i < d->regions.size(); ++i) {
961- UCBottomEdgeRegion *region = d->regions[i];
962- d->validateRegion(region, i);
963+ for (int i = 1; i < regions.size(); ++i) {
964+ UCBottomEdgeRegion *region = regions[i];
965+ validateRegion(region, i);
966 }
967 }
968
969
970=== modified file 'src/Ubuntu/Components/plugin/ucbottomedge.h'
971--- src/Ubuntu/Components/plugin/ucbottomedge.h 2015-11-24 13:41:47 +0000
972+++ src/Ubuntu/Components/plugin/ucbottomedge.h 2015-12-11 12:19:41 +0000
973@@ -101,7 +101,6 @@
974
975 void initializeComponent();
976 void classBegin();
977- void componentComplete();
978 void itemChange(ItemChange change, const ItemChangeData &data);
979 bool eventFilter(QObject *target, QEvent *event) override;
980
981
982=== modified file 'src/Ubuntu/Components/plugin/ucbottomedge_p.h'
983--- src/Ubuntu/Components/plugin/ucbottomedge_p.h 2015-12-01 20:34:50 +0000
984+++ src/Ubuntu/Components/plugin/ucbottomedge_p.h 2015-12-11 12:19:41 +0000
985@@ -37,6 +37,8 @@
986 }
987 void init();
988
989+ void completeComponentInitialization() override;
990+
991 // data property
992 QQmlListProperty<QObject> data();
993 static void overload_data_append(QQmlListProperty<QObject> *, QObject *);
994
995=== modified file 'src/Ubuntu/Components/plugin/ucbottomedgehint.cpp'
996--- src/Ubuntu/Components/plugin/ucbottomedgehint.cpp 2015-12-03 11:50:40 +0000
997+++ src/Ubuntu/Components/plugin/ucbottomedgehint.cpp 2015-12-11 12:19:41 +0000
998@@ -17,6 +17,7 @@
999 */
1000
1001 #include "ucbottomedgehint.h"
1002+#include "ucbottomedgehint_p.h"
1003 #include "ucstyleditembase_p.h"
1004 #include "quickutils.h"
1005 #include "ucunits.h"
1006@@ -27,6 +28,45 @@
1007
1008 #define SWIPE_AREA_HEIGHT_GU 3
1009
1010+UCBottomEdgeHintPrivate::UCBottomEdgeHintPrivate()
1011+ : UCActionItemPrivate()
1012+ , swipeArea(new UCSwipeArea)
1013+ , flickable(Q_NULLPTR)
1014+ , flickableBottomMargin(Q_NULLPTR)
1015+ , deactivateTimeout(800)
1016+ // FIXME: we need QInputDeviceInfo to be complete with the locked!!
1017+ // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1276808
1018+ , status(QuickUtils::instance().mouseAttached() ? UCBottomEdgeHint::Locked : UCBottomEdgeHint::Inactive)
1019+ , pressed(false)
1020+{
1021+}
1022+
1023+void UCBottomEdgeHintPrivate::init()
1024+{
1025+ Q_Q(UCBottomEdgeHint);
1026+ QObject::connect(q, &UCBottomEdgeHint::clicked, [=]() {
1027+ // make sure the overloaded trigger is called!
1028+ q->metaObject()->invokeMethod(q, "trigger", Q_ARG(QVariant, QVariant()));
1029+ });
1030+ /*
1031+ * we cannot use setStyleName as that will trigger style loading
1032+ * and the qmlEngine is not known at this phase of the of the initialization
1033+ * Therefore we simply set the style name default. Style loading will
1034+ * happen during component completion.
1035+ */
1036+ styleDocument = "BottomEdgeHintStyle";
1037+
1038+ // connect old stateChanged
1039+ QObject::connect(q, &QQuickItem::stateChanged, q, &UCBottomEdgeHint::stateChanged);
1040+
1041+ // FIXME: use QInputDeviceInfo once available
1042+ // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1276808
1043+ QObject::connect(&QuickUtils::instance(), &QuickUtils::mouseAttachedChanged, q, &UCBottomEdgeHint::onMouseAttached);
1044+
1045+ // accept mouse events
1046+ q->setAcceptedMouseButtons(Qt::LeftButton);
1047+}
1048+
1049 /*!
1050 \qmltype BottomEdgeHint
1051 \inqmlmodule Ubuntu.Components 1.3
1052@@ -54,36 +94,15 @@
1053 The component is styled through \b BottomEdgeHintStyle.
1054 */
1055 UCBottomEdgeHint::UCBottomEdgeHint(QQuickItem *parent)
1056- : UCActionItem(parent)
1057- , m_swipeArea(new UCSwipeArea)
1058- , m_flickable(Q_NULLPTR)
1059- , m_deactivateTimeout(800)
1060- // FIXME: we need QInputDeviceInfo to be complete with the locked!!
1061- // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1276808
1062- , m_status(QuickUtils::instance().mouseAttached() ? Locked : Inactive)
1063- , m_pressed(false)
1064-{
1065- connect(this, &UCBottomEdgeHint::clicked, [=]() {
1066- // make sure the overloaded trigger is called!
1067- metaObject()->invokeMethod(this, "trigger", Q_ARG(QVariant, QVariant()));
1068- });
1069- /*
1070- * we cannot use setStyleName as that will trigger style loading
1071- * and the qmlEngine is not known at this phase of the of the initialization
1072- * Therefore we simply set the style name default. Style loading will
1073- * happen during component completion.
1074- */
1075- UCStyledItemBasePrivate::get(this)->styleDocument = "BottomEdgeHintStyle";
1076-
1077- // connect old stateChanged
1078- connect(this, &QQuickItem::stateChanged, this, &UCBottomEdgeHint::stateChanged);
1079-
1080- // FIXME: use QInputDeviceInfo once available
1081- // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1276808
1082- connect(&QuickUtils::instance(), &QuickUtils::mouseAttachedChanged, this, &UCBottomEdgeHint::onMouseAttached);
1083-
1084- // accept mouse events
1085- setAcceptedMouseButtons(Qt::LeftButton);
1086+ : UCActionItem(*(new UCBottomEdgeHintPrivate), parent)
1087+{
1088+ d_func()->init();
1089+}
1090+
1091+UCBottomEdgeHint::UCBottomEdgeHint(UCBottomEdgeHintPrivate &&dd, QQuickItem *parent)
1092+ : UCActionItem(dd, parent)
1093+{
1094+ d_func()->init();
1095 }
1096
1097 void UCBottomEdgeHint::classBegin()
1098@@ -94,57 +113,61 @@
1099
1100 void UCBottomEdgeHint::init()
1101 {
1102- QQml_setParent_noEvent(m_swipeArea, this);
1103- m_swipeArea->setParentItem(this);
1104+ Q_D(UCBottomEdgeHint);
1105+ QQml_setParent_noEvent(d->swipeArea, this);
1106+ d->swipeArea->setParentItem(this);
1107
1108 // set context
1109- QQmlEngine::setContextForObject(m_swipeArea, qmlContext(this));
1110+ QQmlEngine::setContextForObject(d->swipeArea, qmlContext(this));
1111
1112 // initialize swipe area size
1113- QQuickAnchors *anchors = QQuickItemPrivate::get(m_swipeArea)->anchors();
1114+ QQuickAnchors *anchors = QQuickItemPrivate::get(d->swipeArea)->anchors();
1115 QQuickItemPrivate *thisPrivate = QQuickItemPrivate::get(this);
1116 anchors->setLeft(thisPrivate->left());
1117 anchors->setBottom(thisPrivate->bottom());
1118 anchors->setRight(thisPrivate->right());
1119- m_swipeArea->setImplicitHeight(UCUnits::instance().gu(SWIPE_AREA_HEIGHT_GU));
1120+ d->swipeArea->setImplicitHeight(UCUnits::instance().gu(SWIPE_AREA_HEIGHT_GU));
1121
1122 // direction
1123- m_swipeArea->setDirection(UCSwipeArea::Upwards);
1124+ d->swipeArea->setDirection(UCSwipeArea::Upwards);
1125
1126 // grid unit sync
1127 connect(&UCUnits::instance(), &UCUnits::gridUnitChanged, this, &UCBottomEdgeHint::onGridUnitChanged);
1128
1129 // connect to gesture detection
1130- connect(m_swipeArea, &UCSwipeArea::draggingChanged,
1131+ connect(d->swipeArea, &UCSwipeArea::draggingChanged,
1132 this, &UCBottomEdgeHint::onDraggingChanged, Qt::DirectConnection);
1133 }
1134
1135 void UCBottomEdgeHint::onMouseAttached()
1136 {
1137+ Q_D(UCBottomEdgeHint);
1138 setStatus(QuickUtils::instance().mouseAttached() ? Locked : Active);
1139- if (m_status == Active) {
1140- m_deactivationTimer.start(m_deactivateTimeout, this);
1141- if (m_flickableBottomMargin) {
1142- delete m_flickableBottomMargin;
1143- m_flickableBottomMargin = Q_NULLPTR;
1144+ if (d->status == Active) {
1145+ d->deactivationTimer.start(d->deactivateTimeout, this);
1146+ if (d->flickableBottomMargin) {
1147+ delete d->flickableBottomMargin;
1148+ d->flickableBottomMargin = Q_NULLPTR;
1149 }
1150- } else if (m_flickable) {
1151+ } else if (d->flickable) {
1152 adjustFlickableBottomMargin();
1153 }
1154 }
1155
1156 void UCBottomEdgeHint::adjustFlickableBottomMargin()
1157 {
1158- if (!m_flickableBottomMargin) {
1159- m_flickableBottomMargin = new PropertyChange(m_flickable, "bottomMargin");
1160+ Q_D(UCBottomEdgeHint);
1161+ if (!d->flickableBottomMargin) {
1162+ d->flickableBottomMargin = new PropertyChange(d->flickable, "bottomMargin");
1163 }
1164- PropertyChange::setValue(m_flickableBottomMargin, height());
1165- m_flickable->setContentY(m_flickable->contentY() + height());
1166+ PropertyChange::setValue(d->flickableBottomMargin, height());
1167+ d->flickable->setContentY(d->flickable->contentY() + height());
1168 }
1169
1170 void UCBottomEdgeHint::onGridUnitChanged()
1171 {
1172- m_swipeArea->setImplicitHeight(UCUnits::instance().gu(SWIPE_AREA_HEIGHT_GU));
1173+ Q_D(UCBottomEdgeHint);
1174+ d->swipeArea->setImplicitHeight(UCUnits::instance().gu(SWIPE_AREA_HEIGHT_GU));
1175 }
1176
1177 void UCBottomEdgeHint::itemChange(ItemChange change, const ItemChangeData &data)
1178@@ -161,10 +184,11 @@
1179
1180 void UCBottomEdgeHint::timerEvent(QTimerEvent *event)
1181 {
1182+ Q_D(UCBottomEdgeHint);
1183 UCActionItem::timerEvent(event);
1184- if (event->timerId() == m_deactivationTimer.timerId()) {
1185+ if (event->timerId() == d->deactivationTimer.timerId()) {
1186 setStatus(Inactive);
1187- m_deactivationTimer.stop();
1188+ d->deactivationTimer.stop();
1189 }
1190 }
1191
1192@@ -180,8 +204,9 @@
1193 // handle click event
1194 void UCBottomEdgeHint::mousePressEvent(QMouseEvent *event)
1195 {
1196- if (contains(event->localPos()) && (m_status >= Active)) {
1197- m_pressed = true;
1198+ Q_D(UCBottomEdgeHint);
1199+ if (contains(event->localPos()) && (d->status >= Active)) {
1200+ d->pressed = true;
1201 event->accept();
1202 // also call requestFocus
1203 requestFocus(Qt::MouseFocusReason);
1204@@ -191,7 +216,8 @@
1205 }
1206 void UCBottomEdgeHint::mouseReleaseEvent(QMouseEvent *event)
1207 {
1208- if (m_pressed && (m_status >= Active) && contains(event->localPos())) {
1209+ Q_D(UCBottomEdgeHint);
1210+ if (d->pressed && (d->status >= Active) && contains(event->localPos())) {
1211 Q_EMIT clicked();
1212 event->accept();
1213 } else {
1214@@ -202,11 +228,12 @@
1215 // watch gesture detection status changes
1216 void UCBottomEdgeHint::onDraggingChanged(bool dragging)
1217 {
1218+ Q_D(UCBottomEdgeHint);
1219 if (dragging) {
1220- m_deactivationTimer.stop();
1221+ d->deactivationTimer.stop();
1222 setStatus(Active);
1223- } else if (m_status == Active) {
1224- m_deactivationTimer.start(m_deactivateTimeout, this);
1225+ } else if (d->status == Active) {
1226+ d->deactivationTimer.start(d->deactivateTimeout, this);
1227 }
1228 }
1229
1230@@ -243,22 +270,28 @@
1231 which is flicking or moving. It is recommended to set the property
1232 when the hint is placed above a flickable content. Defaults to null.
1233 */
1234+QQuickFlickable *UCBottomEdgeHint::flickable() const
1235+{
1236+ Q_D(const UCBottomEdgeHint);
1237+ return d->flickable;
1238+}
1239 void UCBottomEdgeHint::setFlickable(QQuickFlickable *flickable)
1240 {
1241- if (flickable == m_flickable) {
1242+ Q_D(UCBottomEdgeHint);
1243+ if (flickable == d->flickable) {
1244 return;
1245 }
1246- if (m_flickable) {
1247- disconnect(m_flickable, &QQuickFlickable::flickingChanged,
1248+ if (d->flickable) {
1249+ disconnect(d->flickable, &QQuickFlickable::flickingChanged,
1250 this, &UCBottomEdgeHint::handleFlickableActivation);
1251- disconnect(m_flickable, &QQuickFlickable::movingChanged,
1252+ disconnect(d->flickable, &QQuickFlickable::movingChanged,
1253 this, &UCBottomEdgeHint::handleFlickableActivation);
1254 }
1255- m_flickable = flickable;
1256- if (m_flickable) {
1257- connect(m_flickable, &QQuickFlickable::flickingChanged,
1258+ d->flickable = flickable;
1259+ if (d->flickable) {
1260+ connect(d->flickable, &QQuickFlickable::flickingChanged,
1261 this, &UCBottomEdgeHint::handleFlickableActivation, Qt::DirectConnection);
1262- connect(m_flickable, &QQuickFlickable::movingChanged,
1263+ connect(d->flickable, &QQuickFlickable::movingChanged,
1264 this, &UCBottomEdgeHint::handleFlickableActivation, Qt::DirectConnection);
1265 }
1266 Q_EMIT flickableChanged();
1267@@ -267,11 +300,12 @@
1268 // flickable moves hide the hint only if the current status is not Locked
1269 void UCBottomEdgeHint::handleFlickableActivation()
1270 {
1271- if (m_status < Locked && !m_swipeArea->dragging() && !m_deactivationTimer.isActive()) {
1272- bool moving = m_flickable->isFlicking() || m_flickable->isMoving();
1273+ Q_D(UCBottomEdgeHint);
1274+ if (d->status < Locked && !d->swipeArea->dragging() && !d->deactivationTimer.isActive()) {
1275+ bool moving = d->flickable->isFlicking() || d->flickable->isMoving();
1276 if (moving) {
1277 setStatus(Hidden);
1278- } else if (m_status == Hidden) {
1279+ } else if (d->status == Hidden) {
1280 setStatus(Inactive);
1281 }
1282 }
1283@@ -305,7 +339,8 @@
1284 QQuickItem::setState(state);
1285
1286 qmlInfo(this) << "Overloaded 'state' property deprecated, will be removed from 1.3 release. Use 'status' instead.";
1287- QQuickItem *style = UCStyledItemBasePrivate::get(this)->styleItem;
1288+ Q_D(UCBottomEdgeHint);
1289+ QQuickItem *style = d->styleItem;
1290 if (!style) {
1291 return;
1292 }
1293@@ -356,10 +391,11 @@
1294 {
1295 // FIXME: we won't need this once we get the QInputDeviceInfo reporting mouse attach/detach
1296 // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1276808
1297+ Q_D(UCBottomEdgeHint);
1298 if (QuickUtils::instance().mouseAttached()) {
1299- m_status = Locked;
1300+ d->status = Locked;
1301 }
1302- return m_status;
1303+ return d->status;
1304 }
1305
1306 void UCBottomEdgeHint::setStatus(Status status)
1307@@ -367,17 +403,18 @@
1308 // FIXME: we need QInputDeviceInfo to complete this!
1309 // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1276808
1310 // cannot unlock if mouse is attached or we don't have touch screen available
1311- if (status == m_status || (status != Locked && QuickUtils::instance().mouseAttached())) {
1312+ Q_D(UCBottomEdgeHint);
1313+ if (status == d->status || (status != Locked && QuickUtils::instance().mouseAttached())) {
1314 return;
1315 }
1316 // if the previous state was Locked and the new one is Active, start deactivation timer
1317- if (m_status == Locked && status == Active && !m_deactivationTimer.isActive()) {
1318- m_deactivationTimer.start(m_deactivateTimeout, this);
1319- } else if (status != Active && m_deactivationTimer.isActive()) {
1320+ if (d->status == Locked && status == Active && !d->deactivationTimer.isActive()) {
1321+ d->deactivationTimer.start(d->deactivateTimeout, this);
1322+ } else if (status != Active && d->deactivationTimer.isActive()) {
1323 // make sure we stop the deactivation timer if Inactive or Locked
1324- m_deactivationTimer.stop();
1325+ d->deactivationTimer.stop();
1326 }
1327- m_status = status;
1328+ d->status = status;
1329 Q_EMIT statusChanged();
1330 }
1331
1332@@ -388,16 +425,21 @@
1333 * is only possible when mouse is not attached to the device. Defaults to 800
1334 * milliseconds.
1335 */
1336-
1337+int UCBottomEdgeHint::deactivateTimeout() const
1338+{
1339+ Q_D(const UCBottomEdgeHint);
1340+ return d->deactivateTimeout;
1341+}
1342 void UCBottomEdgeHint::setDeactivateTimeout(int timeout)
1343 {
1344- if (timeout == m_deactivateTimeout || timeout < 0) {
1345+ Q_D(UCBottomEdgeHint);
1346+ if (timeout == d->deactivateTimeout || timeout < 0) {
1347 return;
1348 }
1349- m_deactivateTimeout = timeout;
1350- if (m_deactivationTimer.isActive()) {
1351- m_deactivationTimer.stop();
1352- m_deactivationTimer.start(m_deactivateTimeout, this);
1353+ d->deactivateTimeout = timeout;
1354+ if (d->deactivationTimer.isActive()) {
1355+ d->deactivationTimer.stop();
1356+ d->deactivationTimer.start(d->deactivateTimeout, this);
1357 }
1358 Q_EMIT deactivateTimeoutChanged();
1359 }
1360@@ -408,3 +450,9 @@
1361 * The property specifies the SwipeArea attached to the component driving its
1362 * behavior.
1363 */
1364+UCSwipeArea *UCBottomEdgeHint::swipeArea() const
1365+{
1366+ return d_func()->swipeArea;
1367+}
1368+
1369+#include "moc_ucbottomedgehint.cpp"
1370
1371=== modified file 'src/Ubuntu/Components/plugin/ucbottomedgehint.h'
1372--- src/Ubuntu/Components/plugin/ucbottomedgehint.h 2015-12-03 11:50:40 +0000
1373+++ src/Ubuntu/Components/plugin/ucbottomedgehint.h 2015-12-11 12:19:41 +0000
1374@@ -24,13 +24,14 @@
1375 class QQuickFlickable;
1376 class UCSwipeArea;
1377 class PropertyChange;
1378+class UCBottomEdgeHintPrivate;
1379 class UCBottomEdgeHint : public UCActionItem
1380 {
1381 Q_OBJECT
1382 Q_ENUMS(Status)
1383- Q_PROPERTY(QQuickFlickable *flickable MEMBER m_flickable WRITE setFlickable NOTIFY flickableChanged FINAL)
1384- Q_PROPERTY(Status status MEMBER m_status WRITE setStatus NOTIFY statusChanged FINAL)
1385- Q_PROPERTY(int deactivateTimeout MEMBER m_deactivateTimeout WRITE setDeactivateTimeout NOTIFY deactivateTimeoutChanged FINAL)
1386+ Q_PROPERTY(QQuickFlickable *flickable READ flickable WRITE setFlickable NOTIFY flickableChanged FINAL)
1387+ Q_PROPERTY(Status status READ status WRITE setStatus NOTIFY statusChanged FINAL)
1388+ Q_PROPERTY(int deactivateTimeout READ deactivateTimeout WRITE setDeactivateTimeout NOTIFY deactivateTimeoutChanged FINAL)
1389 Q_PROPERTY(UCSwipeArea* swipeArea READ swipeArea CONSTANT FINAL)
1390 // deprecated
1391 Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
1392@@ -43,14 +44,13 @@
1393 };
1394 explicit UCBottomEdgeHint(QQuickItem *parent = 0);
1395
1396+ QQuickFlickable *flickable() const;
1397 void setFlickable(QQuickFlickable *flickable);
1398 Status status();
1399 void setStatus(Status status);
1400+ int deactivateTimeout() const;
1401 void setDeactivateTimeout(int timeout);
1402- UCSwipeArea *swipeArea() const
1403- {
1404- return m_swipeArea;
1405- }
1406+ UCSwipeArea *swipeArea() const;
1407
1408 // deprecated
1409 QString state() const;
1410@@ -69,6 +69,7 @@
1411 // deprecated
1412 void stateChanged();
1413 protected:
1414+ UCBottomEdgeHint(UCBottomEdgeHintPrivate &&, QQuickItem *parent);
1415 void classBegin();
1416 void itemChange(ItemChange change, const ItemChangeData &data);
1417 void timerEvent(QTimerEvent *event);
1418@@ -84,13 +85,7 @@
1419 void onGridUnitChanged();
1420
1421 private:
1422- QBasicTimer m_deactivationTimer;
1423- UCSwipeArea *m_swipeArea;
1424- QQuickFlickable *m_flickable;
1425- PropertyChange *m_flickableBottomMargin = nullptr;
1426- int m_deactivateTimeout;
1427- Status m_status;
1428- bool m_pressed:1;
1429+ Q_DECLARE_PRIVATE(UCBottomEdgeHint)
1430
1431 friend class UCBottomEdge;
1432
1433
1434=== added file 'src/Ubuntu/Components/plugin/ucbottomedgehint_p.h'
1435--- src/Ubuntu/Components/plugin/ucbottomedgehint_p.h 1970-01-01 00:00:00 +0000
1436+++ src/Ubuntu/Components/plugin/ucbottomedgehint_p.h 2015-12-11 12:19:41 +0000
1437@@ -0,0 +1,46 @@
1438+/*
1439+ * Copyright 2015 Canonical Ltd.
1440+ *
1441+ * This program is free software; you can redistribute it and/or modify
1442+ * it under the terms of the GNU Lesser General Public License as published by
1443+ * the Free Software Foundation; version 3.
1444+ *
1445+ * This program is distributed in the hope that it will be useful,
1446+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1447+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1448+ * GNU Lesser General Public License for more details.
1449+ *
1450+ * You should have received a copy of the GNU Lesser General Public License
1451+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1452+ *
1453+ * Authors: Zsombor Egri <zsombor.egri@canonical.com>
1454+ */
1455+
1456+#ifndef UCBOTTOMEDGEHINT_P
1457+#define UCBOTTOMEDGEHINT_P
1458+
1459+#include "ucbottomedgehint.h"
1460+#include "ucactionitem_p.h"
1461+
1462+class UCBottomEdgeHintPrivate : public UCActionItemPrivate
1463+{
1464+ Q_DECLARE_PUBLIC(UCBottomEdgeHint)
1465+public:
1466+ static UCBottomEdgeHintPrivate *get(UCBottomEdgeHint *item)
1467+ {
1468+ return item->d_func();
1469+ }
1470+ UCBottomEdgeHintPrivate();
1471+ void init();
1472+
1473+ QBasicTimer deactivationTimer;
1474+ UCSwipeArea *swipeArea;
1475+ QQuickFlickable *flickable;
1476+ PropertyChange *flickableBottomMargin;
1477+ int deactivateTimeout;
1478+ UCBottomEdgeHint::Status status;
1479+ bool pressed:1;
1480+};
1481+
1482+#endif // UCBOTTOMEDGEHINT_P
1483+
1484
1485=== modified file 'src/Ubuntu/Components/plugin/ucstyleditembase.cpp'
1486--- src/Ubuntu/Components/plugin/ucstyleditembase.cpp 2015-12-01 00:44:21 +0000
1487+++ src/Ubuntu/Components/plugin/ucstyleditembase.cpp 2015-12-11 12:19:41 +0000
1488@@ -479,7 +479,12 @@
1489 }
1490 }
1491
1492-void UCStyledItemBasePrivate::completeStyledItem()
1493+/*
1494+ * The method is called on component completion, separated for the cases when
1495+ * the component is embedded in another CPP component and functionality depends
1496+ * on this initialization.
1497+ */
1498+void UCStyledItemBasePrivate::completeComponentInitialization()
1499 {
1500 // no animation at this time
1501 // prepare style context if not been done yet
1502@@ -494,7 +499,7 @@
1503 // make sure the theme version is up to date
1504 d->styleVersion = d->importVersion(this);
1505 UCTheme::checkMixedVersionImports(this, d->styleVersion);
1506- d->completeStyledItem();
1507+ d->completeComponentInitialization();
1508 }
1509
1510 void UCStyledItemBase::itemChange(ItemChange change, const ItemChangeData &data)
1511
1512=== modified file 'src/Ubuntu/Components/plugin/ucstyleditembase_p.h'
1513--- src/Ubuntu/Components/plugin/ucstyleditembase_p.h 2015-11-23 20:03:32 +0000
1514+++ src/Ubuntu/Components/plugin/ucstyleditembase_p.h 2015-12-11 12:19:41 +0000
1515@@ -56,7 +56,7 @@
1516 virtual void preStyleChanged();
1517 virtual void postStyleChanged() {}
1518 virtual bool loadStyleItem(bool animated = true);
1519- virtual void completeStyledItem();
1520+ virtual void completeComponentInitialization();
1521
1522 // from UCImportVersionChecker
1523 virtual QString propertyForVersion(quint16 version) const;

Subscribers

People subscribed via source and target branches