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