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
=== modified file 'src/Ubuntu/Components/plugin/plugin.pri'
--- src/Ubuntu/Components/plugin/plugin.pri 2015-12-07 17:02:28 +0000
+++ src/Ubuntu/Components/plugin/plugin.pri 2015-12-11 12:19:41 +0000
@@ -86,8 +86,10 @@
86 $$PWD/livetimer_p.h \86 $$PWD/livetimer_p.h \
87 $$PWD/timeutils_p.h \87 $$PWD/timeutils_p.h \
88 $$PWD/ucactionitem.h \88 $$PWD/ucactionitem.h \
89 $$PWD/ucactionitem_p.h \
89 $$PWD/uchaptics.h \90 $$PWD/uchaptics.h \
90 $$PWD/ucabstractbutton.h \91 $$PWD/ucabstractbutton.h \
92 $$PWD/ucabstractbutton_p.h \
91 $$PWD/ucthemingextension.h \93 $$PWD/ucthemingextension.h \
92 $$PWD/ucheader.h \94 $$PWD/ucheader.h \
93 $$PWD/uclabel.h \95 $$PWD/uclabel.h \
@@ -95,6 +97,7 @@
95 $$PWD/privates/threelabelsslot_p.h \97 $$PWD/privates/threelabelsslot_p.h \
96 $$PWD/ucimportversionchecker_p.h \98 $$PWD/ucimportversionchecker_p.h \
97 $$PWD/ucbottomedgehint.h \99 $$PWD/ucbottomedgehint.h \
100 $$PWD/ucbottomedgehint_p.h \
98 $$PWD/gestures/ucswipearea.h \101 $$PWD/gestures/ucswipearea.h \
99 $$PWD/gestures/ucswipearea_p.h \102 $$PWD/gestures/ucswipearea_p.h \
100 $$PWD/gestures/damper.h \103 $$PWD/gestures/damper.h \
101104
=== modified file 'src/Ubuntu/Components/plugin/ucabstractbutton.cpp'
--- src/Ubuntu/Components/plugin/ucabstractbutton.cpp 2015-12-05 05:59:07 +0000
+++ src/Ubuntu/Components/plugin/ucabstractbutton.cpp 2015-12-11 12:19:41 +0000
@@ -15,11 +15,26 @@
15 */15 */
1616
17#include "ucabstractbutton.h"17#include "ucabstractbutton.h"
18#include "ucabstractbutton_p.h"
18#include "uchaptics.h"19#include "uchaptics.h"
19#include <QtQuick/private/qquickitem_p.h>20#include <QtQuick/private/qquickitem_p.h>
20#include <QtQuick/private/qquickmousearea_p.h>21#include <QtQuick/private/qquickmousearea_p.h>
21#include <QtQml/private/qqmlglobal_p.h>22#include <QtQml/private/qqmlglobal_p.h>
2223
24UCAbstractButtonPrivate::UCAbstractButtonPrivate()
25 : UCActionItemPrivate()
26 , mouseArea(new QQuickMouseArea)
27 , acceptEvents(true)
28 , pressAndHoldConnected(false)
29{
30}
31void UCAbstractButtonPrivate::init()
32{
33 Q_Q(UCAbstractButton);
34 q->setActiveFocusOnPress(true);
35 q->setActiveFocusOnTab(true);
36}
37
23/*!38/*!
24 \qmltype AbstractButton39 \qmltype AbstractButton
25 \instantiates UCAbstractButton40 \instantiates UCAbstractButton
@@ -49,18 +64,20 @@
49 */64 */
5065
51UCAbstractButton::UCAbstractButton(QQuickItem *parent)66UCAbstractButton::UCAbstractButton(QQuickItem *parent)
52 : UCActionItem(parent)67 : UCActionItem(*(new UCAbstractButtonPrivate), parent)
53 , m_mouseArea(new QQuickMouseArea)68{
54 , m_acceptEvents(true)69 d_func()->init();
55 , m_pressAndHoldConnected(false)70}
56{71UCAbstractButton::UCAbstractButton(UCAbstractButtonPrivate &&dd, QQuickItem *parent)
57 setActiveFocusOnPress(true);72 : UCActionItem(dd, parent)
58 setActiveFocusOnTab(true);73{
74 d_func()->init();
59}75}
6076
61bool UCAbstractButton::isPressAndHoldConnected()77bool UCAbstractButtonPrivate::isPressAndHoldConnected()
62{78{
63 IS_SIGNAL_CONNECTED(this, UCAbstractButton, pressAndHold, ());79 Q_Q(UCAbstractButton);
80 IS_SIGNAL_CONNECTED(q, UCAbstractButton, pressAndHold, ());
64}81}
6582
66void UCAbstractButton::classBegin()83void UCAbstractButton::classBegin()
@@ -71,63 +88,68 @@
71 HapticsProxy::instance().initialize();88 HapticsProxy::instance().initialize();
7289
73 // set up mouse area90 // set up mouse area
74 QQml_setParent_noEvent(m_mouseArea, this);91 Q_D(UCAbstractButton);
75 m_mouseArea->setParentItem(this);92 QQml_setParent_noEvent(d->mouseArea, this);
76 QQuickAnchors *anchors = QQuickItemPrivate::get(m_mouseArea)->anchors();93 d->mouseArea->setParentItem(this);
94 QQuickAnchors *anchors = QQuickItemPrivate::get(d->mouseArea)->anchors();
77 anchors->setFill(this);95 anchors->setFill(this);
78 m_mouseArea->setHoverEnabled(true);96 d->mouseArea->setHoverEnabled(true);
79}97}
8098
81void UCAbstractButton::componentComplete()99void UCAbstractButtonPrivate::completeComponentInitialization()
82{100{
83 UCActionItem::componentComplete();101 UCActionItemPrivate::completeComponentInitialization();
102 Q_Q(UCAbstractButton);
84 // connect to the right slot, using macros so we get the proper slot103 // connect to the right slot, using macros so we get the proper slot
85 connect(m_mouseArea, SIGNAL(clicked(QQuickMouseEvent*)), this, SLOT(trigger()));104 QObject::connect(mouseArea, SIGNAL(clicked(QQuickMouseEvent*)), q, SLOT(trigger()));
86105
87 // bind mouse area106 // bind mouse area
88 connect(m_mouseArea, &QQuickMouseArea::pressedChanged, this, &UCAbstractButton::pressedChanged);107 QObject::connect(mouseArea, &QQuickMouseArea::pressedChanged, q, &UCAbstractButton::pressedChanged);
89 connect(m_mouseArea, &QQuickMouseArea::hoveredChanged, this, &UCAbstractButton::hoveredChanged);108 QObject::connect(mouseArea, &QQuickMouseArea::hoveredChanged, q, &UCAbstractButton::hoveredChanged);
90 connect(m_mouseArea, SIGNAL(clicked(QQuickMouseEvent*)), this, SLOT(_q_mouseAreaClicked()));109 QObject::connect(mouseArea, SIGNAL(clicked(QQuickMouseEvent*)), q, SLOT(_q_mouseAreaClicked()));
91 connect(m_mouseArea, SIGNAL(pressed(QQuickMouseEvent*)), this, SLOT(_q_mouseAreaPressed()));110 QObject::connect(mouseArea, SIGNAL(pressed(QQuickMouseEvent*)), q, SLOT(_q_mouseAreaPressed()));
92}111}
93112
94// check the pressAndHold connection on runtime, as Connections113// check the pressAndHold connection on runtime, as Connections
95// may not be available on compoennt completion114// may not be available on compoennt completion
96void UCAbstractButton::_q_mouseAreaPressed()115void UCAbstractButtonPrivate::_q_mouseAreaPressed()
97{116{
98 bool longPressConnected = isPressAndHoldConnected();117 bool longPressConnected = isPressAndHoldConnected();
99 if (longPressConnected && !m_pressAndHoldConnected) {118 Q_Q(UCAbstractButton);
119 if (longPressConnected && !pressAndHoldConnected) {
100 // do not use UniqueConnection as that has huge impact on performance120 // do not use UniqueConnection as that has huge impact on performance
101 connect(m_mouseArea, SIGNAL(pressAndHold(QQuickMouseEvent*)),121 QObject::connect(mouseArea, SIGNAL(pressAndHold(QQuickMouseEvent*)),
102 this, SLOT(_q_mouseAreaPressAndHold()));122 q, SLOT(_q_mouseAreaPressAndHold()));
103 m_pressAndHoldConnected = true;123 pressAndHoldConnected = true;
104 } else if (!longPressConnected && m_pressAndHoldConnected) {124 } else if (!longPressConnected && pressAndHoldConnected) {
105 disconnect(m_mouseArea, SIGNAL(pressAndHold(QQuickMouseEvent*)),125 QObject::disconnect(mouseArea, SIGNAL(pressAndHold(QQuickMouseEvent*)),
106 this, SLOT(_q_mouseAreaPressAndHold()));126 q, SLOT(_q_mouseAreaPressAndHold()));
107 m_pressAndHoldConnected = false;127 pressAndHoldConnected = false;
108 }128 }
109}129}
110130
111// handle mouseClicked with Haptics131// handle mouseClicked with Haptics
112void UCAbstractButton::_q_mouseAreaClicked()132void UCAbstractButtonPrivate::_q_mouseAreaClicked()
113{133{
114 // required by the deprecated ListItem module134 // required by the deprecated ListItem module
115 if (!m_acceptEvents) {135 Q_Q(UCAbstractButton);
136 if (!acceptEvents) {
116 return;137 return;
117 }138 }
118 // play haptics139 // play haptics
119 HapticsProxy::instance().play(QVariant());140 HapticsProxy::instance().play(QVariant());
120 Q_EMIT clicked();141 Q_EMIT q->clicked();
121}142}
122143
123// handle pressAndHold144// handle pressAndHold
124void UCAbstractButton::_q_mouseAreaPressAndHold()145void UCAbstractButtonPrivate::_q_mouseAreaPressAndHold()
125{146{
126 // required by the deprecated ListItem module147 // required by the deprecated ListItem module
127 if (!m_acceptEvents) {148 Q_Q(UCAbstractButton);
149 if (!acceptEvents) {
128 return;150 return;
129 }151 }
130 Q_EMIT pressAndHold();152 Q_EMIT q->pressAndHold();
131}153}
132154
133// emit clicked when Enter/Return is pressed155// emit clicked when Enter/Return is pressed
@@ -153,7 +175,8 @@
153 */175 */
154bool UCAbstractButton::pressed() const176bool UCAbstractButton::pressed() const
155{177{
156 return m_mouseArea ? m_mouseArea->pressed() : false;178 Q_D(const UCAbstractButton);
179 return d->mouseArea ? d->mouseArea->pressed() : false;
157}180}
158181
159/*!182/*!
@@ -162,10 +185,25 @@
162 */185 */
163bool UCAbstractButton::hovered() const186bool UCAbstractButton::hovered() const
164{187{
165 return m_mouseArea ? m_mouseArea->hovered() : false;188 Q_D(const UCAbstractButton);
189 return d->mouseArea ? d->mouseArea->hovered() : false;
190}
191
192bool UCAbstractButton::acceptEvents() const
193{
194 Q_D(const UCAbstractButton);
195 return d->acceptEvents;
196}
197void UCAbstractButton::setAcceptEvents(bool value)
198{
199 Q_D(UCAbstractButton);
200 d->acceptEvents = value;
166}201}
167202
168QQuickMouseArea *UCAbstractButton::privateMouseArea() const203QQuickMouseArea *UCAbstractButton::privateMouseArea() const
169{204{
170 return m_mouseArea;205 Q_D(const UCAbstractButton);
206 return d->mouseArea;
171}207}
208
209#include "moc_ucabstractbutton.cpp"
172210
=== modified file 'src/Ubuntu/Components/plugin/ucabstractbutton.h'
--- src/Ubuntu/Components/plugin/ucabstractbutton.h 2015-09-30 18:55:20 +0000
+++ src/Ubuntu/Components/plugin/ucabstractbutton.h 2015-12-11 12:19:41 +0000
@@ -21,6 +21,7 @@
2121
22class QQuickMouseArea;22class QQuickMouseArea;
23class QQuickMouseEvent;23class QQuickMouseEvent;
24class UCAbstractButtonPrivate;
24class UCAbstractButton : public UCActionItem25class UCAbstractButton : public UCActionItem
25{26{
26 Q_OBJECT27 Q_OBJECT
@@ -28,7 +29,7 @@
28 Q_PROPERTY(bool hovered READ hovered NOTIFY hoveredChanged)29 Q_PROPERTY(bool hovered READ hovered NOTIFY hoveredChanged)
2930
30 // internal, declared to support the deprecated ListItem module31 // internal, declared to support the deprecated ListItem module
31 Q_PROPERTY(bool __acceptEvents MEMBER m_acceptEvents)32 Q_PROPERTY(bool __acceptEvents READ acceptEvents WRITE setAcceptEvents)
32 Q_PROPERTY(QQuickMouseArea *__mouseArea READ privateMouseArea CONSTANT)33 Q_PROPERTY(QQuickMouseArea *__mouseArea READ privateMouseArea CONSTANT)
33public:34public:
34 explicit UCAbstractButton(QQuickItem *parent = 0);35 explicit UCAbstractButton(QQuickItem *parent = 0);
@@ -38,11 +39,12 @@
3839
39 bool privateAcceptEvents() const;40 bool privateAcceptEvents() const;
40 void setPrivateAcceptEvents(bool accept);41 void setPrivateAcceptEvents(bool accept);
42 bool acceptEvents() const;
43 void setAcceptEvents(bool value);
41 QQuickMouseArea *privateMouseArea() const;44 QQuickMouseArea *privateMouseArea() const;
4245
43protected:46protected:
44 void classBegin();47 void classBegin();
45 void componentComplete();
46 void keyPressEvent(QKeyEvent *key);48 void keyPressEvent(QKeyEvent *key);
4749
48Q_SIGNALS:50Q_SIGNALS:
@@ -51,17 +53,13 @@
51 void clicked();53 void clicked();
52 void pressAndHold();54 void pressAndHold();
5355
54protected Q_SLOTS:
55 void _q_mouseAreaPressed();
56 void _q_mouseAreaClicked();
57 void _q_mouseAreaPressAndHold();
58
59protected:56protected:
60 QQuickMouseArea *m_mouseArea;57 UCAbstractButton(UCAbstractButtonPrivate &&, QQuickItem *parent = 0);
61 bool m_acceptEvents:1;
62 bool m_pressAndHoldConnected:1;
6358
64 bool isPressAndHoldConnected();59 Q_DECLARE_PRIVATE(UCAbstractButton)
60 Q_PRIVATE_SLOT(d_func(), void _q_mouseAreaPressed())
61 Q_PRIVATE_SLOT(d_func(), void _q_mouseAreaClicked())
62 Q_PRIVATE_SLOT(d_func(), void _q_mouseAreaPressAndHold())
65};63};
6664
67#endif // UCABSTRACTBUTTON_H65#endif // UCABSTRACTBUTTON_H
6866
=== added file 'src/Ubuntu/Components/plugin/ucabstractbutton_p.h'
--- src/Ubuntu/Components/plugin/ucabstractbutton_p.h 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/plugin/ucabstractbutton_p.h 2015-12-11 12:19:41 +0000
@@ -0,0 +1,50 @@
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
17#ifndef UCABSTRACTBUTTON_P
18#define UCABSTRACTBUTTON_P
19
20#include "ucabstractbutton.h"
21#include "ucactionitem_p.h"
22
23class UCAbstractButtonPrivate : public UCActionItemPrivate
24{
25 Q_DECLARE_PUBLIC(UCAbstractButton)
26public:
27 static UCAbstractButtonPrivate *get(UCAbstractButton *item)
28 {
29 return item->d_func();
30 }
31
32 UCAbstractButtonPrivate();
33 void init();
34
35 void completeComponentInitialization() override;
36
37 bool isPressAndHoldConnected();
38
39 // private slots
40 void _q_mouseAreaPressed();
41 void _q_mouseAreaClicked();
42 void _q_mouseAreaPressAndHold();
43
44 QQuickMouseArea *mouseArea;
45 bool acceptEvents:1;
46 bool pressAndHoldConnected:1;
47};
48
49#endif // UCABSTRACTBUTTON_P
50
051
=== modified file 'src/Ubuntu/Components/plugin/ucaction.h'
--- src/Ubuntu/Components/plugin/ucaction.h 2015-12-08 15:13:49 +0000
+++ src/Ubuntu/Components/plugin/ucaction.h 2015-12-11 12:19:41 +0000
@@ -101,6 +101,7 @@
101101
102 friend class UCActionContext;102 friend class UCActionContext;
103 friend class UCActionItem;103 friend class UCActionItem;
104 friend class UCActionItemPrivate;
104 friend class UCListItemPrivate;105 friend class UCListItemPrivate;
105 friend class UCListItemAttached;106 friend class UCListItemAttached;
106 friend class UCListItemActionsPrivate;107 friend class UCListItemActionsPrivate;
107108
=== modified file 'src/Ubuntu/Components/plugin/ucactionitem.cpp'
--- src/Ubuntu/Components/plugin/ucactionitem.cpp 2015-09-16 05:26:36 +0000
+++ src/Ubuntu/Components/plugin/ucactionitem.cpp 2015-12-11 12:19:41 +0000
@@ -15,12 +15,26 @@
15 */15 */
1616
17#include "ucactionitem.h"17#include "ucactionitem.h"
18#include "ucactionitem_p.h"
18#include "ucaction.h"19#include "ucaction.h"
19#include "ucstyleditembase_p.h"20#include "ucstyleditembase_p.h"
20#define foreach Q_FOREACH21#define foreach Q_FOREACH
21#include <QtQml/private/qqmlbinding_p.h>22#include <QtQml/private/qqmlbinding_p.h>
22#undef foreach23#undef foreach
2324
25UCActionItemPrivate::UCActionItemPrivate()
26 : action(Q_NULLPTR)
27 , flags(0)
28{
29}
30
31void UCActionItemPrivate::init()
32{
33 Q_Q(UCActionItem);
34 QObject::connect(q, &UCActionItem::enabledChanged, q, &UCActionItem::enabledChanged2);
35 QObject::connect(q, &UCActionItem::visibleChanged, q, &UCActionItem::visibleChanged2);
36}
37
24/*!38/*!
25 * \qmltype ActionItem39 * \qmltype ActionItem
26 * \instantiates UCActionItem40 * \instantiates UCActionItem
@@ -40,57 +54,61 @@
40 * Called when the actionItem is triggered.54 * Called when the actionItem is triggered.
41 */55 */
42UCActionItem::UCActionItem(QQuickItem *parent)56UCActionItem::UCActionItem(QQuickItem *parent)
43 : UCStyledItemBase(parent)57 : UCStyledItemBase(*(new UCActionItemPrivate), parent)
44 , m_action(Q_NULLPTR)58{
45 , m_flags(0)59 d_func()->init();
46{60}
47 connect(this, &UCActionItem::enabledChanged, this, &UCActionItem::enabledChanged2);61
48 connect(this, &UCActionItem::visibleChanged, this, &UCActionItem::visibleChanged2);62UCActionItem::UCActionItem(UCActionItemPrivate &dd, QQuickItem *parent)
49}63 : UCStyledItemBase(dd, parent)
5064{
51bool UCActionItem::hasBindingOnProperty(const QString &name)65 d_func()->init();
52{66}
53 QQmlProperty property(this, name, qmlContext(this));67
68bool UCActionItemPrivate::hasBindingOnProperty(const QString &name)
69{
70 Q_Q(UCActionItem);
71 QQmlProperty property(q, name, qmlContext(q));
54 return QQmlPropertyPrivate::binding(property) != Q_NULLPTR;72 return QQmlPropertyPrivate::binding(property) != Q_NULLPTR;
55}73}
5674
57void UCActionItem::componentComplete()75void UCActionItemPrivate::completeComponentInitialization()
58{76{
59 UCStyledItemBase::componentComplete();77 UCStyledItemBasePrivate::completeComponentInitialization();
60 // make sure we connect to the right signals, so we detach and re-attach actions78 // make sure we connect to the right signals, so we detach and re-attach actions
61 // to make sure the SLOT macro picks up the custom trigger() slot79 // to make sure the SLOT macro picks up the custom trigger() slot
62 if (m_action) {80 if (action) {
63 attachAction(false);81 attachAction(false);
64 attachAction(true);82 attachAction(true);
65 }83 }
66}84}
6785
68// update visible property86// update visible property
69void UCActionItem::_q_visibleBinding()87void UCActionItemPrivate::_q_visibleBinding()
70{88{
71 if (m_flags & CustomVisible) {89 if (flags & CustomVisible) {
72 return;90 return;
73 }91 }
74 if (hasBindingOnProperty(QStringLiteral("visible"))) {92 if (hasBindingOnProperty(QStringLiteral("visible"))) {
75 m_flags |= CustomEnabled;93 flags |= CustomEnabled;
76 return;94 return;
77 }95 }
78 bool visible = m_action ? m_action->m_visible : true;96 bool visible = action ? action->m_visible : true;
79 setVisible(visible);97 q_func()->setVisible(visible);
80}98}
8199
82// update enabled property100// update enabled property
83void UCActionItem::_q_enabledBinding()101void UCActionItemPrivate::_q_enabledBinding()
84{102{
85 if (m_flags & CustomEnabled) {103 if (flags & CustomEnabled) {
86 return;104 return;
87 }105 }
88 if (hasBindingOnProperty(QStringLiteral("enabled"))) {106 if (hasBindingOnProperty(QStringLiteral("enabled"))) {
89 m_flags |= CustomEnabled;107 flags |= CustomEnabled;
90 return;108 return;
91 }109 }
92 bool enabled = m_action ? m_action->m_enabled : true;110 bool enabled = action ? action->m_enabled : true;
93 setEnabled(enabled);111 q_func()->setEnabled(enabled);
94}112}
95113
96// setter called when bindings from QML set the value. Internal functions will114// setter called when bindings from QML set the value. Internal functions will
@@ -99,75 +117,77 @@
99void UCActionItem::setVisible2(bool visible)117void UCActionItem::setVisible2(bool visible)
100{118{
101 // set the custom flag and forward the value to the original proepry setter119 // set the custom flag and forward the value to the original proepry setter
102 m_flags |= CustomVisible;120 d_func()->flags |= UCActionItemPrivate::CustomVisible;
103 setVisible(visible);121 setVisible(visible);
104}122}
105void UCActionItem::setEnabled2(bool enabled)123void UCActionItem::setEnabled2(bool enabled)
106{124{
107 m_flags |= CustomEnabled;125 d_func()->flags |= UCActionItemPrivate::CustomEnabled;
108 setEnabled(enabled);126 setEnabled(enabled);
109}127}
110128
111void UCActionItem::updateProperties()129void UCActionItemPrivate::updateProperties()
112{130{
113 if (!(m_flags & CustomText)) {131 Q_Q(UCActionItem);
114 Q_EMIT textChanged();132 if (!(flags & CustomText)) {
115 }133 Q_EMIT q->textChanged();
116 if (!(m_flags & CustomIconSource)) {134 }
117 Q_EMIT iconSourceChanged();135 if (!(flags & CustomIconSource)) {
118 }136 Q_EMIT q->iconSourceChanged();
119 if (!(m_flags & CustomIconName)) {137 }
120 Q_EMIT iconNameChanged();138 if (!(flags & CustomIconName)) {
139 Q_EMIT q->iconNameChanged();
121 }140 }
122}141}
123142
124void UCActionItem::attachAction(bool attach)143void UCActionItemPrivate::attachAction(bool attach)
125{144{
145 Q_Q(UCActionItem);
126 if (attach) {146 if (attach) {
127 connect(this, SIGNAL(triggered(QVariant)),147 QObject::connect(q, SIGNAL(triggered(QVariant)),
128 m_action, SLOT(trigger(QVariant)), Qt::DirectConnection);148 action, SLOT(trigger(QVariant)), Qt::DirectConnection);
129 if (!(m_flags & CustomVisible)) {149 if (!(flags & CustomVisible)) {
130 connect(m_action, &UCAction::visibleChanged,150 QObject::connect(action, SIGNAL(visibleChanged()),
131 this, &UCActionItem::_q_visibleBinding, Qt::DirectConnection);151 q, SLOT(_q_visibleBinding()), Qt::DirectConnection);
132 }152 }
133 if (!(m_flags & CustomEnabled)) {153 if (!(flags & CustomEnabled)) {
134 connect(m_action, &UCAction::enabledChanged,154 QObject::connect(action, SIGNAL(enabledChanged()),
135 this, &UCActionItem::_q_enabledBinding, Qt::DirectConnection);155 q, SLOT(_q_enabledBinding()), Qt::DirectConnection);
136 }156 }
137 if (!(m_flags & CustomText)) {157 if (!(flags & CustomText)) {
138 connect(m_action, &UCAction::textChanged,158 QObject::connect(action, &UCAction::textChanged,
139 this, &UCActionItem::textChanged, Qt::DirectConnection);159 q, &UCActionItem::textChanged, Qt::DirectConnection);
140 }160 }
141 if (!(m_flags & CustomIconSource)) {161 if (!(flags & CustomIconSource)) {
142 connect(m_action, &UCAction::iconSourceChanged,162 QObject::connect(action, &UCAction::iconSourceChanged,
143 this, &UCActionItem::iconSourceChanged, Qt::DirectConnection);163 q, &UCActionItem::iconSourceChanged, Qt::DirectConnection);
144 }164 }
145 if (!(m_flags & CustomIconName)) {165 if (!(flags & CustomIconName)) {
146 connect(m_action, &UCAction::iconNameChanged,166 QObject::connect(action, &UCAction::iconNameChanged,
147 this, &UCActionItem::iconNameChanged, Qt::DirectConnection);167 q, &UCActionItem::iconNameChanged, Qt::DirectConnection);
148 }168 }
149 } else {169 } else {
150 disconnect(this, SIGNAL(triggered(QVariant)),170 QObject::disconnect(q, SIGNAL(triggered(QVariant)),
151 m_action, SLOT(trigger(QVariant)));171 action, SLOT(trigger(QVariant)));
152 if (!(m_flags & CustomVisible)) {172 if (!(flags & CustomVisible)) {
153 disconnect(m_action, &UCAction::visibleChanged,173 QObject::disconnect(action, SIGNAL(visibleChanged()),
154 this, &UCActionItem::_q_visibleBinding);174 q, SLOT(_q_visibleBinding()));
155 }175 }
156 if (!(m_flags & CustomEnabled)) {176 if (!(flags & CustomEnabled)) {
157 disconnect(m_action, &UCAction::enabledChanged,177 QObject::disconnect(action, SIGNAL(enabledChanged()),
158 this, &UCActionItem::_q_enabledBinding);178 q, SLOT(_q_enabledBinding()));
159 }179 }
160 if (!(m_flags & CustomText)) {180 if (!(flags & CustomText)) {
161 disconnect(m_action, &UCAction::textChanged,181 QObject::disconnect(action, &UCAction::textChanged,
162 this, &UCActionItem::textChanged);182 q, &UCActionItem::textChanged);
163 }183 }
164 if (!(m_flags & CustomIconSource)) {184 if (!(flags & CustomIconSource)) {
165 disconnect(m_action, &UCAction::iconSourceChanged,185 QObject::disconnect(action, &UCAction::iconSourceChanged,
166 this, &UCActionItem::iconSourceChanged);186 q, &UCActionItem::iconSourceChanged);
167 }187 }
168 if (!(m_flags & CustomIconName)) {188 if (!(flags & CustomIconName)) {
169 disconnect(m_action, &UCAction::iconNameChanged,189 QObject::disconnect(action, &UCAction::iconNameChanged,
170 this, &UCActionItem::iconNameChanged);190 q, &UCActionItem::iconNameChanged);
171 }191 }
172 }192 }
173}193}
@@ -178,23 +198,29 @@
178 * of the \l Action properties are copied to the values of the ActionItem198 * of the \l Action properties are copied to the values of the ActionItem
179 * properties, unless those were previously overridden.199 * properties, unless those were previously overridden.
180 */200 */
201UCAction* UCActionItem::action() const
202{
203 Q_D(const UCActionItem);
204 return d->action;
205}
181void UCActionItem::setAction(UCAction *action)206void UCActionItem::setAction(UCAction *action)
182{207{
183 if (m_action == action) {208 Q_D(UCActionItem);
209 if (d->action == action) {
184 return;210 return;
185 }211 }
186 if (m_action) {212 if (d->action) {
187 attachAction(false);213 d->attachAction(false);
188 }214 }
189 m_action = action;215 d->action = action;
190 Q_EMIT actionChanged();216 Q_EMIT actionChanged();
191217
192 if (m_action) {218 if (d->action) {
193 attachAction(true);219 d->attachAction(true);
194 }220 }
195 _q_visibleBinding();221 d->_q_visibleBinding();
196 _q_enabledBinding();222 d->_q_enabledBinding();
197 updateProperties();223 d->updateProperties();
198}224}
199225
200/*!226/*!
@@ -203,32 +229,35 @@
203 */229 */
204QString UCActionItem::text()230QString UCActionItem::text()
205{231{
206 if (m_flags & CustomText) {232 Q_D(UCActionItem);
207 return m_text;233 if (d->flags & UCActionItemPrivate::CustomText) {
234 return d->text;
208 }235 }
209 return m_action ? m_action->m_text : QString();236 return d->action ? d->action->m_text : QString();
210}237}
211void UCActionItem::setText(const QString &text)238void UCActionItem::setText(const QString &text)
212{239{
213 if (m_text == text) {240 Q_D(UCActionItem);
241 if (d->text == text) {
214 return;242 return;
215 }243 }
216 m_text = text;244 d->text = text;
217 if (m_action && !(m_flags & CustomText)) {245 if (d->action && !(d->flags & UCActionItemPrivate::CustomText)) {
218 // disconnect change signal from Action246 // disconnect change signal from Action
219 disconnect(m_action, &UCAction::textChanged,247 disconnect(d->action, &UCAction::textChanged,
220 this, &UCActionItem::textChanged);248 this, &UCActionItem::textChanged);
221 }249 }
222 m_flags |= CustomText;250 d->flags |= UCActionItemPrivate::CustomText;
223 Q_EMIT textChanged();251 Q_EMIT textChanged();
224}252}
225void UCActionItem::resetText()253void UCActionItem::resetText()
226{254{
227 m_text.clear();255 Q_D(UCActionItem);
228 m_flags &= ~CustomText;256 d->text.clear();
229 if (m_action) {257 d->flags &= ~UCActionItemPrivate::CustomText;
258 if (d->action) {
230 // re-connect change signal from Action259 // re-connect change signal from Action
231 connect(m_action, &UCAction::textChanged,260 connect(d->action, &UCAction::textChanged,
232 this, &UCActionItem::textChanged, Qt::DirectConnection);261 this, &UCActionItem::textChanged, Qt::DirectConnection);
233 }262 }
234 Q_EMIT textChanged();263 Q_EMIT textChanged();
@@ -243,35 +272,38 @@
243 */272 */
244QUrl UCActionItem::iconSource()273QUrl UCActionItem::iconSource()
245{274{
246 if (m_flags & CustomIconSource) {275 Q_D(UCActionItem);
247 return m_iconSource;276 if (d->flags & UCActionItemPrivate::CustomIconSource) {
277 return d->iconSource;
248 }278 }
249 if (m_action) {279 if (d->action) {
250 return m_action->m_iconSource;280 return d->action->m_iconSource;
251 }281 }
252 return !iconName().isEmpty() ? QUrl(QString("image://theme/%1").arg(iconName())) : QUrl();282 return !iconName().isEmpty() ? QUrl(QString("image://theme/%1").arg(iconName())) : QUrl();
253}283}
254void UCActionItem::setIconSource(const QUrl &iconSource)284void UCActionItem::setIconSource(const QUrl &iconSource)
255{285{
256 if (m_iconSource == iconSource) {286 Q_D(UCActionItem);
287 if (d->iconSource == iconSource) {
257 return;288 return;
258 }289 }
259 m_iconSource = iconSource;290 d->iconSource = iconSource;
260 if (m_action && !(m_flags & CustomIconSource)) {291 if (d->action && !(d->flags & UCActionItemPrivate::CustomIconSource)) {
261 // disconnect change signal from Action292 // disconnect change signal from Action
262 disconnect(m_action, &UCAction::iconSourceChanged,293 disconnect(d->action, &UCAction::iconSourceChanged,
263 this, &UCActionItem::iconSourceChanged);294 this, &UCActionItem::iconSourceChanged);
264 }295 }
265 m_flags |= CustomIconSource;296 d->flags |= UCActionItemPrivate::CustomIconSource;
266 Q_EMIT iconSourceChanged();297 Q_EMIT iconSourceChanged();
267}298}
268void UCActionItem::resetIconSource()299void UCActionItem::resetIconSource()
269{300{
270 m_iconSource.clear();301 Q_D(UCActionItem);
271 m_flags &= ~CustomIconSource;302 d->iconSource.clear();
272 if (m_action) {303 d->flags &= ~UCActionItemPrivate::CustomIconSource;
304 if (d->action) {
273 // re-connect change signal from Action305 // re-connect change signal from Action
274 connect(m_action, &UCAction::iconSourceChanged,306 connect(d->action, &UCAction::iconSourceChanged,
275 this, &UCActionItem::iconSourceChanged, Qt::DirectConnection);307 this, &UCActionItem::iconSourceChanged, Qt::DirectConnection);
276 }308 }
277 Q_EMIT iconSourceChanged();309 Q_EMIT iconSourceChanged();
@@ -294,36 +326,39 @@
294 */326 */
295QString UCActionItem::iconName()327QString UCActionItem::iconName()
296{328{
297 if (m_flags & CustomIconName) {329 Q_D(UCActionItem);
298 return m_iconName;330 if (d->flags & UCActionItemPrivate::CustomIconName) {
331 return d->iconName;
299 }332 }
300 return m_action ? m_action->m_iconName : QString();333 return d->action ? d->action->m_iconName : QString();
301}334}
302void UCActionItem::setIconName(const QString &iconName)335void UCActionItem::setIconName(const QString &iconName)
303{336{
304 if (m_iconName == iconName) {337 Q_D(UCActionItem);
338 if (d->iconName == iconName) {
305 return;339 return;
306 }340 }
307 m_iconName = iconName;341 d->iconName = iconName;
308 if (m_action && !(m_flags & CustomIconName)) {342 if (d->action && !(d->flags & UCActionItemPrivate::CustomIconName)) {
309 // disconnect change signal from Action343 // disconnect change signal from Action
310 disconnect(m_action, &UCAction::iconNameChanged,344 disconnect(d->action, &UCAction::iconNameChanged,
311 this, &UCActionItem::iconNameChanged);345 this, &UCActionItem::iconNameChanged);
312 }346 }
313 m_flags |= CustomIconName;347 d->flags |= UCActionItemPrivate::CustomIconName;
314 Q_EMIT iconNameChanged();348 Q_EMIT iconNameChanged();
315 // also sync iconSource if that is not a custom one or taken from action349 // also sync iconSource if that is not a custom one or taken from action
316 if (!m_action || (m_flags & CustomIconSource)) {350 if (!d->action || (d->flags & UCActionItemPrivate::CustomIconSource)) {
317 Q_EMIT iconSourceChanged();351 Q_EMIT iconSourceChanged();
318 }352 }
319}353}
320void UCActionItem::resetIconName()354void UCActionItem::resetIconName()
321{355{
322 m_iconName.clear();356 Q_D(UCActionItem);
323 m_flags &= ~CustomIconName;357 d->iconName.clear();
324 if (m_action) {358 d->flags &= ~UCActionItemPrivate::CustomIconName;
359 if (d->action) {
325 // re-connect change signal from Action360 // re-connect change signal from Action
326 connect(m_action, &UCAction::iconNameChanged,361 connect(d->action, &UCAction::iconNameChanged,
327 this, &UCActionItem::iconNameChanged, Qt::DirectConnection);362 this, &UCActionItem::iconNameChanged, Qt::DirectConnection);
328 }363 }
329 Q_EMIT iconNameChanged();364 Q_EMIT iconNameChanged();
@@ -339,3 +374,5 @@
339 Q_EMIT triggered(value);374 Q_EMIT triggered(value);
340 }375 }
341}376}
377
378#include "moc_ucactionitem.cpp"
342379
=== modified file 'src/Ubuntu/Components/plugin/ucactionitem.h'
--- src/Ubuntu/Components/plugin/ucactionitem.h 2015-09-16 05:26:36 +0000
+++ src/Ubuntu/Components/plugin/ucactionitem.h 2015-12-11 12:19:41 +0000
@@ -19,10 +19,11 @@
19#include "ucstyleditembase.h"19#include "ucstyleditembase.h"
2020
21class UCAction;21class UCAction;
22class UCActionItemPrivate;
22class UCActionItem : public UCStyledItemBase23class UCActionItem : public UCStyledItemBase
23{24{
24 Q_OBJECT25 Q_OBJECT
25 Q_PROPERTY(UCAction *action MEMBER m_action WRITE setAction NOTIFY actionChanged FINAL)26 Q_PROPERTY(UCAction *action READ action WRITE setAction NOTIFY actionChanged FINAL)
26 Q_PROPERTY(QString text READ text WRITE setText RESET resetText NOTIFY textChanged)27 Q_PROPERTY(QString text READ text WRITE setText RESET resetText NOTIFY textChanged)
27 Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource RESET resetIconSource NOTIFY iconSourceChanged)28 Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource RESET resetIconSource NOTIFY iconSourceChanged)
28 Q_PROPERTY(QString iconName READ iconName WRITE setIconName RESET resetIconName NOTIFY iconNameChanged)29 Q_PROPERTY(QString iconName READ iconName WRITE setIconName RESET resetIconName NOTIFY iconNameChanged)
@@ -33,6 +34,7 @@
33public:34public:
34 explicit UCActionItem(QQuickItem *parent = 0);35 explicit UCActionItem(QQuickItem *parent = 0);
3536
37 UCAction *action() const;
36 void setAction(UCAction *action);38 void setAction(UCAction *action);
37 QString text();39 QString text();
38 void setText(const QString &text);40 void setText(const QString &text);
@@ -60,29 +62,12 @@
60public Q_SLOTS:62public Q_SLOTS:
61 void trigger(const QVariant &value = QVariant());63 void trigger(const QVariant &value = QVariant());
6264
63protected Q_SLOTS:
64 void _q_visibleBinding();
65 void _q_enabledBinding();
66
67protected:65protected:
68 enum {66 UCActionItem(UCActionItemPrivate &, QQuickItem *parent);
69 CustomText = 0x01,67
70 CustomIconSource = 0x02,68 Q_DECLARE_PRIVATE(UCActionItem)
71 CustomIconName = 0x04,69 Q_PRIVATE_SLOT(d_func(), void _q_visibleBinding())
72 CustomVisible = 0x40,70 Q_PRIVATE_SLOT(d_func(), void _q_enabledBinding())
73 CustomEnabled = 0x80
74 };
75 QString m_text;
76 QString m_iconName;
77 QUrl m_iconSource;
78 UCAction *m_action;
79 quint8 m_flags;
80
81 void componentComplete();
82
83 bool hasBindingOnProperty(const QString &name);
84 void updateProperties();
85 void attachAction(bool attach);
86};71};
8772
88#endif // UCACTIONITEM_H73#endif // UCACTIONITEM_H
8974
=== added file 'src/Ubuntu/Components/plugin/ucactionitem_p.h'
--- src/Ubuntu/Components/plugin/ucactionitem_p.h 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/plugin/ucactionitem_p.h 2015-12-11 12:19:41 +0000
@@ -0,0 +1,63 @@
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 * Author: Zsombor Egri <zsombor.egri@canonical.com>
17 */
18
19#ifndef UCACTIONITEM_P
20#define UCACTIONITEM_P
21
22#include "ucactionitem.h"
23#include "ucstyleditembase_p.h"
24
25class UCActionItemPrivate : public UCStyledItemBasePrivate
26{
27 Q_DECLARE_PUBLIC(UCActionItem)
28public:
29 static UCActionItemPrivate* get(UCActionItem *item)
30 {
31 return item->d_func();
32 }
33
34 UCActionItemPrivate();
35 void init();
36
37 bool hasBindingOnProperty(const QString &name);
38 void updateProperties();
39 void attachAction(bool attach);
40
41 // overrides
42 void completeComponentInitialization() override;
43
44 // private slots
45 void _q_visibleBinding();
46 void _q_enabledBinding();
47
48 enum {
49 CustomText = 0x01,
50 CustomIconSource = 0x02,
51 CustomIconName = 0x04,
52 CustomVisible = 0x40,
53 CustomEnabled = 0x80
54 };
55 QString text;
56 QString iconName;
57 QUrl iconSource;
58 UCAction *action;
59 quint8 flags;
60};
61
62#endif // UCACTIONITEM_P
63
064
=== modified file 'src/Ubuntu/Components/plugin/ucbottomedge.cpp'
--- src/Ubuntu/Components/plugin/ucbottomedge.cpp 2015-12-02 15:31:53 +0000
+++ src/Ubuntu/Components/plugin/ucbottomedge.cpp 2015-12-11 12:19:41 +0000
@@ -19,7 +19,7 @@
19#include "ucbottomedge_p.h"19#include "ucbottomedge_p.h"
20#include "ucbottomedgestyle.h"20#include "ucbottomedgestyle.h"
21#include "ucbottomedgeregion.h"21#include "ucbottomedgeregion.h"
22#include "ucbottomedgehint.h"22#include "ucbottomedgehint_p.h"
23#include "ucstyleditembase_p.h"23#include "ucstyleditembase_p.h"
24#include <QtQml/QQmlEngine>24#include <QtQml/QQmlEngine>
25#include <QtGui/QScreen>25#include <QtGui/QScreen>
@@ -737,26 +737,26 @@
737 initializeComponent();737 initializeComponent();
738}738}
739739
740void UCBottomEdge::componentComplete()740void UCBottomEdgePrivate::completeComponentInitialization()
741{741{
742 UCStyledItemBase::componentComplete();742 UCStyledItemBasePrivate::completeComponentInitialization();
743 Q_D(UCBottomEdge);743 Q_Q(UCBottomEdge);
744 // fix the hint's style version as that has no qmlContext of its own744 // fix the hint's style version as that has no qmlContext of its own
745 // and thus import version check will fail; setting the context for745 // and thus import version check will fail; setting the context for
746 // the hint using this component's hint won't work either as this746 // the hint using this component's hint won't work either as this
747 // component's context does not contain the properties from the hint.747 // component's context does not contain the properties from the hint.
748 UCStyledItemBasePrivate *hintPrivate = UCStyledItemBasePrivate::get(d->hint);748 UCBottomEdgeHintPrivate *hintPrivate = UCBottomEdgeHintPrivate::get(hint);
749 hintPrivate->styleVersion = d->styleVersion;749 hintPrivate->styleVersion = styleVersion;
750 // also set the qml data as hitn does not have that either750 // also set the qml data as hint does not have that either
751 QQmlData::get(d->hint, true);751 QQmlData::get(hint, true);
752 QQmlEngine::setContextForObject(d->hint, new QQmlContext(qmlContext(this), d->hint));752 QQmlEngine::setContextForObject(hint, new QQmlContext(qmlContext(q), hint));
753 // finally complete hint creation753 // finally complete hint creation
754 hintPrivate->completeStyledItem();754 hintPrivate->completeComponentInitialization();
755 // and validate regions, leave out the first one as that supposed to be added first755 // and validate regions, leave out the first one as that supposed to be added first
756 // mimic the top limit of the regions list like we would add them one by one756 // mimic the top limit of the regions list like we would add them one by one
757 for (int i = 1; i < d->regions.size(); ++i) {757 for (int i = 1; i < regions.size(); ++i) {
758 UCBottomEdgeRegion *region = d->regions[i];758 UCBottomEdgeRegion *region = regions[i];
759 d->validateRegion(region, i);759 validateRegion(region, i);
760 }760 }
761}761}
762762
763763
=== modified file 'src/Ubuntu/Components/plugin/ucbottomedge.h'
--- src/Ubuntu/Components/plugin/ucbottomedge.h 2015-11-24 13:41:47 +0000
+++ src/Ubuntu/Components/plugin/ucbottomedge.h 2015-12-11 12:19:41 +0000
@@ -101,7 +101,6 @@
101101
102 void initializeComponent();102 void initializeComponent();
103 void classBegin();103 void classBegin();
104 void componentComplete();
105 void itemChange(ItemChange change, const ItemChangeData &data);104 void itemChange(ItemChange change, const ItemChangeData &data);
106 bool eventFilter(QObject *target, QEvent *event) override;105 bool eventFilter(QObject *target, QEvent *event) override;
107106
108107
=== modified file 'src/Ubuntu/Components/plugin/ucbottomedge_p.h'
--- src/Ubuntu/Components/plugin/ucbottomedge_p.h 2015-12-01 20:34:50 +0000
+++ src/Ubuntu/Components/plugin/ucbottomedge_p.h 2015-12-11 12:19:41 +0000
@@ -37,6 +37,8 @@
37 }37 }
38 void init();38 void init();
3939
40 void completeComponentInitialization() override;
41
40 // data property42 // data property
41 QQmlListProperty<QObject> data();43 QQmlListProperty<QObject> data();
42 static void overload_data_append(QQmlListProperty<QObject> *, QObject *);44 static void overload_data_append(QQmlListProperty<QObject> *, QObject *);
4345
=== modified file 'src/Ubuntu/Components/plugin/ucbottomedgehint.cpp'
--- src/Ubuntu/Components/plugin/ucbottomedgehint.cpp 2015-12-03 11:50:40 +0000
+++ src/Ubuntu/Components/plugin/ucbottomedgehint.cpp 2015-12-11 12:19:41 +0000
@@ -17,6 +17,7 @@
17 */17 */
1818
19#include "ucbottomedgehint.h"19#include "ucbottomedgehint.h"
20#include "ucbottomedgehint_p.h"
20#include "ucstyleditembase_p.h"21#include "ucstyleditembase_p.h"
21#include "quickutils.h"22#include "quickutils.h"
22#include "ucunits.h"23#include "ucunits.h"
@@ -27,6 +28,45 @@
2728
28#define SWIPE_AREA_HEIGHT_GU 329#define SWIPE_AREA_HEIGHT_GU 3
2930
31UCBottomEdgeHintPrivate::UCBottomEdgeHintPrivate()
32 : UCActionItemPrivate()
33 , swipeArea(new UCSwipeArea)
34 , flickable(Q_NULLPTR)
35 , flickableBottomMargin(Q_NULLPTR)
36 , deactivateTimeout(800)
37 // FIXME: we need QInputDeviceInfo to be complete with the locked!!
38 // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1276808
39 , status(QuickUtils::instance().mouseAttached() ? UCBottomEdgeHint::Locked : UCBottomEdgeHint::Inactive)
40 , pressed(false)
41{
42}
43
44void UCBottomEdgeHintPrivate::init()
45{
46 Q_Q(UCBottomEdgeHint);
47 QObject::connect(q, &UCBottomEdgeHint::clicked, [=]() {
48 // make sure the overloaded trigger is called!
49 q->metaObject()->invokeMethod(q, "trigger", Q_ARG(QVariant, QVariant()));
50 });
51 /*
52 * we cannot use setStyleName as that will trigger style loading
53 * and the qmlEngine is not known at this phase of the of the initialization
54 * Therefore we simply set the style name default. Style loading will
55 * happen during component completion.
56 */
57 styleDocument = "BottomEdgeHintStyle";
58
59 // connect old stateChanged
60 QObject::connect(q, &QQuickItem::stateChanged, q, &UCBottomEdgeHint::stateChanged);
61
62 // FIXME: use QInputDeviceInfo once available
63 // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1276808
64 QObject::connect(&QuickUtils::instance(), &QuickUtils::mouseAttachedChanged, q, &UCBottomEdgeHint::onMouseAttached);
65
66 // accept mouse events
67 q->setAcceptedMouseButtons(Qt::LeftButton);
68}
69
30/*!70/*!
31 \qmltype BottomEdgeHint71 \qmltype BottomEdgeHint
32 \inqmlmodule Ubuntu.Components 1.372 \inqmlmodule Ubuntu.Components 1.3
@@ -54,36 +94,15 @@
54 The component is styled through \b BottomEdgeHintStyle.94 The component is styled through \b BottomEdgeHintStyle.
55*/95*/
56UCBottomEdgeHint::UCBottomEdgeHint(QQuickItem *parent)96UCBottomEdgeHint::UCBottomEdgeHint(QQuickItem *parent)
57 : UCActionItem(parent)97 : UCActionItem(*(new UCBottomEdgeHintPrivate), parent)
58 , m_swipeArea(new UCSwipeArea)98{
59 , m_flickable(Q_NULLPTR)99 d_func()->init();
60 , m_deactivateTimeout(800)100}
61 // FIXME: we need QInputDeviceInfo to be complete with the locked!!101
62 // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1276808102UCBottomEdgeHint::UCBottomEdgeHint(UCBottomEdgeHintPrivate &&dd, QQuickItem *parent)
63 , m_status(QuickUtils::instance().mouseAttached() ? Locked : Inactive)103 : UCActionItem(dd, parent)
64 , m_pressed(false)104{
65{105 d_func()->init();
66 connect(this, &UCBottomEdgeHint::clicked, [=]() {
67 // make sure the overloaded trigger is called!
68 metaObject()->invokeMethod(this, "trigger", Q_ARG(QVariant, QVariant()));
69 });
70 /*
71 * we cannot use setStyleName as that will trigger style loading
72 * and the qmlEngine is not known at this phase of the of the initialization
73 * Therefore we simply set the style name default. Style loading will
74 * happen during component completion.
75 */
76 UCStyledItemBasePrivate::get(this)->styleDocument = "BottomEdgeHintStyle";
77
78 // connect old stateChanged
79 connect(this, &QQuickItem::stateChanged, this, &UCBottomEdgeHint::stateChanged);
80
81 // FIXME: use QInputDeviceInfo once available
82 // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1276808
83 connect(&QuickUtils::instance(), &QuickUtils::mouseAttachedChanged, this, &UCBottomEdgeHint::onMouseAttached);
84
85 // accept mouse events
86 setAcceptedMouseButtons(Qt::LeftButton);
87}106}
88107
89void UCBottomEdgeHint::classBegin()108void UCBottomEdgeHint::classBegin()
@@ -94,57 +113,61 @@
94113
95void UCBottomEdgeHint::init()114void UCBottomEdgeHint::init()
96{115{
97 QQml_setParent_noEvent(m_swipeArea, this);116 Q_D(UCBottomEdgeHint);
98 m_swipeArea->setParentItem(this);117 QQml_setParent_noEvent(d->swipeArea, this);
118 d->swipeArea->setParentItem(this);
99119
100 // set context120 // set context
101 QQmlEngine::setContextForObject(m_swipeArea, qmlContext(this));121 QQmlEngine::setContextForObject(d->swipeArea, qmlContext(this));
102122
103 // initialize swipe area size123 // initialize swipe area size
104 QQuickAnchors *anchors = QQuickItemPrivate::get(m_swipeArea)->anchors();124 QQuickAnchors *anchors = QQuickItemPrivate::get(d->swipeArea)->anchors();
105 QQuickItemPrivate *thisPrivate = QQuickItemPrivate::get(this);125 QQuickItemPrivate *thisPrivate = QQuickItemPrivate::get(this);
106 anchors->setLeft(thisPrivate->left());126 anchors->setLeft(thisPrivate->left());
107 anchors->setBottom(thisPrivate->bottom());127 anchors->setBottom(thisPrivate->bottom());
108 anchors->setRight(thisPrivate->right());128 anchors->setRight(thisPrivate->right());
109 m_swipeArea->setImplicitHeight(UCUnits::instance().gu(SWIPE_AREA_HEIGHT_GU));129 d->swipeArea->setImplicitHeight(UCUnits::instance().gu(SWIPE_AREA_HEIGHT_GU));
110130
111 // direction131 // direction
112 m_swipeArea->setDirection(UCSwipeArea::Upwards);132 d->swipeArea->setDirection(UCSwipeArea::Upwards);
113133
114 // grid unit sync134 // grid unit sync
115 connect(&UCUnits::instance(), &UCUnits::gridUnitChanged, this, &UCBottomEdgeHint::onGridUnitChanged);135 connect(&UCUnits::instance(), &UCUnits::gridUnitChanged, this, &UCBottomEdgeHint::onGridUnitChanged);
116136
117 // connect to gesture detection137 // connect to gesture detection
118 connect(m_swipeArea, &UCSwipeArea::draggingChanged,138 connect(d->swipeArea, &UCSwipeArea::draggingChanged,
119 this, &UCBottomEdgeHint::onDraggingChanged, Qt::DirectConnection);139 this, &UCBottomEdgeHint::onDraggingChanged, Qt::DirectConnection);
120}140}
121141
122void UCBottomEdgeHint::onMouseAttached()142void UCBottomEdgeHint::onMouseAttached()
123{143{
144 Q_D(UCBottomEdgeHint);
124 setStatus(QuickUtils::instance().mouseAttached() ? Locked : Active);145 setStatus(QuickUtils::instance().mouseAttached() ? Locked : Active);
125 if (m_status == Active) {146 if (d->status == Active) {
126 m_deactivationTimer.start(m_deactivateTimeout, this);147 d->deactivationTimer.start(d->deactivateTimeout, this);
127 if (m_flickableBottomMargin) {148 if (d->flickableBottomMargin) {
128 delete m_flickableBottomMargin;149 delete d->flickableBottomMargin;
129 m_flickableBottomMargin = Q_NULLPTR;150 d->flickableBottomMargin = Q_NULLPTR;
130 }151 }
131 } else if (m_flickable) {152 } else if (d->flickable) {
132 adjustFlickableBottomMargin();153 adjustFlickableBottomMargin();
133 }154 }
134}155}
135156
136void UCBottomEdgeHint::adjustFlickableBottomMargin()157void UCBottomEdgeHint::adjustFlickableBottomMargin()
137{158{
138 if (!m_flickableBottomMargin) {159 Q_D(UCBottomEdgeHint);
139 m_flickableBottomMargin = new PropertyChange(m_flickable, "bottomMargin");160 if (!d->flickableBottomMargin) {
161 d->flickableBottomMargin = new PropertyChange(d->flickable, "bottomMargin");
140 }162 }
141 PropertyChange::setValue(m_flickableBottomMargin, height());163 PropertyChange::setValue(d->flickableBottomMargin, height());
142 m_flickable->setContentY(m_flickable->contentY() + height());164 d->flickable->setContentY(d->flickable->contentY() + height());
143}165}
144166
145void UCBottomEdgeHint::onGridUnitChanged()167void UCBottomEdgeHint::onGridUnitChanged()
146{168{
147 m_swipeArea->setImplicitHeight(UCUnits::instance().gu(SWIPE_AREA_HEIGHT_GU));169 Q_D(UCBottomEdgeHint);
170 d->swipeArea->setImplicitHeight(UCUnits::instance().gu(SWIPE_AREA_HEIGHT_GU));
148}171}
149172
150void UCBottomEdgeHint::itemChange(ItemChange change, const ItemChangeData &data)173void UCBottomEdgeHint::itemChange(ItemChange change, const ItemChangeData &data)
@@ -161,10 +184,11 @@
161184
162void UCBottomEdgeHint::timerEvent(QTimerEvent *event)185void UCBottomEdgeHint::timerEvent(QTimerEvent *event)
163{186{
187 Q_D(UCBottomEdgeHint);
164 UCActionItem::timerEvent(event);188 UCActionItem::timerEvent(event);
165 if (event->timerId() == m_deactivationTimer.timerId()) {189 if (event->timerId() == d->deactivationTimer.timerId()) {
166 setStatus(Inactive);190 setStatus(Inactive);
167 m_deactivationTimer.stop();191 d->deactivationTimer.stop();
168 }192 }
169}193}
170194
@@ -180,8 +204,9 @@
180// handle click event204// handle click event
181void UCBottomEdgeHint::mousePressEvent(QMouseEvent *event)205void UCBottomEdgeHint::mousePressEvent(QMouseEvent *event)
182{206{
183 if (contains(event->localPos()) && (m_status >= Active)) {207 Q_D(UCBottomEdgeHint);
184 m_pressed = true;208 if (contains(event->localPos()) && (d->status >= Active)) {
209 d->pressed = true;
185 event->accept();210 event->accept();
186 // also call requestFocus211 // also call requestFocus
187 requestFocus(Qt::MouseFocusReason);212 requestFocus(Qt::MouseFocusReason);
@@ -191,7 +216,8 @@
191}216}
192void UCBottomEdgeHint::mouseReleaseEvent(QMouseEvent *event)217void UCBottomEdgeHint::mouseReleaseEvent(QMouseEvent *event)
193{218{
194 if (m_pressed && (m_status >= Active) && contains(event->localPos())) {219 Q_D(UCBottomEdgeHint);
220 if (d->pressed && (d->status >= Active) && contains(event->localPos())) {
195 Q_EMIT clicked();221 Q_EMIT clicked();
196 event->accept();222 event->accept();
197 } else {223 } else {
@@ -202,11 +228,12 @@
202// watch gesture detection status changes228// watch gesture detection status changes
203void UCBottomEdgeHint::onDraggingChanged(bool dragging)229void UCBottomEdgeHint::onDraggingChanged(bool dragging)
204{230{
231 Q_D(UCBottomEdgeHint);
205 if (dragging) {232 if (dragging) {
206 m_deactivationTimer.stop();233 d->deactivationTimer.stop();
207 setStatus(Active);234 setStatus(Active);
208 } else if (m_status == Active) {235 } else if (d->status == Active) {
209 m_deactivationTimer.start(m_deactivateTimeout, this);236 d->deactivationTimer.start(d->deactivateTimeout, this);
210 }237 }
211}238}
212239
@@ -243,22 +270,28 @@
243 which is flicking or moving. It is recommended to set the property270 which is flicking or moving. It is recommended to set the property
244 when the hint is placed above a flickable content. Defaults to null.271 when the hint is placed above a flickable content. Defaults to null.
245 */272 */
273QQuickFlickable *UCBottomEdgeHint::flickable() const
274{
275 Q_D(const UCBottomEdgeHint);
276 return d->flickable;
277}
246void UCBottomEdgeHint::setFlickable(QQuickFlickable *flickable)278void UCBottomEdgeHint::setFlickable(QQuickFlickable *flickable)
247{279{
248 if (flickable == m_flickable) {280 Q_D(UCBottomEdgeHint);
281 if (flickable == d->flickable) {
249 return;282 return;
250 }283 }
251 if (m_flickable) {284 if (d->flickable) {
252 disconnect(m_flickable, &QQuickFlickable::flickingChanged,285 disconnect(d->flickable, &QQuickFlickable::flickingChanged,
253 this, &UCBottomEdgeHint::handleFlickableActivation);286 this, &UCBottomEdgeHint::handleFlickableActivation);
254 disconnect(m_flickable, &QQuickFlickable::movingChanged,287 disconnect(d->flickable, &QQuickFlickable::movingChanged,
255 this, &UCBottomEdgeHint::handleFlickableActivation);288 this, &UCBottomEdgeHint::handleFlickableActivation);
256 }289 }
257 m_flickable = flickable;290 d->flickable = flickable;
258 if (m_flickable) {291 if (d->flickable) {
259 connect(m_flickable, &QQuickFlickable::flickingChanged,292 connect(d->flickable, &QQuickFlickable::flickingChanged,
260 this, &UCBottomEdgeHint::handleFlickableActivation, Qt::DirectConnection);293 this, &UCBottomEdgeHint::handleFlickableActivation, Qt::DirectConnection);
261 connect(m_flickable, &QQuickFlickable::movingChanged,294 connect(d->flickable, &QQuickFlickable::movingChanged,
262 this, &UCBottomEdgeHint::handleFlickableActivation, Qt::DirectConnection);295 this, &UCBottomEdgeHint::handleFlickableActivation, Qt::DirectConnection);
263 }296 }
264 Q_EMIT flickableChanged();297 Q_EMIT flickableChanged();
@@ -267,11 +300,12 @@
267// flickable moves hide the hint only if the current status is not Locked300// flickable moves hide the hint only if the current status is not Locked
268void UCBottomEdgeHint::handleFlickableActivation()301void UCBottomEdgeHint::handleFlickableActivation()
269{302{
270 if (m_status < Locked && !m_swipeArea->dragging() && !m_deactivationTimer.isActive()) {303 Q_D(UCBottomEdgeHint);
271 bool moving = m_flickable->isFlicking() || m_flickable->isMoving();304 if (d->status < Locked && !d->swipeArea->dragging() && !d->deactivationTimer.isActive()) {
305 bool moving = d->flickable->isFlicking() || d->flickable->isMoving();
272 if (moving) {306 if (moving) {
273 setStatus(Hidden);307 setStatus(Hidden);
274 } else if (m_status == Hidden) {308 } else if (d->status == Hidden) {
275 setStatus(Inactive);309 setStatus(Inactive);
276 }310 }
277 }311 }
@@ -305,7 +339,8 @@
305 QQuickItem::setState(state);339 QQuickItem::setState(state);
306340
307 qmlInfo(this) << "Overloaded 'state' property deprecated, will be removed from 1.3 release. Use 'status' instead.";341 qmlInfo(this) << "Overloaded 'state' property deprecated, will be removed from 1.3 release. Use 'status' instead.";
308 QQuickItem *style = UCStyledItemBasePrivate::get(this)->styleItem;342 Q_D(UCBottomEdgeHint);
343 QQuickItem *style = d->styleItem;
309 if (!style) {344 if (!style) {
310 return;345 return;
311 }346 }
@@ -356,10 +391,11 @@
356{391{
357 // FIXME: we won't need this once we get the QInputDeviceInfo reporting mouse attach/detach392 // FIXME: we won't need this once we get the QInputDeviceInfo reporting mouse attach/detach
358 // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1276808393 // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1276808
394 Q_D(UCBottomEdgeHint);
359 if (QuickUtils::instance().mouseAttached()) {395 if (QuickUtils::instance().mouseAttached()) {
360 m_status = Locked;396 d->status = Locked;
361 }397 }
362 return m_status;398 return d->status;
363}399}
364400
365void UCBottomEdgeHint::setStatus(Status status)401void UCBottomEdgeHint::setStatus(Status status)
@@ -367,17 +403,18 @@
367 // FIXME: we need QInputDeviceInfo to complete this!403 // FIXME: we need QInputDeviceInfo to complete this!
368 // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1276808404 // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1276808
369 // cannot unlock if mouse is attached or we don't have touch screen available405 // cannot unlock if mouse is attached or we don't have touch screen available
370 if (status == m_status || (status != Locked && QuickUtils::instance().mouseAttached())) {406 Q_D(UCBottomEdgeHint);
407 if (status == d->status || (status != Locked && QuickUtils::instance().mouseAttached())) {
371 return;408 return;
372 }409 }
373 // if the previous state was Locked and the new one is Active, start deactivation timer410 // if the previous state was Locked and the new one is Active, start deactivation timer
374 if (m_status == Locked && status == Active && !m_deactivationTimer.isActive()) {411 if (d->status == Locked && status == Active && !d->deactivationTimer.isActive()) {
375 m_deactivationTimer.start(m_deactivateTimeout, this);412 d->deactivationTimer.start(d->deactivateTimeout, this);
376 } else if (status != Active && m_deactivationTimer.isActive()) {413 } else if (status != Active && d->deactivationTimer.isActive()) {
377 // make sure we stop the deactivation timer if Inactive or Locked414 // make sure we stop the deactivation timer if Inactive or Locked
378 m_deactivationTimer.stop();415 d->deactivationTimer.stop();
379 }416 }
380 m_status = status;417 d->status = status;
381 Q_EMIT statusChanged();418 Q_EMIT statusChanged();
382}419}
383420
@@ -388,16 +425,21 @@
388 * is only possible when mouse is not attached to the device. Defaults to 800425 * is only possible when mouse is not attached to the device. Defaults to 800
389 * milliseconds.426 * milliseconds.
390 */427 */
391428int UCBottomEdgeHint::deactivateTimeout() const
429{
430 Q_D(const UCBottomEdgeHint);
431 return d->deactivateTimeout;
432}
392void UCBottomEdgeHint::setDeactivateTimeout(int timeout)433void UCBottomEdgeHint::setDeactivateTimeout(int timeout)
393{434{
394 if (timeout == m_deactivateTimeout || timeout < 0) {435 Q_D(UCBottomEdgeHint);
436 if (timeout == d->deactivateTimeout || timeout < 0) {
395 return;437 return;
396 }438 }
397 m_deactivateTimeout = timeout;439 d->deactivateTimeout = timeout;
398 if (m_deactivationTimer.isActive()) {440 if (d->deactivationTimer.isActive()) {
399 m_deactivationTimer.stop();441 d->deactivationTimer.stop();
400 m_deactivationTimer.start(m_deactivateTimeout, this);442 d->deactivationTimer.start(d->deactivateTimeout, this);
401 }443 }
402 Q_EMIT deactivateTimeoutChanged();444 Q_EMIT deactivateTimeoutChanged();
403}445}
@@ -408,3 +450,9 @@
408 * The property specifies the SwipeArea attached to the component driving its450 * The property specifies the SwipeArea attached to the component driving its
409 * behavior.451 * behavior.
410 */452 */
453UCSwipeArea *UCBottomEdgeHint::swipeArea() const
454{
455 return d_func()->swipeArea;
456}
457
458#include "moc_ucbottomedgehint.cpp"
411459
=== modified file 'src/Ubuntu/Components/plugin/ucbottomedgehint.h'
--- src/Ubuntu/Components/plugin/ucbottomedgehint.h 2015-12-03 11:50:40 +0000
+++ src/Ubuntu/Components/plugin/ucbottomedgehint.h 2015-12-11 12:19:41 +0000
@@ -24,13 +24,14 @@
24class QQuickFlickable;24class QQuickFlickable;
25class UCSwipeArea;25class UCSwipeArea;
26class PropertyChange;26class PropertyChange;
27class UCBottomEdgeHintPrivate;
27class UCBottomEdgeHint : public UCActionItem28class UCBottomEdgeHint : public UCActionItem
28{29{
29 Q_OBJECT30 Q_OBJECT
30 Q_ENUMS(Status)31 Q_ENUMS(Status)
31 Q_PROPERTY(QQuickFlickable *flickable MEMBER m_flickable WRITE setFlickable NOTIFY flickableChanged FINAL)32 Q_PROPERTY(QQuickFlickable *flickable READ flickable WRITE setFlickable NOTIFY flickableChanged FINAL)
32 Q_PROPERTY(Status status MEMBER m_status WRITE setStatus NOTIFY statusChanged FINAL)33 Q_PROPERTY(Status status READ status WRITE setStatus NOTIFY statusChanged FINAL)
33 Q_PROPERTY(int deactivateTimeout MEMBER m_deactivateTimeout WRITE setDeactivateTimeout NOTIFY deactivateTimeoutChanged FINAL)34 Q_PROPERTY(int deactivateTimeout READ deactivateTimeout WRITE setDeactivateTimeout NOTIFY deactivateTimeoutChanged FINAL)
34 Q_PROPERTY(UCSwipeArea* swipeArea READ swipeArea CONSTANT FINAL)35 Q_PROPERTY(UCSwipeArea* swipeArea READ swipeArea CONSTANT FINAL)
35 // deprecated36 // deprecated
36 Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)37 Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged)
@@ -43,14 +44,13 @@
43 };44 };
44 explicit UCBottomEdgeHint(QQuickItem *parent = 0);45 explicit UCBottomEdgeHint(QQuickItem *parent = 0);
4546
47 QQuickFlickable *flickable() const;
46 void setFlickable(QQuickFlickable *flickable);48 void setFlickable(QQuickFlickable *flickable);
47 Status status();49 Status status();
48 void setStatus(Status status);50 void setStatus(Status status);
51 int deactivateTimeout() const;
49 void setDeactivateTimeout(int timeout);52 void setDeactivateTimeout(int timeout);
50 UCSwipeArea *swipeArea() const53 UCSwipeArea *swipeArea() const;
51 {
52 return m_swipeArea;
53 }
5454
55 // deprecated55 // deprecated
56 QString state() const;56 QString state() const;
@@ -69,6 +69,7 @@
69 // deprecated69 // deprecated
70 void stateChanged();70 void stateChanged();
71protected:71protected:
72 UCBottomEdgeHint(UCBottomEdgeHintPrivate &&, QQuickItem *parent);
72 void classBegin();73 void classBegin();
73 void itemChange(ItemChange change, const ItemChangeData &data);74 void itemChange(ItemChange change, const ItemChangeData &data);
74 void timerEvent(QTimerEvent *event);75 void timerEvent(QTimerEvent *event);
@@ -84,13 +85,7 @@
84 void onGridUnitChanged();85 void onGridUnitChanged();
8586
86private:87private:
87 QBasicTimer m_deactivationTimer;88 Q_DECLARE_PRIVATE(UCBottomEdgeHint)
88 UCSwipeArea *m_swipeArea;
89 QQuickFlickable *m_flickable;
90 PropertyChange *m_flickableBottomMargin = nullptr;
91 int m_deactivateTimeout;
92 Status m_status;
93 bool m_pressed:1;
9489
95 friend class UCBottomEdge;90 friend class UCBottomEdge;
9691
9792
=== added file 'src/Ubuntu/Components/plugin/ucbottomedgehint_p.h'
--- src/Ubuntu/Components/plugin/ucbottomedgehint_p.h 1970-01-01 00:00:00 +0000
+++ src/Ubuntu/Components/plugin/ucbottomedgehint_p.h 2015-12-11 12:19:41 +0000
@@ -0,0 +1,46 @@
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#ifndef UCBOTTOMEDGEHINT_P
20#define UCBOTTOMEDGEHINT_P
21
22#include "ucbottomedgehint.h"
23#include "ucactionitem_p.h"
24
25class UCBottomEdgeHintPrivate : public UCActionItemPrivate
26{
27 Q_DECLARE_PUBLIC(UCBottomEdgeHint)
28public:
29 static UCBottomEdgeHintPrivate *get(UCBottomEdgeHint *item)
30 {
31 return item->d_func();
32 }
33 UCBottomEdgeHintPrivate();
34 void init();
35
36 QBasicTimer deactivationTimer;
37 UCSwipeArea *swipeArea;
38 QQuickFlickable *flickable;
39 PropertyChange *flickableBottomMargin;
40 int deactivateTimeout;
41 UCBottomEdgeHint::Status status;
42 bool pressed:1;
43};
44
45#endif // UCBOTTOMEDGEHINT_P
46
047
=== modified file 'src/Ubuntu/Components/plugin/ucstyleditembase.cpp'
--- src/Ubuntu/Components/plugin/ucstyleditembase.cpp 2015-12-01 00:44:21 +0000
+++ src/Ubuntu/Components/plugin/ucstyleditembase.cpp 2015-12-11 12:19:41 +0000
@@ -479,7 +479,12 @@
479 }479 }
480}480}
481481
482void UCStyledItemBasePrivate::completeStyledItem()482/*
483 * The method is called on component completion, separated for the cases when
484 * the component is embedded in another CPP component and functionality depends
485 * on this initialization.
486 */
487void UCStyledItemBasePrivate::completeComponentInitialization()
483{488{
484 // no animation at this time489 // no animation at this time
485 // prepare style context if not been done yet490 // prepare style context if not been done yet
@@ -494,7 +499,7 @@
494 // make sure the theme version is up to date499 // make sure the theme version is up to date
495 d->styleVersion = d->importVersion(this);500 d->styleVersion = d->importVersion(this);
496 UCTheme::checkMixedVersionImports(this, d->styleVersion);501 UCTheme::checkMixedVersionImports(this, d->styleVersion);
497 d->completeStyledItem();502 d->completeComponentInitialization();
498}503}
499504
500void UCStyledItemBase::itemChange(ItemChange change, const ItemChangeData &data)505void UCStyledItemBase::itemChange(ItemChange change, const ItemChangeData &data)
501506
=== modified file 'src/Ubuntu/Components/plugin/ucstyleditembase_p.h'
--- src/Ubuntu/Components/plugin/ucstyleditembase_p.h 2015-11-23 20:03:32 +0000
+++ src/Ubuntu/Components/plugin/ucstyleditembase_p.h 2015-12-11 12:19:41 +0000
@@ -56,7 +56,7 @@
56 virtual void preStyleChanged();56 virtual void preStyleChanged();
57 virtual void postStyleChanged() {}57 virtual void postStyleChanged() {}
58 virtual bool loadStyleItem(bool animated = true);58 virtual bool loadStyleItem(bool animated = true);
59 virtual void completeStyledItem();59 virtual void completeComponentInitialization();
6060
61 // from UCImportVersionChecker61 // from UCImportVersionChecker
62 virtual QString propertyForVersion(quint16 version) const;62 virtual QString propertyForVersion(quint16 version) const;

Subscribers

People subscribed via source and target branches