Merge lp:~unity-api-team/hud/lp-1288025 into lp:hud/14.04

Proposed by Pete Woods
Status: Merged
Approved by: Antti Kaijanmäki
Approved revision: 398
Merged at revision: 380
Proposed branch: lp:~unity-api-team/hud/lp-1288025
Merge into: lp:hud/14.04
Prerequisite: lp:~pete-woods/hud/use-new-libdbusmenu
Diff against target: 983 lines (+182/-161)
26 files modified
libqtgmenu/QtGMenuImporter.cpp (+11/-7)
libqtgmenu/QtGMenuImporter.h (+6/-4)
libqtgmenu/internal/QtGActionGroup.cpp (+15/-7)
libqtgmenu/internal/QtGActionGroup.h (+2/-1)
libqtgmenu/internal/QtGMenuImporterPrivate.cpp (+55/-51)
libqtgmenu/internal/QtGMenuImporterPrivate.h (+7/-7)
libqtgmenu/internal/QtGMenuModel.cpp (+1/-9)
libqtgmenu/internal/QtGMenuModel.h (+1/-4)
service/Collector.h (+1/-1)
service/DBusMenuCollector.cpp (+4/-4)
service/DBusMenuCollector.h (+1/-1)
service/Factory.cpp (+3/-2)
service/Factory.h (+2/-1)
service/GMenuCollector.cpp (+6/-7)
service/GMenuCollector.h (+4/-3)
service/GMenuWindowCollector.cpp (+28/-10)
service/GMenuWindowCollector.h (+2/-16)
service/WindowContextImpl.cpp (+4/-1)
service/WindowImpl.cpp (+1/-4)
tests/integration/TestHud.cpp (+2/-2)
tests/testapps/qtgmenu/MainWindow.cpp (+2/-2)
tests/testapps/qtgmenu/MainWindow.h (+1/-1)
tests/testapps/qtgmenu/main.cpp (+1/-1)
tests/unit/qtgmenu/TestQtGMenu.cpp (+1/-1)
tests/unit/service/Mocks.h (+3/-2)
tests/unit/service/TestWindow.cpp (+18/-12)
To merge this branch: bzr merge lp:~unity-api-team/hud/lp-1288025
Reviewer Review Type Date Requested Status
Antti Kaijanmäki (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+209449@code.launchpad.net

Commit message

Support multiple GMenuCollectors for each window, and multiple QtGActionGroups for each QtGMenuModel.

Description of the change

* Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
  * Yes
 * Did you build your software in a clean sbuild/pbuilder chroot or ppa?
  * Yes
 * Did you build your software in a clean sbuild/pbuilder armhf chroot or ppa?
  * Yes
 * Has your component "TestPlan” been executed successfully on emulator, N4?
  * Yes
 * Has a 5 minute exploratory testing run been executed on N4?
  * Yes
 * If you changed the packaging (debian), did you subscribe a core-dev to this MP?
  * N/A
 * If you changed the UI, did you subscribe the design-reviewers to this MP?
  * No change
 * What components might get impacted by your changes?
  * Unity7
  * Unity8
 * Have you requested review by the teams of these owning components?
  * Yes

Check List:
https://wiki.ubuntu.com/Process/Merges/Checklists/hud

Test Plan:
https://wiki.ubuntu.com/Process/Merges/TestPlan/hud

Silo:
https://launchpad.net/~ci-train-ppa-service/+archive/landing-002/

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Things are looking good now.

The gmenu importer now accepts multiple action paths each pointing to a different action group.

Each action group is aware of it's own prefix, so upon triggering an action, this prefix is used to determine which action group to target.

When actions are enabled and parameterised the action group prepends it's prefix to the action name before informing the menu model.

Revision history for this message
Pete Woods (pete-woods) wrote :

Looking good. I can confirm that Nautlus and LibreOffice both work now. :)

Revision history for this message
Pete Woods (pete-woods) wrote :

Also, just so you know, you can convert a QString to a C string using the following:

string.toUtf8().constData()

Revision history for this message
Michi Henning (michihenning) wrote :

> Also, just so you know, you can convert a QString to a C string using the
> following:
>
> string.toUtf8().constData()

Awesome! How bloody obvious. Silly me for not seeing that immediately ;-)

Revision history for this message
Pete Woods (pete-woods) wrote :

> > Also, just so you know, you can convert a QString to a C string using the
> > following:
> >
> > string.toUtf8().constData()
>
> Awesome! How bloody obvious. Silly me for not seeing that immediately ;-)

I think it all comes from them trying supporting UTF across platforms. You need a temporary object representing just some bytes.

IIRC:
* Windows uses UTF-16 by default => use std::wstring
* Linux and OSX use UTF-8 by default => use std::string.

This means you have a difficult choice if you're making an app you want to work on both platforms. So I would think this is why Trolltech made QString. Maybe things have changed since I gathered this information? I'd be happy to be wrong on this!

Revision history for this message
Michi Henning (michihenning) wrote :

> > > Also, just so you know, you can convert a QString to a C string using the
> > > following:
> > >
> > > string.toUtf8().constData()
> >
> > Awesome! How bloody obvious. Silly me for not seeing that immediately ;-)
>
> I think it all comes from them trying supporting UTF across platforms. You
> need a temporary object representing just some bytes.

Yeah. I was commenting on the really awkward and counter-intuitive API. Would be nice have something like string.c_str() or similar.

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

> Also, just so you know, you can convert a QString to a C string using the
> following:
>
> string.toUtf8().constData()

Ok cool, I've cleanup up that class now to use the QDBusObjectPaths provided instead of std::strings.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

was there anything missing there? it would be nice to see that fix landing in trusty...

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

> was there anything missing there? it would be nice to see that fix landing in
> trusty...

"Silo:
<no silo>"

Looks like we're still waiting for a landing slot for this.

Revision history for this message
Pete Woods (pete-woods) wrote :

Yes, we're basically stuck waiting for qt5.2 to land, as HUD already has a landing in that silo.

lp:~unity-api-team/hud/lp-1288025 updated
388. By Marcus Tomlinson

Narrowed down QtGMenuImporter to one choice of constructor.

389. By Marcus Tomlinson

QtGMenuImporter now accepts a map of action paths.

390. By Marcus Tomlinson

Removed unused "unused" function

391. By Marcus Tomlinson

QtGMenuImporter now maintains multiple action paths and groups

392. By Marcus Tomlinson

Check action prefix on QtGActionGroup::TriggerAction()

393. By Marcus Tomlinson

Removed now unnecessary "explicit" specifier

394. By Marcus Tomlinson

Prepend action prefix to action name when emitting ActionEnabled and ActionParameterized from QtGActionGroup

395. By Marcus Tomlinson

Some cleaning up

396. By Marcus Tomlinson

QtGMenuImporterPrivate stores QDBusObjectPath members for menu and action paths rather than std::strings.

397. By Pete Woods

Use a smaller import

398. By Pete Woods

Fix formatting

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Antti Kaijanmäki (kaijanmaki) wrote :

LGTM. Waiting for silo.

Revision history for this message
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?
Yes.

 * Did you do exploratory testing related to the component you own with the MP changeset included?
Yes.

 * 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?
Yes.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libqtgmenu/QtGMenuImporter.cpp'
--- libqtgmenu/QtGMenuImporter.cpp 2013-12-23 10:54:14 +0000
+++ libqtgmenu/QtGMenuImporter.cpp 2014-03-14 14:09:41 +0000
@@ -23,15 +23,19 @@
2323
24using namespace qtgmenu;24using namespace qtgmenu;
2525
26QtGMenuImporter::QtGMenuImporter( const QString &service, const QString& path, QObject* parent )26QtGMenuImporter::QtGMenuImporter( const QString& service, const QDBusObjectPath& menu_path,
27 : QtGMenuImporter( service, path, path, parent )27 const QString& action_prefix, const QDBusObjectPath& action_path, QObject* parent )
28 : QObject( parent )
28{29{
30 QMap<QString, QDBusObjectPath> action_paths;
31 action_paths[action_prefix] = action_path;
32 d.reset( new QtGMenuImporterPrivate( service, menu_path, action_paths, *this ) );
29}33}
3034
31QtGMenuImporter::QtGMenuImporter( const QString &service, const QString& menu_path,35QtGMenuImporter::QtGMenuImporter( const QString& service, const QDBusObjectPath& menu_path,
32 const QString& actions_path, QObject* parent )36 const QMap<QString, QDBusObjectPath>& action_paths, QObject* parent )
33 : QObject( parent ),37 : QObject( parent ),
34 d( new QtGMenuImporterPrivate( service, menu_path, actions_path, *this ) )38 d( new QtGMenuImporterPrivate( service, menu_path, action_paths, *this ) )
35{39{
36}40}
3741
@@ -44,9 +48,9 @@
44 return d->GetGMenuModel();48 return d->GetGMenuModel();
45}49}
4650
47GActionGroup* QtGMenuImporter::GetGActionGroup() const51GActionGroup* QtGMenuImporter::GetGActionGroup( int index ) const
48{52{
49 return d->GetGActionGroup();53 return d->GetGActionGroup( index );
50}54}
5155
52std::shared_ptr< QMenu > QtGMenuImporter::GetQMenu() const56std::shared_ptr< QMenu > QtGMenuImporter::GetQMenu() const
5357
=== modified file 'libqtgmenu/QtGMenuImporter.h'
--- libqtgmenu/QtGMenuImporter.h 2013-12-24 10:02:26 +0000
+++ libqtgmenu/QtGMenuImporter.h 2014-03-14 14:09:41 +0000
@@ -20,6 +20,7 @@
20#define QTGMENUIMPORTER_H20#define QTGMENUIMPORTER_H
2121
22#include <QObject>22#include <QObject>
23#include <QDBusObjectPath>
23#include <memory>24#include <memory>
2425
25class QMenu;26class QMenu;
@@ -40,13 +41,14 @@
40Q_OBJECT41Q_OBJECT
4142
42public:43public:
43 QtGMenuImporter( const QString& service, const QString& path, QObject* parent = 0 );44 QtGMenuImporter( const QString& service, const QDBusObjectPath& menu_path,
44 QtGMenuImporter( const QString& service, const QString& menu_path, const QString& actions_path,45 const QString& action_prefix, const QDBusObjectPath& action_path, QObject* parent = 0 );
45 QObject* parent = 0 );46 QtGMenuImporter( const QString& service, const QDBusObjectPath& menu_path,
47 const QMap<QString, QDBusObjectPath>& action_paths, QObject* parent = 0 );
46 virtual ~QtGMenuImporter();48 virtual ~QtGMenuImporter();
4749
48 GMenuModel* GetGMenuModel() const;50 GMenuModel* GetGMenuModel() const;
49 GActionGroup* GetGActionGroup() const;51 GActionGroup* GetGActionGroup( int index = 0 ) const;
5052
51 std::shared_ptr< QMenu > GetQMenu() const;53 std::shared_ptr< QMenu > GetQMenu() const;
5254
5355
=== modified file 'libqtgmenu/internal/QtGActionGroup.cpp'
--- libqtgmenu/internal/QtGActionGroup.cpp 2014-02-05 14:02:28 +0000
+++ libqtgmenu/internal/QtGActionGroup.cpp 2014-03-14 14:09:41 +0000
@@ -21,8 +21,9 @@
2121
22using namespace qtgmenu;22using namespace qtgmenu;
2323
24QtGActionGroup::QtGActionGroup( GActionGroup* action_group )24QtGActionGroup::QtGActionGroup( const QString& action_prefix, GActionGroup* action_group )
25 : m_action_group( action_group )25 : m_action_prefix( action_prefix ),
26 m_action_group( action_group )
26{27{
27 ConnectCallbacks();28 ConnectCallbacks();
2829
@@ -93,6 +94,13 @@
9394
94void QtGActionGroup::TriggerAction( QString action_name, bool checked )95void QtGActionGroup::TriggerAction( QString action_name, bool checked )
95{96{
97 QString prefix = action_name.left( action_name.indexOf( '.' ) );
98 if( prefix != m_action_prefix )
99 {
100 return;
101 }
102
103 action_name = action_name.right( action_name.size() - action_name.indexOf( '.' ) - 1 );
96 std::string action = action_name.toStdString();104 std::string action = action_name.toStdString();
97105
98 const GVariantType* type = g_action_group_get_action_parameter_type( m_action_group,106 const GVariantType* type = g_action_group_get_action_parameter_type( m_action_group,
@@ -124,12 +132,12 @@
124 bool enabled = G_ACTION_GROUP_GET_IFACE( m_action_group ) ->get_action_enabled( m_action_group,132 bool enabled = G_ACTION_GROUP_GET_IFACE( m_action_group ) ->get_action_enabled( m_action_group,
125 action_name );133 action_name );
126 if( !enabled )134 if( !enabled )
127 emit ActionEnabled( action_name, enabled );135 emit ActionEnabled( m_action_prefix + "." + action_name, enabled );
128136
129 const GVariantType* type = g_action_group_get_action_parameter_type( m_action_group,137 const GVariantType* type = g_action_group_get_action_parameter_type( m_action_group,
130 action_name );138 action_name );
131 if( type != nullptr )139 if( type != nullptr )
132 emit ActionParameterized( action_name, type != nullptr );140 emit ActionParameterized( m_action_prefix + "." + action_name, type != nullptr );
133 }141 }
134142
135 g_strfreev( actions_list );143 g_strfreev( actions_list );
@@ -144,12 +152,12 @@
144 bool enabled = G_ACTION_GROUP_GET_IFACE( self->m_action_group ) ->get_action_enabled(152 bool enabled = G_ACTION_GROUP_GET_IFACE( self->m_action_group ) ->get_action_enabled(
145 self->m_action_group, action_name );153 self->m_action_group, action_name );
146 if( !enabled )154 if( !enabled )
147 emit self->ActionEnabled( action_name, enabled );155 emit self->ActionEnabled( self->m_action_prefix + "." + action_name, enabled );
148156
149 const GVariantType* type = g_action_group_get_action_parameter_type( self->m_action_group,157 const GVariantType* type = g_action_group_get_action_parameter_type( self->m_action_group,
150 action_name );158 action_name );
151 if( type != nullptr )159 if( type != nullptr )
152 emit self->ActionParameterized( action_name, type != nullptr );160 emit self->ActionParameterized( self->m_action_prefix + "." + action_name, type != nullptr );
153161
154 ++self->m_size;162 ++self->m_size;
155}163}
@@ -167,7 +175,7 @@
167 gboolean enabled, gpointer user_data )175 gboolean enabled, gpointer user_data )
168{176{
169 QtGActionGroup* self = reinterpret_cast< QtGActionGroup* >( user_data );177 QtGActionGroup* self = reinterpret_cast< QtGActionGroup* >( user_data );
170 emit self->ActionEnabled( action_name, enabled );178 emit self->ActionEnabled( self->m_action_prefix + "." + action_name, enabled );
171}179}
172180
173void QtGActionGroup::ActionStateChangedCallback( GActionGroup* action_group, gchar* action_name,181void QtGActionGroup::ActionStateChangedCallback( GActionGroup* action_group, gchar* action_name,
174182
=== modified file 'libqtgmenu/internal/QtGActionGroup.h'
--- libqtgmenu/internal/QtGActionGroup.h 2014-02-05 14:02:28 +0000
+++ libqtgmenu/internal/QtGActionGroup.h 2014-03-14 14:09:41 +0000
@@ -33,7 +33,7 @@
33Q_OBJECT33Q_OBJECT
3434
35public:35public:
36 explicit QtGActionGroup( GActionGroup* action_group );36 QtGActionGroup( const QString& action_prefix, GActionGroup* action_group );
37 virtual ~QtGActionGroup();37 virtual ~QtGActionGroup();
3838
39 GActionGroup* ActionGroup() const;39 GActionGroup* ActionGroup() const;
@@ -68,6 +68,7 @@
68private:68private:
69 int m_size = 0;69 int m_size = 0;
7070
71 QString m_action_prefix;
71 GActionGroup* m_action_group = nullptr;72 GActionGroup* m_action_group = nullptr;
7273
73 gulong m_action_added_handler = 0;74 gulong m_action_added_handler = 0;
7475
=== modified file 'libqtgmenu/internal/QtGMenuImporterPrivate.cpp'
--- libqtgmenu/internal/QtGMenuImporterPrivate.cpp 2013-12-24 10:02:26 +0000
+++ libqtgmenu/internal/QtGMenuImporterPrivate.cpp 2014-03-14 14:09:41 +0000
@@ -24,21 +24,16 @@
2424
25using namespace qtgmenu;25using namespace qtgmenu;
2626
27// this is used to suppress compiler warnings about unused parameters27QtGMenuImporterPrivate::QtGMenuImporterPrivate( const QString& service, const QDBusObjectPath& menu_path,
28template< typename ... T > void unused( T&& ... )28 const QMap<QString, QDBusObjectPath>& action_paths, QtGMenuImporter& parent )
29{
30}
31
32QtGMenuImporterPrivate::QtGMenuImporterPrivate( const QString& service, const QString& menu_path,
33 const QString& actions_path, QtGMenuImporter& parent )
34 : QObject( 0 ),29 : QObject( 0 ),
35 m_service_watcher( service, QDBusConnection::sessionBus(),30 m_service_watcher( service, QDBusConnection::sessionBus(),
36 QDBusServiceWatcher::WatchForOwnerChange ),31 QDBusServiceWatcher::WatchForOwnerChange ),
37 m_parent( parent ),32 m_parent( parent ),
38 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 ) ),
39 m_service( service.toStdString() ),34 m_service( service.toStdString() ),
40 m_menu_path( menu_path.toStdString() ),35 m_menu_path( menu_path ),
41 m_actions_path( actions_path.toStdString() )36 m_action_paths( action_paths )
42{37{
43 connect( &m_service_watcher, SIGNAL( serviceRegistered( const QString& ) ), this,38 connect( &m_service_watcher, SIGNAL( serviceRegistered( const QString& ) ), this,
44 SLOT( ServiceRegistered() ) );39 SLOT( ServiceRegistered() ) );
@@ -52,7 +47,7 @@
52QtGMenuImporterPrivate::~QtGMenuImporterPrivate()47QtGMenuImporterPrivate::~QtGMenuImporterPrivate()
53{48{
54 ClearMenuModel();49 ClearMenuModel();
55 ClearActionGroup();50 ClearActionGroups();
5651
57 g_object_unref( m_connection );52 g_object_unref( m_connection );
58}53}
@@ -67,14 +62,15 @@
67 return m_menu_model->Model();62 return m_menu_model->Model();
68}63}
6964
70GActionGroup* QtGMenuImporterPrivate::GetGActionGroup()65GActionGroup* QtGMenuImporterPrivate::GetGActionGroup( int index )
71{66{
72 if( m_action_group == nullptr )67 if( index >= m_action_groups.size() ||
68 m_action_groups[index] == nullptr )
73 {69 {
74 return nullptr;70 return nullptr;
75 }71 }
7672
77 return m_action_group->ActionGroup();73 return m_action_groups[index]->ActionGroup();
78}74}
7975
80std::shared_ptr< QMenu > QtGMenuImporterPrivate::GetQMenu()76std::shared_ptr< QMenu > QtGMenuImporterPrivate::GetQMenu()
@@ -89,12 +85,12 @@
8985
90void QtGMenuImporterPrivate::Refresh()86void QtGMenuImporterPrivate::Refresh()
91{87{
92 if( !m_menu_path.empty() )88 if( !m_menu_path.path().isEmpty() )
93 {89 {
94 RefreshGMenuModel();90 RefreshGMenuModel();
95 }91 }
9692
97 if( !m_actions_path.empty() )93 if( !m_action_paths.empty() )
98 {94 {
99 RefreshGActionGroup();95 RefreshGActionGroup();
100 }96 }
@@ -113,34 +109,35 @@
113 m_menu_model = nullptr;109 m_menu_model = nullptr;
114}110}
115111
116void QtGMenuImporterPrivate::ClearActionGroup()112void QtGMenuImporterPrivate::ClearActionGroups()
117{113{
118 if( m_action_group == nullptr )114 for( auto& action_group : m_action_groups )
119 {115 {
120 return;116 action_group->disconnect();
121 }117 }
122118
123 m_action_group->disconnect();
124 m_menu_actions_linked = false;119 m_menu_actions_linked = false;
125120 m_action_groups.clear();
126 m_action_group = nullptr;
127}121}
128122
129void QtGMenuImporterPrivate::LinkMenuActions()123void QtGMenuImporterPrivate::LinkMenuActions()
130{124{
131 if( m_menu_model && m_action_group && !m_menu_actions_linked )125 if( m_menu_model && !m_action_groups.empty() && !m_menu_actions_linked )
132 {126 {
133 connect( m_menu_model.get(), SIGNAL( ActionTriggered( QString, bool ) ), m_action_group.get(),127 for( auto& action_group : m_action_groups )
134 SLOT( TriggerAction( QString, bool ) ) );128 {
135129 connect( m_menu_model.get(), SIGNAL( ActionTriggered( QString, bool ) ), action_group.get(),
136 connect( m_menu_model.get(), SIGNAL( MenuItemsChanged( QtGMenuModel*, int, int, int ) ),130 SLOT( TriggerAction( QString, bool ) ) );
137 m_action_group.get(), SLOT( EmitStates() ) );131
138132 connect( m_menu_model.get(), SIGNAL( MenuItemsChanged( QtGMenuModel*, int, int, int ) ),
139 connect( m_action_group.get(), SIGNAL( ActionEnabled( QString, bool ) ), m_menu_model.get(),133 action_group.get(), SLOT( EmitStates() ) );
140 SLOT( ActionEnabled( QString, bool ) ) );134
141135 connect( action_group.get(), SIGNAL( ActionEnabled( QString, bool ) ), m_menu_model.get(),
142 connect( m_action_group.get(), SIGNAL( ActionParameterized( QString, bool ) ),136 SLOT( ActionEnabled( QString, bool ) ) );
143 m_menu_model.get(), SLOT( ActionParameterized( QString, bool ) ) );137
138 connect( action_group.get(), SIGNAL( ActionParameterized( QString, bool ) ),
139 m_menu_model.get(), SLOT( ActionParameterized( QString, bool ) ) );
140 }
144141
145 m_menu_actions_linked = true;142 m_menu_actions_linked = true;
146 }143 }
@@ -154,7 +151,7 @@
154void QtGMenuImporterPrivate::ServiceUnregistered()151void QtGMenuImporterPrivate::ServiceUnregistered()
155{152{
156 ClearMenuModel();153 ClearMenuModel();
157 ClearActionGroup();154 ClearActionGroups();
158}155}
159156
160void QtGMenuImporterPrivate::RefreshGMenuModel()157void QtGMenuImporterPrivate::RefreshGMenuModel()
@@ -162,10 +159,11 @@
162 // clear the menu model for the refresh159 // clear the menu model for the refresh
163 ClearMenuModel();160 ClearMenuModel();
164161
162 QString menu_path = m_menu_path.path();
165 m_menu_model =163 m_menu_model =
166 std::make_shared< QtGMenuModel > (164 std::make_shared< QtGMenuModel > (
167 G_MENU_MODEL( g_dbus_menu_model_get( m_connection, m_service.c_str(), m_menu_path.c_str() ) ),165 G_MENU_MODEL( g_dbus_menu_model_get( m_connection, m_service.c_str(), menu_path.toUtf8().constData() ) ),
168 m_service.c_str(), m_menu_path.c_str(), m_actions_path.c_str() );166 m_service.c_str(), menu_path.toUtf8().constData() );
169167
170 connect( m_menu_model.get(), SIGNAL( MenuItemsChanged( QtGMenuModel*, int, int,168 connect( m_menu_model.get(), SIGNAL( MenuItemsChanged( QtGMenuModel*, int, int,
171 int ) ), &m_parent, SIGNAL( MenuItemsChanged()) );169 int ) ), &m_parent, SIGNAL( MenuItemsChanged()) );
@@ -173,21 +171,27 @@
173171
174void QtGMenuImporterPrivate::RefreshGActionGroup()172void QtGMenuImporterPrivate::RefreshGActionGroup()
175{173{
176 // clear the action group for the refresh174 // clear the action groups for the refresh
177 ClearActionGroup();175 ClearActionGroups();
178176
179 m_action_group =177 for( auto const& action_path_it : m_action_paths.toStdMap() )
180 std::make_shared< QtGActionGroup > (178 {
181 G_ACTION_GROUP( g_dbus_action_group_get( m_connection, m_service.c_str(), m_actions_path.c_str() ) ) );179 QString action_path = action_path_it.second.path();
182180 m_action_groups.push_back(
183 connect( m_action_group.get(), SIGNAL( ActionAdded( QString ) ), &m_parent,181 std::make_shared< QtGActionGroup > ( action_path_it.first,
184 SIGNAL( ActionAdded( QString ) ) );182 G_ACTION_GROUP( g_dbus_action_group_get( m_connection, m_service.c_str(), action_path.toUtf8().constData() ) ) ) );
185 connect( m_action_group.get(), SIGNAL( ActionRemoved( QString ) ), &m_parent,183
186 SIGNAL( ActionRemoved( QString ) ) );184 auto action_group = m_action_groups.back();
187 connect( m_action_group.get(), SIGNAL( ActionEnabled( QString, bool ) ), &m_parent,185
188 SIGNAL( ActionEnabled( QString, bool ) ) );186 connect( action_group.get(), SIGNAL( ActionAdded( QString ) ), &m_parent,
189 connect( m_action_group.get(), SIGNAL( ActionStateChanged( QString,187 SIGNAL( ActionAdded( QString ) ) );
190 QVariant ) ), &m_parent, SIGNAL( ActionStateChanged( QString, QVariant) ) );188 connect( action_group.get(), SIGNAL( ActionRemoved( QString ) ), &m_parent,
189 SIGNAL( ActionRemoved( QString ) ) );
190 connect( action_group.get(), SIGNAL( ActionEnabled( QString, bool ) ), &m_parent,
191 SIGNAL( ActionEnabled( QString, bool ) ) );
192 connect( action_group.get(), SIGNAL( ActionStateChanged( QString,
193 QVariant ) ), &m_parent, SIGNAL( ActionStateChanged( QString, QVariant) ) );
194 }
191195
192 LinkMenuActions();196 LinkMenuActions();
193}197}
194198
=== modified file 'libqtgmenu/internal/QtGMenuImporterPrivate.h'
--- libqtgmenu/internal/QtGMenuImporterPrivate.h 2013-12-24 10:02:26 +0000
+++ libqtgmenu/internal/QtGMenuImporterPrivate.h 2014-03-14 14:09:41 +0000
@@ -39,12 +39,12 @@
39Q_OBJECT39Q_OBJECT
4040
41public:41public:
42 QtGMenuImporterPrivate( const QString& service, const QString& menu_path,42 QtGMenuImporterPrivate( const QString& service, const QDBusObjectPath& menu_path,
43 const QString& actions_path, QtGMenuImporter& parent );43 const QMap<QString, QDBusObjectPath>& action_paths, QtGMenuImporter& parent );
44 virtual ~QtGMenuImporterPrivate();44 virtual ~QtGMenuImporterPrivate();
4545
46 GMenuModel* GetGMenuModel();46 GMenuModel* GetGMenuModel();
47 GActionGroup* GetGActionGroup();47 GActionGroup* GetGActionGroup( int index = 0);
4848
49 std::shared_ptr< QMenu > GetQMenu();49 std::shared_ptr< QMenu > GetQMenu();
5050
@@ -52,7 +52,7 @@
5252
53private:53private:
54 void ClearMenuModel();54 void ClearMenuModel();
55 void ClearActionGroup();55 void ClearActionGroups();
5656
57 void LinkMenuActions();57 void LinkMenuActions();
5858
@@ -70,11 +70,11 @@
7070
71 GDBusConnection* m_connection;71 GDBusConnection* m_connection;
72 std::string m_service;72 std::string m_service;
73 std::string m_menu_path;73 QDBusObjectPath m_menu_path;
74 std::string m_actions_path;74 QMap<QString, QDBusObjectPath> m_action_paths;
7575
76 std::shared_ptr< QtGMenuModel > m_menu_model = nullptr;76 std::shared_ptr< QtGMenuModel > m_menu_model = nullptr;
77 std::shared_ptr< QtGActionGroup > m_action_group = nullptr;77 std::vector< std::shared_ptr< QtGActionGroup > > m_action_groups;
7878
79 bool m_menu_actions_linked = false;79 bool m_menu_actions_linked = false;
80};80};
8181
=== modified file 'libqtgmenu/internal/QtGMenuModel.cpp'
--- libqtgmenu/internal/QtGMenuModel.cpp 2014-02-18 12:23:33 +0000
+++ libqtgmenu/internal/QtGMenuModel.cpp 2014-03-14 14:09:41 +0000
@@ -26,13 +26,11 @@
26{26{
27}27}
2828
29QtGMenuModel::QtGMenuModel( GMenuModel* model, const QString& bus_name, const QString& menu_path,29QtGMenuModel::QtGMenuModel( GMenuModel* model, const QString& bus_name, const QString& menu_path )
30 const QString& actions_path )
31 : QtGMenuModel( model, LinkType::Root, nullptr, 0 )30 : QtGMenuModel( model, LinkType::Root, nullptr, 0 )
32{31{
33 m_bus_name = bus_name;32 m_bus_name = bus_name;
34 m_menu_path = menu_path;33 m_menu_path = menu_path;
35 m_actions_path = actions_path;
36}34}
3735
38QtGMenuModel::QtGMenuModel( GMenuModel* model, LinkType link_type, QtGMenuModel* parent, int index )36QtGMenuModel::QtGMenuModel( GMenuModel* model, LinkType link_type, QtGMenuModel* parent, int index )
@@ -48,7 +46,6 @@
4846
49 m_bus_name = m_parent->m_bus_name;47 m_bus_name = m_parent->m_bus_name;
50 m_menu_path = m_parent->m_menu_path;48 m_menu_path = m_parent->m_menu_path;
51 m_actions_path = m_parent->m_actions_path;
5249
53 gchar* label = NULL;50 gchar* label = NULL;
54 if( g_menu_model_get_item_attribute( m_parent->m_model, index,51 if( g_menu_model_get_item_attribute( m_parent->m_model, index,
@@ -87,7 +84,6 @@
87 // dbus paths84 // dbus paths
88 m_ext_menu->menuAction()->setProperty( c_property_busName, m_bus_name );85 m_ext_menu->menuAction()->setProperty( c_property_busName, m_bus_name );
89 m_ext_menu->menuAction()->setProperty( c_property_menuPath, m_menu_path );86 m_ext_menu->menuAction()->setProperty( c_property_menuPath, m_menu_path );
90 m_ext_menu->menuAction()->setProperty( c_property_actionsPath, m_actions_path );
91 }87 }
92 }88 }
9389
@@ -360,9 +356,6 @@
360 QString qaction_name = QString::fromUtf8( action_name );356 QString qaction_name = QString::fromUtf8( action_name );
361 g_free( action_name );357 g_free( action_name );
362358
363 int name_length = qaction_name.size() - qaction_name.indexOf( '.' ) - 1;
364 qaction_name = qaction_name.right( name_length );
365
366 action->setProperty( c_property_actionName, qaction_name );359 action->setProperty( c_property_actionName, qaction_name );
367 }360 }
368361
@@ -372,7 +365,6 @@
372 // dbus paths365 // dbus paths
373 action->setProperty( c_property_busName, m_bus_name );366 action->setProperty( c_property_busName, m_bus_name );
374 action->setProperty( c_property_menuPath, m_menu_path );367 action->setProperty( c_property_menuPath, m_menu_path );
375 action->setProperty( c_property_actionsPath, m_actions_path );
376368
377 // action icon369 // action icon
378 GVariant* icon = g_menu_model_get_item_attribute_value( m_model, index, G_MENU_ATTRIBUTE_ICON,370 GVariant* icon = g_menu_model_get_item_attribute_value( m_model, index, G_MENU_ATTRIBUTE_ICON,
379371
=== modified file 'libqtgmenu/internal/QtGMenuModel.h'
--- libqtgmenu/internal/QtGMenuModel.h 2014-02-18 11:13:27 +0000
+++ libqtgmenu/internal/QtGMenuModel.h 2014-03-14 14:09:41 +0000
@@ -43,8 +43,7 @@
43 };43 };
4444
45 explicit QtGMenuModel( GMenuModel* model );45 explicit QtGMenuModel( GMenuModel* model );
46 QtGMenuModel( GMenuModel* model, const QString& bus_name, const QString& menu_path,46 QtGMenuModel( GMenuModel* model, const QString& bus_name, const QString& menu_path );
47 const QString& actions_path );
48 virtual ~QtGMenuModel();47 virtual ~QtGMenuModel();
4948
50 GMenuModel* Model() const;49 GMenuModel* Model() const;
@@ -61,7 +60,6 @@
61 constexpr static const char* c_property_isParameterized = "isParameterized";60 constexpr static const char* c_property_isParameterized = "isParameterized";
62 constexpr static const char* c_property_busName = "busName";61 constexpr static const char* c_property_busName = "busName";
63 constexpr static const char* c_property_menuPath = "menuPath";62 constexpr static const char* c_property_menuPath = "menuPath";
64 constexpr static const char* c_property_actionsPath = "actionsPath";
65 constexpr static const char* c_property_keywords = "keywords";63 constexpr static const char* c_property_keywords = "keywords";
66 constexpr static const char* c_property_hud_toolbar_item = "hud-toolbar-item";64 constexpr static const char* c_property_hud_toolbar_item = "hud-toolbar-item";
6765
@@ -115,7 +113,6 @@
115113
116 QString m_bus_name;114 QString m_bus_name;
117 QString m_menu_path;115 QString m_menu_path;
118 QString m_actions_path;
119116
120 std::map< QString, QAction* > m_actions;117 std::map< QString, QAction* > m_actions;
121};118};
122119
=== modified file 'service/Collector.h'
--- service/Collector.h 2013-12-17 16:37:55 +0000
+++ service/Collector.h 2014-03-14 14:09:41 +0000
@@ -69,7 +69,7 @@
6969
70 virtual bool isValid() const = 0;70 virtual bool isValid() const = 0;
7171
72 virtual CollectorToken::Ptr activate() = 0;72 virtual QList<CollectorToken::Ptr> activate() = 0;
7373
74protected:74protected:
75 virtual void deactivate() = 0;75 virtual void deactivate() = 0;
7676
=== modified file 'service/DBusMenuCollector.cpp'
--- service/DBusMenuCollector.cpp 2014-03-14 14:09:41 +0000
+++ service/DBusMenuCollector.cpp 2014-03-14 14:09:41 +0000
@@ -128,18 +128,18 @@
128 }128 }
129}129}
130130
131CollectorToken::Ptr DBusMenuCollector::activate() {131QList<CollectorToken::Ptr> DBusMenuCollector::activate() {
132 CollectorToken::Ptr collectorToken(m_collectorToken);132 CollectorToken::Ptr collectorToken(m_collectorToken);
133133
134 if(m_menuImporter.isNull()) {134 if(m_menuImporter.isNull()) {
135 return CollectorToken::Ptr();135 return QList<CollectorToken::Ptr>();
136 }136 }
137137
138 if (collectorToken.isNull()) {138 if (collectorToken.isNull()) {
139 openMenu(m_menuImporter->menu());139 openMenu(m_menuImporter->menu());
140140
141 if(m_menuImporter.isNull()) {141 if(m_menuImporter.isNull()) {
142 return CollectorToken::Ptr();142 return QList<CollectorToken::Ptr>();
143 }143 }
144144
145 collectorToken.reset(145 collectorToken.reset(
@@ -147,7 +147,7 @@
147 m_collectorToken = collectorToken;147 m_collectorToken = collectorToken;
148 }148 }
149149
150 return collectorToken;150 return QList<CollectorToken::Ptr>() << collectorToken;
151}151}
152152
153void DBusMenuCollector::deactivate() {153void DBusMenuCollector::deactivate() {
154154
=== modified file 'service/DBusMenuCollector.h'
--- service/DBusMenuCollector.h 2014-02-17 16:27:22 +0000
+++ service/DBusMenuCollector.h 2014-03-14 14:09:41 +0000
@@ -47,7 +47,7 @@
4747
48 virtual bool isValid() const override;48 virtual bool isValid() const override;
4949
50 virtual CollectorToken::Ptr activate() override;50 virtual QList<CollectorToken::Ptr> activate() override;
5151
52protected Q_SLOTS:52protected Q_SLOTS:
53 void WindowRegistered(uint windowId, const QString &service,53 void WindowRegistered(uint windowId, const QString &service,
5454
=== modified file 'service/Factory.cpp'
--- service/Factory.cpp 2014-03-14 14:09:41 +0000
+++ service/Factory.cpp 2014-03-14 14:09:41 +0000
@@ -167,8 +167,9 @@
167}167}
168168
169Collector::Ptr Factory::newGMenuCollector(const QString &name,169Collector::Ptr Factory::newGMenuCollector(const QString &name,
170 const QDBusObjectPath &actionPath, const QDBusObjectPath &menuPath) {170 const QMap<QString, QDBusObjectPath> &actions,
171 return Collector::Ptr(new GMenuCollector(name, actionPath, menuPath));171 const QDBusObjectPath &menuPath) {
172 return Collector::Ptr(new GMenuCollector(name, actions, menuPath));
172}173}
173174
174Collector::Ptr Factory::newGMenuWindowCollector(unsigned int windowId,175Collector::Ptr Factory::newGMenuWindowCollector(unsigned int windowId,
175176
=== modified file 'service/Factory.h'
--- service/Factory.h 2014-03-14 14:09:41 +0000
+++ service/Factory.h 2014-03-14 14:09:41 +0000
@@ -87,7 +87,8 @@
87 const QString &applicationId);87 const QString &applicationId);
8888
89 virtual Collector::Ptr newGMenuCollector(const QString &name,89 virtual Collector::Ptr newGMenuCollector(const QString &name,
90 const QDBusObjectPath &actionPath, const QDBusObjectPath &menuPath);90 const QMap<QString, QDBusObjectPath> &actions,
91 const QDBusObjectPath &menuPath);
9192
92 virtual Collector::Ptr newGMenuWindowCollector(unsigned int windowId,93 virtual Collector::Ptr newGMenuWindowCollector(unsigned int windowId,
93 const QString &applicationId);94 const QString &applicationId);
9495
=== modified file 'service/GMenuCollector.cpp'
--- service/GMenuCollector.cpp 2013-12-24 10:02:26 +0000
+++ service/GMenuCollector.cpp 2014-03-14 14:09:41 +0000
@@ -28,12 +28,11 @@
28using namespace qtgmenu;28using namespace qtgmenu;
2929
30GMenuCollector::GMenuCollector(const QString &name,30GMenuCollector::GMenuCollector(const QString &name,
31 const QDBusObjectPath &actionPath, const QDBusObjectPath &menuPath) :31 const QMap<QString, QDBusObjectPath> &actions,
32 m_name(name), m_actionPath(actionPath), m_menuPath(menuPath) {32 const QDBusObjectPath &menuPath) :
33 m_name(name), m_actions(actions), m_menuPath(menuPath) {
3334
34 m_importer.reset(35 m_importer.reset(new QtGMenuImporter(m_name, m_menuPath, actions));
35 new QtGMenuImporter(m_name, m_menuPath.path(),
36 m_actionPath.path()));
3736
38 connect(m_importer.data(), SIGNAL(MenuItemsChanged()), this,37 connect(m_importer.data(), SIGNAL(MenuItemsChanged()), this,
39 SLOT(menuItemsChanged()));38 SLOT(menuItemsChanged()));
@@ -46,7 +45,7 @@
46 return !m_menuPath.path().isEmpty();45 return !m_menuPath.path().isEmpty();
47}46}
4847
49CollectorToken::Ptr GMenuCollector::activate() {48QList<CollectorToken::Ptr> GMenuCollector::activate() {
50 CollectorToken::Ptr collectorToken(m_collectorToken);49 CollectorToken::Ptr collectorToken(m_collectorToken);
5150
52 std::shared_ptr<QMenu> menu(m_importer->GetQMenu());51 std::shared_ptr<QMenu> menu(m_importer->GetQMenu());
@@ -58,7 +57,7 @@
58 m_collectorToken = collectorToken;57 m_collectorToken = collectorToken;
59 }58 }
6059
61 return collectorToken;60 return QList<CollectorToken::Ptr>() << collectorToken;
62}61}
6362
64void GMenuCollector::deactivate() {63void GMenuCollector::deactivate() {
6564
=== modified file 'service/GMenuCollector.h'
--- service/GMenuCollector.h 2013-12-24 10:02:26 +0000
+++ service/GMenuCollector.h 2014-03-14 14:09:41 +0000
@@ -39,14 +39,15 @@
39public:39public:
40 typedef std::shared_ptr<GMenuCollector> Ptr;40 typedef std::shared_ptr<GMenuCollector> Ptr;
4141
42 GMenuCollector(const QString &name, const QDBusObjectPath &actionPath,42 GMenuCollector(const QString &name,
43 const QMap<QString, QDBusObjectPath> &actions,
43 const QDBusObjectPath &menuPath);44 const QDBusObjectPath &menuPath);
4445
45 virtual ~GMenuCollector();46 virtual ~GMenuCollector();
4647
47 virtual bool isValid() const override;48 virtual bool isValid() const override;
4849
49 virtual CollectorToken::Ptr activate() override;50 virtual QList<CollectorToken::Ptr> activate() override;
5051
51protected Q_SLOTS:52protected Q_SLOTS:
52 void menuItemsChanged();53 void menuItemsChanged();
@@ -58,7 +59,7 @@
5859
59 QString m_name;60 QString m_name;
6061
61 QDBusObjectPath m_actionPath;62 QMap<QString, QDBusObjectPath> m_actions;
6263
63 QDBusObjectPath m_menuPath;64 QDBusObjectPath m_menuPath;
6465
6566
=== modified file 'service/GMenuWindowCollector.cpp'
--- service/GMenuWindowCollector.cpp 2013-11-27 15:04:13 +0000
+++ service/GMenuWindowCollector.cpp 2014-03-14 14:09:41 +0000
@@ -62,35 +62,53 @@
62 return;62 return;
63 }63 }
6464
65 QSet<QDBusObjectPath> menus;
66 QMap<QString, QDBusObjectPath> actions;
67
65 if (!windowProperties.at(1).isEmpty()) {68 if (!windowProperties.at(1).isEmpty()) {
66 m_appmenuPath = QDBusObjectPath(windowProperties.at(1));69 // _GTK_APP_MENU_OBJECT_PATH -> menu
70 menus << QDBusObjectPath(windowProperties.at(1));
67 }71 }
68 if (!windowProperties.at(2).isEmpty()) {72 if (!windowProperties.at(2).isEmpty()) {
69 m_menubarPath = QDBusObjectPath(windowProperties.at(2));73 // _GTK_MENUBAR_OBJECT_PATH -> menu
74 menus << QDBusObjectPath(windowProperties.at(2));
70 }75 }
71 if (!windowProperties.at(3).isEmpty()) {76 if (!windowProperties.at(3).isEmpty()) {
72 m_applicationPath = QDBusObjectPath(windowProperties.at(3));77 // _GTK_APPLICATION_OBJECT_PATH -> actions with prefix "app"
78 actions["app"] = QDBusObjectPath(windowProperties.at(3));
73 }79 }
74 if (!windowProperties.at(4).isEmpty()) {80 if (!windowProperties.at(4).isEmpty()) {
75 m_windowPath = QDBusObjectPath(windowProperties.at(4));81 // _GTK_WINDOW_OBJECT_PATH -> actions with prefix "win"
82 actions["win"] = QDBusObjectPath(windowProperties.at(4));
76 }83 }
77 if (!windowProperties.at(5).isEmpty()) {84 if (!windowProperties.at(5).isEmpty()) {
78 m_unityPath = QDBusObjectPath(windowProperties.at(5));85 // _UNITY_OBJECT_PATH -> menu + action with prefix "unity"
86 menus << QDBusObjectPath(windowProperties.at(5));
87 actions["unity"] = QDBusObjectPath(windowProperties.at(5));
79 }88 }
8089
81 m_menubarCollector = factory.newGMenuCollector(m_busName, m_menubarPath,90 if (!actions.isEmpty()) {
82 m_menubarPath);91 for (const QDBusObjectPath &menu : menus) {
92 m_collectors << factory.newGMenuCollector(m_busName, actions, menu);
93 }
94 }
83}95}
8496
85GMenuWindowCollector::~GMenuWindowCollector() {97GMenuWindowCollector::~GMenuWindowCollector() {
86}98}
8799
88bool GMenuWindowCollector::isValid() const {100bool GMenuWindowCollector::isValid() const {
89 return !m_menubarPath.path().isEmpty();101 return !m_collectors.isEmpty();
90}102}
91103
92CollectorToken::Ptr GMenuWindowCollector::activate() {104QList<CollectorToken::Ptr> GMenuWindowCollector::activate() {
93 return m_menubarCollector->activate();105 QList<CollectorToken::Ptr> tokens;
106
107 for (Collector::Ptr collector : m_collectors) {
108 tokens.append(collector->activate());
109 }
110
111 return tokens;
94}112}
95113
96void GMenuWindowCollector::deactivate() {114void GMenuWindowCollector::deactivate() {
97115
=== modified file 'service/GMenuWindowCollector.h'
--- service/GMenuWindowCollector.h 2013-12-17 16:37:55 +0000
+++ service/GMenuWindowCollector.h 2014-03-14 14:09:41 +0000
@@ -47,30 +47,16 @@
4747
48 virtual bool isValid() const override;48 virtual bool isValid() const override;
4949
50 virtual CollectorToken::Ptr activate() override;50 virtual QList<CollectorToken::Ptr> activate() override;
5151
52protected:52protected:
53 virtual void deactivate();53 virtual void deactivate();
5454
55 QSharedPointer<ComCanonicalUnityWindowStackInterface> m_windowStack;55 QSharedPointer<ComCanonicalUnityWindowStackInterface> m_windowStack;
5656
57 QWeakPointer<CollectorToken> m_collectorToken;
58
59 QString m_busName;57 QString m_busName;
6058
61 QDBusObjectPath m_appmenuPath;59 QList<Collector::Ptr> m_collectors;
62
63 QDBusObjectPath m_menubarPath;
64
65 QDBusObjectPath m_applicationPath;
66
67 QDBusObjectPath m_windowPath;
68
69 QDBusObjectPath m_unityPath;
70
71 Collector::Ptr m_menubarCollector;
72
73 std::shared_ptr<QMenu> m_menubar;
74};60};
7561
76}62}
7763
=== modified file 'service/WindowContextImpl.cpp'
--- service/WindowContextImpl.cpp 2013-11-27 22:45:10 +0000
+++ service/WindowContextImpl.cpp 2014-03-14 14:09:41 +0000
@@ -46,8 +46,11 @@
46void WindowContextImpl::addMenu(const QString &context,46void WindowContextImpl::addMenu(const QString &context,
47 const MenuDefinition &menuDefinition) {47 const MenuDefinition &menuDefinition) {
4848
49 QMap<QString, QDBusObjectPath> actions;
50 actions[menuDefinition.actionPrefix] = menuDefinition.actionPath;
51
49 m_collectors[context] = m_factory.newGMenuCollector(menuDefinition.name,52 m_collectors[context] = m_factory.newGMenuCollector(menuDefinition.name,
50 menuDefinition.actionPath, menuDefinition.menuPath);53 actions, menuDefinition.menuPath);
51}54}
5255
53Collector::Ptr WindowContextImpl::activeCollector() {56Collector::Ptr WindowContextImpl::activeCollector() {
5457
=== modified file 'service/WindowImpl.cpp'
--- service/WindowImpl.cpp 2014-03-14 14:09:41 +0000
+++ service/WindowImpl.cpp 2014-03-14 14:09:41 +0000
@@ -95,10 +95,7 @@
95 QList<CollectorToken::Ptr> tokens;95 QList<CollectorToken::Ptr> tokens;
96 for (Collector::Ptr collector : collectors) {96 for (Collector::Ptr collector : collectors) {
97 if (collector && collector->isValid()) {97 if (collector && collector->isValid()) {
98 CollectorToken::Ptr token(collector->activate());98 tokens.append(collector->activate());
99 if (token) {
100 tokens << token;
101 }
102 }99 }
103 }100 }
104101
105102
=== modified file 'tests/integration/TestHud.cpp'
--- tests/integration/TestHud.cpp 2014-03-14 14:09:41 +0000
+++ tests/integration/TestHud.cpp 2014-03-14 14:09:41 +0000
@@ -239,7 +239,7 @@
239 " ret.append('/menu')\n"239 " ret.append('/menu')\n"
240 " ret.append('')\n"240 " ret.append('')\n"
241 " ret.append('')\n"241 " ret.append('')\n"
242 " ret.append('')\n"242 " ret.append('/menu')\n"
243 "else:\n"243 "else:\n"
244 " for arg in args[2]:\n"244 " for arg in args[2]:\n"
245 " ret.append('')").waitForFinished();245 " ret.append('')").waitForFinished();
@@ -339,7 +339,7 @@
339 " ret.append('/menu')\n"339 " ret.append('/menu')\n"
340 " ret.append('')\n"340 " ret.append('')\n"
341 " ret.append('')\n"341 " ret.append('')\n"
342 " ret.append('')\n"342 " ret.append('/menu')\n"
343 "else:\n"343 "else:\n"
344 " for arg in args[2]:\n"344 " for arg in args[2]:\n"
345 " ret.append('')").waitForFinished();345 " ret.append('')").waitForFinished();
346346
=== modified file 'tests/testapps/qtgmenu/MainWindow.cpp'
--- tests/testapps/qtgmenu/MainWindow.cpp 2013-11-23 11:42:04 +0000
+++ tests/testapps/qtgmenu/MainWindow.cpp 2014-03-14 14:09:41 +0000
@@ -2,8 +2,8 @@
22
3#include <QtWidgets>3#include <QtWidgets>
44
5MainWindow::MainWindow(const QString &name, const QString &actionPath, const QString &menuPath)5MainWindow::MainWindow(const QString &name, const QDBusObjectPath &actionPath, const QDBusObjectPath &menuPath)
6 : m_menu_importer( name, menuPath, actionPath )6 : m_menu_importer( name, menuPath, "", actionPath )
7{7{
8 m_refresh_connection = connect( &m_menu_importer, SIGNAL( MenuItemsChanged() ), this,8 m_refresh_connection = connect( &m_menu_importer, SIGNAL( MenuItemsChanged() ), this,
9 SLOT( RefreshMenus() ) );9 SLOT( RefreshMenus() ) );
1010
=== modified file 'tests/testapps/qtgmenu/MainWindow.h'
--- tests/testapps/qtgmenu/MainWindow.h 2013-11-23 11:42:04 +0000
+++ tests/testapps/qtgmenu/MainWindow.h 2014-03-14 14:09:41 +0000
@@ -10,7 +10,7 @@
10Q_OBJECT10Q_OBJECT
1111
12public:12public:
13 MainWindow(const QString &name, const QString &actionPath, const QString &menuPath);13 MainWindow(const QString &name, const QDBusObjectPath &actionPath, const QDBusObjectPath &menuPath);
1414
15 ~MainWindow();15 ~MainWindow();
1616
1717
=== modified file 'tests/testapps/qtgmenu/main.cpp'
--- tests/testapps/qtgmenu/main.cpp 2013-11-23 11:42:04 +0000
+++ tests/testapps/qtgmenu/main.cpp 2014-03-14 14:09:41 +0000
@@ -29,7 +29,7 @@
29 return 1;29 return 1;
30 }30 }
3131
32 MainWindow mainWindow(argv[1], argv[2], argv[3]);32 MainWindow mainWindow(argv[1], QDBusObjectPath( argv[2] ), QDBusObjectPath( argv[3] ) );
33 mainWindow.show();33 mainWindow.show();
3434
35 return application.exec();35 return application.exec();
3636
=== modified file 'tests/unit/qtgmenu/TestQtGMenu.cpp'
--- tests/unit/qtgmenu/TestQtGMenu.cpp 2013-12-24 10:02:26 +0000
+++ tests/unit/qtgmenu/TestQtGMenu.cpp 2014-03-14 14:09:41 +0000
@@ -40,7 +40,7 @@
4040
41protected:41protected:
42 TestQtGMenu()42 TestQtGMenu()
43 : m_importer( c_service, c_path ),43 : m_importer( c_service, QDBusObjectPath( c_path ), "", QDBusObjectPath( c_path ) ),
4444
45 m_items_changed_spy( &m_importer, SIGNAL( MenuItemsChanged() ) ),45 m_items_changed_spy( &m_importer, SIGNAL( MenuItemsChanged() ) ),
4646
4747
=== modified file 'tests/unit/service/Mocks.h'
--- tests/unit/service/Mocks.h 2014-03-14 14:09:41 +0000
+++ tests/unit/service/Mocks.h 2014-03-14 14:09:41 +0000
@@ -49,7 +49,8 @@
49 MOCK_METHOD2(newGMenuWindowCollector, Collector::Ptr(unsigned int, const QString &));49 MOCK_METHOD2(newGMenuWindowCollector, Collector::Ptr(unsigned int, const QString &));
5050
51 MOCK_METHOD3(newGMenuCollector, Collector::Ptr(const QString &,51 MOCK_METHOD3(newGMenuCollector, Collector::Ptr(const QString &,
52 const QDBusObjectPath &, const QDBusObjectPath &));52 const QMap<QString, QDBusObjectPath> &,
53 const QDBusObjectPath &));
53};54};
5455
55class MockHudService: public HudService {56class MockHudService: public HudService {
@@ -163,7 +164,7 @@
163public:164public:
164 MOCK_CONST_METHOD0(isValid, bool());165 MOCK_CONST_METHOD0(isValid, bool());
165166
166 MOCK_METHOD0(activate, CollectorToken::Ptr());167 MOCK_METHOD0(activate, QList<CollectorToken::Ptr>());
167168
168 MOCK_METHOD2(search, void(const QString &, QList<Result> &));169 MOCK_METHOD2(search, void(const QString &, QList<Result> &));
169170
170171
=== modified file 'tests/unit/service/TestWindow.cpp'
--- tests/unit/service/TestWindow.cpp 2013-12-19 16:10:20 +0000
+++ tests/unit/service/TestWindow.cpp 2014-03-14 14:09:41 +0000
@@ -110,7 +110,7 @@
110 CollectorToken::Ptr dbusMenuCollectorToken(110 CollectorToken::Ptr dbusMenuCollectorToken(
111 new CollectorToken(dbusMenuCollector, &dbusMenuCollectorMenu));111 new CollectorToken(dbusMenuCollector, &dbusMenuCollectorMenu));
112 EXPECT_CALL(*dbusMenuCollector, activate()).Times(1).WillOnce(112 EXPECT_CALL(*dbusMenuCollector, activate()).Times(1).WillOnce(
113 Return(dbusMenuCollectorToken));113 Return(QList<CollectorToken::Ptr>() << dbusMenuCollectorToken));
114114
115 WindowToken::Ptr token(window->activate());115 WindowToken::Ptr token(window->activate());
116 EXPECT_EQ(QList<CollectorToken::Ptr>() << dbusMenuCollectorToken,116 EXPECT_EQ(QList<CollectorToken::Ptr>() << dbusMenuCollectorToken,
@@ -129,7 +129,7 @@
129 new CollectorToken(gmenuWindowCollector,129 new CollectorToken(gmenuWindowCollector,
130 &gmenuWindowCollectorMenu));130 &gmenuWindowCollectorMenu));
131 EXPECT_CALL(*gmenuWindowCollector, activate()).Times(1).WillOnce(131 EXPECT_CALL(*gmenuWindowCollector, activate()).Times(1).WillOnce(
132 Return(gmenuWindowCollectorToken));132 Return(QList<CollectorToken::Ptr>() << gmenuWindowCollectorToken));
133133
134 WindowToken::Ptr token(window->activate());134 WindowToken::Ptr token(window->activate());
135 EXPECT_EQ(QList<CollectorToken::Ptr>() << gmenuWindowCollectorToken,135 EXPECT_EQ(QList<CollectorToken::Ptr>() << gmenuWindowCollectorToken,
@@ -147,7 +147,7 @@
147 CollectorToken::Ptr allWindowsCollectorToken(147 CollectorToken::Ptr allWindowsCollectorToken(
148 new CollectorToken(allWindowsCollector, &allWindowsCollectorMenu));148 new CollectorToken(allWindowsCollector, &allWindowsCollectorMenu));
149 EXPECT_CALL(*allWindowsCollector, activate()).Times(1).WillOnce(149 EXPECT_CALL(*allWindowsCollector, activate()).Times(1).WillOnce(
150 Return(allWindowsCollectorToken));150 Return(QList<CollectorToken::Ptr>() << allWindowsCollectorToken));
151151
152 ON_CALL(*allWindowsContext, activeCollector()).WillByDefault(152 ON_CALL(*allWindowsContext, activeCollector()).WillByDefault(
153 Return(allWindowsCollector));153 Return(allWindowsCollector));
@@ -169,7 +169,10 @@
169 definition.actionPrefix = "hud";169 definition.actionPrefix = "hud";
170 definition.menuPath = QDBusObjectPath("/menu/path");170 definition.menuPath = QDBusObjectPath("/menu/path");
171171
172 EXPECT_CALL(factory, newGMenuCollector(definition.name, definition.actionPath, definition.menuPath)).Times(172 QMap<QString, QDBusObjectPath> actions;
173 actions[definition.actionPrefix] = definition.actionPath;
174
175 EXPECT_CALL(factory, newGMenuCollector(definition.name, actions, definition.menuPath)).Times(
173 1).WillOnce(Return(windowCollector));176 1).WillOnce(Return(windowCollector));
174177
175 window->addMenu("context_1", definition);178 window->addMenu("context_1", definition);
@@ -179,7 +182,7 @@
179 CollectorToken::Ptr windowCollectorToken(182 CollectorToken::Ptr windowCollectorToken(
180 new CollectorToken(windowCollector, &windowCollectorMenu));183 new CollectorToken(windowCollector, &windowCollectorMenu));
181 EXPECT_CALL(*windowCollector, activate()).Times(1).WillOnce(184 EXPECT_CALL(*windowCollector, activate()).Times(1).WillOnce(
182 Return(windowCollectorToken));185 Return(QList<CollectorToken::Ptr>() << windowCollectorToken));
183186
184 WindowToken::Ptr token(window->activate());187 WindowToken::Ptr token(window->activate());
185 EXPECT_EQ(QList<CollectorToken::Ptr>() << windowCollectorToken,188 EXPECT_EQ(QList<CollectorToken::Ptr>() << windowCollectorToken,
@@ -196,19 +199,19 @@
196 new CollectorToken(gmenuWindowCollector,199 new CollectorToken(gmenuWindowCollector,
197 &gmenuWindowCollectorMenu));200 &gmenuWindowCollectorMenu));
198 EXPECT_CALL(*gmenuWindowCollector, activate()).Times(1).WillOnce(201 EXPECT_CALL(*gmenuWindowCollector, activate()).Times(1).WillOnce(
199 Return(gmenuWindowCollectorToken));202 Return(QList<CollectorToken::Ptr>() << gmenuWindowCollectorToken));
200203
201 QMenu dbusMenuCollectorMenu;204 QMenu dbusMenuCollectorMenu;
202 CollectorToken::Ptr dbusMenuCollectorToken(205 CollectorToken::Ptr dbusMenuCollectorToken(
203 new CollectorToken(dbusMenuCollector, &dbusMenuCollectorMenu));206 new CollectorToken(dbusMenuCollector, &dbusMenuCollectorMenu));
204 EXPECT_CALL(*dbusMenuCollector, activate()).Times(1).WillOnce(207 EXPECT_CALL(*dbusMenuCollector, activate()).Times(1).WillOnce(
205 Return(dbusMenuCollectorToken));208 Return(QList<CollectorToken::Ptr>() << dbusMenuCollectorToken));
206209
207 QMenu allWindowsCollectorMenu;210 QMenu allWindowsCollectorMenu;
208 CollectorToken::Ptr allWindowsCollectorToken(211 CollectorToken::Ptr allWindowsCollectorToken(
209 new CollectorToken(allWindowsCollector, &allWindowsCollectorMenu));212 new CollectorToken(allWindowsCollector, &allWindowsCollectorMenu));
210 EXPECT_CALL(*allWindowsCollector, activate()).Times(1).WillOnce(213 EXPECT_CALL(*allWindowsCollector, activate()).Times(1).WillOnce(
211 Return(allWindowsCollectorToken));214 Return(QList<CollectorToken::Ptr>() << allWindowsCollectorToken));
212 ON_CALL(*allWindowsContext, activeCollector()).WillByDefault(215 ON_CALL(*allWindowsContext, activeCollector()).WillByDefault(
213 Return(allWindowsCollector));216 Return(allWindowsCollector));
214217
@@ -224,13 +227,13 @@
224 new CollectorToken(gmenuWindowCollector,227 new CollectorToken(gmenuWindowCollector,
225 &gmenuWindowCollectorMenuChanged));228 &gmenuWindowCollectorMenuChanged));
226 EXPECT_CALL(*gmenuWindowCollector, activate()).Times(1).WillOnce(229 EXPECT_CALL(*gmenuWindowCollector, activate()).Times(1).WillOnce(
227 Return(gmenuWindowCollectorTokenChanged));230 Return(QList<CollectorToken::Ptr>() << gmenuWindowCollectorTokenChanged));
228231
229 // Re-prime the other collectors232 // Re-prime the other collectors
230 EXPECT_CALL(*dbusMenuCollector, activate()).Times(1).WillOnce(233 EXPECT_CALL(*dbusMenuCollector, activate()).Times(1).WillOnce(
231 Return(dbusMenuCollectorToken));234 Return(QList<CollectorToken::Ptr>() << dbusMenuCollectorToken));
232 EXPECT_CALL(*allWindowsCollector, activate()).Times(1).WillOnce(235 EXPECT_CALL(*allWindowsCollector, activate()).Times(1).WillOnce(
233 Return(allWindowsCollectorToken));236 Return(QList<CollectorToken::Ptr>() << allWindowsCollectorToken));
234237
235 WindowToken::Ptr tokenChanged(window->activate());238 WindowToken::Ptr tokenChanged(window->activate());
236 EXPECT_NE(token, tokenChanged);239 EXPECT_NE(token, tokenChanged);
@@ -249,7 +252,10 @@
249 definition.actionPrefix = "hud";252 definition.actionPrefix = "hud";
250 definition.menuPath = QDBusObjectPath("/menu/path");253 definition.menuPath = QDBusObjectPath("/menu/path");
251254
252 EXPECT_CALL(factory, newGMenuCollector(definition.name, definition.actionPath, definition.menuPath)).Times(255 QMap<QString, QDBusObjectPath> actions;
256 actions[definition.actionPrefix] = definition.actionPath;
257
258 EXPECT_CALL(factory, newGMenuCollector(definition.name, actions, definition.menuPath)).Times(
253 1).WillOnce(Return(windowCollector));259 1).WillOnce(Return(windowCollector));
254260
255 context.addMenu("context_1", definition);261 context.addMenu("context_1", definition);

Subscribers

People subscribed via source and target branches