Merge lp:~unity-api-team/hud/forward-port into lp:hud/14.10
- forward-port
- Merge into trunk.14.10
Status: | Merged |
---|---|
Approved by: | Pete Woods |
Approved revision: | 395 |
Merged at revision: | 394 |
Proposed branch: | lp:~unity-api-team/hud/forward-port |
Merge into: | lp:hud/14.10 |
Diff against target: |
1455 lines (+515/-209) 14 files modified
data/hud.conf.in (+0/-12) debian/changelog (+34/-0) libqtgmenu/QtGMenuImporter.cpp (+2/-2) libqtgmenu/QtGMenuImporter.h (+2/-2) libqtgmenu/internal/QtGActionGroup.cpp (+31/-31) libqtgmenu/internal/QtGActionGroup.h (+7/-3) libqtgmenu/internal/QtGMenuImporterPrivate.cpp (+21/-13) libqtgmenu/internal/QtGMenuImporterPrivate.h (+4/-3) libqtgmenu/internal/QtGMenuModel.cpp (+331/-99) libqtgmenu/internal/QtGMenuModel.h (+20/-17) service/DBusMenuCollector.cpp (+9/-17) service/HudServiceImpl.cpp (+45/-5) service/HudServiceImpl.h (+5/-1) tests/unit/qtgmenu/TestQtGMenu.cpp (+4/-4) |
To merge this branch: | bzr merge lp:~unity-api-team/hud/forward-port |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Indicator Applet Developers | Pending | ||
Review via email: mp+223025@code.launchpad.net |
Commit message
Forward port trusty SRU
Description of the change
Forward port trusty SRU
PS Jenkins bot (ps-jenkins) wrote : | # |
Antti Kaijanmäki (kaijanmaki) wrote : | # |
* Are any changes against your component pending/needed to land the MP under review in a functional state and are those called out explicitly by the submitter?
Only affects HUD.
* Did you do exploratory testing related to the component you own with the MP changeset included?
Ran the whole TestPlan. Note, HUD is disabled on the phone, so only could do simple smoke test. Desktop testing completed fully.
* Has the submitter requested review by all the relevant teams/reviewres?
Yes.
* If you are the reviewer owning the component the MP is against, have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
This is a forward port of an already accepted SRU.
Preview Diff
1 | === modified file 'data/hud.conf.in' | |||
2 | --- data/hud.conf.in 2013-11-27 14:28:43 +0000 | |||
3 | +++ data/hud.conf.in 2014-06-13 07:41:53 +0000 | |||
4 | @@ -1,22 +1,10 @@ | |||
5 | 1 | description "Unity HUD" | 1 | description "Unity HUD" |
6 | 2 | 2 | ||
7 | 3 | pre-start script | ||
8 | 4 | if [ -z $DBUS_SESSION_BUS_ADDRESS ]; then | ||
9 | 5 | echo "Working around missing DBUS_SESSION_BUS_ADDRESS variable" | ||
10 | 6 | printf "DuplicateSignature\0DBusSessionAddressNotSet" | /usr/share/apport/recoverable_problem -p `pidof -s -o 1 init` | ||
11 | 7 | . "${HOME}/.cache/upstart/dbus-session" | ||
12 | 8 | initctl set-env "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS" | ||
13 | 9 | fi | ||
14 | 10 | end script | ||
15 | 11 | |||
16 | 12 | # Currently started by the dbus service file | 3 | # Currently started by the dbus service file |
17 | 13 | # start on dbus-activation com.canonical.hud | 4 | # start on dbus-activation com.canonical.hud |
18 | 14 | stop on desktop-end | 5 | stop on desktop-end |
19 | 15 | start on started dbus and ((xsession SESSION=ubuntu-touch) or (xsession SESSION=ubuntu-touch-surfaceflinger) or (xsession SESSION=ubuntu)) | 6 | start on started dbus and ((xsession SESSION=ubuntu-touch) or (xsession SESSION=ubuntu-touch-surfaceflinger) or (xsession SESSION=ubuntu)) |
20 | 16 | 7 | ||
21 | 17 | env HUD_SERVICE_TIMEOUT=0 | ||
22 | 18 | export HUD_SERVICE_TIMEOUT | ||
23 | 19 | |||
24 | 20 | pre-start script | 8 | pre-start script |
25 | 21 | if [ -z $DBUS_SESSION_BUS_ADDRESS ]; then | 9 | if [ -z $DBUS_SESSION_BUS_ADDRESS ]; then |
26 | 22 | echo "Working around missing DBUS_SESSION_BUS_ADDRESS variable" | 10 | echo "Working around missing DBUS_SESSION_BUS_ADDRESS variable" |
27 | 23 | 11 | ||
28 | === modified file 'debian/changelog' | |||
29 | --- debian/changelog 2014-06-09 14:06:31 +0000 | |||
30 | +++ debian/changelog 2014-06-13 07:41:53 +0000 | |||
31 | @@ -1,3 +1,21 @@ | |||
32 | 1 | hud (14.10-0ubuntu1) UNRELEASED; urgency=medium | ||
33 | 2 | |||
34 | 3 | [ Pete Woods ] | ||
35 | 4 | * Forward port changes from trusty. | ||
36 | 5 | |||
37 | 6 | -- Pete Woods <pete.woods@canonical.com> Fri, 13 Jun 2014 08:22:34 +0100 | ||
38 | 7 | |||
39 | 8 | hud (14.04+14.04.20140604-0ubuntu1) trusty; urgency=medium | ||
40 | 9 | |||
41 | 10 | [ Pete Woods ] | ||
42 | 11 | * Resolve crasher in previous attempted SRU. (LP: #1298656) | ||
43 | 12 | - Fix order of menu traversal. | ||
44 | 13 | - Add timeout to legacy HUD queries. | ||
45 | 14 | - Improve legacy menu safety valve trigger. | ||
46 | 15 | - Remove duplicate entries in upstart job. | ||
47 | 16 | |||
48 | 17 | -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 04 Jun 2014 14:04:12 +0000 | ||
49 | 18 | |||
50 | 1 | hud (13.10.1+14.10.20140609-0ubuntu1) utopic; urgency=low | 19 | hud (13.10.1+14.10.20140609-0ubuntu1) utopic; urgency=low |
51 | 2 | 20 | ||
52 | 3 | [ Ubuntu daily release ] | 21 | [ Ubuntu daily release ] |
53 | @@ -8,6 +26,22 @@ | |||
54 | 8 | 26 | ||
55 | 9 | -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Mon, 09 Jun 2014 14:06:31 +0000 | 27 | -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Mon, 09 Jun 2014 14:06:31 +0000 |
56 | 10 | 28 | ||
57 | 29 | hud (13.10.1+14.04.20140425-0ubuntu1) trusty; urgency=low | ||
58 | 30 | |||
59 | 31 | [ Pete Woods ] | ||
60 | 32 | * Harden HUD against misbehaving applications Report the offending | ||
61 | 33 | applications using Apport's recoverable problem tool. Switch to | ||
62 | 34 | using shared pointers where possible for managing memory. (LP: | ||
63 | 35 | #1298656) | ||
64 | 36 | |||
65 | 37 | [ Marcus Tomlinson ] | ||
66 | 38 | * Harden HUD against misbehaving applications Report the offending | ||
67 | 39 | applications using Apport's recoverable problem tool. Switch to | ||
68 | 40 | using shared pointers where possible for managing memory. (LP: | ||
69 | 41 | #1298656) | ||
70 | 42 | |||
71 | 43 | -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Fri, 25 Apr 2014 08:48:46 +0000 | ||
72 | 44 | |||
73 | 11 | hud (13.10.1+14.04.20140402-0ubuntu2) utopic; urgency=medium | 45 | hud (13.10.1+14.04.20140402-0ubuntu2) utopic; urgency=medium |
74 | 12 | 46 | ||
75 | 13 | * No-change rebuild for shlib changes in qtbase and qtdeclarative. | 47 | * No-change rebuild for shlib changes in qtbase and qtdeclarative. |
76 | 14 | 48 | ||
77 | === modified file 'libqtgmenu/QtGMenuImporter.cpp' | |||
78 | --- libqtgmenu/QtGMenuImporter.cpp 2014-03-11 05:04:08 +0000 | |||
79 | +++ libqtgmenu/QtGMenuImporter.cpp 2014-06-13 07:41:53 +0000 | |||
80 | @@ -43,12 +43,12 @@ | |||
81 | 43 | { | 43 | { |
82 | 44 | } | 44 | } |
83 | 45 | 45 | ||
85 | 46 | GMenuModel* QtGMenuImporter::GetGMenuModel() const | 46 | QSharedPointer<GMenuModel> QtGMenuImporter::GetGMenuModel() const |
86 | 47 | { | 47 | { |
87 | 48 | return d->GetGMenuModel(); | 48 | return d->GetGMenuModel(); |
88 | 49 | } | 49 | } |
89 | 50 | 50 | ||
91 | 51 | GActionGroup* QtGMenuImporter::GetGActionGroup( int index ) const | 51 | QSharedPointer<GActionGroup> QtGMenuImporter::GetGActionGroup( int index ) const |
92 | 52 | { | 52 | { |
93 | 53 | return d->GetGActionGroup( index ); | 53 | return d->GetGActionGroup( index ); |
94 | 54 | } | 54 | } |
95 | 55 | 55 | ||
96 | === modified file 'libqtgmenu/QtGMenuImporter.h' | |||
97 | --- libqtgmenu/QtGMenuImporter.h 2014-03-12 09:04:14 +0000 | |||
98 | +++ libqtgmenu/QtGMenuImporter.h 2014-06-13 07:41:53 +0000 | |||
99 | @@ -47,8 +47,8 @@ | |||
100 | 47 | const QMap<QString, QDBusObjectPath>& action_paths, QObject* parent = 0 ); | 47 | const QMap<QString, QDBusObjectPath>& action_paths, QObject* parent = 0 ); |
101 | 48 | virtual ~QtGMenuImporter(); | 48 | virtual ~QtGMenuImporter(); |
102 | 49 | 49 | ||
105 | 50 | GMenuModel* GetGMenuModel() const; | 50 | QSharedPointer<GMenuModel> GetGMenuModel() const; |
106 | 51 | GActionGroup* GetGActionGroup( int index = 0 ) const; | 51 | QSharedPointer<GActionGroup> GetGActionGroup( int index = 0 ) const; |
107 | 52 | 52 | ||
108 | 53 | std::shared_ptr< QMenu > GetQMenu() const; | 53 | std::shared_ptr< QMenu > GetQMenu() const; |
109 | 54 | 54 | ||
110 | 55 | 55 | ||
111 | === modified file 'libqtgmenu/internal/QtGActionGroup.cpp' | |||
112 | --- libqtgmenu/internal/QtGActionGroup.cpp 2014-03-19 23:40:09 +0000 | |||
113 | +++ libqtgmenu/internal/QtGActionGroup.cpp 2014-06-13 07:41:53 +0000 | |||
114 | @@ -21,13 +21,20 @@ | |||
115 | 21 | 21 | ||
116 | 22 | using namespace qtgmenu; | 22 | using namespace qtgmenu; |
117 | 23 | 23 | ||
119 | 24 | QtGActionGroup::QtGActionGroup( const QString& action_prefix, GActionGroup* action_group ) | 24 | QtGActionGroup::QtGActionGroup( QSharedPointer<GDBusConnection> connection, |
120 | 25 | const QString& action_prefix, | ||
121 | 26 | const QString& service, | ||
122 | 27 | const QString& path ) | ||
123 | 25 | : m_action_prefix( action_prefix ), | 28 | : m_action_prefix( action_prefix ), |
125 | 26 | m_action_group( action_group ) | 29 | m_action_group( |
126 | 30 | G_ACTION_GROUP( | ||
127 | 31 | g_dbus_action_group_get(connection.data(), | ||
128 | 32 | service.toUtf8().constData(), | ||
129 | 33 | path.toUtf8().constData())), &g_object_unref) | ||
130 | 27 | { | 34 | { |
131 | 28 | ConnectCallbacks(); | 35 | ConnectCallbacks(); |
132 | 29 | 36 | ||
134 | 30 | auto actions_list = g_action_group_list_actions( m_action_group ); | 37 | auto actions_list = g_action_group_list_actions( m_action_group.data() ); |
135 | 31 | if( actions_list ) | 38 | if( actions_list ) |
136 | 32 | { | 39 | { |
137 | 33 | for( int i = 0; actions_list[i]; ++i ) | 40 | for( int i = 0; actions_list[i]; ++i ) |
138 | @@ -46,7 +53,7 @@ | |||
139 | 46 | return; | 53 | return; |
140 | 47 | } | 54 | } |
141 | 48 | 55 | ||
143 | 49 | auto actions_list = g_action_group_list_actions( m_action_group ); | 56 | auto actions_list = g_action_group_list_actions( m_action_group.data() ); |
144 | 50 | if( actions_list ) | 57 | if( actions_list ) |
145 | 51 | { | 58 | { |
146 | 52 | for( int i = 0; actions_list[i]; ++i ) | 59 | for( int i = 0; actions_list[i]; ++i ) |
147 | @@ -58,14 +65,9 @@ | |||
148 | 58 | } | 65 | } |
149 | 59 | 66 | ||
150 | 60 | DisconnectCallbacks(); | 67 | DisconnectCallbacks(); |
151 | 61 | |||
152 | 62 | g_object_unref( m_action_group ); | ||
153 | 63 | m_action_group = nullptr; | ||
154 | 64 | |||
155 | 65 | return; | ||
156 | 66 | } | 68 | } |
157 | 67 | 69 | ||
159 | 68 | GActionGroup* QtGActionGroup::ActionGroup() const | 70 | QSharedPointer<GActionGroup> QtGActionGroup::ActionGroup() const |
160 | 69 | { | 71 | { |
161 | 70 | return m_action_group; | 72 | return m_action_group; |
162 | 71 | } | 73 | } |
163 | @@ -83,12 +85,12 @@ | |||
164 | 83 | const QString& action(split.second); | 85 | const QString& action(split.second); |
165 | 84 | QByteArray action_utf = action.toUtf8(); | 86 | QByteArray action_utf = action.toUtf8(); |
166 | 85 | 87 | ||
168 | 86 | const GVariantType* type = g_action_group_get_action_parameter_type( m_action_group, | 88 | const GVariantType* type = g_action_group_get_action_parameter_type( m_action_group.data(), |
169 | 87 | action_utf.constData() ); | 89 | action_utf.constData() ); |
170 | 88 | 90 | ||
171 | 89 | if( type == nullptr ) | 91 | if( type == nullptr ) |
172 | 90 | { | 92 | { |
174 | 91 | g_action_group_activate_action( m_action_group, action_utf.constData(), nullptr ); | 93 | g_action_group_activate_action( m_action_group.data(), action_utf.constData(), nullptr ); |
175 | 92 | } | 94 | } |
176 | 93 | else | 95 | else |
177 | 94 | { | 96 | { |
178 | @@ -96,7 +98,7 @@ | |||
179 | 96 | if( g_variant_type_equal( type, G_VARIANT_TYPE_STRING ) ) | 98 | if( g_variant_type_equal( type, G_VARIANT_TYPE_STRING ) ) |
180 | 97 | { | 99 | { |
181 | 98 | GVariant* param = g_variant_new_string( action_utf.constData() ); | 100 | GVariant* param = g_variant_new_string( action_utf.constData() ); |
183 | 99 | g_action_group_activate_action( m_action_group, action_utf.constData(), param ); | 101 | g_action_group_activate_action( m_action_group.data(), action_utf.constData(), param ); |
184 | 100 | g_variant_unref( param ); | 102 | g_variant_unref( param ); |
185 | 101 | } | 103 | } |
186 | 102 | } | 104 | } |
187 | @@ -116,21 +118,19 @@ | |||
188 | 116 | 118 | ||
189 | 117 | void QtGActionGroup::EmitStates() | 119 | void QtGActionGroup::EmitStates() |
190 | 118 | { | 120 | { |
192 | 119 | auto actions_list = g_action_group_list_actions( m_action_group ); | 121 | auto actions_list = g_action_group_list_actions( m_action_group.data() ); |
193 | 120 | 122 | ||
194 | 121 | for( int i = 0; actions_list && actions_list[i]; ++i ) | 123 | for( int i = 0; actions_list && actions_list[i]; ++i ) |
195 | 122 | { | 124 | { |
196 | 123 | gchar* action_name = actions_list[i]; | 125 | gchar* action_name = actions_list[i]; |
197 | 124 | 126 | ||
199 | 125 | bool enabled = G_ACTION_GROUP_GET_IFACE( m_action_group ) ->get_action_enabled( m_action_group, | 127 | bool enabled = G_ACTION_GROUP_GET_IFACE( m_action_group.data() ) ->get_action_enabled( m_action_group.data(), |
200 | 126 | action_name ); | 128 | action_name ); |
203 | 127 | if( !enabled ) | 129 | emit ActionEnabled( FullName(m_action_prefix, action_name), enabled ); |
202 | 128 | emit ActionEnabled( FullName(m_action_prefix, action_name), enabled ); | ||
204 | 129 | 130 | ||
206 | 130 | const GVariantType* type = g_action_group_get_action_parameter_type( m_action_group, | 131 | const GVariantType* type = g_action_group_get_action_parameter_type( m_action_group.data(), |
207 | 131 | action_name ); | 132 | action_name ); |
210 | 132 | if( type != nullptr ) | 133 | emit ActionParameterized( FullName(m_action_prefix, action_name), type != nullptr ); |
209 | 133 | emit ActionParameterized( FullName(m_action_prefix, action_name), type != nullptr ); | ||
211 | 134 | } | 134 | } |
212 | 135 | 135 | ||
213 | 136 | g_strfreev( actions_list ); | 136 | g_strfreev( actions_list ); |
214 | @@ -142,12 +142,12 @@ | |||
215 | 142 | QtGActionGroup* self = reinterpret_cast< QtGActionGroup* >( user_data ); | 142 | QtGActionGroup* self = reinterpret_cast< QtGActionGroup* >( user_data ); |
216 | 143 | emit self->ActionAdded( action_name ); | 143 | emit self->ActionAdded( action_name ); |
217 | 144 | 144 | ||
220 | 145 | bool enabled = G_ACTION_GROUP_GET_IFACE( self->m_action_group ) ->get_action_enabled( | 145 | bool enabled = G_ACTION_GROUP_GET_IFACE( self->m_action_group.data() ) ->get_action_enabled( |
221 | 146 | self->m_action_group, action_name ); | 146 | self->m_action_group.data(), action_name ); |
222 | 147 | if( !enabled ) | 147 | if( !enabled ) |
223 | 148 | emit self->ActionEnabled( FullName(self->m_action_prefix, action_name), enabled ); | 148 | emit self->ActionEnabled( FullName(self->m_action_prefix, action_name), enabled ); |
224 | 149 | 149 | ||
226 | 150 | const GVariantType* type = g_action_group_get_action_parameter_type( self->m_action_group, | 150 | const GVariantType* type = g_action_group_get_action_parameter_type( self->m_action_group.data(), |
227 | 151 | action_name ); | 151 | action_name ); |
228 | 152 | if( type != nullptr ) | 152 | if( type != nullptr ) |
229 | 153 | emit self->ActionParameterized( FullName(self->m_action_prefix, action_name), type != nullptr ); | 153 | emit self->ActionParameterized( FullName(self->m_action_prefix, action_name), type != nullptr ); |
230 | @@ -178,22 +178,22 @@ | |||
231 | 178 | { | 178 | { |
232 | 179 | if( m_action_group && m_action_added_handler == 0 ) | 179 | if( m_action_group && m_action_added_handler == 0 ) |
233 | 180 | { | 180 | { |
235 | 181 | m_action_added_handler = g_signal_connect( m_action_group, "action-added", | 181 | m_action_added_handler = g_signal_connect( m_action_group.data(), "action-added", |
236 | 182 | G_CALLBACK( ActionAddedCallback ), this ); | 182 | G_CALLBACK( ActionAddedCallback ), this ); |
237 | 183 | } | 183 | } |
238 | 184 | if( m_action_group && m_action_removed_handler == 0 ) | 184 | if( m_action_group && m_action_removed_handler == 0 ) |
239 | 185 | { | 185 | { |
241 | 186 | m_action_removed_handler = g_signal_connect( m_action_group, "action-removed", | 186 | m_action_removed_handler = g_signal_connect( m_action_group.data(), "action-removed", |
242 | 187 | G_CALLBACK( ActionRemovedCallback ), this ); | 187 | G_CALLBACK( ActionRemovedCallback ), this ); |
243 | 188 | } | 188 | } |
244 | 189 | if( m_action_group && m_action_enabled_handler == 0 ) | 189 | if( m_action_group && m_action_enabled_handler == 0 ) |
245 | 190 | { | 190 | { |
247 | 191 | m_action_enabled_handler = g_signal_connect( m_action_group, "action-enabled-changed", | 191 | m_action_enabled_handler = g_signal_connect( m_action_group.data(), "action-enabled-changed", |
248 | 192 | G_CALLBACK( ActionEnabledCallback ), this ); | 192 | G_CALLBACK( ActionEnabledCallback ), this ); |
249 | 193 | } | 193 | } |
250 | 194 | if( m_action_group && m_action_state_changed_handler == 0 ) | 194 | if( m_action_group && m_action_state_changed_handler == 0 ) |
251 | 195 | { | 195 | { |
253 | 196 | m_action_state_changed_handler = g_signal_connect( m_action_group, "action-state-changed", | 196 | m_action_state_changed_handler = g_signal_connect( m_action_group.data(), "action-state-changed", |
254 | 197 | G_CALLBACK( ActionStateChangedCallback ), this ); | 197 | G_CALLBACK( ActionStateChangedCallback ), this ); |
255 | 198 | } | 198 | } |
256 | 199 | } | 199 | } |
257 | @@ -202,19 +202,19 @@ | |||
258 | 202 | { | 202 | { |
259 | 203 | if( m_action_group && m_action_added_handler != 0 ) | 203 | if( m_action_group && m_action_added_handler != 0 ) |
260 | 204 | { | 204 | { |
262 | 205 | g_signal_handler_disconnect( m_action_group, m_action_added_handler ); | 205 | g_signal_handler_disconnect( m_action_group.data(), m_action_added_handler ); |
263 | 206 | } | 206 | } |
264 | 207 | if( m_action_group && m_action_removed_handler != 0 ) | 207 | if( m_action_group && m_action_removed_handler != 0 ) |
265 | 208 | { | 208 | { |
267 | 209 | g_signal_handler_disconnect( m_action_group, m_action_removed_handler ); | 209 | g_signal_handler_disconnect( m_action_group.data(), m_action_removed_handler ); |
268 | 210 | } | 210 | } |
269 | 211 | if( m_action_group && m_action_enabled_handler != 0 ) | 211 | if( m_action_group && m_action_enabled_handler != 0 ) |
270 | 212 | { | 212 | { |
272 | 213 | g_signal_handler_disconnect( m_action_group, m_action_enabled_handler ); | 213 | g_signal_handler_disconnect( m_action_group.data(), m_action_enabled_handler ); |
273 | 214 | } | 214 | } |
274 | 215 | if( m_action_group && m_action_state_changed_handler != 0 ) | 215 | if( m_action_group && m_action_state_changed_handler != 0 ) |
275 | 216 | { | 216 | { |
277 | 217 | g_signal_handler_disconnect( m_action_group, m_action_state_changed_handler ); | 217 | g_signal_handler_disconnect( m_action_group.data(), m_action_state_changed_handler ); |
278 | 218 | } | 218 | } |
279 | 219 | 219 | ||
280 | 220 | m_action_added_handler = 0; | 220 | m_action_added_handler = 0; |
281 | 221 | 221 | ||
282 | === modified file 'libqtgmenu/internal/QtGActionGroup.h' | |||
283 | --- libqtgmenu/internal/QtGActionGroup.h 2014-03-19 23:40:09 +0000 | |||
284 | +++ libqtgmenu/internal/QtGActionGroup.h 2014-06-13 07:41:53 +0000 | |||
285 | @@ -20,6 +20,7 @@ | |||
286 | 20 | #define QTGACTIONGROUP_H | 20 | #define QTGACTIONGROUP_H |
287 | 21 | 21 | ||
288 | 22 | #include <QObject> | 22 | #include <QObject> |
289 | 23 | #include <QSharedPointer> | ||
290 | 23 | #include <QVariant> | 24 | #include <QVariant> |
291 | 24 | 25 | ||
292 | 25 | #undef signals | 26 | #undef signals |
293 | @@ -33,10 +34,13 @@ | |||
294 | 33 | Q_OBJECT | 34 | Q_OBJECT |
295 | 34 | 35 | ||
296 | 35 | public: | 36 | public: |
298 | 36 | QtGActionGroup( const QString& action_prefix, GActionGroup* action_group ); | 37 | QtGActionGroup(QSharedPointer<GDBusConnection> connection, |
299 | 38 | const QString& action_prefix, | ||
300 | 39 | const QString& service, | ||
301 | 40 | const QString& path); | ||
302 | 37 | virtual ~QtGActionGroup(); | 41 | virtual ~QtGActionGroup(); |
303 | 38 | 42 | ||
305 | 39 | GActionGroup* ActionGroup() const; | 43 | QSharedPointer<GActionGroup> ActionGroup() const; |
306 | 40 | 44 | ||
307 | 41 | Q_SIGNALS: | 45 | Q_SIGNALS: |
308 | 42 | void ActionAdded( QString action_name ); | 46 | void ActionAdded( QString action_name ); |
309 | @@ -66,7 +70,7 @@ | |||
310 | 66 | private: | 70 | private: |
311 | 67 | 71 | ||
312 | 68 | QString m_action_prefix; | 72 | QString m_action_prefix; |
314 | 69 | GActionGroup* m_action_group = nullptr; | 73 | QSharedPointer<GActionGroup> m_action_group; |
315 | 70 | 74 | ||
316 | 71 | gulong m_action_added_handler = 0; | 75 | gulong m_action_added_handler = 0; |
317 | 72 | gulong m_action_removed_handler = 0; | 76 | gulong m_action_removed_handler = 0; |
318 | 73 | 77 | ||
319 | === modified file 'libqtgmenu/internal/QtGMenuImporterPrivate.cpp' | |||
320 | --- libqtgmenu/internal/QtGMenuImporterPrivate.cpp 2014-03-19 23:26:48 +0000 | |||
321 | +++ libqtgmenu/internal/QtGMenuImporterPrivate.cpp 2014-06-13 07:41:53 +0000 | |||
322 | @@ -30,7 +30,7 @@ | |||
323 | 30 | m_service_watcher( service, QDBusConnection::sessionBus(), | 30 | m_service_watcher( service, QDBusConnection::sessionBus(), |
324 | 31 | QDBusServiceWatcher::WatchForOwnerChange ), | 31 | QDBusServiceWatcher::WatchForOwnerChange ), |
325 | 32 | m_parent( parent ), | 32 | m_parent( parent ), |
327 | 33 | m_connection( g_bus_get_sync( G_BUS_TYPE_SESSION, NULL, NULL ) ), | 33 | m_connection( g_bus_get_sync( G_BUS_TYPE_SESSION, NULL, NULL ), &g_object_unref ), |
328 | 34 | m_service( service ), | 34 | m_service( service ), |
329 | 35 | m_menu_path( menu_path ), | 35 | m_menu_path( menu_path ), |
330 | 36 | m_action_paths( action_paths ) | 36 | m_action_paths( action_paths ) |
331 | @@ -48,26 +48,24 @@ | |||
332 | 48 | { | 48 | { |
333 | 49 | ClearMenuModel(); | 49 | ClearMenuModel(); |
334 | 50 | ClearActionGroups(); | 50 | ClearActionGroups(); |
335 | 51 | |||
336 | 52 | g_object_unref( m_connection ); | ||
337 | 53 | } | 51 | } |
338 | 54 | 52 | ||
340 | 55 | GMenuModel* QtGMenuImporterPrivate::GetGMenuModel() | 53 | QSharedPointer<GMenuModel> QtGMenuImporterPrivate::GetGMenuModel() |
341 | 56 | { | 54 | { |
342 | 57 | if( m_menu_model == nullptr ) | 55 | if( m_menu_model == nullptr ) |
343 | 58 | { | 56 | { |
345 | 59 | return nullptr; | 57 | return QSharedPointer<GMenuModel>(); |
346 | 60 | } | 58 | } |
347 | 61 | 59 | ||
348 | 62 | return m_menu_model->Model(); | 60 | return m_menu_model->Model(); |
349 | 63 | } | 61 | } |
350 | 64 | 62 | ||
352 | 65 | GActionGroup* QtGMenuImporterPrivate::GetGActionGroup( int index ) | 63 | QSharedPointer<GActionGroup> QtGMenuImporterPrivate::GetGActionGroup( int index ) |
353 | 66 | { | 64 | { |
354 | 67 | if( index >= m_action_groups.size() || | 65 | if( index >= m_action_groups.size() || |
355 | 68 | m_action_groups[index] == nullptr ) | 66 | m_action_groups[index] == nullptr ) |
356 | 69 | { | 67 | { |
358 | 70 | return nullptr; | 68 | return QSharedPointer<GActionGroup>(); |
359 | 71 | } | 69 | } |
360 | 72 | 70 | ||
361 | 73 | return m_action_groups[index]->ActionGroup(); | 71 | return m_action_groups[index]->ActionGroup(); |
362 | @@ -160,13 +158,12 @@ | |||
363 | 160 | ClearMenuModel(); | 158 | ClearMenuModel(); |
364 | 161 | 159 | ||
365 | 162 | QString menu_path = m_menu_path.path(); | 160 | QString menu_path = m_menu_path.path(); |
370 | 163 | m_menu_model = | 161 | m_menu_model = std::make_shared< QtGMenuModel > ( m_connection, m_service, menu_path, m_action_paths ); |
367 | 164 | std::make_shared< QtGMenuModel > ( | ||
368 | 165 | G_MENU_MODEL( g_dbus_menu_model_get( m_connection, m_service.toUtf8().constData(), menu_path.toUtf8().constData() ) ), | ||
369 | 166 | m_service, menu_path, m_action_paths ); | ||
371 | 167 | 162 | ||
372 | 168 | connect( m_menu_model.get(), SIGNAL( MenuItemsChanged( QtGMenuModel*, int, int, | 163 | connect( m_menu_model.get(), SIGNAL( MenuItemsChanged( QtGMenuModel*, int, int, |
373 | 169 | int ) ), &m_parent, SIGNAL( MenuItemsChanged()) ); | 164 | int ) ), &m_parent, SIGNAL( MenuItemsChanged()) ); |
374 | 165 | |||
375 | 166 | connect( m_menu_model.get(), SIGNAL( MenuInvalid() ), this, SLOT( MenuInvalid() ) ); | ||
376 | 170 | } | 167 | } |
377 | 171 | 168 | ||
378 | 172 | void QtGMenuImporterPrivate::RefreshGActionGroup() | 169 | void QtGMenuImporterPrivate::RefreshGActionGroup() |
379 | @@ -181,8 +178,8 @@ | |||
380 | 181 | 178 | ||
381 | 182 | QString action_path = action_path_it.value().path(); | 179 | QString action_path = action_path_it.value().path(); |
382 | 183 | m_action_groups.push_back( | 180 | m_action_groups.push_back( |
385 | 184 | std::make_shared< QtGActionGroup > ( action_path_it.key(), | 181 | std::make_shared<QtGActionGroup>(m_connection, |
386 | 185 | G_ACTION_GROUP( g_dbus_action_group_get( m_connection, m_service.toUtf8().constData(), action_path.toUtf8().constData() ) ) ) ); | 182 | action_path_it.key(), m_service, action_path)); |
387 | 186 | 183 | ||
388 | 187 | auto action_group = m_action_groups.back(); | 184 | auto action_group = m_action_groups.back(); |
389 | 188 | 185 | ||
390 | @@ -198,3 +195,14 @@ | |||
391 | 198 | 195 | ||
392 | 199 | LinkMenuActions(); | 196 | LinkMenuActions(); |
393 | 200 | } | 197 | } |
394 | 198 | |||
395 | 199 | void QtGMenuImporterPrivate::MenuInvalid() | ||
396 | 200 | { | ||
397 | 201 | disconnect( &m_service_watcher, SIGNAL( serviceRegistered( const QString& ) ), this, | ||
398 | 202 | SLOT( ServiceRegistered() ) ); | ||
399 | 203 | |||
400 | 204 | disconnect( &m_service_watcher, SIGNAL( serviceUnregistered( const QString& ) ), this, | ||
401 | 205 | SLOT( ServiceUnregistered() ) ); | ||
402 | 206 | |||
403 | 207 | ServiceUnregistered(); | ||
404 | 208 | } | ||
405 | 201 | 209 | ||
406 | === modified file 'libqtgmenu/internal/QtGMenuImporterPrivate.h' | |||
407 | --- libqtgmenu/internal/QtGMenuImporterPrivate.h 2014-03-19 23:26:48 +0000 | |||
408 | +++ libqtgmenu/internal/QtGMenuImporterPrivate.h 2014-06-13 07:41:53 +0000 | |||
409 | @@ -43,8 +43,8 @@ | |||
410 | 43 | const QMap<QString, QDBusObjectPath>& action_paths, QtGMenuImporter& parent ); | 43 | const QMap<QString, QDBusObjectPath>& action_paths, QtGMenuImporter& parent ); |
411 | 44 | virtual ~QtGMenuImporterPrivate(); | 44 | virtual ~QtGMenuImporterPrivate(); |
412 | 45 | 45 | ||
415 | 46 | GMenuModel* GetGMenuModel(); | 46 | QSharedPointer<GMenuModel> GetGMenuModel(); |
416 | 47 | GActionGroup* GetGActionGroup( int index = 0); | 47 | QSharedPointer<GActionGroup> GetGActionGroup( int index = 0); |
417 | 48 | 48 | ||
418 | 49 | std::shared_ptr< QMenu > GetQMenu(); | 49 | std::shared_ptr< QMenu > GetQMenu(); |
419 | 50 | 50 | ||
420 | @@ -62,13 +62,14 @@ | |||
421 | 62 | 62 | ||
422 | 63 | void RefreshGMenuModel(); | 63 | void RefreshGMenuModel(); |
423 | 64 | void RefreshGActionGroup(); | 64 | void RefreshGActionGroup(); |
424 | 65 | void MenuInvalid(); | ||
425 | 65 | 66 | ||
426 | 66 | private: | 67 | private: |
427 | 67 | QDBusServiceWatcher m_service_watcher; | 68 | QDBusServiceWatcher m_service_watcher; |
428 | 68 | 69 | ||
429 | 69 | QtGMenuImporter& m_parent; | 70 | QtGMenuImporter& m_parent; |
430 | 70 | 71 | ||
432 | 71 | GDBusConnection* m_connection; | 72 | QSharedPointer<GDBusConnection> m_connection; |
433 | 72 | QString m_service; | 73 | QString m_service; |
434 | 73 | QDBusObjectPath m_menu_path; | 74 | QDBusObjectPath m_menu_path; |
435 | 74 | QMap<QString, QDBusObjectPath> m_action_paths; | 75 | QMap<QString, QDBusObjectPath> m_action_paths; |
436 | 75 | 76 | ||
437 | === modified file 'libqtgmenu/internal/QtGMenuModel.cpp' | |||
438 | --- libqtgmenu/internal/QtGMenuModel.cpp 2014-03-19 23:26:48 +0000 | |||
439 | +++ libqtgmenu/internal/QtGMenuModel.cpp 2014-06-13 07:41:53 +0000 | |||
440 | @@ -18,44 +18,52 @@ | |||
441 | 18 | 18 | ||
442 | 19 | #include <QtGMenuModel.h> | 19 | #include <QtGMenuModel.h> |
443 | 20 | #include <QtGMenuUtils.h> | 20 | #include <QtGMenuUtils.h> |
444 | 21 | #include <QCoreApplication> | ||
445 | 22 | #include <QDBusConnection> | ||
446 | 23 | #include <QDBusConnectionInterface> | ||
447 | 21 | #include <QDebug> | 24 | #include <QDebug> |
448 | 25 | #include <QProcess> | ||
449 | 26 | #include <QRegularExpression> | ||
450 | 22 | 27 | ||
451 | 23 | using namespace qtgmenu; | 28 | using namespace qtgmenu; |
452 | 24 | 29 | ||
457 | 25 | QtGMenuModel::QtGMenuModel( GMenuModel* model ) | 30 | static const QRegularExpression SINGLE_UNDERSCORE("(?<![_])[_](?![_])"); |
454 | 26 | : QtGMenuModel( model, LinkType::Root, nullptr, 0 ) | ||
455 | 27 | { | ||
456 | 28 | } | ||
458 | 29 | 31 | ||
461 | 30 | QtGMenuModel::QtGMenuModel( GMenuModel* model, const QString& bus_name, const QString& menu_path, const QMap<QString, QDBusObjectPath>& action_paths ) | 32 | QtGMenuModel::QtGMenuModel( QSharedPointer<GDBusConnection> connection, const QString& bus_name, |
462 | 31 | : QtGMenuModel( model, LinkType::Root, nullptr, 0 ) | 33 | const QString& menu_path, const QMap<QString, QDBusObjectPath>& action_paths ) |
463 | 34 | : QtGMenuModel( QSharedPointer<GMenuModel>(G_MENU_MODEL( g_dbus_menu_model_get( connection.data(), | ||
464 | 35 | bus_name.toUtf8().constData(), | ||
465 | 36 | menu_path.toUtf8().constData() ) ), &g_object_unref ), | ||
466 | 37 | LinkType::Root, nullptr, 0 ) | ||
467 | 32 | { | 38 | { |
468 | 39 | m_connection = connection; | ||
469 | 33 | m_bus_name = bus_name; | 40 | m_bus_name = bus_name; |
470 | 34 | m_menu_path = menu_path; | 41 | m_menu_path = menu_path; |
471 | 35 | m_action_paths = action_paths; | 42 | m_action_paths = action_paths; |
472 | 36 | } | 43 | } |
473 | 37 | 44 | ||
475 | 38 | QtGMenuModel::QtGMenuModel( GMenuModel* model, LinkType link_type, QtGMenuModel* parent, int index ) | 45 | QtGMenuModel::QtGMenuModel( QSharedPointer<GMenuModel> model, LinkType link_type, QtGMenuModel* parent, int index ) |
476 | 39 | : m_parent( parent ), | 46 | : m_parent( parent ), |
477 | 40 | m_model( model ), | 47 | m_model( model ), |
479 | 41 | m_link_type( link_type ) | 48 | m_link_type( link_type ), |
480 | 49 | m_menu( new QMenu() ), | ||
481 | 50 | m_ext_menu( new QMenu() ) | ||
482 | 42 | { | 51 | { |
483 | 43 | ConnectCallback(); | 52 | ConnectCallback(); |
484 | 44 | 53 | ||
485 | 45 | if( m_parent ) | 54 | if( m_parent ) |
486 | 46 | { | 55 | { |
489 | 47 | m_parent->InsertChild( this, index ); | 56 | m_connection = m_parent->m_connection; |
488 | 48 | |||
490 | 49 | m_bus_name = m_parent->m_bus_name; | 57 | m_bus_name = m_parent->m_bus_name; |
491 | 50 | m_menu_path = m_parent->m_menu_path; | 58 | m_menu_path = m_parent->m_menu_path; |
492 | 51 | m_action_paths = m_parent->m_action_paths; | 59 | m_action_paths = m_parent->m_action_paths; |
493 | 52 | 60 | ||
494 | 53 | gchar* label = NULL; | 61 | gchar* label = NULL; |
496 | 54 | if( g_menu_model_get_item_attribute( m_parent->m_model, index, | 62 | if( g_menu_model_get_item_attribute( m_parent->m_model.data(), index, |
497 | 55 | G_MENU_ATTRIBUTE_LABEL, "s", &label ) ) | 63 | G_MENU_ATTRIBUTE_LABEL, "s", &label ) ) |
498 | 56 | { | 64 | { |
499 | 57 | QString qlabel = QString::fromUtf8( label ); | 65 | QString qlabel = QString::fromUtf8( label ); |
501 | 58 | qlabel.replace( '_', '&' ); | 66 | qlabel.replace( SINGLE_UNDERSCORE, "&" ); |
502 | 59 | g_free( label ); | 67 | g_free( label ); |
503 | 60 | 68 | ||
504 | 61 | m_ext_menu->setTitle( qlabel ); | 69 | m_ext_menu->setTitle( qlabel ); |
505 | @@ -63,7 +71,7 @@ | |||
506 | 63 | 71 | ||
507 | 64 | gchar* action_name = NULL; | 72 | gchar* action_name = NULL; |
508 | 65 | QString qaction_name; | 73 | QString qaction_name; |
510 | 66 | if( g_menu_model_get_item_attribute( m_parent->m_model, index, | 74 | if( g_menu_model_get_item_attribute( m_parent->m_model.data(), index, |
511 | 67 | G_MENU_ATTRIBUTE_ACTION, "s", &action_name ) ) | 75 | G_MENU_ATTRIBUTE_ACTION, "s", &action_name ) ) |
512 | 68 | { | 76 | { |
513 | 69 | qaction_name = QString::fromUtf8( action_name ); | 77 | qaction_name = QString::fromUtf8( action_name ); |
514 | @@ -74,7 +82,7 @@ | |||
515 | 74 | 82 | ||
516 | 75 | // if this model has a "commitLabel" property, it is a libhud parameterized action | 83 | // if this model has a "commitLabel" property, it is a libhud parameterized action |
517 | 76 | gchar* commit_label = NULL; | 84 | gchar* commit_label = NULL; |
519 | 77 | if( g_menu_model_get_item_attribute( m_parent->m_model, index, | 85 | if( g_menu_model_get_item_attribute( m_parent->m_model.data(), index, |
520 | 78 | "commitLabel", "s", &commit_label ) ) | 86 | "commitLabel", "s", &commit_label ) ) |
521 | 79 | { | 87 | { |
522 | 80 | g_free( commit_label ); | 88 | g_free( commit_label ); |
523 | @@ -100,7 +108,7 @@ | |||
524 | 100 | 108 | ||
525 | 101 | if( m_model ) | 109 | if( m_model ) |
526 | 102 | { | 110 | { |
528 | 103 | m_size = g_menu_model_get_n_items( m_model ); | 111 | m_size = g_menu_model_get_n_items( m_model.data() ); |
529 | 104 | } | 112 | } |
530 | 105 | 113 | ||
531 | 106 | ChangeMenuItems( 0, m_size, 0 ); | 114 | ChangeMenuItems( 0, m_size, 0 ); |
532 | @@ -112,23 +120,15 @@ | |||
533 | 112 | { | 120 | { |
534 | 113 | if( m_size > 0 ) | 121 | if( m_size > 0 ) |
535 | 114 | { | 122 | { |
537 | 115 | MenuItemsChangedCallback( m_model, 0, m_size, 0, this ); | 123 | ChangeMenuItems( 0, 0, m_size ); |
538 | 116 | } | 124 | } |
539 | 117 | DisconnectCallback(); | 125 | DisconnectCallback(); |
540 | 118 | g_object_unref( m_model ); | ||
541 | 119 | } | 126 | } |
542 | 120 | 127 | ||
543 | 121 | for( auto child : m_children ) | ||
544 | 122 | { | ||
545 | 123 | delete child; | ||
546 | 124 | } | ||
547 | 125 | m_children.clear(); | 128 | m_children.clear(); |
548 | 126 | |||
549 | 127 | delete m_menu; | ||
550 | 128 | delete m_ext_menu; | ||
551 | 129 | } | 129 | } |
552 | 130 | 130 | ||
554 | 131 | GMenuModel* QtGMenuModel::Model() const | 131 | QSharedPointer<GMenuModel> QtGMenuModel::Model() const |
555 | 132 | { | 132 | { |
556 | 133 | return m_model; | 133 | return m_model; |
557 | 134 | } | 134 | } |
558 | @@ -138,24 +138,19 @@ | |||
559 | 138 | return m_link_type; | 138 | return m_link_type; |
560 | 139 | } | 139 | } |
561 | 140 | 140 | ||
562 | 141 | int QtGMenuModel::Size() const | ||
563 | 142 | { | ||
564 | 143 | return m_size; | ||
565 | 144 | } | ||
566 | 145 | |||
567 | 146 | QtGMenuModel* QtGMenuModel::Parent() const | 141 | QtGMenuModel* QtGMenuModel::Parent() const |
568 | 147 | { | 142 | { |
569 | 148 | return m_parent; | 143 | return m_parent; |
570 | 149 | } | 144 | } |
571 | 150 | 145 | ||
573 | 151 | QtGMenuModel* QtGMenuModel::Child( int index ) const | 146 | QSharedPointer<QtGMenuModel> QtGMenuModel::Child( int index ) const |
574 | 152 | { | 147 | { |
575 | 153 | if( m_children.contains( index ) ) | 148 | if( m_children.contains( index ) ) |
576 | 154 | { | 149 | { |
577 | 155 | return m_children.value( index ); | 150 | return m_children.value( index ); |
578 | 156 | } | 151 | } |
579 | 157 | 152 | ||
581 | 158 | return nullptr; | 153 | return QSharedPointer<QtGMenuModel>(); |
582 | 159 | } | 154 | } |
583 | 160 | 155 | ||
584 | 161 | std::shared_ptr< QMenu > QtGMenuModel::GetQMenu() | 156 | std::shared_ptr< QMenu > QtGMenuModel::GetQMenu() |
585 | @@ -178,7 +173,10 @@ | |||
586 | 178 | auto action_it = m_actions.find( action_name ); | 173 | auto action_it = m_actions.find( action_name ); |
587 | 179 | if( action_it != end( m_actions ) ) | 174 | if( action_it != end( m_actions ) ) |
588 | 180 | { | 175 | { |
590 | 181 | action_it->second->setEnabled( enabled ); | 176 | for( auto& action : action_it->second ) |
591 | 177 | { | ||
592 | 178 | action->setEnabled( enabled ); | ||
593 | 179 | } | ||
594 | 182 | } | 180 | } |
595 | 183 | } | 181 | } |
596 | 184 | 182 | ||
597 | @@ -187,78 +185,122 @@ | |||
598 | 187 | auto action_it = m_actions.find( action_name ); | 185 | auto action_it = m_actions.find( action_name ); |
599 | 188 | if( action_it != end( m_actions ) ) | 186 | if( action_it != end( m_actions ) ) |
600 | 189 | { | 187 | { |
602 | 190 | action_it->second->setProperty( c_property_isParameterized, parameterized ); | 188 | for( auto& action : action_it->second ) |
603 | 189 | { | ||
604 | 190 | action->setProperty( c_property_isParameterized, parameterized ); | ||
605 | 191 | } | ||
606 | 191 | } | 192 | } |
607 | 192 | } | 193 | } |
608 | 193 | 194 | ||
610 | 194 | QtGMenuModel* QtGMenuModel::CreateChild( QtGMenuModel* parent, GMenuModel* model, int index ) | 195 | QSharedPointer<QtGMenuModel> QtGMenuModel::CreateChild( QtGMenuModel* parent_qtgmenu, QSharedPointer<GMenuModel> parent_gmenu, int child_index ) |
611 | 195 | { | 196 | { |
627 | 196 | LinkType linkType( LinkType::SubMenu ); | 197 | QSharedPointer<QtGMenuModel> new_child; |
628 | 197 | GMenuModel* link = g_menu_model_get_item_link( model, index, G_MENU_LINK_SUBMENU ); | 198 | |
629 | 198 | 199 | GMenuLinkIter* link_it = g_menu_model_iterate_item_links( parent_gmenu.data(), child_index ); | |
630 | 199 | if( !link ) | 200 | |
631 | 200 | { | 201 | // get the first link, if it exists, create the child accordingly |
632 | 201 | linkType = LinkType::Section; | 202 | if( link_it && g_menu_link_iter_next( link_it ) ) |
633 | 202 | link = g_menu_model_get_item_link( model, index, G_MENU_LINK_SECTION ); | 203 | { |
634 | 203 | } | 204 | // if link is a sub menu |
635 | 204 | 205 | if( strcmp( g_menu_link_iter_get_name( link_it ), G_MENU_LINK_SUBMENU ) == 0 ) | |
636 | 205 | if( link ) | 206 | { |
637 | 206 | { | 207 | new_child.reset( |
638 | 207 | return new QtGMenuModel( link, linkType, parent, index ); | 208 | new QtGMenuModel( |
639 | 208 | } | 209 | QSharedPointer<GMenuModel>( |
640 | 209 | 210 | g_menu_link_iter_get_value(link_it), | |
641 | 210 | return nullptr; | 211 | &g_object_unref), LinkType::SubMenu, |
642 | 212 | parent_qtgmenu, child_index)); | ||
643 | 213 | } | ||
644 | 214 | // else if link is a section | ||
645 | 215 | else if( strcmp( g_menu_link_iter_get_name( link_it ), G_MENU_LINK_SECTION ) == 0 ) | ||
646 | 216 | { | ||
647 | 217 | new_child.reset( | ||
648 | 218 | new QtGMenuModel( | ||
649 | 219 | QSharedPointer<GMenuModel>( | ||
650 | 220 | g_menu_link_iter_get_value(link_it), | ||
651 | 221 | &g_object_unref), LinkType::Section, | ||
652 | 222 | parent_qtgmenu, child_index)); | ||
653 | 223 | } | ||
654 | 224 | } | ||
655 | 225 | |||
656 | 226 | g_object_unref( link_it ); | ||
657 | 227 | return new_child; | ||
658 | 211 | } | 228 | } |
659 | 212 | 229 | ||
660 | 213 | void QtGMenuModel::MenuItemsChangedCallback( GMenuModel* model, gint index, gint removed, | 230 | void QtGMenuModel::MenuItemsChangedCallback( GMenuModel* model, gint index, gint removed, |
661 | 214 | gint added, gpointer user_data ) | 231 | gint added, gpointer user_data ) |
662 | 215 | { | 232 | { |
663 | 216 | QtGMenuModel* self = reinterpret_cast< QtGMenuModel* >( user_data ); | 233 | QtGMenuModel* self = reinterpret_cast< QtGMenuModel* >( user_data ); |
664 | 234 | |||
665 | 235 | if( self->m_model != model ) | ||
666 | 236 | { | ||
667 | 237 | qWarning() << "\"items-changed\" signal received from an unrecognised menu model"; | ||
668 | 238 | return; | ||
669 | 239 | } | ||
670 | 240 | |||
671 | 217 | self->ChangeMenuItems( index, added, removed ); | 241 | self->ChangeMenuItems( index, added, removed ); |
672 | 218 | } | 242 | } |
673 | 219 | 243 | ||
675 | 220 | void QtGMenuModel::ChangeMenuItems( int index, int added, int removed ) | 244 | void QtGMenuModel::ChangeMenuItems( const int index, const int added, const int removed ) |
676 | 221 | { | 245 | { |
677 | 246 | const int n_items = g_menu_model_get_n_items( m_model.data() ); | ||
678 | 247 | |||
679 | 248 | if( index < 0 || added < 0 || removed < 0 || index + added > n_items || index + removed > m_size ) | ||
680 | 249 | { | ||
681 | 250 | ReportRecoverableError(index, added, removed); | ||
682 | 251 | return; | ||
683 | 252 | } | ||
684 | 253 | |||
685 | 254 | // process removed items first (see "items-changed" on the GMenuModel man page) | ||
686 | 222 | if( removed > 0 ) | 255 | if( removed > 0 ) |
687 | 223 | { | 256 | { |
688 | 257 | // remove QAction from 'index' of our QMenu, 'removed' times | ||
689 | 224 | for( int i = 0; i < removed; ++i ) | 258 | for( int i = 0; i < removed; ++i ) |
690 | 225 | { | 259 | { |
691 | 226 | if( index < m_menu->actions().size() ) | 260 | if( index < m_menu->actions().size() ) |
692 | 227 | { | 261 | { |
693 | 228 | QAction* at_action = m_menu->actions().at( index ); | 262 | QAction* at_action = m_menu->actions().at( index ); |
695 | 229 | ActionRemoved( at_action->property( c_property_actionName ).toString() ); | 263 | ActionRemoved( at_action->property( c_property_actionName ).toString(), at_action ); |
696 | 230 | m_menu->removeAction( at_action ); | 264 | m_menu->removeAction( at_action ); |
697 | 231 | } | 265 | } |
698 | 232 | } | 266 | } |
699 | 233 | 267 | ||
700 | 268 | // update m_children | ||
701 | 234 | for( int i = index; i < m_size; ++i ) | 269 | for( int i = index; i < m_size; ++i ) |
702 | 235 | { | 270 | { |
704 | 236 | if( i <= ( index + removed ) ) | 271 | // remove children from index until ( index + removed ) |
705 | 272 | if( i < ( index + removed ) ) | ||
706 | 237 | { | 273 | { |
708 | 238 | delete m_children.take( i ); | 274 | m_children.take( i ); |
709 | 239 | } | 275 | } |
710 | 276 | // shift children from ( index + removed ) to m_size into the now empty positions | ||
711 | 240 | else if( m_children.contains( i ) ) | 277 | else if( m_children.contains( i ) ) |
712 | 241 | { | 278 | { |
713 | 242 | m_children.insert( i - removed, m_children.take( i ) ); | 279 | m_children.insert( i - removed, m_children.take( i ) ); |
714 | 243 | } | 280 | } |
715 | 244 | } | 281 | } |
716 | 245 | 282 | ||
717 | 283 | // update m_size | ||
718 | 246 | m_size -= removed; | 284 | m_size -= removed; |
719 | 247 | } | 285 | } |
720 | 248 | 286 | ||
721 | 287 | // now process added items | ||
722 | 249 | if( added > 0 ) | 288 | if( added > 0 ) |
723 | 250 | { | 289 | { |
726 | 251 | // shift items up | 290 | // update m_children (start from the end and work backwards as not to overlap items as we shift them up) |
727 | 252 | for( int i = ( m_size + added ) - 1; i >= index; --i ) | 291 | for( int i = m_size - 1; i >= index; --i ) |
728 | 253 | { | 292 | { |
729 | 293 | // shift 'added' items up from their current index to ( index + added ) | ||
730 | 254 | if( m_children.contains( i ) ) | 294 | if( m_children.contains( i ) ) |
731 | 255 | { | 295 | { |
732 | 256 | m_children.insert( i + added, m_children.take( i ) ); | 296 | m_children.insert( i + added, m_children.take( i ) ); |
733 | 257 | } | 297 | } |
734 | 258 | } | 298 | } |
735 | 259 | 299 | ||
736 | 300 | // update m_size | ||
737 | 260 | m_size += added; | 301 | m_size += added; |
738 | 261 | 302 | ||
739 | 303 | // now add a new QAction to our QMenu for each new item | ||
740 | 262 | for( int i = index; i < ( index + added ); ++i ) | 304 | for( int i = index; i < ( index + added ); ++i ) |
741 | 263 | { | 305 | { |
742 | 264 | QAction* at_action = nullptr; | 306 | QAction* at_action = nullptr; |
743 | @@ -267,32 +309,37 @@ | |||
744 | 267 | at_action = m_menu->actions().at( i ); | 309 | at_action = m_menu->actions().at( i ); |
745 | 268 | } | 310 | } |
746 | 269 | 311 | ||
748 | 270 | QtGMenuModel* model = CreateChild( this, m_model, i ); | 312 | // try first to create a child model |
749 | 313 | QSharedPointer< QtGMenuModel > model = CreateChild( this, m_model, i ); | ||
750 | 271 | 314 | ||
751 | 315 | // if this is a menu item and not a model | ||
752 | 272 | if( !model ) | 316 | if( !model ) |
753 | 273 | { | 317 | { |
754 | 274 | QAction* new_action = CreateAction( i ); | 318 | QAction* new_action = CreateAction( i ); |
755 | 275 | ActionAdded( new_action->property( c_property_actionName ).toString(), new_action ); | 319 | ActionAdded( new_action->property( c_property_actionName ).toString(), new_action ); |
756 | 276 | m_menu->insertAction( at_action, new_action ); | 320 | m_menu->insertAction( at_action, new_action ); |
757 | 277 | } | 321 | } |
758 | 322 | // else if this is a section model | ||
759 | 278 | else if( model->Type() == LinkType::Section ) | 323 | else if( model->Type() == LinkType::Section ) |
760 | 279 | { | 324 | { |
761 | 325 | InsertChild( model, i ); | ||
762 | 280 | m_menu->insertSeparator( at_action ); | 326 | m_menu->insertSeparator( at_action ); |
763 | 281 | } | 327 | } |
764 | 328 | // else if this is a sub menu model | ||
765 | 282 | else if( model->Type() == LinkType::SubMenu ) | 329 | else if( model->Type() == LinkType::SubMenu ) |
766 | 283 | { | 330 | { |
768 | 284 | m_menu->insertMenu( at_action, model->m_ext_menu ); | 331 | InsertChild( model, i ); |
769 | 332 | ActionAdded( model->m_ext_menu->menuAction()->property( c_property_actionName ).toString(), | ||
770 | 333 | model->m_ext_menu->menuAction() ); | ||
771 | 334 | m_menu->insertMenu( at_action, model->m_ext_menu.data() ); | ||
772 | 285 | } | 335 | } |
773 | 286 | } | 336 | } |
774 | 287 | } | 337 | } |
775 | 288 | 338 | ||
776 | 289 | // update external menu | 339 | // update external menu |
777 | 290 | UpdateExtQMenu(); | 340 | UpdateExtQMenu(); |
778 | 291 | if( m_link_type == LinkType::Section && m_parent ) | ||
779 | 292 | { | ||
780 | 293 | m_parent->UpdateExtQMenu(); | ||
781 | 294 | } | ||
782 | 295 | 341 | ||
783 | 342 | // now tell the outside world that items have changed | ||
784 | 296 | emit MenuItemsChanged( this, index, removed, added ); | 343 | emit MenuItemsChanged( this, index, removed, added ); |
785 | 297 | } | 344 | } |
786 | 298 | 345 | ||
787 | @@ -300,7 +347,7 @@ | |||
788 | 300 | { | 347 | { |
789 | 301 | if( m_model && m_items_changed_handler == 0 ) | 348 | if( m_model && m_items_changed_handler == 0 ) |
790 | 302 | { | 349 | { |
792 | 303 | m_items_changed_handler = g_signal_connect( m_model, "items-changed", | 350 | m_items_changed_handler = g_signal_connect( m_model.data(), "items-changed", |
793 | 304 | G_CALLBACK( MenuItemsChangedCallback ), this ); | 351 | G_CALLBACK( MenuItemsChangedCallback ), this ); |
794 | 305 | } | 352 | } |
795 | 306 | } | 353 | } |
796 | @@ -309,13 +356,13 @@ | |||
797 | 309 | { | 356 | { |
798 | 310 | if( m_model && m_items_changed_handler != 0 ) | 357 | if( m_model && m_items_changed_handler != 0 ) |
799 | 311 | { | 358 | { |
801 | 312 | g_signal_handler_disconnect( m_model, m_items_changed_handler ); | 359 | g_signal_handler_disconnect( m_model.data(), m_items_changed_handler ); |
802 | 313 | } | 360 | } |
803 | 314 | 361 | ||
804 | 315 | m_items_changed_handler = 0; | 362 | m_items_changed_handler = 0; |
805 | 316 | } | 363 | } |
806 | 317 | 364 | ||
808 | 318 | void QtGMenuModel::InsertChild( QtGMenuModel* child, int index ) | 365 | void QtGMenuModel::InsertChild( QSharedPointer<QtGMenuModel> child, int index ) |
809 | 319 | { | 366 | { |
810 | 320 | if( m_children.contains( index ) ) | 367 | if( m_children.contains( index ) ) |
811 | 321 | { | 368 | { |
812 | @@ -325,35 +372,27 @@ | |||
813 | 325 | child->m_parent = this; | 372 | child->m_parent = this; |
814 | 326 | m_children.insert( index, child ); | 373 | m_children.insert( index, child ); |
815 | 327 | 374 | ||
817 | 328 | connect( child, SIGNAL( MenuItemsChanged( QtGMenuModel*, int, int, int ) ), this, | 375 | connect( child.data(), SIGNAL( MenuItemsChanged( QtGMenuModel*, int, int, int ) ), this, |
818 | 329 | SIGNAL( MenuItemsChanged( QtGMenuModel*, int, int, int ) ) ); | 376 | SIGNAL( MenuItemsChanged( QtGMenuModel*, int, int, int ) ) ); |
819 | 330 | 377 | ||
821 | 331 | connect( child, SIGNAL( ActionTriggered( QString, bool ) ), this, | 378 | connect( child.data(), SIGNAL( ActionTriggered( QString, bool ) ), this, |
822 | 332 | SIGNAL( ActionTriggered( QString, bool ) ) ); | 379 | SIGNAL( ActionTriggered( QString, bool ) ) ); |
836 | 333 | } | 380 | |
837 | 334 | 381 | connect( child.data(), SIGNAL( MenuInvalid() ), this, SIGNAL( MenuInvalid() ) ); | |
838 | 335 | int QtGMenuModel::ChildIndex( QtGMenuModel* child ) | 382 | |
839 | 336 | { | 383 | // emit signal informing subscribers that this child has added all of its menu items |
840 | 337 | for( int i = 0; i < m_children.size(); ++i ) | 384 | emit MenuItemsChanged( child.data(), 0, 0, child->m_size ); |
828 | 338 | { | ||
829 | 339 | if( child == m_children[i] ) | ||
830 | 340 | { | ||
831 | 341 | return i; | ||
832 | 342 | } | ||
833 | 343 | } | ||
834 | 344 | |||
835 | 345 | return -1; | ||
841 | 346 | } | 385 | } |
842 | 347 | 386 | ||
843 | 348 | QAction* QtGMenuModel::CreateAction( int index ) | 387 | QAction* QtGMenuModel::CreateAction( int index ) |
844 | 349 | { | 388 | { |
845 | 389 | QAction* action = new QAction( m_menu.data() ); | ||
846 | 390 | |||
847 | 350 | // action label | 391 | // action label |
848 | 351 | QAction* action = new QAction( this ); | ||
849 | 352 | |||
850 | 353 | gchar* label = NULL; | 392 | gchar* label = NULL; |
852 | 354 | if( g_menu_model_get_item_attribute( m_model, index, G_MENU_ATTRIBUTE_LABEL, "s", &label ) ) { | 393 | if( g_menu_model_get_item_attribute( m_model.data(), index, G_MENU_ATTRIBUTE_LABEL, "s", &label ) ) { |
853 | 355 | QString qlabel = QString::fromUtf8( label ); | 394 | QString qlabel = QString::fromUtf8( label ); |
855 | 356 | qlabel.replace( '_', '&' ); | 395 | qlabel.replace( SINGLE_UNDERSCORE, "&" ); |
856 | 357 | g_free( label ); | 396 | g_free( label ); |
857 | 358 | 397 | ||
858 | 359 | action->setText( qlabel ); | 398 | action->setText( qlabel ); |
859 | @@ -361,7 +400,7 @@ | |||
860 | 361 | 400 | ||
861 | 362 | // action name | 401 | // action name |
862 | 363 | gchar* action_name = NULL; | 402 | gchar* action_name = NULL; |
864 | 364 | if( g_menu_model_get_item_attribute( m_model, index, | 403 | if( g_menu_model_get_item_attribute( m_model.data(), index, |
865 | 365 | G_MENU_ATTRIBUTE_ACTION, "s", &action_name ) ) | 404 | G_MENU_ATTRIBUTE_ACTION, "s", &action_name ) ) |
866 | 366 | { | 405 | { |
867 | 367 | QString qaction_name = QString::fromUtf8( action_name ); | 406 | QString qaction_name = QString::fromUtf8( action_name ); |
868 | @@ -378,7 +417,7 @@ | |||
869 | 378 | action->setProperty( c_property_menuPath, m_menu_path ); | 417 | action->setProperty( c_property_menuPath, m_menu_path ); |
870 | 379 | 418 | ||
871 | 380 | // action icon | 419 | // action icon |
873 | 381 | GVariant* icon = g_menu_model_get_item_attribute_value( m_model, index, G_MENU_ATTRIBUTE_ICON, | 420 | GVariant* icon = g_menu_model_get_item_attribute_value( m_model.data(), index, G_MENU_ATTRIBUTE_ICON, |
874 | 382 | G_VARIANT_TYPE_VARIANT ); | 421 | G_VARIANT_TYPE_VARIANT ); |
875 | 383 | 422 | ||
876 | 384 | if( icon ) | 423 | if( icon ) |
877 | @@ -388,7 +427,7 @@ | |||
878 | 388 | 427 | ||
879 | 389 | // action shortcut | 428 | // action shortcut |
880 | 390 | gchar* shortcut = NULL; | 429 | gchar* shortcut = NULL; |
882 | 391 | if( g_menu_model_get_item_attribute( m_model, index, "accel", "s", &shortcut ) ) | 430 | if( g_menu_model_get_item_attribute( m_model.data(), index, "accel", "s", &shortcut ) ) |
883 | 392 | { | 431 | { |
884 | 393 | QString qshortcut = QString::fromUtf8( shortcut ); | 432 | QString qshortcut = QString::fromUtf8( shortcut ); |
885 | 394 | g_free( shortcut ); | 433 | g_free( shortcut ); |
886 | @@ -398,7 +437,7 @@ | |||
887 | 398 | 437 | ||
888 | 399 | // action shortcut | 438 | // action shortcut |
889 | 400 | gchar* toolbar_item = NULL; | 439 | gchar* toolbar_item = NULL; |
891 | 401 | if( g_menu_model_get_item_attribute( m_model, index, c_property_hud_toolbar_item, "s", &toolbar_item ) ) | 440 | if( g_menu_model_get_item_attribute( m_model.data(), index, c_property_hud_toolbar_item, "s", &toolbar_item ) ) |
892 | 402 | { | 441 | { |
893 | 403 | QString qtoolbar_item = QString::fromUtf8( toolbar_item ); | 442 | QString qtoolbar_item = QString::fromUtf8( toolbar_item ); |
894 | 404 | g_free( toolbar_item ); | 443 | g_free( toolbar_item ); |
895 | @@ -408,7 +447,7 @@ | |||
896 | 408 | 447 | ||
897 | 409 | // action keywords | 448 | // action keywords |
898 | 410 | gchar* keywords = NULL; | 449 | gchar* keywords = NULL; |
900 | 411 | if( g_menu_model_get_item_attribute( m_model, index, c_property_keywords, "s", &keywords ) ) | 450 | if( g_menu_model_get_item_attribute( m_model.data(), index, c_property_keywords, "s", &keywords ) ) |
901 | 412 | { | 451 | { |
902 | 413 | QVariant qkeywords = QString::fromUtf8( keywords ); | 452 | QVariant qkeywords = QString::fromUtf8( keywords ); |
903 | 414 | g_free( keywords ); | 453 | g_free( keywords ); |
904 | @@ -458,14 +497,13 @@ | |||
905 | 458 | 497 | ||
906 | 459 | if( action->isSeparator() ) | 498 | if( action->isSeparator() ) |
907 | 460 | { | 499 | { |
909 | 461 | QtGMenuModel* child = Child( i ); | 500 | QSharedPointer<QtGMenuModel> child = Child( i ); |
910 | 462 | if( !child || child->Type() != LinkType::Section ) | 501 | if( !child || child->Type() != LinkType::Section ) |
911 | 463 | { | 502 | { |
912 | 464 | continue; | 503 | continue; |
913 | 465 | } | 504 | } |
914 | 466 | QMenu* section = child->m_ext_menu; | ||
915 | 467 | 505 | ||
917 | 468 | for( QAction* sub_action : section->actions() ) | 506 | for( QAction* sub_action : child->m_ext_menu->actions() ) |
918 | 469 | { | 507 | { |
919 | 470 | m_ext_menu->addAction( sub_action ); | 508 | m_ext_menu->addAction( sub_action ); |
920 | 471 | } | 509 | } |
921 | @@ -485,6 +523,12 @@ | |||
922 | 485 | m_ext_menu->removeAction( last_action ); | 523 | m_ext_menu->removeAction( last_action ); |
923 | 486 | } | 524 | } |
924 | 487 | } | 525 | } |
925 | 526 | |||
926 | 527 | // if this is a section within a parent menu, we need to update the parent menu as well | ||
927 | 528 | if( m_link_type == LinkType::Section && m_parent ) | ||
928 | 529 | { | ||
929 | 530 | m_parent->UpdateExtQMenu(); | ||
930 | 531 | } | ||
931 | 488 | } | 532 | } |
932 | 489 | 533 | ||
933 | 490 | void QtGMenuModel::ActionAdded( const QString& name, QAction* action ) | 534 | void QtGMenuModel::ActionAdded( const QString& name, QAction* action ) |
934 | @@ -494,17 +538,205 @@ | |||
935 | 494 | { | 538 | { |
936 | 495 | m_parent->ActionAdded( name, action ); | 539 | m_parent->ActionAdded( name, action ); |
937 | 496 | } | 540 | } |
940 | 497 | 541 | else | |
941 | 498 | m_actions[name] = action; | 542 | { |
942 | 543 | // check if the action name is already in our map | ||
943 | 544 | if( m_actions.find( name ) != m_actions.end() ) | ||
944 | 545 | { | ||
945 | 546 | // add the QAction pointer to the list of actions under this name | ||
946 | 547 | m_actions[name].push_back( action ); | ||
947 | 548 | } | ||
948 | 549 | else | ||
949 | 550 | { | ||
950 | 551 | // otherwise insert the new action into the map | ||
951 | 552 | m_actions.insert( std::make_pair( name, std::vector< QAction* >{ action } ) ); | ||
952 | 553 | } | ||
953 | 554 | } | ||
954 | 499 | } | 555 | } |
955 | 500 | 556 | ||
957 | 501 | void QtGMenuModel::ActionRemoved( const QString& name ) | 557 | void QtGMenuModel::ActionRemoved( const QString& name, QAction* action ) |
958 | 502 | { | 558 | { |
959 | 503 | // remove action from top menu's m_actions | 559 | // remove action from top menu's m_actions |
960 | 504 | if( m_parent ) | 560 | if( m_parent ) |
961 | 505 | { | 561 | { |
966 | 506 | m_parent->ActionRemoved( name ); | 562 | m_parent->ActionRemoved( name, action ); |
967 | 507 | } | 563 | } |
968 | 508 | 564 | else | |
969 | 509 | m_actions.erase( name ); | 565 | { |
970 | 566 | // check if this action is actually in our map | ||
971 | 567 | if( m_actions.find( name ) != m_actions.end() ) | ||
972 | 568 | { | ||
973 | 569 | // remove the QAction pointer from the list of actions under this name | ||
974 | 570 | auto& actionList = m_actions[name]; | ||
975 | 571 | auto actionIt = std::find( actionList.begin(), actionList.end(), action ); | ||
976 | 572 | |||
977 | 573 | if( actionIt != actionList.end()) | ||
978 | 574 | { | ||
979 | 575 | actionList.erase( actionIt ); | ||
980 | 576 | } | ||
981 | 577 | |||
982 | 578 | // if there are no more references to this action, remove it from the map | ||
983 | 579 | if( actionList.size() == 0 ) | ||
984 | 580 | { | ||
985 | 581 | m_actions.erase( name ); | ||
986 | 582 | } | ||
987 | 583 | } | ||
988 | 584 | } | ||
989 | 585 | } | ||
990 | 586 | |||
991 | 587 | static void write_pair(QIODevice& device, const QString& key, const QString& value, bool last = false) | ||
992 | 588 | { | ||
993 | 589 | device.write(key.toUtf8()); | ||
994 | 590 | device.write("", 1); | ||
995 | 591 | device.write(value.toUtf8()); | ||
996 | 592 | if( !last ) | ||
997 | 593 | { | ||
998 | 594 | device.write("", 1); | ||
999 | 595 | } | ||
1000 | 596 | |||
1001 | 597 | if( !value.isEmpty()) | ||
1002 | 598 | { | ||
1003 | 599 | qWarning() << key << " =" << value; | ||
1004 | 600 | } | ||
1005 | 601 | } | ||
1006 | 602 | |||
1007 | 603 | void QtGMenuModel::ReportRecoverableError(const int index, const int added, const int removed) | ||
1008 | 604 | { | ||
1009 | 605 | if( m_error_reported ) | ||
1010 | 606 | { | ||
1011 | 607 | return; | ||
1012 | 608 | } | ||
1013 | 609 | |||
1014 | 610 | // gmenumodel properties | ||
1015 | 611 | int gmenu_item_count = 0; | ||
1016 | 612 | QString gmenu_action_names; | ||
1017 | 613 | |||
1018 | 614 | gmenu_item_count = g_menu_model_get_n_items( m_model.data() ); | ||
1019 | 615 | |||
1020 | 616 | qWarning() << "Illegal arguments when updating GMenuModel: position =" | ||
1021 | 617 | << index << ", added =" << added << ", removed =" << removed | ||
1022 | 618 | << ", size =" << gmenu_item_count; | ||
1023 | 619 | |||
1024 | 620 | for( int i = 0; i < gmenu_item_count; ++i ) | ||
1025 | 621 | { | ||
1026 | 622 | gchar* action_name = NULL; | ||
1027 | 623 | if( g_menu_model_get_item_attribute( m_model.data(), i, | ||
1028 | 624 | G_MENU_ATTRIBUTE_ACTION, "s", &action_name ) ) | ||
1029 | 625 | { | ||
1030 | 626 | gmenu_action_names += action_name; | ||
1031 | 627 | gmenu_action_names += ";"; | ||
1032 | 628 | g_free( action_name ); | ||
1033 | 629 | } | ||
1034 | 630 | } | ||
1035 | 631 | |||
1036 | 632 | // parent model properties | ||
1037 | 633 | QString parent_menu_label; | ||
1038 | 634 | QString parent_menu_name; | ||
1039 | 635 | QString parent_action_names; | ||
1040 | 636 | QString parent_link_type; | ||
1041 | 637 | |||
1042 | 638 | if( m_parent ) | ||
1043 | 639 | { | ||
1044 | 640 | parent_menu_label = m_parent->m_menu->menuAction()->text(); | ||
1045 | 641 | parent_menu_name = m_parent->m_menu->menuAction()->property( c_property_actionName ).toString(); | ||
1046 | 642 | |||
1047 | 643 | for( QAction* action : m_parent->m_menu->actions() ) | ||
1048 | 644 | { | ||
1049 | 645 | parent_action_names += action->property( c_property_actionName ).toString() + ";"; | ||
1050 | 646 | } | ||
1051 | 647 | |||
1052 | 648 | switch( m_parent->m_link_type ) | ||
1053 | 649 | { | ||
1054 | 650 | case LinkType::Root: | ||
1055 | 651 | parent_link_type = "root"; | ||
1056 | 652 | break; | ||
1057 | 653 | case LinkType::Section: | ||
1058 | 654 | parent_link_type = "section"; | ||
1059 | 655 | break; | ||
1060 | 656 | case LinkType::SubMenu: | ||
1061 | 657 | parent_link_type = "sub menu"; | ||
1062 | 658 | break; | ||
1063 | 659 | } | ||
1064 | 660 | } | ||
1065 | 661 | |||
1066 | 662 | // local model properties | ||
1067 | 663 | QString menu_label; | ||
1068 | 664 | QString menu_name; | ||
1069 | 665 | QString action_names; | ||
1070 | 666 | QString link_type; | ||
1071 | 667 | QString action_paths; | ||
1072 | 668 | |||
1073 | 669 | menu_label = m_menu->menuAction()->text(); | ||
1074 | 670 | menu_name = m_menu->menuAction()->property( c_property_actionName ).toString(); | ||
1075 | 671 | for( QAction* action : m_menu->actions() ) | ||
1076 | 672 | { | ||
1077 | 673 | action_names += action->property( c_property_actionName ).toString() + ";"; | ||
1078 | 674 | } | ||
1079 | 675 | |||
1080 | 676 | switch( m_link_type ) | ||
1081 | 677 | { | ||
1082 | 678 | case LinkType::Root: | ||
1083 | 679 | link_type = "root"; | ||
1084 | 680 | break; | ||
1085 | 681 | case LinkType::Section: | ||
1086 | 682 | link_type = "section"; | ||
1087 | 683 | break; | ||
1088 | 684 | case LinkType::SubMenu: | ||
1089 | 685 | link_type = "sub menu"; | ||
1090 | 686 | break; | ||
1091 | 687 | } | ||
1092 | 688 | |||
1093 | 689 | for( auto const& action : m_action_paths ) | ||
1094 | 690 | { | ||
1095 | 691 | action_paths += action.path() + ";"; | ||
1096 | 692 | } | ||
1097 | 693 | |||
1098 | 694 | uint sender_pid = QDBusConnection::sessionBus().interface()->servicePid( | ||
1099 | 695 | m_bus_name); | ||
1100 | 696 | if( sender_pid == 0 ) { | ||
1101 | 697 | qWarning() << "Failed to read PID, cannot report error"; | ||
1102 | 698 | return; | ||
1103 | 699 | } | ||
1104 | 700 | |||
1105 | 701 | QProcess recoverable; | ||
1106 | 702 | recoverable.setProcessChannelMode(QProcess::ForwardedChannels); | ||
1107 | 703 | recoverable.start("/usr/share/apport/recoverable_problem", | ||
1108 | 704 | QStringList() << "-p" << QString::number(sender_pid)); | ||
1109 | 705 | if (recoverable.waitForStarted()) | ||
1110 | 706 | { | ||
1111 | 707 | write_pair(recoverable, "DuplicateSignature", "GMenuModelItemsChangedInvalidIndex"); | ||
1112 | 708 | write_pair(recoverable, "BusName", m_bus_name); | ||
1113 | 709 | write_pair(recoverable, "Position", QString::number(index)); | ||
1114 | 710 | write_pair(recoverable, "Added", QString::number(added)); | ||
1115 | 711 | write_pair(recoverable, "Removed", QString::number(removed)); | ||
1116 | 712 | write_pair(recoverable, "ItemCount", QString::number(gmenu_item_count)); | ||
1117 | 713 | write_pair(recoverable, "ActionNames", gmenu_action_names); | ||
1118 | 714 | |||
1119 | 715 | if ( m_parent ) | ||
1120 | 716 | { | ||
1121 | 717 | write_pair(recoverable, "ParentMenuLabel", parent_menu_label); | ||
1122 | 718 | write_pair(recoverable, "ParentMenuName", parent_menu_name); | ||
1123 | 719 | write_pair(recoverable, "ParentActionNames", parent_action_names); | ||
1124 | 720 | write_pair(recoverable, "ParentLinkType", parent_link_type); | ||
1125 | 721 | } | ||
1126 | 722 | |||
1127 | 723 | write_pair(recoverable, "MenuLabel", menu_label); | ||
1128 | 724 | write_pair(recoverable, "MenuName", menu_name); | ||
1129 | 725 | write_pair(recoverable, "ActionNames", action_names); | ||
1130 | 726 | write_pair(recoverable, "LinkType", link_type); | ||
1131 | 727 | |||
1132 | 728 | write_pair(recoverable, "MenuPath", m_menu_path); | ||
1133 | 729 | write_pair(recoverable, "ActionPaths", action_paths, true); | ||
1134 | 730 | |||
1135 | 731 | recoverable.closeWriteChannel(); | ||
1136 | 732 | recoverable.waitForFinished(); | ||
1137 | 733 | |||
1138 | 734 | m_error_reported = true; | ||
1139 | 735 | } | ||
1140 | 736 | else | ||
1141 | 737 | { | ||
1142 | 738 | qWarning() << "Failed to report recoverable error"; | ||
1143 | 739 | } | ||
1144 | 740 | |||
1145 | 741 | emit MenuInvalid(); | ||
1146 | 510 | } | 742 | } |
1147 | 511 | 743 | ||
1148 | === modified file 'libqtgmenu/internal/QtGMenuModel.h' | |||
1149 | --- libqtgmenu/internal/QtGMenuModel.h 2014-03-19 23:26:48 +0000 | |||
1150 | +++ libqtgmenu/internal/QtGMenuModel.h 2014-06-13 07:41:53 +0000 | |||
1151 | @@ -43,17 +43,14 @@ | |||
1152 | 43 | Root, Section, SubMenu | 43 | Root, Section, SubMenu |
1153 | 44 | }; | 44 | }; |
1154 | 45 | 45 | ||
1157 | 46 | explicit QtGMenuModel( GMenuModel* model ); | 46 | QtGMenuModel( QSharedPointer<GDBusConnection> connection, const QString& bus_name, const QString& menu_path, const QMap<QString, QDBusObjectPath>& action_paths ); |
1156 | 47 | QtGMenuModel( GMenuModel* model, const QString& bus_name, const QString& menu_path, const QMap<QString, QDBusObjectPath>& action_paths ); | ||
1158 | 48 | virtual ~QtGMenuModel(); | 47 | virtual ~QtGMenuModel(); |
1159 | 49 | 48 | ||
1161 | 50 | GMenuModel* Model() const; | 49 | QSharedPointer<GMenuModel> Model() const; |
1162 | 51 | LinkType Type() const; | 50 | LinkType Type() const; |
1163 | 52 | 51 | ||
1164 | 53 | int Size() const; | ||
1165 | 54 | |||
1166 | 55 | QtGMenuModel* Parent() const; | 52 | QtGMenuModel* Parent() const; |
1168 | 56 | QtGMenuModel* Child( int index ) const; | 53 | QSharedPointer<QtGMenuModel> Child( int index ) const; |
1169 | 57 | 54 | ||
1170 | 58 | std::shared_ptr< QMenu > GetQMenu(); | 55 | std::shared_ptr< QMenu > GetQMenu(); |
1171 | 59 | 56 | ||
1172 | @@ -68,6 +65,7 @@ | |||
1173 | 68 | Q_SIGNALS: | 65 | Q_SIGNALS: |
1174 | 69 | void MenuItemsChanged( QtGMenuModel* model, int index, int removed, int added ); | 66 | void MenuItemsChanged( QtGMenuModel* model, int index, int removed, int added ); |
1175 | 70 | void ActionTriggered( QString action_name, bool checked ); | 67 | void ActionTriggered( QString action_name, bool checked ); |
1176 | 68 | void MenuInvalid(); | ||
1177 | 71 | 69 | ||
1178 | 72 | public Q_SLOTS: | 70 | public Q_SLOTS: |
1179 | 73 | void ActionEnabled( QString action_name, bool enabled ); | 71 | void ActionEnabled( QString action_name, bool enabled ); |
1180 | @@ -77,20 +75,19 @@ | |||
1181 | 77 | void ActionTriggered( bool ); | 75 | void ActionTriggered( bool ); |
1182 | 78 | 76 | ||
1183 | 79 | private: | 77 | private: |
1185 | 80 | QtGMenuModel( GMenuModel* model, LinkType link_type, QtGMenuModel* parent, int index ); | 78 | QtGMenuModel( QSharedPointer<GMenuModel> model, LinkType link_type, QtGMenuModel* parent, int index ); |
1186 | 81 | 79 | ||
1188 | 82 | static QtGMenuModel* CreateChild( QtGMenuModel* parent, GMenuModel* model, int index ); | 80 | static QSharedPointer<QtGMenuModel> CreateChild( QtGMenuModel* parent_qtgmenu, QSharedPointer<GMenuModel> parent_gmenu, int child_index ); |
1189 | 83 | 81 | ||
1190 | 84 | static void MenuItemsChangedCallback( GMenuModel* model, gint index, gint removed, gint added, | 82 | static void MenuItemsChangedCallback( GMenuModel* model, gint index, gint removed, gint added, |
1191 | 85 | gpointer user_data ); | 83 | gpointer user_data ); |
1192 | 86 | 84 | ||
1194 | 87 | void ChangeMenuItems( int index, int added, int removed ); | 85 | void ChangeMenuItems( const int index, const int added, const int removed ); |
1195 | 88 | 86 | ||
1196 | 89 | void ConnectCallback(); | 87 | void ConnectCallback(); |
1197 | 90 | void DisconnectCallback(); | 88 | void DisconnectCallback(); |
1198 | 91 | 89 | ||
1201 | 92 | void InsertChild( QtGMenuModel* child, int index ); | 90 | void InsertChild( QSharedPointer<QtGMenuModel> child, int index ); |
1200 | 93 | int ChildIndex( QtGMenuModel* child ); | ||
1202 | 94 | 91 | ||
1203 | 95 | QAction* CreateAction( int index ); | 92 | QAction* CreateAction( int index ); |
1204 | 96 | 93 | ||
1205 | @@ -98,26 +95,32 @@ | |||
1206 | 98 | void UpdateExtQMenu(); | 95 | void UpdateExtQMenu(); |
1207 | 99 | 96 | ||
1208 | 100 | void ActionAdded( const QString& name, QAction* action ); | 97 | void ActionAdded( const QString& name, QAction* action ); |
1210 | 101 | void ActionRemoved( const QString& name ); | 98 | void ActionRemoved( const QString& name, QAction* action ); |
1211 | 99 | |||
1212 | 100 | void ReportRecoverableError(const int index, const int added, const int removed); | ||
1213 | 102 | 101 | ||
1214 | 103 | private: | 102 | private: |
1215 | 104 | QtGMenuModel* m_parent = nullptr; | 103 | QtGMenuModel* m_parent = nullptr; |
1217 | 105 | QMap< int, QtGMenuModel* > m_children; | 104 | QMap< int, QSharedPointer<QtGMenuModel>> m_children; |
1218 | 106 | 105 | ||
1220 | 107 | GMenuModel* m_model = nullptr; | 106 | QSharedPointer<GMenuModel> m_model; |
1221 | 108 | gulong m_items_changed_handler = 0; | 107 | gulong m_items_changed_handler = 0; |
1222 | 109 | 108 | ||
1223 | 110 | LinkType m_link_type; | 109 | LinkType m_link_type; |
1224 | 111 | int m_size = 0; | 110 | int m_size = 0; |
1225 | 112 | 111 | ||
1228 | 113 | QMenu* m_menu = new QMenu(); | 112 | QScopedPointer<QMenu> m_menu; |
1229 | 114 | QMenu* m_ext_menu = new QMenu(); | 113 | QScopedPointer<QMenu> m_ext_menu; |
1230 | 115 | 114 | ||
1231 | 115 | QSharedPointer<GDBusConnection> m_connection; | ||
1232 | 116 | QString m_bus_name; | 116 | QString m_bus_name; |
1233 | 117 | QString m_menu_path; | 117 | QString m_menu_path; |
1234 | 118 | QMap<QString, QDBusObjectPath> m_action_paths; | 118 | QMap<QString, QDBusObjectPath> m_action_paths; |
1235 | 119 | 119 | ||
1237 | 120 | std::map< QString, QAction* > m_actions; | 120 | // a map of QActions indexed by their name and stored with a reference count |
1238 | 121 | std::map< QString, std::vector< QAction* > > m_actions; | ||
1239 | 122 | |||
1240 | 123 | bool m_error_reported = false; | ||
1241 | 121 | }; | 124 | }; |
1242 | 122 | 125 | ||
1243 | 123 | } // namespace qtgmenu | 126 | } // namespace qtgmenu |
1244 | 124 | 127 | ||
1245 | === modified file 'service/DBusMenuCollector.cpp' | |||
1246 | --- service/DBusMenuCollector.cpp 2014-04-01 13:13:04 +0000 | |||
1247 | +++ service/DBusMenuCollector.cpp 2014-06-13 07:41:53 +0000 | |||
1248 | @@ -82,25 +82,18 @@ | |||
1249 | 82 | return !m_menuImporter.isNull(); | 82 | return !m_menuImporter.isNull(); |
1250 | 83 | } | 83 | } |
1251 | 84 | 84 | ||
1252 | 85 | inline uint qHash(const QStringList &key, uint seed) { | ||
1253 | 86 | uint hash(0); | ||
1254 | 87 | for (const QString &s : key) { | ||
1255 | 88 | hash ^= qHash(s, seed); | ||
1256 | 89 | } | ||
1257 | 90 | return hash; | ||
1258 | 91 | } | ||
1259 | 92 | |||
1260 | 93 | void DBusMenuCollector::openMenu(QMenu *menu, unsigned int &limit) { | 85 | void DBusMenuCollector::openMenu(QMenu *menu, unsigned int &limit) { |
1261 | 86 | --limit; | ||
1262 | 87 | if (limit == 0) { | ||
1263 | 88 | QString error = "Hit DBusMenu safety valve opening menu at " + m_service | ||
1264 | 89 | + " " + m_path.path(); | ||
1265 | 90 | throw std::logic_error(error.toStdString()); | ||
1266 | 91 | } | ||
1267 | 92 | |||
1268 | 94 | if (!menu) { | 93 | if (!menu) { |
1269 | 95 | return; | 94 | return; |
1270 | 96 | } | 95 | } |
1271 | 97 | 96 | ||
1272 | 98 | if (limit == 0) { | ||
1273 | 99 | QString error = "Hit DBusMenu safety valve for menu at " + m_service | ||
1274 | 100 | + " " + m_path.path(); | ||
1275 | 101 | throw std::logic_error(error.toStdString()); | ||
1276 | 102 | } | ||
1277 | 103 | |||
1278 | 104 | menu->aboutToShow(); | 97 | menu->aboutToShow(); |
1279 | 105 | 98 | ||
1280 | 106 | for (int i(0); m_menuImporter && i < menu->actions().size(); ++i) { | 99 | for (int i(0); m_menuImporter && i < menu->actions().size(); ++i) { |
1281 | @@ -114,15 +107,15 @@ | |||
1282 | 114 | 107 | ||
1283 | 115 | QMenu *child(action->menu()); | 108 | QMenu *child(action->menu()); |
1284 | 116 | if (child) { | 109 | if (child) { |
1285 | 117 | --limit; | ||
1286 | 118 | openMenu(child, limit); | 110 | openMenu(child, limit); |
1287 | 119 | } | 111 | } |
1288 | 120 | } | 112 | } |
1289 | 121 | } | 113 | } |
1290 | 122 | 114 | ||
1291 | 123 | void DBusMenuCollector::hideMenu(QMenu *menu, unsigned int &limit) { | 115 | void DBusMenuCollector::hideMenu(QMenu *menu, unsigned int &limit) { |
1292 | 116 | --limit; | ||
1293 | 124 | if (limit == 0) { | 117 | if (limit == 0) { |
1295 | 125 | QString error = "Hit DBusMenu safety valve for menu at " + m_service | 118 | QString error = "Hit DBusMenu safety valve closing menu at " + m_service |
1296 | 126 | + " " + m_path.path(); | 119 | + " " + m_path.path(); |
1297 | 127 | throw std::logic_error(error.toStdString()); | 120 | throw std::logic_error(error.toStdString()); |
1298 | 128 | } | 121 | } |
1299 | @@ -131,7 +124,6 @@ | |||
1300 | 131 | QAction *action = menu->actions().at(i); | 124 | QAction *action = menu->actions().at(i); |
1301 | 132 | QMenu *child(action->menu()); | 125 | QMenu *child(action->menu()); |
1302 | 133 | if (child) { | 126 | if (child) { |
1303 | 134 | --limit; | ||
1304 | 135 | hideMenu(child, limit); | 127 | hideMenu(child, limit); |
1305 | 136 | } | 128 | } |
1306 | 137 | } | 129 | } |
1307 | 138 | 130 | ||
1308 | === modified file 'service/HudServiceImpl.cpp' | |||
1309 | --- service/HudServiceImpl.cpp 2014-02-18 13:35:12 +0000 | |||
1310 | +++ service/HudServiceImpl.cpp 2014-06-13 07:41:53 +0000 | |||
1311 | @@ -104,13 +104,24 @@ | |||
1312 | 104 | QList<Suggestion> &suggestions, QDBusVariant &querykey) { | 104 | QList<Suggestion> &suggestions, QDBusVariant &querykey) { |
1313 | 105 | QString sender(messageSender()); | 105 | QString sender(messageSender()); |
1314 | 106 | 106 | ||
1316 | 107 | Query::Ptr query(m_legacyQueries[sender]); | 107 | QPair<Query::Ptr, QSharedPointer<QTimer>> entry(m_legacyQueries[sender]); |
1317 | 108 | Query::Ptr query(entry.first); | ||
1318 | 109 | QSharedPointer<QTimer> legacyTimeout(entry.second); | ||
1319 | 108 | if (query.isNull()) { | 110 | if (query.isNull()) { |
1320 | 109 | query = createQuery(queryString, sender, | 111 | query = createQuery(queryString, sender, |
1321 | 110 | Query::EmptyBehaviour::NO_SUGGESTIONS); | 112 | Query::EmptyBehaviour::NO_SUGGESTIONS); |
1323 | 111 | m_legacyQueries[sender] = query; | 113 | |
1324 | 114 | legacyTimeout.reset(new QTimer()); | ||
1325 | 115 | legacyTimeout->setInterval(2000); | ||
1326 | 116 | legacyTimeout->setSingleShot(true); | ||
1327 | 117 | connect(legacyTimeout.data(), SIGNAL(timeout()), this, | ||
1328 | 118 | SLOT(legacyTimeout())); | ||
1329 | 119 | |||
1330 | 120 | m_legacyQueries[sender] = qMakePair(query, legacyTimeout); | ||
1331 | 112 | } else { | 121 | } else { |
1332 | 113 | query->UpdateQuery(queryString); | 122 | query->UpdateQuery(queryString); |
1333 | 123 | legacyTimeout->stop(); | ||
1334 | 124 | legacyTimeout->setProperty("sender", QVariant()); | ||
1335 | 114 | } | 125 | } |
1336 | 115 | 126 | ||
1337 | 116 | // The legacy API only allows you to search the current application | 127 | // The legacy API only allows you to search the current application |
1338 | @@ -142,8 +153,13 @@ | |||
1339 | 142 | Q_UNUSED(timestamp); | 153 | Q_UNUSED(timestamp); |
1340 | 143 | QString sender(messageSender()); | 154 | QString sender(messageSender()); |
1341 | 144 | 155 | ||
1343 | 145 | Query::Ptr query(m_legacyQueries.take(sender)); | 156 | QPair<Query::Ptr, QSharedPointer<QTimer>> entry(m_legacyQueries.take(sender)); |
1344 | 157 | Query::Ptr query(entry.first); | ||
1345 | 158 | QSharedPointer<QTimer> legacyTimeout(entry.second); | ||
1346 | 146 | if (!query.isNull()) { | 159 | if (!query.isNull()) { |
1347 | 160 | legacyTimeout->stop(); | ||
1348 | 161 | legacyTimeout->setProperty("sender", QVariant()); | ||
1349 | 162 | |||
1350 | 147 | query->ExecuteCommand(itemKey, timestamp); | 163 | query->ExecuteCommand(itemKey, timestamp); |
1351 | 148 | closeQuery(query->path()); | 164 | closeQuery(query->path()); |
1352 | 149 | } | 165 | } |
1353 | @@ -156,8 +172,32 @@ | |||
1354 | 156 | // We don't actually close legacy queries, or we'd be constructing | 172 | // We don't actually close legacy queries, or we'd be constructing |
1355 | 157 | // and destructing them during the search, due to the way that | 173 | // and destructing them during the search, due to the way that |
1356 | 158 | // Unity7 uses the API. | 174 | // Unity7 uses the API. |
1358 | 159 | Query::Ptr query(m_legacyQueries[sender]); | 175 | QPair<Query::Ptr, QSharedPointer<QTimer>> entry(m_legacyQueries[sender]); |
1359 | 176 | Query::Ptr query(entry.first); | ||
1360 | 177 | QSharedPointer<QTimer> legacyTimeout(entry.second); | ||
1361 | 160 | if (!query.isNull()) { | 178 | if (!query.isNull()) { |
1362 | 161 | query->UpdateQuery(QString()); | 179 | query->UpdateQuery(QString()); |
1364 | 162 | } | 180 | legacyTimeout->start(); |
1365 | 181 | legacyTimeout->setProperty("sender", sender); | ||
1366 | 182 | } | ||
1367 | 183 | } | ||
1368 | 184 | |||
1369 | 185 | void HudServiceImpl::legacyTimeout() { | ||
1370 | 186 | QObject *timer(sender()); | ||
1371 | 187 | if (!timer) { | ||
1372 | 188 | return; | ||
1373 | 189 | } | ||
1374 | 190 | |||
1375 | 191 | QVariant from(timer->property("sender")); | ||
1376 | 192 | if (from.isNull()) { | ||
1377 | 193 | return; | ||
1378 | 194 | } | ||
1379 | 195 | |||
1380 | 196 | QString sender(from.toString()); | ||
1381 | 197 | QPair<Query::Ptr, QSharedPointer<QTimer>> entry(m_legacyQueries.take(sender)); | ||
1382 | 198 | Query::Ptr query(entry.first); | ||
1383 | 199 | if (query) { | ||
1384 | 200 | closeQuery(query->path()); | ||
1385 | 201 | } | ||
1386 | 202 | |||
1387 | 163 | } | 203 | } |
1388 | 164 | 204 | ||
1389 | === modified file 'service/HudServiceImpl.h' | |||
1390 | --- service/HudServiceImpl.h 2014-02-18 13:35:12 +0000 | |||
1391 | +++ service/HudServiceImpl.h 2014-06-13 07:41:53 +0000 | |||
1392 | @@ -28,6 +28,7 @@ | |||
1393 | 28 | #include <QDBusVariant> | 28 | #include <QDBusVariant> |
1394 | 29 | #include <QMap> | 29 | #include <QMap> |
1395 | 30 | #include <QScopedPointer> | 30 | #include <QScopedPointer> |
1396 | 31 | #include <QTimer> | ||
1397 | 31 | 32 | ||
1398 | 32 | class HudAdaptor; | 33 | class HudAdaptor; |
1399 | 33 | 34 | ||
1400 | @@ -73,6 +74,9 @@ | |||
1401 | 73 | 74 | ||
1402 | 74 | void CloseQuery(const QDBusVariant &querykey); | 75 | void CloseQuery(const QDBusVariant &querykey); |
1403 | 75 | 76 | ||
1404 | 77 | protected Q_SLOTS: | ||
1405 | 78 | void legacyTimeout(); | ||
1406 | 79 | |||
1407 | 76 | protected: | 80 | protected: |
1408 | 77 | Query::Ptr createQuery(const QString &query, const QString &service, | 81 | Query::Ptr createQuery(const QString &query, const QString &service, |
1409 | 78 | Query::EmptyBehaviour emptyBehaviour); | 82 | Query::EmptyBehaviour emptyBehaviour); |
1410 | @@ -85,7 +89,7 @@ | |||
1411 | 85 | 89 | ||
1412 | 86 | QMap<QDBusObjectPath, Query::Ptr> m_queries; | 90 | QMap<QDBusObjectPath, Query::Ptr> m_queries; |
1413 | 87 | 91 | ||
1415 | 88 | QMap<QString, Query::Ptr> m_legacyQueries; | 92 | QMap<QString, QPair<Query::Ptr, QSharedPointer<QTimer>>> m_legacyQueries; |
1416 | 89 | 93 | ||
1417 | 90 | QSharedPointer<ApplicationList> m_applicationList; | 94 | QSharedPointer<ApplicationList> m_applicationList; |
1418 | 91 | 95 | ||
1419 | 92 | 96 | ||
1420 | === modified file 'tests/unit/qtgmenu/TestQtGMenu.cpp' | |||
1421 | --- tests/unit/qtgmenu/TestQtGMenu.cpp 2014-03-20 06:46:57 +0000 | |||
1422 | +++ tests/unit/qtgmenu/TestQtGMenu.cpp 2014-06-13 07:41:53 +0000 | |||
1423 | @@ -71,28 +71,28 @@ | |||
1424 | 71 | 71 | ||
1425 | 72 | int GetGMenuSize() | 72 | int GetGMenuSize() |
1426 | 73 | { | 73 | { |
1428 | 74 | GMenuModel* menu = m_importer.GetGMenuModel(); | 74 | QSharedPointer<GMenuModel> menu = m_importer.GetGMenuModel(); |
1429 | 75 | 75 | ||
1430 | 76 | if( !menu ) | 76 | if( !menu ) |
1431 | 77 | { | 77 | { |
1432 | 78 | return 0; | 78 | return 0; |
1433 | 79 | } | 79 | } |
1434 | 80 | 80 | ||
1436 | 81 | gint item_count = g_menu_model_get_n_items( G_MENU_MODEL( menu ) ); | 81 | gint item_count = g_menu_model_get_n_items( G_MENU_MODEL( menu.data() ) ); |
1437 | 82 | 82 | ||
1438 | 83 | return item_count; | 83 | return item_count; |
1439 | 84 | } | 84 | } |
1440 | 85 | 85 | ||
1441 | 86 | int GetGActionCount() | 86 | int GetGActionCount() |
1442 | 87 | { | 87 | { |
1444 | 88 | GActionGroup* actions = m_importer.GetGActionGroup(); | 88 | QSharedPointer<GActionGroup> actions = m_importer.GetGActionGroup(); |
1445 | 89 | 89 | ||
1446 | 90 | if( !actions ) | 90 | if( !actions ) |
1447 | 91 | { | 91 | { |
1448 | 92 | return 0; | 92 | return 0; |
1449 | 93 | } | 93 | } |
1450 | 94 | 94 | ||
1452 | 95 | gchar** actions_list = g_action_group_list_actions( actions ); | 95 | gchar** actions_list = g_action_group_list_actions( actions.data() ); |
1453 | 96 | 96 | ||
1454 | 97 | int action_count = 0; | 97 | int action_count = 0; |
1455 | 98 | while( actions_list[action_count] != nullptr ) | 98 | while( actions_list[action_count] != nullptr ) |
PASSED: Continuous integration, rev:395 jenkins. qa.ubuntu. com/job/ hud-ci/ 289/ jenkins. qa.ubuntu. com/job/ hud-utopic- amd64-ci/ 4 jenkins. qa.ubuntu. com/job/ hud-utopic- armhf-ci/ 4 jenkins. qa.ubuntu. com/job/ hud-utopic- i386-ci/ 4
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/hud- ci/289/ rebuild
http://