Merge lp:~albaguirre/qtubuntu/papi-cleanup into lp:qtubuntu

Proposed by Alberto Aguirre
Status: Needs review
Proposed branch: lp:~albaguirre/qtubuntu/papi-cleanup
Merge into: lp:qtubuntu
Prerequisite: lp:~albaguirre/qtubuntu/use-mir-rs-api
Diff against target: 2476 lines (+70/-2204) (has conflicts)
23 files modified
debian/qtubuntu-appmenutheme.install (+0/-1)
debian/rules (+0/-1)
src/src.pro (+1/-1)
src/ubuntuappmenu/com.ubuntu.MenuRegistrar.xml (+0/-83)
src/ubuntuappmenu/gmenumodelexporter.cpp (+0/-475)
src/ubuntuappmenu/gmenumodelexporter.h (+0/-100)
src/ubuntuappmenu/gmenumodelplatformmenu.cpp (+0/-518)
src/ubuntuappmenu/gmenumodelplatformmenu.h (+0/-181)
src/ubuntuappmenu/logging.h (+0/-27)
src/ubuntuappmenu/menuregistrar.cpp (+0/-137)
src/ubuntuappmenu/menuregistrar.h (+0/-59)
src/ubuntuappmenu/qtubuntuextraactionhandler.cpp (+0/-107)
src/ubuntuappmenu/qtubuntuextraactionhandler.h (+0/-40)
src/ubuntuappmenu/registry.cpp (+0/-97)
src/ubuntuappmenu/registry.h (+0/-56)
src/ubuntuappmenu/themeplugin.cpp (+0/-36)
src/ubuntuappmenu/themeplugin.h (+0/-34)
src/ubuntuappmenu/ubuntuappmenu.json (+0/-3)
src/ubuntumirclient/qmirclientintegration.cpp (+69/-99)
src/ubuntumirclient/qmirclientintegration.h (+0/-15)
src/ubuntumirclient/qmirclientplatformservices.cpp (+0/-75)
src/ubuntumirclient/qmirclientplatformservices.h (+0/-57)
src/ubuntumirclient/ubuntumirclient.pro (+0/-2)
Conflict: can't delete src/ubuntuappmenu because it is not empty.  Not deleting.
Conflict because src/ubuntuappmenu is not versioned, but has versioned children.  Versioned directory.
Contents conflict in src/ubuntuappmenu/theme.cpp
Contents conflict in src/ubuntuappmenu/theme.h
Contents conflict in src/ubuntuappmenu/ubuntuappmenu.pro
Text conflict in src/ubuntumirclient/qmirclientintegration.cpp
To merge this branch: bzr merge lp:~albaguirre/qtubuntu/papi-cleanup
Reviewer Review Type Date Requested Status
Michał Sawicz Needs Fixing
Unity8 CI Bot continuous-integration Needs Fixing
Review via email: mp+324886@code.launchpad.net

Commit message

Completely remove dependency on platform-api

Description of the change

The only real use of platform-api was for url launching. Is there something else we can do for that?

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

I suppose whatever the xcb plugin is using for URLs we can use, too (xdg-open?).

LP reports conflicts, can you please update?

review: Needs Fixing

Unmerged revisions

399. By Alberto Aguirre

Remove platform-api dependency.

398. By Alberto Aguirre

Remove ubuntuappmenu

397. By Alberto Aguirre

Cleanup #pragmas and unneeded repaints when resizing.

396. By Alberto Aguirre

Avoid using mir_window_get_parameters, it will be deprecated

395. By Alberto Aguirre

Remove mir_event_type_key and mir_event_type_motion as they are deprecated.

394. By Alberto Aguirre

Use MirRenderSurface for pixmap cursors.

Creating buffer streams directly will be deprecated in mir in the near future, instead use render surfaces.

393. By Alberto Aguirre

Update resizing now that client can drive the buffer size through mir_render_surface_set_size.

392. By Alberto Aguirre

Avoid use of deprecated mir EGL related apis.

With the new mesa update, the EGLNativeDisplayType is MirConnection and the EGLNativeWindowType is a MirRenderSurface.
Ignore deprecation warnings on use of MirRenderSurface - its "deprecated" because it'll be renamed in mir 1.0.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'debian/qtubuntu-appmenutheme.install'
2--- debian/qtubuntu-appmenutheme.install 2016-06-17 12:40:26 +0000
3+++ debian/qtubuntu-appmenutheme.install 1970-01-01 00:00:00 +0000
4@@ -1,1 +0,0 @@
5-usr/lib/*/qt5/plugins/platformthemes/*
6
7=== modified file 'debian/rules'
8--- debian/rules 2016-06-17 12:40:26 +0000
9+++ debian/rules 2017-05-31 19:29:52 +0000
10@@ -62,4 +62,3 @@
11 dh_install --sourcedir=$(TMP1_DIR) -pqtubuntu-android
12 endif
13 dh_install --sourcedir=$(TMP2_DIR) -pqtubuntu-desktop
14- dh_install --sourcedir=$(TMP2_DIR) -pqtubuntu-appmenutheme
15
16=== modified file 'src/src.pro'
17--- src/src.pro 2016-06-21 16:33:19 +0000
18+++ src/src.pro 2017-05-31 19:29:52 +0000
19@@ -1,3 +1,3 @@
20 TEMPLATE = subdirs
21
22-SUBDIRS += ubuntumirclient ubuntuappmenu
23+SUBDIRS += ubuntumirclient
24
25=== removed file 'src/ubuntuappmenu/com.ubuntu.MenuRegistrar.xml'
26--- src/ubuntuappmenu/com.ubuntu.MenuRegistrar.xml 2016-09-29 10:24:29 +0000
27+++ src/ubuntuappmenu/com.ubuntu.MenuRegistrar.xml 1970-01-01 00:00:00 +0000
28@@ -1,83 +0,0 @@
29-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
30-<node xmlns:dox="http://www.ayatana.org/dbus/dox.dtd">
31- <dox:d><![CDATA[
32- @mainpage
33-
34- An interface to register menus that are associated with a window in an application. The
35- main interface is documented here: @ref com::ubuntu::MenuRegistrar.
36-
37- The actual menus are transported using the gmenumodel protocol
38- ]]></dox:d>
39- <interface name="com.ubuntu.MenuRegistrar" xmlns:dox="http://www.ayatana.org/dbus/dox.dtd">
40- <dox:d>
41- An interface to register a menu from an application to be displayed in another
42- window. This manages that association between processes and/or Mir surface IDs and the dbus
43- address and object that provides the menus using the org.gtk.Menus interface.
44- </dox:d>
45- <method name="RegisterAppMenu">
46- <dox:d><![CDATA[
47- Associates a gmenumodel with an application
48-
49- /note this method assumes that the connection from the caller is the DBus connection
50- to use for the object. Applications that use multiple DBus connections will need to
51- ensure this method is called with the same connection that implements the object.
52- ]]></dox:d>
53- <arg name="pid" type="u" direction="in">
54- <dox:d>The process ID of the application for which the menu is associated</dox:d>
55- </arg>
56- <arg name="menuObjectPath" type="o" direction="in">
57- <dox:d>The dbus path where the gmenumodel interface for the application menu has been exported</dox:d>
58- </arg>
59- <arg name="actionObjectPath" type="o" direction="in">
60- <dox:d>The dbus path where the gactionmenu interface for the application menu actions has been exported</dox:d>
61- </arg>
62- <arg name="service" type="s" direction="in">
63- <dox:d>The dbus conection name of the client application to be registered (e.g. :1.23 or org.example.service)</dox:d>
64- </arg>
65- </method>
66- <method name="UnregisterAppMenu">
67- <dox:d>
68- A method to allow removing an application menu from the database.
69- </dox:d>
70- <arg name="pid" type="u" direction="in">
71- <dox:d>The process id of the application</dox:d>
72- </arg>
73- <arg name="menuObjectPath" type="o" direction="in">
74- <dox:d>The dbus path for the registered application menu to be unregistered</dox:d>
75- </arg>
76- </method>
77-
78- <method name="RegisterSurfaceMenu">
79- <dox:d><![CDATA[
80- Associates a gmenumodel with a surface
81-
82- /note this method assumes that the connection from the caller is the DBus connection
83- to use for the object. Applications that use multiple DBus connections will need to
84- ensure this method is called with the same connection that implements the object.
85- ]]></dox:d>
86- <arg name="surface" type="s" direction="in">
87- <dox:d>The surface ID of the surface</dox:d>
88- </arg>
89- <arg name="menuObjectPath" type="o" direction="in">
90- <dox:d>The dbus path where the gmenumodel interface for the surface menu has been exported</dox:d>
91- </arg>
92- <arg name="actionObjectPath" type="o" direction="in">
93- <dox:d>The dbus path where the gactionmenu interface for the surface menu actions has been exported</dox:d>
94- </arg>
95- <arg name="service" type="s" direction="in">
96- <dox:d>The dbus conection name of the client application to be registered (e.g. :1.23 or org.example.service)</dox:d>
97- </arg>
98- </method>
99- <method name="UnregisterSurfaceMenu">
100- <dox:d>
101- A method to allow removing a surface menu from the database.
102- </dox:d>
103- <arg name="surfaceId" type="s" direction="in">
104- <dox:d>The surface id of the surface</dox:d>
105- </arg>
106- <arg name="menuObjectPath" type="o" direction="in">
107- <dox:d>The dbus path for the registered surface menu to be unregistered</dox:d>
108- </arg>
109- </method>
110- </interface>
111-</node>
112
113=== removed file 'src/ubuntuappmenu/gmenumodelexporter.cpp'
114--- src/ubuntuappmenu/gmenumodelexporter.cpp 2017-03-27 08:23:00 +0000
115+++ src/ubuntuappmenu/gmenumodelexporter.cpp 1970-01-01 00:00:00 +0000
116@@ -1,475 +0,0 @@
117-/*
118- * Copyright (C) 2016 Canonical, Ltd.
119- *
120- * This program is free software: you can redistribute it and/or modify it under
121- * the terms of the GNU Lesser General Public License version 3, as published by
122- * the Free Software Foundation.
123- *
124- * This program is distributed in the hope that it will be useful, but WITHOUT
125- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
126- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
127- * Lesser General Public License for more details.
128- *
129- * You should have received a copy of the GNU Lesser General Public License
130- * along with this program. If not, see <http://www.gnu.org/licenses/>.
131- */
132-
133-// Local
134-#include "gmenumodelexporter.h"
135-#include "registry.h"
136-#include "logging.h"
137-#include "qtubuntuextraactionhandler.h"
138-
139-#include <QDebug>
140-#include <QTimerEvent>
141-
142-#include <functional>
143-
144-namespace {
145-
146-// Derive an action name from the label by removing spaces and Capitilizing the words.
147-// Also remove mnemonics from the label.
148-inline QString getActionString(QString label)
149-{
150- QRegExp re("\\W");
151- label = label.replace(QRegExp("(&|_)"), "");
152- QStringList parts = label.split(re, QString::SkipEmptyParts);
153-
154- QString result;
155- Q_FOREACH(const QString& part, parts) {
156- result += part[0].toUpper();
157- result += part.right(part.length()-1);
158- }
159- return result;
160-}
161-
162-static void activate_cb(GSimpleAction *action, GVariant *, gpointer user_data)
163-{
164- qCDebug(ubuntuappmenu, "Activate menu action '%s'", g_action_get_name(G_ACTION(action)));
165- auto item = static_cast<UbuntuPlatformMenuItem*>(user_data);
166- item->activated();
167-}
168-
169-static uint s_menuId = 0;
170-
171-#define MENU_OBJECT_PATH "/com/ubuntu/Menu/%1"
172-
173-} // namespace
174-
175-
176-UbuntuMenuBarExporter::UbuntuMenuBarExporter(UbuntuPlatformMenuBar * bar)
177- : UbuntuGMenuModelExporter(bar)
178-{
179- qCDebug(ubuntuappmenu, "UbuntuMenuBarExporter::UbuntuMenuBarExporter");
180-
181- connect(bar, &UbuntuPlatformMenuBar::structureChanged, this, [this]() {
182- m_structureTimer.start();
183- });
184- connect(&m_structureTimer, &QTimer::timeout, this, [this, bar]() {
185- clear();
186- Q_FOREACH(QPlatformMenu *platformMenu, bar->menus()) {
187- GMenuItem* item = createSubmenu(platformMenu, nullptr);
188- if (item) {
189- g_menu_append_item(m_gmainMenu, item);
190- g_object_unref(item);
191- }
192-
193- UbuntuPlatformMenu* gplatformMenu = static_cast<UbuntuPlatformMenu*>(platformMenu);
194- if (gplatformMenu) {
195- // Sadly we don't have a better way to propagate a enabled change in a top level menu
196- // than reseting the whole menubar
197- connect(gplatformMenu, &UbuntuPlatformMenu::enabledChanged, bar, &UbuntuPlatformMenuBar::structureChanged);
198- }
199- }
200- });
201-
202- connect(bar, &UbuntuPlatformMenuBar::ready, this, [this]() {
203- exportModels();
204- });
205-}
206-
207-UbuntuMenuBarExporter::~UbuntuMenuBarExporter()
208-{
209- qCDebug(ubuntuappmenu, "UbuntuMenuBarExporter::~UbuntuMenuBarExporter");
210-}
211-
212-UbuntuMenuExporter::UbuntuMenuExporter(UbuntuPlatformMenu *menu)
213- : UbuntuGMenuModelExporter(menu)
214-{
215- qCDebug(ubuntuappmenu, "UbuntuMenuExporter::UbuntuMenuExporter");
216-
217- connect(menu, &UbuntuPlatformMenu::structureChanged, this, [this]() {
218- m_structureTimer.start();
219- });
220- connect(&m_structureTimer, &QTimer::timeout, this, [this, menu]() {
221- clear();
222- addSubmenuItems(menu, m_gmainMenu);
223- });
224- addSubmenuItems(menu, m_gmainMenu);
225-}
226-
227-UbuntuMenuExporter::~UbuntuMenuExporter()
228-{
229- qCDebug(ubuntuappmenu, "UbuntuMenuExporter::~UbuntuMenuExporter");
230-}
231-
232-UbuntuGMenuModelExporter::UbuntuGMenuModelExporter(QObject *parent)
233- : QObject(parent)
234- , m_connection(nullptr)
235- , m_gmainMenu(g_menu_new())
236- , m_gactionGroup(g_simple_action_group_new())
237- , m_exportedModel(0)
238- , m_exportedActions(0)
239- , m_qtubuntuExtraHandler(nullptr)
240- , m_menuPath(QStringLiteral(MENU_OBJECT_PATH).arg(s_menuId++))
241-{
242- m_structureTimer.setSingleShot(true);
243- m_structureTimer.setInterval(0);
244-}
245-
246-UbuntuGMenuModelExporter::~UbuntuGMenuModelExporter()
247-{
248- unexportModels();
249- clear();
250-
251- g_object_unref(m_gmainMenu);
252- g_object_unref(m_gactionGroup);
253-}
254-
255-// Clear the menu and actions that have been created.
256-void UbuntuGMenuModelExporter::clear()
257-{
258- Q_FOREACH(const QVector<QMetaObject::Connection>& menuPropertyConnections, m_propertyConnections) {
259- Q_FOREACH(const QMetaObject::Connection& connection, menuPropertyConnections) {
260- QObject::disconnect(connection);
261- }
262- }
263- m_propertyConnections.clear();
264-
265- g_menu_remove_all(m_gmainMenu);
266-
267- Q_FOREACH(const QSet<QByteArray>& menuActions, m_actions) {
268- Q_FOREACH(const QByteArray& action, menuActions) {
269- g_action_map_remove_action(G_ACTION_MAP(m_gactionGroup), action.constData());
270- }
271- }
272- m_actions.clear();
273-
274- m_gmenusForMenus.clear();
275-}
276-
277-void UbuntuGMenuModelExporter::timerEvent(QTimerEvent *e)
278-{
279- // Find the menu, it's a very short list
280- auto it = m_reloadMenuTimers.begin();
281- for (; it != m_reloadMenuTimers.end(); ++it) {
282- if (e->timerId() == it.value())
283- break;
284- }
285-
286- if (it != m_reloadMenuTimers.end()) {
287- UbuntuPlatformMenu* gplatformMenu = it.key();
288- GMenu *menu = m_gmenusForMenus.value(gplatformMenu);
289- if (menu) {
290- Q_FOREACH(const QMetaObject::Connection& connection, m_propertyConnections[menu]) {
291- QObject::disconnect(connection);
292- }
293- m_propertyConnections.remove(menu);
294- Q_FOREACH(const QByteArray& action, m_actions[menu]) {
295- g_action_map_remove_action(G_ACTION_MAP(m_gactionGroup), action.constData());
296- }
297- m_actions.remove(menu);
298- g_menu_remove_all(menu);
299- addSubmenuItems(gplatformMenu, menu);
300- } else {
301- qWarning() << "Got an update timer for a menu that has no GMenu" << gplatformMenu;
302- }
303-
304- m_reloadMenuTimers.erase(it);
305- } else {
306- qWarning() << "Got an update timer for a timer that was not running";
307- }
308- killTimer(e->timerId());
309-}
310-
311-// Export the model on dbus
312-void UbuntuGMenuModelExporter::exportModels()
313-{
314- GError *error = nullptr;
315- m_connection = g_bus_get_sync (G_BUS_TYPE_SESSION, nullptr, &error);
316- if (!m_connection) {
317- qCWarning(ubuntuappmenu, "Failed to retreive session bus - %s", error ? error->message : "unknown error");
318- g_error_free (error);
319- return;
320- }
321-
322- QByteArray menuPath(m_menuPath.toUtf8());
323-
324- if (m_exportedModel == 0) {
325- m_exportedModel = g_dbus_connection_export_menu_model(m_connection, menuPath.constData(), G_MENU_MODEL(m_gmainMenu), &error);
326- if (m_exportedModel == 0) {
327- qCWarning(ubuntuappmenu, "Failed to export menu - %s", error ? error->message : "unknown error");
328- g_error_free (error);
329- error = nullptr;
330- } else {
331- qCDebug(ubuntuappmenu, "Exported menu on %s", g_dbus_connection_get_unique_name(m_connection));
332- }
333- }
334-
335- if (m_exportedActions == 0) {
336- m_exportedActions = g_dbus_connection_export_action_group(m_connection, menuPath.constData(), G_ACTION_GROUP(m_gactionGroup), &error);
337- if (m_exportedActions == 0) {
338- qCWarning(ubuntuappmenu, "Failed to export actions - %s", error ? error->message : "unknown error");
339- g_error_free (error);
340- error = nullptr;
341- } else {
342- qCDebug(ubuntuappmenu, "Exported actions on %s", g_dbus_connection_get_unique_name(m_connection));
343- }
344- }
345-
346- if (!m_qtubuntuExtraHandler) {
347- m_qtubuntuExtraHandler = new QtUbuntuExtraActionHandler();
348- if (!m_qtubuntuExtraHandler->connect(m_connection, menuPath, this)) {
349- delete m_qtubuntuExtraHandler;
350- m_qtubuntuExtraHandler = nullptr;
351- }
352- }
353-}
354-
355-void UbuntuGMenuModelExporter::aboutToShow(quint64 tag)
356-{
357- UbuntuPlatformMenu* gplatformMenu = m_submenusWithTag.value(tag);
358- if (!gplatformMenu) {
359- qWarning() << "Got an aboutToShow call with an unknown tag";
360- return;
361- }
362-
363- gplatformMenu->aboutToShow();
364-}
365-
366-// Unexport the model
367-void UbuntuGMenuModelExporter::unexportModels()
368-{
369- GError *error = nullptr;
370- if (!m_connection) {
371- qCWarning(ubuntuappmenu, "Failed to retreive session bus - %s", error ? error->message : "unknown error");
372- return;
373- }
374-
375- if (m_exportedModel != 0) {
376- g_dbus_connection_unexport_menu_model(m_connection, m_exportedModel);
377- m_exportedModel = 0;
378- }
379- if (m_exportedActions != 0) {
380- g_dbus_connection_unexport_action_group(m_connection, m_exportedActions);
381- m_exportedActions = 0;
382- }
383- if (m_qtubuntuExtraHandler) {
384- m_qtubuntuExtraHandler->disconnect(m_connection);
385- delete m_qtubuntuExtraHandler;
386- m_qtubuntuExtraHandler = nullptr;
387- }
388- g_object_unref(m_connection);
389- m_connection = nullptr;
390-}
391-
392-// Create a submenu for the given platform menu.
393-// Returns a gmenuitem entry for the menu, which must be cleaned up using g_object_unref.
394-// If forItem is suplied, use it's label.
395-GMenuItem *UbuntuGMenuModelExporter::createSubmenu(QPlatformMenu *platformMenu, UbuntuPlatformMenuItem *forItem)
396-{
397- UbuntuPlatformMenu* gplatformMenu = static_cast<UbuntuPlatformMenu*>(platformMenu);
398- if (!gplatformMenu) return nullptr;
399- GMenu* menu = g_menu_new();
400-
401- m_gmenusForMenus.insert(gplatformMenu, menu);
402-
403- QByteArray label;
404- bool enabled;
405- if (forItem) {
406- label = UbuntuPlatformMenuItem::get_text(forItem).toUtf8();
407- enabled = UbuntuPlatformMenuItem::get_enabled(forItem);
408- } else {
409- label = UbuntuPlatformMenu::get_text(gplatformMenu).toUtf8();
410- enabled = UbuntuPlatformMenu::get_enabled(gplatformMenu);
411- }
412-
413- addSubmenuItems(gplatformMenu, menu);
414-
415- Q_FOREACH(QPlatformMenuItem *childItem, gplatformMenu->menuItems()) {
416- UbuntuPlatformMenuItem* gplatformMenuItem = static_cast<UbuntuPlatformMenuItem*>(childItem);
417- if (!gplatformMenuItem) continue;
418-
419- // Sadly we don't have a better way to propagate a enabled change in a item-that-is-submenu
420- // than reseting the whole parent menu
421- if (gplatformMenuItem->menu()) {
422- connect(gplatformMenuItem, &UbuntuPlatformMenuItem::enabledChanged, gplatformMenu, &UbuntuPlatformMenu::structureChanged);
423- }
424- connect(gplatformMenuItem, &UbuntuPlatformMenuItem::visibleChanged, gplatformMenu, &UbuntuPlatformMenu::structureChanged);
425- }
426-
427- GMenuItem* gmenuItem = g_menu_item_new_submenu(label.constData(), G_MENU_MODEL(menu));
428- const quint64 tag = gplatformMenu->tag();
429- if (tag != 0) {
430- g_menu_item_set_attribute_value(gmenuItem, "qtubuntu-tag", g_variant_new_uint64 (tag));
431- m_submenusWithTag.insert(gplatformMenu->tag(), gplatformMenu);
432- }
433- g_object_unref(menu);
434-
435- g_menu_item_set_attribute_value(gmenuItem, "submenu-enabled", g_variant_new_boolean(enabled));
436-
437- connect(gplatformMenu, &UbuntuPlatformMenu::structureChanged, this, [this, gplatformMenu]
438- {
439- if (!m_reloadMenuTimers.contains(gplatformMenu)) {
440- const int timerId = startTimer(0);
441- m_reloadMenuTimers.insert(gplatformMenu, timerId);
442- }
443- });
444-
445- connect(gplatformMenu, &UbuntuPlatformMenu::destroyed, this, [this, tag, gplatformMenu]
446- {
447- m_submenusWithTag.remove(tag);
448- m_gmenusForMenus.remove(gplatformMenu);
449- auto timerIdIt = m_reloadMenuTimers.find(gplatformMenu);
450- if (timerIdIt != m_reloadMenuTimers.end()) {
451- killTimer(*timerIdIt);
452- m_reloadMenuTimers.erase(timerIdIt);
453- }
454- });
455-
456- return gmenuItem;
457-}
458-
459-// Add a platform menu's items to the given gmenu.
460-// The items are inserted into menus sections, split by the menu separators.
461-void UbuntuGMenuModelExporter::addSubmenuItems(UbuntuPlatformMenu* gplatformMenu, GMenu* menu)
462-{
463- auto iter = gplatformMenu->menuItems().begin();
464- auto lastSectionStart = iter;
465- // Iterate through all the menu items adding sections when a separator is found.
466- for (; iter != gplatformMenu->menuItems().end(); ++iter) {
467- UbuntuPlatformMenuItem* gplatformMenuItem = static_cast<UbuntuPlatformMenuItem*>(*iter);
468- if (!gplatformMenuItem) continue;
469-
470- // don't add a section until we have separator
471- if (UbuntuPlatformMenuItem::get_separator(gplatformMenuItem)) {
472- if (lastSectionStart != gplatformMenu->menuItems().begin()) {
473- GMenuItem* section = createSection(lastSectionStart, iter);
474- g_menu_append_item(menu, section);
475- g_object_unref(section);
476- }
477- lastSectionStart = iter + 1;
478- } else if (lastSectionStart == gplatformMenu->menuItems().begin()) {
479- processItemForGMenu(gplatformMenuItem, menu);
480- }
481- }
482-
483- // Add the last section
484- if (lastSectionStart != gplatformMenu->menuItems().begin() &&
485- lastSectionStart != gplatformMenu->menuItems().end()) {
486- GMenuItem* gsectionItem = createSection(lastSectionStart, gplatformMenu->menuItems().end());
487- g_menu_append_item(menu, gsectionItem);
488- g_object_unref(gsectionItem);
489- }
490-}
491-
492-// Create and return a gmenu item for the given platform menu item.
493-// Returned GMenuItem must be cleaned up using g_object_unref
494-GMenuItem *UbuntuGMenuModelExporter::createMenuItem(QPlatformMenuItem *platformMenuItem, GMenu *parentMenu)
495-{
496- UbuntuPlatformMenuItem* gplatformMenuItem = static_cast<UbuntuPlatformMenuItem*>(platformMenuItem);
497- if (!gplatformMenuItem) return nullptr;
498-
499- if (!UbuntuPlatformMenuItem::get_visible(gplatformMenuItem))
500- return nullptr;
501-
502- QByteArray label(UbuntuPlatformMenuItem::get_text(gplatformMenuItem).toUtf8());
503- QByteArray actionLabel(getActionString(UbuntuPlatformMenuItem::get_text(gplatformMenuItem)).toUtf8());
504- QByteArray shortcut(UbuntuPlatformMenuItem::get_shortcut(gplatformMenuItem).toString(QKeySequence::NativeText).toUtf8());
505-
506- GMenuItem* gmenuItem = g_menu_item_new(label.constData(), nullptr);
507- g_menu_item_set_attribute(gmenuItem, "accel", "s", shortcut.constData());
508- g_menu_item_set_detailed_action(gmenuItem, ("unity." + actionLabel).constData());
509-
510- addAction(actionLabel, gplatformMenuItem, parentMenu);
511- return gmenuItem;
512-}
513-
514-// Create a menu section for a section of separated menu items.
515-// Returned GMenuItem must be cleaned up using g_object_unref
516-GMenuItem *UbuntuGMenuModelExporter::createSection(QList<QPlatformMenuItem *>::const_iterator iter, QList<QPlatformMenuItem *>::const_iterator end)
517-{
518- GMenu* gsectionMenu = g_menu_new();
519- for (; iter != end; ++iter) {
520- processItemForGMenu(*iter, gsectionMenu);
521- }
522- GMenuItem* gsectionItem = g_menu_item_new_section("", G_MENU_MODEL(gsectionMenu));
523- g_object_unref(gsectionMenu);
524- return gsectionItem;
525-}
526-
527-// Add the given platform menu item to the menu.
528-// If it has an attached submenu, then create and add the submenu.
529-void UbuntuGMenuModelExporter::processItemForGMenu(QPlatformMenuItem *platformMenuItem, GMenu *gmenu)
530-{
531- UbuntuPlatformMenuItem* gplatformMenuItem = static_cast<UbuntuPlatformMenuItem*>(platformMenuItem);
532- if (!gplatformMenuItem) return;
533-
534- GMenuItem* gmenuItem = gplatformMenuItem->menu() ? createSubmenu(gplatformMenuItem->menu(), gplatformMenuItem) :
535- createMenuItem(gplatformMenuItem, gmenu);
536- if (gmenuItem) {
537- g_menu_append_item(gmenu, gmenuItem);
538- g_object_unref(gmenuItem);
539- }
540-}
541-
542-// Create and add an action for a menu item.
543-void UbuntuGMenuModelExporter::addAction(const QByteArray &name, UbuntuPlatformMenuItem *gplatformMenuItem, GMenu *parentMenu)
544-{
545- disconnect(gplatformMenuItem, &UbuntuPlatformMenuItem::checkedChanged, this, 0);
546- disconnect(gplatformMenuItem, &UbuntuPlatformMenuItem::enabledChanged, this, 0);
547-
548- QSet<QByteArray> &actions = m_actions[parentMenu];
549- QVector<QMetaObject::Connection> &propertyConnections = m_propertyConnections[parentMenu];
550-
551- if (actions.contains(name)) {
552- g_action_map_remove_action(G_ACTION_MAP(m_gactionGroup), name.constData());
553- actions.remove(name);
554- }
555-
556- bool checkable = UbuntuPlatformMenuItem::get_checkable(gplatformMenuItem);
557-
558- GSimpleAction* action = nullptr;
559- if (checkable) {
560- bool checked = UbuntuPlatformMenuItem::get_checked(gplatformMenuItem);
561- action = g_simple_action_new_stateful(name.constData(), nullptr, g_variant_new_boolean(checked));
562-
563- std::function<void(bool)> updateChecked = [gplatformMenuItem, action](bool checked) {
564- auto type = g_action_get_state_type(G_ACTION(action));
565- if (type && g_variant_type_equal(type, G_VARIANT_TYPE_BOOLEAN)) {
566- g_simple_action_set_state(action, g_variant_new_boolean(checked ? TRUE : FALSE));
567- }
568- };
569- // save the connection to disconnect in UbuntuGMenuModelExporter::clear()
570- propertyConnections << connect(gplatformMenuItem, &UbuntuPlatformMenuItem::checkedChanged, this, updateChecked);
571- } else {
572- action = g_simple_action_new(name.constData(), nullptr);
573- }
574-
575- // Enabled update
576- std::function<void(bool)> updateEnabled = [gplatformMenuItem, action](bool enabled) {
577- GValue value = G_VALUE_INIT;
578- g_value_init (&value, G_TYPE_BOOLEAN);
579- g_value_set_boolean(&value, enabled ? TRUE : FALSE);
580- g_object_set_property(G_OBJECT(action), "enabled", &value);
581- };
582- updateEnabled(UbuntuPlatformMenuItem::get_enabled(gplatformMenuItem));
583- // save the connection to disconnect in UbuntuGMenuModelExporter::clear()
584- propertyConnections << connect(gplatformMenuItem, &UbuntuPlatformMenuItem::enabledChanged, this, updateEnabled);
585-
586- g_signal_connect(action, "activate", G_CALLBACK(activate_cb), gplatformMenuItem);
587-
588- actions.insert(name);
589- g_action_map_add_action(G_ACTION_MAP(m_gactionGroup), G_ACTION(action));
590- g_object_unref(action);
591-}
592
593=== removed file 'src/ubuntuappmenu/gmenumodelexporter.h'
594--- src/ubuntuappmenu/gmenumodelexporter.h 2017-03-15 08:47:51 +0000
595+++ src/ubuntuappmenu/gmenumodelexporter.h 1970-01-01 00:00:00 +0000
596@@ -1,100 +0,0 @@
597-/*
598- * Copyright (C) 2016 Canonical, Ltd.
599- *
600- * This program is free software: you can redistribute it and/or modify it under
601- * the terms of the GNU Lesser General Public License version 3, as published by
602- * the Free Software Foundation.
603- *
604- * This program is distributed in the hope that it will be useful, but WITHOUT
605- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
606- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
607- * Lesser General Public License for more details.
608- *
609- * You should have received a copy of the GNU Lesser General Public License
610- * along with this program. If not, see <http://www.gnu.org/licenses/>.
611- */
612-
613-#ifndef GMENUMODELEXPORTER_H
614-#define GMENUMODELEXPORTER_H
615-
616-#include "gmenumodelplatformmenu.h"
617-
618-#include <gio/gio.h>
619-
620-#include <QTimer>
621-#include <QMap>
622-#include <QSet>
623-#include <QMetaObject>
624-
625-class QtUbuntuExtraActionHandler;
626-
627-// Base class for a gmenumodel exporter
628-class UbuntuGMenuModelExporter : public QObject
629-{
630- Q_OBJECT
631-public:
632- virtual ~UbuntuGMenuModelExporter();
633-
634- void exportModels();
635- void unexportModels();
636-
637- QString menuPath() const { return m_menuPath;}
638-
639- void aboutToShow(quint64 tag);
640-
641-protected:
642- UbuntuGMenuModelExporter(QObject *parent);
643-
644- GMenuItem *createSubmenu(QPlatformMenu* platformMenu, UbuntuPlatformMenuItem* forItem);
645- GMenuItem *createMenuItem(QPlatformMenuItem* platformMenuItem, GMenu *parentMenu);
646- GMenuItem *createSection(QList<QPlatformMenuItem*>::const_iterator iter, QList<QPlatformMenuItem*>::const_iterator end);
647- void addAction(const QByteArray& name, UbuntuPlatformMenuItem* gplatformItem, GMenu *parentMenu);
648-
649- void addSubmenuItems(UbuntuPlatformMenu* gplatformMenu, GMenu* menu);
650- void processItemForGMenu(QPlatformMenuItem* item, GMenu* gmenu);
651-
652- void clear();
653-
654- void timerEvent(QTimerEvent *e) override;
655-
656-protected:
657- GDBusConnection *m_connection;
658- GMenu *m_gmainMenu;
659- GSimpleActionGroup *m_gactionGroup;
660- guint m_exportedModel;
661- guint m_exportedActions;
662- QtUbuntuExtraActionHandler *m_qtubuntuExtraHandler;
663- QTimer m_structureTimer;
664- QString m_menuPath;
665-
666- // UbuntuPlatformMenu::tag -> UbuntuPlatformMenu
667- QMap<quint64, UbuntuPlatformMenu*> m_submenusWithTag;
668-
669- // UbuntuPlatformMenu -> reload TimerId (startTimer)
670- QHash<UbuntuPlatformMenu*, int> m_reloadMenuTimers;
671-
672- QHash<UbuntuPlatformMenu*, GMenu*> m_gmenusForMenus;
673-
674- QHash<GMenu*, QSet<QByteArray>> m_actions;
675- QHash<GMenu*, QVector<QMetaObject::Connection>> m_propertyConnections;
676-
677-};
678-
679-// Class which exports a qt platform menu bar.
680-class UbuntuMenuBarExporter : public UbuntuGMenuModelExporter
681-{
682-public:
683- UbuntuMenuBarExporter(UbuntuPlatformMenuBar *parent);
684- ~UbuntuMenuBarExporter();
685-};
686-
687-// Class which exports a qt platform menu.
688-// This will allow exporting of context menus.
689-class UbuntuMenuExporter : public UbuntuGMenuModelExporter
690-{
691-public:
692- UbuntuMenuExporter(UbuntuPlatformMenu *parent);
693- ~UbuntuMenuExporter();
694-};
695-
696-#endif // GMENUMODELEXPORTER_H
697
698=== removed file 'src/ubuntuappmenu/gmenumodelplatformmenu.cpp'
699--- src/ubuntuappmenu/gmenumodelplatformmenu.cpp 2017-03-27 08:23:00 +0000
700+++ src/ubuntuappmenu/gmenumodelplatformmenu.cpp 1970-01-01 00:00:00 +0000
701@@ -1,518 +0,0 @@
702-/*
703- * Copyright (C) 2016 Canonical, Ltd.
704- *
705- * This program is free software: you can redistribute it and/or modify it under
706- * the terms of the GNU Lesser General Public License version 3, as published by
707- * the Free Software Foundation.
708- *
709- * This program is distributed in the hope that it will be useful, but WITHOUT
710- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
711- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
712- * Lesser General Public License for more details.
713- *
714- * You should have received a copy of the GNU Lesser General Public License
715- * along with this program. If not, see <http://www.gnu.org/licenses/>.
716- */
717-
718-// Local
719-#include "gmenumodelplatformmenu.h"
720-#include "gmenumodelexporter.h"
721-#include "registry.h"
722-#include "menuregistrar.h"
723-#include "logging.h"
724-
725-// Qt
726-#include <QDebug>
727-#include <QWindow>
728-#include <QCoreApplication>
729-
730-#define BAR_DEBUG_MSG qCDebug(ubuntuappmenu).nospace() << "UbuntuPlatformMenuBar[" << (void*)this <<"]::" << __func__
731-#define MENU_DEBUG_MSG qCDebug(ubuntuappmenu).nospace() << "UbuntuPlatformMenu[" << (void*)this <<"]::" << __func__
732-#define ITEM_DEBUG_MSG qCDebug(ubuntuappmenu).nospace() << "UbuntuPlatformMenuItem[" << (void*)this <<"]::" << __func__
733-
734-namespace {
735-
736-int logRecusion = 0;
737-
738-}
739-
740-QDebug operator<<(QDebug stream, UbuntuPlatformMenuBar* bar) {
741- if (bar) return bar->operator<<(stream);
742- return stream;
743-}
744-QDebug operator<<(QDebug stream, UbuntuPlatformMenu* menu) {
745- if (menu) return menu->operator<<(stream);
746- return stream;
747-}
748-QDebug operator<<(QDebug stream, UbuntuPlatformMenuItem* menuItem) {
749- if (menuItem) return menuItem->operator<<(stream);
750- return stream;
751-}
752-
753-UbuntuPlatformMenuBar::UbuntuPlatformMenuBar()
754- : m_exporter(new UbuntuMenuBarExporter(this))
755- , m_registrar(new UbuntuMenuRegistrar())
756- , m_ready(false)
757-{
758- BAR_DEBUG_MSG << "()";
759-
760- connect(this, &UbuntuPlatformMenuBar::menuInserted, this, &UbuntuPlatformMenuBar::structureChanged);
761- connect(this,&UbuntuPlatformMenuBar::menuRemoved, this, &UbuntuPlatformMenuBar::structureChanged);
762-}
763-
764-UbuntuPlatformMenuBar::~UbuntuPlatformMenuBar()
765-{
766- BAR_DEBUG_MSG << "()";
767-}
768-
769-void UbuntuPlatformMenuBar::insertMenu(QPlatformMenu *menu, QPlatformMenu *before)
770-{
771- BAR_DEBUG_MSG << "(menu=" << menu << ", before=" << before << ")";
772-
773- if (m_menus.contains(menu)) return;
774-
775- if (!before) {
776- m_menus.push_back(menu);
777- } else {
778- for (auto iter = m_menus.begin(); iter != m_menus.end(); ++iter) {
779- if (*iter == before) {
780- m_menus.insert(iter, menu);
781- break;
782- }
783- }
784- }
785- Q_EMIT menuInserted(menu);
786-}
787-
788-void UbuntuPlatformMenuBar::removeMenu(QPlatformMenu *menu)
789-{
790- BAR_DEBUG_MSG << "(menu=" << menu << ")";
791-
792- QMutableListIterator<QPlatformMenu*> iterator(m_menus);
793- while(iterator.hasNext()) {
794- if (iterator.next() == menu) {
795- iterator.remove();
796- break;
797- }
798- }
799- Q_EMIT menuRemoved(menu);
800-}
801-
802-void UbuntuPlatformMenuBar::syncMenu(QPlatformMenu *menu)
803-{
804- BAR_DEBUG_MSG << "(menu=" << menu << ")";
805-
806- Q_UNUSED(menu)
807-}
808-
809-void UbuntuPlatformMenuBar::handleReparent(QWindow *parentWindow)
810-{
811- BAR_DEBUG_MSG << "(parentWindow=" << parentWindow << ")";
812-
813- setReady(true);
814- m_registrar->registerMenuForWindow(parentWindow, QDBusObjectPath(m_exporter->menuPath()));
815-}
816-
817-QPlatformMenu *UbuntuPlatformMenuBar::menuForTag(quintptr tag) const
818-{
819- Q_FOREACH(QPlatformMenu* menu, m_menus) {
820- if (menu->tag() == tag) {
821- return menu;
822- }
823- }
824- return nullptr;
825-}
826-
827-const QList<QPlatformMenu *> UbuntuPlatformMenuBar::menus() const
828-{
829- return m_menus;
830-}
831-
832-QDebug UbuntuPlatformMenuBar::operator<<(QDebug stream)
833-{
834- stream.nospace().noquote() << QString("%1").arg("", logRecusion, QLatin1Char('\t'))
835- << "UbuntuPlatformMenuBar(this=" << (void*)this << ")" << endl;
836- Q_FOREACH(QPlatformMenu* menu, m_menus) {
837- auto myMenu = static_cast<UbuntuPlatformMenu*>(menu);
838- if (myMenu) {
839- logRecusion++;
840- stream << myMenu;
841- logRecusion--;
842- }
843- }
844-
845- return stream;
846-}
847-
848-#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
849-QPlatformMenu *UbuntuPlatformMenuBar::createMenu() const
850-{
851- return new UbuntuPlatformMenu();
852-}
853-#endif
854-
855-void UbuntuPlatformMenuBar::setReady(bool isReady)
856-{
857- if (m_ready != isReady) {
858- m_ready = isReady;
859- Q_EMIT ready();
860- }
861-}
862-
863-//////////////////////////////////////////////////////////////
864-
865-UbuntuPlatformMenu::UbuntuPlatformMenu()
866- : m_tag(reinterpret_cast<quintptr>(this))
867- , m_parentWindow(nullptr)
868- , m_exporter(nullptr)
869- , m_registrar(nullptr)
870-{
871- MENU_DEBUG_MSG << "()";
872-
873- connect(this, &UbuntuPlatformMenu::menuItemInserted, this, &UbuntuPlatformMenu::structureChanged);
874- connect(this, &UbuntuPlatformMenu::menuItemRemoved, this, &UbuntuPlatformMenu::structureChanged);
875-}
876-
877-UbuntuPlatformMenu::~UbuntuPlatformMenu()
878-{
879- MENU_DEBUG_MSG << "()";
880-}
881-
882-void UbuntuPlatformMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before)
883-{
884- MENU_DEBUG_MSG << "(menuItem=" << menuItem << ", before=" << before << ")";
885-
886- if (m_menuItems.contains(menuItem)) return;
887-
888- if (!before) {
889- m_menuItems.push_back(menuItem);
890- } else {
891- for (auto iter = m_menuItems.begin(); iter != m_menuItems.end(); ++iter) {
892- if (*iter == before) {
893- m_menuItems.insert(iter, menuItem);
894- break;
895- }
896- }
897- }
898-
899- Q_EMIT menuItemInserted(menuItem);
900-}
901-
902-void UbuntuPlatformMenu::removeMenuItem(QPlatformMenuItem *menuItem)
903-{
904- MENU_DEBUG_MSG << "(menuItem=" << menuItem << ")";
905-
906- QMutableListIterator<QPlatformMenuItem*> iterator(m_menuItems);
907- while(iterator.hasNext()) {
908- if (iterator.next() == menuItem) {
909- iterator.remove();
910- break;
911- }
912- }
913- Q_EMIT menuItemRemoved(menuItem);
914-}
915-
916-void UbuntuPlatformMenu::syncMenuItem(QPlatformMenuItem *menuItem)
917-{
918- MENU_DEBUG_MSG << "(menuItem=" << menuItem << ")";
919-
920- Q_UNUSED(menuItem)
921-}
922-
923-void UbuntuPlatformMenu::syncSeparatorsCollapsible(bool enable)
924-{
925- MENU_DEBUG_MSG << "(enable=" << enable << ")";
926- Q_UNUSED(enable)
927-}
928-
929-void UbuntuPlatformMenu::setTag(quintptr tag)
930-{
931- MENU_DEBUG_MSG << "(tag=" << tag << ")";
932- m_tag = tag;
933-}
934-
935-quintptr UbuntuPlatformMenu::tag() const
936-{
937- return m_tag;
938-}
939-
940-void UbuntuPlatformMenu::setText(const QString &text)
941-{
942- MENU_DEBUG_MSG << "(text=" << text << ")";
943- if (m_text != text) {
944- m_text = text;
945- }
946-}
947-
948-void UbuntuPlatformMenu::setIcon(const QIcon &icon)
949-{
950- MENU_DEBUG_MSG << "(icon=" << icon.name() << ")";
951-
952- if (!icon.isNull() || (!m_icon.isNull() && icon.isNull())) {
953- m_icon = icon;
954- }
955-}
956-
957-void UbuntuPlatformMenu::setEnabled(bool enabled)
958-{
959- MENU_DEBUG_MSG << "(enabled=" << enabled << ")";
960-
961- if (m_enabled != enabled) {
962- m_enabled = enabled;
963- Q_EMIT enabledChanged(enabled);
964- }
965-}
966-
967-void UbuntuPlatformMenu::setVisible(bool isVisible)
968-{
969- MENU_DEBUG_MSG << "(visible=" << isVisible << ")";
970-
971- if (m_visible != isVisible) {
972- m_visible = isVisible;
973- }
974-}
975-
976-void UbuntuPlatformMenu::setMinimumWidth(int width)
977-{
978- MENU_DEBUG_MSG << "(width=" << width << ")";
979-
980- Q_UNUSED(width)
981-}
982-
983-void UbuntuPlatformMenu::setFont(const QFont &font)
984-{
985- MENU_DEBUG_MSG << "(font=" << font << ")";
986-
987- Q_UNUSED(font)
988-}
989-
990-void UbuntuPlatformMenu::showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item)
991-{
992- MENU_DEBUG_MSG << "(parentWindow=" << parentWindow << ", targetRect=" << targetRect << ", item=" << item << ")";
993-
994- if (!m_exporter) {
995- m_exporter.reset(new UbuntuMenuExporter(this));
996- m_exporter->exportModels();
997- }
998-
999- if (parentWindow != m_parentWindow) {
1000- if (m_parentWindow) {
1001- m_registrar->unregisterMenu();
1002- }
1003-
1004- m_parentWindow = parentWindow;
1005-
1006- if (m_parentWindow) {
1007- if (!m_registrar) m_registrar.reset(new UbuntuMenuRegistrar);
1008- m_registrar->registerMenuForWindow(const_cast<QWindow*>(m_parentWindow),
1009- QDBusObjectPath(m_exporter->menuPath()));
1010- }
1011- }
1012-
1013- Q_UNUSED(targetRect);
1014- Q_UNUSED(item);
1015- setVisible(true);
1016-}
1017-
1018-void UbuntuPlatformMenu::dismiss()
1019-{
1020- MENU_DEBUG_MSG << "()";
1021-
1022- if (m_registrar) { m_registrar->unregisterMenu(); }
1023- if (m_exporter) { m_exporter->unexportModels(); }
1024-}
1025-
1026-QPlatformMenuItem *UbuntuPlatformMenu::menuItemAt(int position) const
1027-{
1028- if (position < 0 || position >= m_menuItems.count()) return nullptr;
1029- return m_menuItems.at(position);
1030-}
1031-
1032-QPlatformMenuItem *UbuntuPlatformMenu::menuItemForTag(quintptr tag) const
1033-{
1034- Q_FOREACH(QPlatformMenuItem* menuItem, m_menuItems) {
1035- if (menuItem->tag() == tag) {
1036- return menuItem;
1037- }
1038- }
1039- return nullptr;
1040-}
1041-
1042-QPlatformMenuItem *UbuntuPlatformMenu::createMenuItem() const
1043-{
1044- return new UbuntuPlatformMenuItem();
1045-}
1046-
1047-#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
1048-QPlatformMenu *UbuntuPlatformMenu::createSubMenu() const
1049-{
1050- return new UbuntuPlatformMenu();
1051-}
1052-#endif
1053-
1054-const QList<QPlatformMenuItem *> UbuntuPlatformMenu::menuItems() const
1055-{
1056- return m_menuItems;
1057-}
1058-
1059-QDebug UbuntuPlatformMenu::operator<<(QDebug stream)
1060-{
1061- stream.nospace().noquote() << QString("%1").arg("", logRecusion, QLatin1Char('\t'))
1062- << "UbuntuPlatformMenu(this=" << (void*)this << ", text=\"" << m_text << "\")" << endl;
1063- Q_FOREACH(QPlatformMenuItem* item, m_menuItems) {
1064- logRecusion++;
1065- auto myItem = static_cast<UbuntuPlatformMenuItem*>(item);
1066- if (myItem) {
1067- stream << myItem;
1068- }
1069- logRecusion--;
1070- }
1071- return stream;
1072-}
1073-
1074-//////////////////////////////////////////////////////////////
1075-
1076-UbuntuPlatformMenuItem::UbuntuPlatformMenuItem()
1077- : m_menu(nullptr)
1078- , m_tag(reinterpret_cast<quintptr>(this))
1079-{
1080- ITEM_DEBUG_MSG << "()";
1081-}
1082-
1083-UbuntuPlatformMenuItem::~UbuntuPlatformMenuItem()
1084-{
1085- ITEM_DEBUG_MSG << "()";
1086-}
1087-
1088-void UbuntuPlatformMenuItem::setTag(quintptr tag)
1089-{
1090- ITEM_DEBUG_MSG << "(tag=" << tag << ")";
1091- m_tag = tag;
1092-}
1093-
1094-quintptr UbuntuPlatformMenuItem::tag() const
1095-{
1096- return m_tag;
1097-}
1098-
1099-void UbuntuPlatformMenuItem::setText(const QString &text)
1100-{
1101- ITEM_DEBUG_MSG << "(text=" << text << ")";
1102- if (m_text != text) {
1103- m_text = text;
1104- }
1105-}
1106-
1107-void UbuntuPlatformMenuItem::setIcon(const QIcon &icon)
1108-{
1109- ITEM_DEBUG_MSG << "(icon=" << icon.name() << ")";
1110-
1111- if (!icon.isNull() || (!m_icon.isNull() && icon.isNull())) {
1112- m_icon = icon;
1113- }
1114-}
1115-
1116-void UbuntuPlatformMenuItem::setVisible(bool isVisible)
1117-{
1118- ITEM_DEBUG_MSG << "(visible=" << isVisible << ")";
1119- if (m_visible != isVisible) {
1120- m_visible = isVisible;
1121- Q_EMIT visibleChanged(m_visible);
1122- }
1123-}
1124-
1125-void UbuntuPlatformMenuItem::setIsSeparator(bool isSeparator)
1126-{
1127- ITEM_DEBUG_MSG << "(separator=" << isSeparator << ")";
1128- if (m_separator != isSeparator) {
1129- m_separator = isSeparator;
1130- }
1131-}
1132-
1133-void UbuntuPlatformMenuItem::setFont(const QFont &font)
1134-{
1135- ITEM_DEBUG_MSG << "(font=" << font << ")";
1136- Q_UNUSED(font);
1137-}
1138-
1139-void UbuntuPlatformMenuItem::setRole(QPlatformMenuItem::MenuRole role)
1140-{
1141- ITEM_DEBUG_MSG << "(role=" << role << ")";
1142- Q_UNUSED(role);
1143-}
1144-
1145-void UbuntuPlatformMenuItem::setCheckable(bool checkable)
1146-{
1147- ITEM_DEBUG_MSG << "(checkable=" << checkable << ")";
1148- if (m_checkable != checkable) {
1149- m_checkable = checkable;
1150- }
1151-}
1152-
1153-void UbuntuPlatformMenuItem::setChecked(bool isChecked)
1154-{
1155- ITEM_DEBUG_MSG << "(checked=" << isChecked << ")";
1156- if (m_checked != isChecked) {
1157- m_checked = isChecked;
1158- Q_EMIT checkedChanged(isChecked);
1159- }
1160-}
1161-
1162-void UbuntuPlatformMenuItem::setShortcut(const QKeySequence &shortcut)
1163-{
1164- ITEM_DEBUG_MSG << "(shortcut=" << shortcut << ")";
1165- if (m_shortcut != shortcut) {
1166- m_shortcut = shortcut;
1167- }
1168-}
1169-
1170-void UbuntuPlatformMenuItem::setEnabled(bool enabled)
1171-{
1172- ITEM_DEBUG_MSG << "(enabled=" << enabled << ")";
1173- if (m_enabled != enabled) {
1174- m_enabled = enabled;
1175- Q_EMIT enabledChanged(enabled);
1176- }
1177-}
1178-
1179-void UbuntuPlatformMenuItem::setIconSize(int size)
1180-{
1181- ITEM_DEBUG_MSG << "(size=" << size << ")";
1182- Q_UNUSED(size);
1183-}
1184-
1185-void UbuntuPlatformMenuItem::setMenu(QPlatformMenu *menu)
1186-{
1187- ITEM_DEBUG_MSG << "(menu=" << menu << ")";
1188- if (m_menu != menu) {
1189- m_menu = menu;
1190-
1191- if (menu) {
1192- connect(menu, &QObject::destroyed,
1193- this, [this] { setMenu(nullptr); });
1194- }
1195- }
1196-}
1197-
1198-QPlatformMenu *UbuntuPlatformMenuItem::menu() const
1199-{
1200- return m_menu;
1201-}
1202-
1203-QDebug UbuntuPlatformMenuItem::operator<<(QDebug stream)
1204-{
1205- QString properties = "text=\"" + m_text + "\"";
1206-
1207- stream.nospace().noquote() << QString("%1").arg("", logRecusion, QLatin1Char('\t'))
1208- << "UbuntuPlatformMenuItem(this=" << (void*)this << ", "
1209- << (m_separator ? "Separator" : properties) << ")" << endl;
1210- if (m_menu) {
1211- auto myMenu = static_cast<UbuntuPlatformMenu*>(m_menu);
1212- if (myMenu) {
1213- logRecusion++;
1214- stream << myMenu;
1215- logRecusion--;
1216- }
1217- }
1218- return stream;
1219-}
1220
1221=== removed file 'src/ubuntuappmenu/gmenumodelplatformmenu.h'
1222--- src/ubuntuappmenu/gmenumodelplatformmenu.h 2017-03-27 08:23:00 +0000
1223+++ src/ubuntuappmenu/gmenumodelplatformmenu.h 1970-01-01 00:00:00 +0000
1224@@ -1,181 +0,0 @@
1225-/*
1226- * Copyright (C) 2016 Canonical, Ltd.
1227- *
1228- * This program is free software: you can redistribute it and/or modify it under
1229- * the terms of the GNU Lesser General Public License version 3, as published by
1230- * the Free Software Foundation.
1231- *
1232- * This program is distributed in the hope that it will be useful, but WITHOUT
1233- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1234- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1235- * Lesser General Public License for more details.
1236- *
1237- * You should have received a copy of the GNU Lesser General Public License
1238- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1239- */
1240-
1241-#ifndef EXPORTEDPLATFORMMENUBAR_H
1242-#define EXPORTEDPLATFORMMENUBAR_H
1243-
1244-#include <qpa/qplatformmenu.h>
1245-
1246-// Local
1247-class UbuntuGMenuModelExporter;
1248-class UbuntuMenuRegistrar;
1249-class QWindow;
1250-
1251-class UbuntuPlatformMenuBar : public QPlatformMenuBar
1252-{
1253- Q_OBJECT
1254-public:
1255- UbuntuPlatformMenuBar();
1256- ~UbuntuPlatformMenuBar();
1257-
1258- QString exportedPath() const;
1259-
1260- virtual void insertMenu(QPlatformMenu *menu, QPlatformMenu* before) override;
1261- virtual void removeMenu(QPlatformMenu *menu) override;
1262- virtual void syncMenu(QPlatformMenu *menu) override;
1263- virtual void handleReparent(QWindow *newParentWindow) override;
1264- virtual QPlatformMenu *menuForTag(quintptr tag) const override;
1265-
1266- const QList<QPlatformMenu*> menus() const;
1267-
1268- QDebug operator<<(QDebug stream);
1269-
1270-#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
1271- virtual QPlatformMenu *createMenu() const override;
1272-#endif
1273-
1274-Q_SIGNALS:
1275- void menuInserted(QPlatformMenu *menu);
1276- void menuRemoved(QPlatformMenu *menu);
1277-
1278- void structureChanged();
1279- void ready();
1280-
1281-private:
1282- void setReady(bool);
1283-
1284- QList<QPlatformMenu*> m_menus;
1285- QScopedPointer<UbuntuGMenuModelExporter> m_exporter;
1286- QScopedPointer<UbuntuMenuRegistrar> m_registrar;
1287- bool m_ready;
1288-};
1289-
1290-#define MENU_PROPERTY(class, name, type, defaultValue) \
1291- static type get_##name(const class *menuItem) { return menuItem->m_##name; } \
1292- type m_##name = defaultValue;
1293-
1294-class Q_DECL_EXPORT UbuntuPlatformMenu : public QPlatformMenu
1295-{
1296- Q_OBJECT
1297-public:
1298- UbuntuPlatformMenu();
1299- ~UbuntuPlatformMenu();
1300-
1301- virtual void insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before) override;
1302- virtual void removeMenuItem(QPlatformMenuItem *menuItem) override;
1303- virtual void syncMenuItem(QPlatformMenuItem *menuItem) override;
1304- virtual void syncSeparatorsCollapsible(bool enable) override;
1305-
1306- virtual void setTag(quintptr tag) override;
1307- virtual quintptr tag() const override;
1308-
1309- virtual void setText(const QString &text) override;
1310- virtual void setIcon(const QIcon &icon) override;
1311- virtual void setEnabled(bool isEnabled) override;
1312- virtual void setVisible(bool isVisible) override;
1313- virtual void setMinimumWidth(int width) override;
1314- virtual void setFont(const QFont &font) override;
1315-
1316- virtual void showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item) override;
1317-
1318- virtual void dismiss() override; // Closes this and all its related menu popups
1319-
1320- virtual QPlatformMenuItem *menuItemAt(int position) const override;
1321- virtual QPlatformMenuItem *menuItemForTag(quintptr tag) const override;
1322-
1323- virtual QPlatformMenuItem *createMenuItem() const override;
1324-#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
1325- virtual QPlatformMenu *createSubMenu() const override;
1326-#endif
1327-
1328- int id() const;
1329-
1330- const QList<QPlatformMenuItem*> menuItems() const;
1331-
1332- QDebug operator<<(QDebug stream);
1333-
1334-Q_SIGNALS:
1335- void menuItemInserted(QPlatformMenuItem *menuItem);
1336- void menuItemRemoved(QPlatformMenuItem *menuItem);
1337- void structureChanged();
1338- void enabledChanged(bool);
1339-
1340-private:
1341- MENU_PROPERTY(UbuntuPlatformMenu, visible, bool, true)
1342- MENU_PROPERTY(UbuntuPlatformMenu, text, QString, QString())
1343- MENU_PROPERTY(UbuntuPlatformMenu, enabled, bool, true)
1344- MENU_PROPERTY(UbuntuPlatformMenu, icon, QIcon, QIcon())
1345-
1346- quintptr m_tag;
1347- QList<QPlatformMenuItem*> m_menuItems;
1348- const QWindow* m_parentWindow;
1349- QScopedPointer<UbuntuGMenuModelExporter> m_exporter;
1350- QScopedPointer<UbuntuMenuRegistrar> m_registrar;
1351-
1352- friend class UbuntuGMenuModelExporter;
1353-};
1354-
1355-
1356-class Q_DECL_EXPORT UbuntuPlatformMenuItem : public QPlatformMenuItem
1357-{
1358- Q_OBJECT
1359-public:
1360- UbuntuPlatformMenuItem();
1361- ~UbuntuPlatformMenuItem();
1362-
1363- virtual void setTag(quintptr tag) override;
1364- virtual quintptr tag() const override;
1365-
1366- virtual void setText(const QString &text) override;
1367- virtual void setIcon(const QIcon &icon) override;
1368- virtual void setMenu(QPlatformMenu *menu) override;
1369- virtual void setVisible(bool isVisible) override;
1370- virtual void setIsSeparator(bool isSeparator) override;
1371- virtual void setFont(const QFont &font) override;
1372- virtual void setRole(MenuRole role) override;
1373- virtual void setCheckable(bool checkable) override;
1374- virtual void setChecked(bool isChecked) override;
1375- virtual void setShortcut(const QKeySequence& shortcut) override;
1376- virtual void setEnabled(bool enabled) override;
1377- virtual void setIconSize(int size) override;
1378-
1379- QPlatformMenu* menu() const;
1380-
1381- QDebug operator<<(QDebug stream);
1382-
1383-Q_SIGNALS:
1384- void checkedChanged(bool);
1385- void enabledChanged(bool);
1386- void visibleChanged(bool);
1387-
1388-private:
1389- MENU_PROPERTY(UbuntuPlatformMenuItem, separator, bool, false)
1390- MENU_PROPERTY(UbuntuPlatformMenuItem, visible, bool, true)
1391- MENU_PROPERTY(UbuntuPlatformMenuItem, text, QString, QString())
1392- MENU_PROPERTY(UbuntuPlatformMenuItem, enabled, bool, true)
1393- MENU_PROPERTY(UbuntuPlatformMenuItem, checkable, bool, false)
1394- MENU_PROPERTY(UbuntuPlatformMenuItem, checked, bool, false)
1395- MENU_PROPERTY(UbuntuPlatformMenuItem, shortcut, QKeySequence, QKeySequence())
1396- MENU_PROPERTY(UbuntuPlatformMenuItem, icon, QIcon, QIcon())
1397- MENU_PROPERTY(UbuntuPlatformMenuItem, iconSize, int, 16)
1398- MENU_PROPERTY(UbuntuPlatformMenuItem, menu, QPlatformMenu*, nullptr)
1399-
1400-
1401- quintptr m_tag;
1402- friend class UbuntuGMenuModelExporter;
1403-};
1404-
1405-#endif // EXPORTEDPLATFORMMENUBAR_H
1406
1407=== removed file 'src/ubuntuappmenu/logging.h'
1408--- src/ubuntuappmenu/logging.h 2016-08-24 10:08:05 +0000
1409+++ src/ubuntuappmenu/logging.h 1970-01-01 00:00:00 +0000
1410@@ -1,27 +0,0 @@
1411-/*
1412- * Copyright (C) 2016 Canonical, Ltd.
1413- *
1414- * This program is free software: you can redistribute it and/or modify it under
1415- * the terms of the GNU Lesser General Public License version 3, as published by
1416- * the Free Software Foundation.
1417- *
1418- * This program is distributed in the hope that it will be useful, but WITHOUT
1419- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1420- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1421- * Lesser General Public License for more details.
1422- *
1423- * You should have received a copy of the GNU Lesser General Public License
1424- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1425- */
1426-
1427-#ifndef QUBUNTUTHEMELOGGING_H
1428-#define QUBUNTUTHEMELOGGING_H
1429-
1430-#include <QLoggingCategory>
1431-
1432-#define ASSERT(cond) ((!(cond)) ? qt_assert(#cond,__FILE__,__LINE__) : qt_noop())
1433-
1434-Q_DECLARE_LOGGING_CATEGORY(ubuntuappmenu)
1435-Q_DECLARE_LOGGING_CATEGORY(ubuntuappmenuRegistrar)
1436-
1437-#endif // QUBUNTUTHEMELOGGING_H
1438
1439=== removed file 'src/ubuntuappmenu/menuregistrar.cpp'
1440--- src/ubuntuappmenu/menuregistrar.cpp 2016-09-30 16:10:35 +0000
1441+++ src/ubuntuappmenu/menuregistrar.cpp 1970-01-01 00:00:00 +0000
1442@@ -1,137 +0,0 @@
1443-/*
1444- * Copyright (C) 2016 Canonical, Ltd.
1445- *
1446- * This program is free software: you can redistribute it and/or modify it under
1447- * the terms of the GNU Lesser General Public License version 3, as published by
1448- * the Free Software Foundation.
1449- *
1450- * This program is distributed in the hope that it will be useful, but WITHOUT
1451- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1452- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1453- * Lesser General Public License for more details.
1454- *
1455- * You should have received a copy of the GNU Lesser General Public License
1456- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1457- */
1458-
1459-#include "menuregistrar.h"
1460-#include "registry.h"
1461-#include "logging.h"
1462-
1463-#include <QDebug>
1464-#include <QDBusObjectPath>
1465-#include <QGuiApplication>
1466-#include <qpa/qplatformnativeinterface.h>
1467-#include <qpa/qplatformwindow.h>
1468-
1469-namespace {
1470-
1471-bool isMirClient() {
1472- return qGuiApp->platformName() == "ubuntumirclient";
1473-}
1474-
1475-}
1476-
1477-UbuntuMenuRegistrar::UbuntuMenuRegistrar()
1478- : m_connection(nullptr)
1479- , m_registeredProcessId(~0)
1480-{
1481- GError *error = NULL;
1482- m_connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
1483- if (!m_connection) {
1484- qCWarning(ubuntuappmenuRegistrar, "Failed to retreive session bus - %s", error ? error->message : "unknown error");
1485- g_error_free (error);
1486- return;
1487- }
1488- m_service = g_dbus_connection_get_unique_name(m_connection);
1489- connect(UbuntuMenuRegistry::instance(), &UbuntuMenuRegistry::serviceChanged, this, &UbuntuMenuRegistrar::onRegistrarServiceChanged);
1490-
1491- if (isMirClient()) {
1492- auto nativeInterface = qGuiApp->platformNativeInterface();
1493- connect(nativeInterface, &QPlatformNativeInterface::windowPropertyChanged, this, [this](QPlatformWindow* window, const QString &property) {
1494- if (property != QStringLiteral("persistentSurfaceId")) {
1495- return;
1496- }
1497- if (window->window() == m_window) {
1498- registerMenuForWindow(m_window, m_path);
1499- }
1500- });
1501- }
1502-}
1503-
1504-UbuntuMenuRegistrar::~UbuntuMenuRegistrar()
1505-{
1506- if (m_connection) {
1507- g_object_unref(m_connection);
1508- }
1509- unregisterMenu();
1510-}
1511-
1512-void UbuntuMenuRegistrar::registerMenuForWindow(QWindow* window, const QDBusObjectPath& path)
1513-{
1514- unregisterMenu();
1515-
1516- m_window = window;
1517- m_path = path;
1518-
1519- registerMenu();
1520-}
1521-
1522-void UbuntuMenuRegistrar::registerMenu()
1523-{
1524- if (UbuntuMenuRegistry::instance()->isConnected() && m_window) {
1525- if (isMirClient()) {
1526- registerSurfaceMenu();
1527- } else {
1528- registerApplicationMenu();
1529- }
1530- }
1531-}
1532-
1533-void UbuntuMenuRegistrar::unregisterMenu()
1534-{
1535- if (!m_registeredSurfaceId.isEmpty()) {
1536- unregisterSurfaceMenu();
1537- } else if (m_registeredProcessId != ~0) {
1538- unregisterApplicationMenu();
1539- }
1540-}
1541-
1542-void UbuntuMenuRegistrar::registerSurfaceMenu()
1543-{
1544- auto nativeInterface = qGuiApp->platformNativeInterface();
1545- QByteArray persistentSurfaceId = nativeInterface->windowProperty(m_window->handle(), "persistentSurfaceId", QByteArray()).toByteArray();
1546- if (persistentSurfaceId.isEmpty()) return;
1547-
1548- UbuntuMenuRegistry::instance()->registerSurfaceMenu(persistentSurfaceId, m_path, m_service);
1549- m_registeredSurfaceId = persistentSurfaceId;
1550-}
1551-
1552-void UbuntuMenuRegistrar::unregisterSurfaceMenu()
1553-{
1554- if (UbuntuMenuRegistry::instance()->isConnected()) {
1555- UbuntuMenuRegistry::instance()->unregisterSurfaceMenu(m_registeredSurfaceId, m_path);
1556- }
1557- m_registeredSurfaceId.clear();
1558-}
1559-
1560-void UbuntuMenuRegistrar::registerApplicationMenu()
1561-{
1562- pid_t pid = getpid();
1563- UbuntuMenuRegistry::instance()->registerApplicationMenu(pid, m_path, m_service);
1564- m_registeredProcessId = pid;
1565-}
1566-
1567-void UbuntuMenuRegistrar::unregisterApplicationMenu()
1568-{
1569- if (UbuntuMenuRegistry::instance()->isConnected()) {
1570- UbuntuMenuRegistry::instance()->unregisterApplicationMenu(m_registeredProcessId, m_path);
1571- }
1572- m_registeredProcessId = ~0;
1573-}
1574-
1575-void UbuntuMenuRegistrar::onRegistrarServiceChanged()
1576-{
1577- unregisterMenu();
1578- registerMenu();
1579-}
1580
1581=== removed file 'src/ubuntuappmenu/menuregistrar.h'
1582--- src/ubuntuappmenu/menuregistrar.h 2016-09-30 08:35:16 +0000
1583+++ src/ubuntuappmenu/menuregistrar.h 1970-01-01 00:00:00 +0000
1584@@ -1,59 +0,0 @@
1585-/*
1586- * Copyright (C) 2016 Canonical, Ltd.
1587- *
1588- * This program is free software: you can redistribute it and/or modify it under
1589- * the terms of the GNU Lesser General Public License version 3, as published by
1590- * the Free Software Foundation.
1591- *
1592- * This program is distributed in the hope that it will be useful, but WITHOUT
1593- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1594- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1595- * Lesser General Public License for more details.
1596- *
1597- * You should have received a copy of the GNU Lesser General Public License
1598- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1599- */
1600-
1601-#ifndef MENUREGISTRAR_H
1602-#define MENUREGISTRAR_H
1603-
1604-#include <QObject>
1605-#include <QWindow>
1606-#include <QPointer>
1607-#include <QDBusObjectPath>
1608-
1609-#include <gio/gio.h>
1610-
1611-class UbuntuMenuRegistrar : public QObject
1612-{
1613- Q_OBJECT
1614-public:
1615- UbuntuMenuRegistrar();
1616- ~UbuntuMenuRegistrar();
1617-
1618- void registerMenuForWindow(QWindow* window, const QDBusObjectPath& path);
1619- void unregisterMenu();
1620-
1621-private Q_SLOTS:
1622- void registerSurfaceMenu();
1623- void onRegistrarServiceChanged();
1624-
1625-private:
1626- void registerMenu();
1627-
1628- void registerApplicationMenu();
1629- void unregisterApplicationMenu();
1630-
1631- void unregisterSurfaceMenu();
1632-
1633- GDBusConnection *m_connection;
1634- QString m_service;
1635- QDBusObjectPath m_path;
1636- QPointer<QWindow> m_window;
1637- QString m_registeredSurfaceId;
1638- pid_t m_registeredProcessId;
1639-};
1640-
1641-
1642-#endif // MENUREGISTRAR_H
1643-
1644
1645=== removed file 'src/ubuntuappmenu/qtubuntuextraactionhandler.cpp'
1646--- src/ubuntuappmenu/qtubuntuextraactionhandler.cpp 2017-03-16 09:42:27 +0000
1647+++ src/ubuntuappmenu/qtubuntuextraactionhandler.cpp 1970-01-01 00:00:00 +0000
1648@@ -1,107 +0,0 @@
1649-/*
1650- * Copyright (C) 2017 Canonical, Ltd.
1651- *
1652- * This program is free software: you can redistribute it and/or modify it under
1653- * the terms of the GNU Lesser General Public License version 3, as published by
1654- * the Free Software Foundation.
1655- *
1656- * This program is distributed in the hope that it will be useful, but WITHOUT
1657- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1658- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1659- * Lesser General Public License for more details.
1660- *
1661- * You should have received a copy of the GNU Lesser General Public License
1662- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1663- */
1664-
1665-#include "qtubuntuextraactionhandler.h"
1666-
1667-#include "gmenumodelexporter.h"
1668-#include "logging.h"
1669-
1670-static const gchar introspection_xml[] =
1671- "<node>"
1672- " <interface name='qtubuntu.actions.extra'>"
1673- " <method name='aboutToShow'>"
1674- " <arg type='t' name='tag' direction='in'/>"
1675- " </method>"
1676- " </interface>"
1677- "</node>";
1678-
1679-static void handle_method_call (GDBusConnection *,
1680- const gchar *,
1681- const gchar *,
1682- const gchar *,
1683- const gchar *method_name,
1684- GVariant *parameters,
1685- GDBusMethodInvocation *invocation,
1686- gpointer user_data)
1687-{
1688-
1689- if (g_strcmp0 (method_name, "aboutToShow") == 0)
1690- {
1691- if (g_variant_check_format_string(parameters, "(t)", false)) {
1692- auto obj = static_cast<UbuntuGMenuModelExporter*>(user_data);
1693- guint64 tag;
1694-
1695- g_variant_get (parameters, "(t)", &tag);
1696- obj->aboutToShow(tag);
1697- }
1698-
1699- g_dbus_method_invocation_return_value (invocation, NULL);
1700- } else {
1701- g_dbus_method_invocation_return_error(invocation,
1702- G_DBUS_ERROR,
1703- G_DBUS_ERROR_UNKNOWN_METHOD,
1704- "Unknown method");
1705- }
1706-}
1707-
1708-
1709-static const GDBusInterfaceVTable interface_vtable =
1710-{
1711- handle_method_call,
1712- NULL,
1713- NULL,
1714- NULL
1715-};
1716-
1717-QtUbuntuExtraActionHandler::QtUbuntuExtraActionHandler()
1718- : m_registration_id(0)
1719-{
1720- m_introspection_data = g_dbus_node_info_new_for_xml (introspection_xml, NULL);
1721-}
1722-
1723-QtUbuntuExtraActionHandler::~QtUbuntuExtraActionHandler()
1724-{
1725- g_clear_pointer(&m_introspection_data, g_dbus_node_info_unref);
1726-}
1727-
1728-bool QtUbuntuExtraActionHandler::connect(GDBusConnection *connection, const QByteArray &menuPath, UbuntuGMenuModelExporter *gmenuexporter)
1729-{
1730- if (m_registration_id != 0) {
1731- qCWarning(ubuntuappmenu, "Called connect in an already connected QtUbuntuExtraActionHandler");
1732- return false;
1733- }
1734-
1735- GError *error = nullptr;
1736- m_registration_id = g_dbus_connection_register_object (connection, menuPath.constData(),
1737- m_introspection_data->interfaces[0],
1738- &interface_vtable,
1739- gmenuexporter,
1740- nullptr,
1741- &error);
1742-
1743- if (!m_registration_id) {
1744- qCWarning(ubuntuappmenu, "Failed to extra actions - %s", error ? error->message : "unknown error");
1745- g_clear_error(&error);
1746- }
1747-
1748- return m_registration_id != 0;
1749-}
1750-
1751-void QtUbuntuExtraActionHandler::disconnect(GDBusConnection *connection) {
1752- if (m_registration_id) {
1753- g_dbus_connection_unregister_object (connection, m_registration_id);
1754- }
1755-}
1756
1757=== removed file 'src/ubuntuappmenu/qtubuntuextraactionhandler.h'
1758--- src/ubuntuappmenu/qtubuntuextraactionhandler.h 2017-03-06 16:19:29 +0000
1759+++ src/ubuntuappmenu/qtubuntuextraactionhandler.h 1970-01-01 00:00:00 +0000
1760@@ -1,40 +0,0 @@
1761-/*
1762- * Copyright (C) 2017 Canonical, Ltd.
1763- *
1764- * This program is free software: you can redistribute it and/or modify it under
1765- * the terms of the GNU Lesser General Public License version 3, as published by
1766- * the Free Software Foundation.
1767- *
1768- * This program is distributed in the hope that it will be useful, but WITHOUT
1769- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1770- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1771- * Lesser General Public License for more details.
1772- *
1773- * You should have received a copy of the GNU Lesser General Public License
1774- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1775- */
1776-
1777-#ifndef QTUBUNTUEXTRAACTIONHANDLER_H
1778-#define QTUBUNTUEXTRAACTIONHANDLER_H
1779-
1780-#include <gio/gio.h>
1781-
1782-class QByteArray;
1783-
1784-class UbuntuGMenuModelExporter;
1785-
1786-class QtUbuntuExtraActionHandler
1787-{
1788-public:
1789- QtUbuntuExtraActionHandler();
1790- ~QtUbuntuExtraActionHandler();
1791-
1792- bool connect(GDBusConnection *connection, const QByteArray &menuPath, UbuntuGMenuModelExporter *gmenuexporter);
1793- void disconnect(GDBusConnection *connection);
1794-
1795-private:
1796- GDBusNodeInfo *m_introspection_data;
1797- guint m_registration_id;
1798-};
1799-
1800-#endif
1801
1802=== removed file 'src/ubuntuappmenu/registry.cpp'
1803--- src/ubuntuappmenu/registry.cpp 2016-09-29 15:12:29 +0000
1804+++ src/ubuntuappmenu/registry.cpp 1970-01-01 00:00:00 +0000
1805@@ -1,97 +0,0 @@
1806-/*
1807- * Copyright (C) 2016 Canonical, Ltd.
1808- *
1809- * This program is free software: you can redistribute it and/or modify it under
1810- * the terms of the GNU Lesser General Public License version 3, as published by
1811- * the Free Software Foundation.
1812- *
1813- * This program is distributed in the hope that it will be useful, but WITHOUT
1814- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1815- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1816- * Lesser General Public License for more details.
1817- *
1818- * You should have received a copy of the GNU Lesser General Public License
1819- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1820- */
1821-
1822-#include "registry.h"
1823-#include "logging.h"
1824-#include "menuregistrar_interface.h"
1825-
1826-#include <QDBusObjectPath>
1827-#include <QDBusServiceWatcher>
1828-
1829-Q_LOGGING_CATEGORY(ubuntuappmenuRegistrar, "ubuntuappmenu.registrar", QtWarningMsg)
1830-
1831-#define REGISTRAR_SERVICE "com.ubuntu.MenuRegistrar"
1832-#define REGISTRY_OBJECT_PATH "/com/ubuntu/MenuRegistrar"
1833-
1834-UbuntuMenuRegistry *UbuntuMenuRegistry::instance()
1835-{
1836- static UbuntuMenuRegistry* registry(new UbuntuMenuRegistry());
1837- return registry;
1838-}
1839-
1840-UbuntuMenuRegistry::UbuntuMenuRegistry(QObject* parent)
1841- : QObject(parent)
1842- , m_serviceWatcher(new QDBusServiceWatcher(REGISTRAR_SERVICE, QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this))
1843- , m_interface(new ComUbuntuMenuRegistrarInterface(REGISTRAR_SERVICE, REGISTRY_OBJECT_PATH, QDBusConnection::sessionBus(), this))
1844- , m_connected(m_interface->isValid())
1845-{
1846- connect(m_serviceWatcher.data(), &QDBusServiceWatcher::serviceOwnerChanged, this, &UbuntuMenuRegistry::serviceOwnerChanged);
1847-}
1848-
1849-UbuntuMenuRegistry::~UbuntuMenuRegistry()
1850-{
1851-}
1852-
1853-void UbuntuMenuRegistry::registerApplicationMenu(pid_t pid, QDBusObjectPath menuObjectPath, const QString &service)
1854-{
1855- qCDebug(ubuntuappmenuRegistrar, "UbuntuMenuRegistry::registerMenu(pid=%d, menuObjectPath=%s, service=%s)",
1856- pid,
1857- qPrintable(menuObjectPath.path()),
1858- qPrintable(service));
1859-
1860- m_interface->RegisterAppMenu(pid, menuObjectPath, menuObjectPath, service);
1861-}
1862-
1863-void UbuntuMenuRegistry::unregisterApplicationMenu(pid_t pid, QDBusObjectPath menuObjectPath)
1864-{
1865- qCDebug(ubuntuappmenuRegistrar, "UbuntuMenuRegistry::unregisterSurfaceMenu(pid=%d, menuObjectPath=%s)",
1866- pid,
1867- qPrintable(menuObjectPath.path()));
1868-
1869- m_interface->UnregisterAppMenu(pid, menuObjectPath);
1870-}
1871-
1872-void UbuntuMenuRegistry::registerSurfaceMenu(const QString &surfaceId, QDBusObjectPath menuObjectPath, const QString &service)
1873-{
1874- qCDebug(ubuntuappmenuRegistrar, "UbuntuMenuRegistry::registerMenu(surfaceId=%s, menuObjectPath=%s, service=%s)",
1875- qPrintable(surfaceId),
1876- qPrintable(menuObjectPath.path()),
1877- qPrintable(service));
1878-
1879- m_interface->RegisterSurfaceMenu(surfaceId, menuObjectPath, menuObjectPath, service);
1880-}
1881-
1882-void UbuntuMenuRegistry::unregisterSurfaceMenu(const QString &surfaceId, QDBusObjectPath menuObjectPath)
1883-{
1884- qCDebug(ubuntuappmenuRegistrar, "UbuntuMenuRegistry::unregisterSurfaceMenu(surfaceId=%s, menuObjectPath=%s)",
1885- qPrintable(surfaceId),
1886- qPrintable(menuObjectPath.path()));
1887-
1888- m_interface->UnregisterSurfaceMenu(surfaceId, menuObjectPath);
1889-}
1890-
1891-
1892-void UbuntuMenuRegistry::serviceOwnerChanged(const QString &serviceName, const QString& oldOwner, const QString &newOwner)
1893-{
1894- qCDebug(ubuntuappmenuRegistrar, "UbuntuMenuRegistry::serviceOwnerChanged(newOwner=%s)", qPrintable(newOwner));
1895-
1896- if (serviceName != REGISTRAR_SERVICE) return;
1897-
1898- if (oldOwner != newOwner) {
1899- m_connected = !newOwner.isEmpty();
1900- Q_EMIT serviceChanged();
1901- }
1902-}
1903
1904=== removed file 'src/ubuntuappmenu/registry.h'
1905--- src/ubuntuappmenu/registry.h 2016-09-29 15:03:17 +0000
1906+++ src/ubuntuappmenu/registry.h 1970-01-01 00:00:00 +0000
1907@@ -1,56 +0,0 @@
1908-/*
1909- * Copyright (C) 2016 Canonical, Ltd.
1910- *
1911- * This program is free software: you can redistribute it and/or modify it under
1912- * the terms of the GNU Lesser General Public License version 3, as published by
1913- * the Free Software Foundation.
1914- *
1915- * This program is distributed in the hope that it will be useful, but WITHOUT
1916- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1917- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1918- * Lesser General Public License for more details.
1919- *
1920- * You should have received a copy of the GNU Lesser General Public License
1921- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1922- */
1923-
1924-#ifndef UBUNTU_MENU_REGISTRY_H
1925-#define UBUNTU_MENU_REGISTRY_H
1926-
1927-#include <QObject>
1928-#include <QScopedPointer>
1929-
1930-class ComUbuntuMenuRegistrarInterface;
1931-class QDBusObjectPath;
1932-class QDBusServiceWatcher;
1933-
1934-class UbuntuMenuRegistry : public QObject
1935-{
1936- Q_OBJECT
1937-public:
1938- UbuntuMenuRegistry(QObject* parent = nullptr);
1939- virtual ~UbuntuMenuRegistry();
1940-
1941- static UbuntuMenuRegistry *instance();
1942-
1943- void registerApplicationMenu(pid_t pid, QDBusObjectPath menuObjectPath, const QString &service);
1944- void unregisterApplicationMenu(pid_t pid, QDBusObjectPath menuObjectPath);
1945-
1946- void registerSurfaceMenu(const QString &surfaceId, QDBusObjectPath menuObjectPath, const QString &service);
1947- void unregisterSurfaceMenu(const QString &surfaceId, QDBusObjectPath menuObjectPath);
1948-
1949- bool isConnected() const { return m_connected; }
1950-
1951-Q_SIGNALS:
1952- void serviceChanged();
1953-
1954-private Q_SLOTS:
1955- void serviceOwnerChanged(const QString &serviceName, const QString& oldOwner, const QString &newOwner);
1956-
1957-private:
1958- QScopedPointer<QDBusServiceWatcher> m_serviceWatcher;
1959- QScopedPointer<ComUbuntuMenuRegistrarInterface> m_interface;
1960- bool m_connected;
1961-};
1962-
1963-#endif // UBUNTU_MENU_REGISTRY_H
1964
1965=== renamed file 'src/ubuntuappmenu/theme.cpp' => 'src/ubuntuappmenu/theme.cpp.THIS'
1966=== renamed file 'src/ubuntuappmenu/theme.h' => 'src/ubuntuappmenu/theme.h.THIS'
1967=== removed file 'src/ubuntuappmenu/themeplugin.cpp'
1968--- src/ubuntuappmenu/themeplugin.cpp 2016-09-29 15:03:17 +0000
1969+++ src/ubuntuappmenu/themeplugin.cpp 1970-01-01 00:00:00 +0000
1970@@ -1,36 +0,0 @@
1971-/*
1972- * Copyright (C) 2016 Canonical, Ltd.
1973- *
1974- * This program is free software: you can redistribute it and/or modify it under
1975- * the terms of the GNU Lesser General Public License version 3, as published by
1976- * the Free Software Foundation.
1977- *
1978- * This program is distributed in the hope that it will be useful, but WITHOUT
1979- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
1980- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1981- * Lesser General Public License for more details.
1982- *
1983- * You should have received a copy of the GNU Lesser General Public License
1984- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1985- */
1986-
1987-#include "themeplugin.h"
1988-#include "theme.h"
1989-
1990-#include <QDebug>
1991-
1992-///////////////////////////////////////////////////////////
1993-
1994-UbuntuAppMenuThemePlugin::UbuntuAppMenuThemePlugin(QObject *parent)
1995- : QPlatformThemePlugin(parent)
1996-{
1997-}
1998-
1999-QPlatformTheme *
2000-UbuntuAppMenuThemePlugin::create(const QString &key, const QStringList&)
2001-{
2002- if (key.compare(QLatin1String(UbuntuAppMenuTheme::name), Qt::CaseInsensitive))
2003- return 0;
2004-
2005- return new UbuntuAppMenuTheme();
2006-}
2007
2008=== removed file 'src/ubuntuappmenu/themeplugin.h'
2009--- src/ubuntuappmenu/themeplugin.h 2016-06-21 16:33:19 +0000
2010+++ src/ubuntuappmenu/themeplugin.h 1970-01-01 00:00:00 +0000
2011@@ -1,34 +0,0 @@
2012-/*
2013- * Copyright (C) 2016 Canonical, Ltd.
2014- *
2015- * This program is free software: you can redistribute it and/or modify it under
2016- * the terms of the GNU Lesser General Public License version 3, as published by
2017- * the Free Software Foundation.
2018- *
2019- * This program is distributed in the hope that it will be useful, but WITHOUT
2020- * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
2021- * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2022- * Lesser General Public License for more details.
2023- *
2024- * You should have received a copy of the GNU Lesser General Public License
2025- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2026- */
2027-
2028-#ifndef UBUNTUTHEMEPLUGIN_H
2029-#define UBUNTUTHEMEPLUGIN_H
2030-
2031-#include <qpa/qplatformthemeplugin.h>
2032-
2033-class UbuntuAppMenuThemePlugin : public QPlatformThemePlugin
2034-{
2035- Q_OBJECT
2036- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1" FILE "ubuntuappmenu.json")
2037-public:
2038- UbuntuAppMenuThemePlugin(QObject *parent = 0);
2039-
2040- virtual QPlatformTheme *create(const QString &key, const QStringList &paramList);
2041-
2042- static const char *name;
2043-};
2044-
2045-#endif
2046
2047=== removed file 'src/ubuntuappmenu/ubuntuappmenu.json'
2048--- src/ubuntuappmenu/ubuntuappmenu.json 2016-06-21 16:33:19 +0000
2049+++ src/ubuntuappmenu/ubuntuappmenu.json 1970-01-01 00:00:00 +0000
2050@@ -1,3 +0,0 @@
2051-{
2052- "Keys": [ "ubuntuappmenu" ]
2053-}
2054
2055=== renamed file 'src/ubuntuappmenu/ubuntuappmenu.pro' => 'src/ubuntuappmenu/ubuntuappmenu.pro.THIS'
2056=== modified file 'src/ubuntumirclient/qmirclientintegration.cpp'
2057--- src/ubuntumirclient/qmirclientintegration.cpp 2017-05-31 19:29:51 +0000
2058+++ src/ubuntumirclient/qmirclientintegration.cpp 2017-05-31 19:29:52 +0000
2059@@ -66,62 +66,95 @@
2060 #include <QOpenGLContext>
2061 #include <QOffscreenSurface>
2062
2063+<<<<<<< TREE
2064 // platform-api
2065 #include <ubuntu/application/lifecycle_delegate.h>
2066 #include <ubuntu/application/id.h>
2067 #include <ubuntu/application/options.h>
2068
2069 static void resumedCallback(const UApplicationOptions */*options*/, void *context)
2070-{
2071- auto integration = static_cast<QMirClientClientIntegration*>(context);
2072- integration->appStateController()->setResumed();
2073+=======
2074+namespace
2075+{
2076+class UbuntuIconTheme : public QGenericUnixTheme
2077+{
2078+public:
2079+ UbuntuIconTheme()
2080+ {}
2081+
2082+ // From QPlatformTheme
2083+ QVariant themeHint(ThemeHint hint) const override
2084+ {
2085+ if (hint == QPlatformTheme::SystemIconThemeName)
2086+ {
2087+ QByteArray iconTheme = qgetenv("QTUBUNTU_ICON_THEME");
2088+ if (iconTheme.isEmpty())
2089+ {
2090+ return QVariant(QStringLiteral("ubuntu-mobile"));
2091+ }
2092+ else
2093+ {
2094+ return QVariant(QString(iconTheme));
2095+ }
2096+ }
2097+ else
2098+ {
2099+ return QGenericUnixTheme::themeHint(hint);
2100+ }
2101+ }
2102+};
2103+
2104+QByteArray generateSessionNameFromQmlFile(QStringList &args)
2105+>>>>>>> MERGE-SOURCE
2106+{
2107+ Q_FOREACH (QString arg, args) {
2108+ if (arg.endsWith(".qml")) {
2109+ QFileInfo fileInfo(arg);
2110+ return fileInfo.fileName().toLocal8Bit();
2111+ }
2112+ }
2113+
2114+ // give up
2115+ return "qmlscene";
2116 }
2117
2118-static void aboutToStopCallback(UApplicationArchive */*archive*/, void *context)
2119+QByteArray generateSessionName(QStringList args)
2120 {
2121- auto integration = static_cast<QMirClientClientIntegration*>(context);
2122- auto inputContext = integration->inputContext();
2123- if (inputContext) {
2124- inputContext->hideInputPanel();
2125+ // Try to come up with some meaningful session name to uniquely identify this session,
2126+ // helping with shell debugging
2127+ if (args.count() == 0) {
2128+ return QByteArray("QtUbuntu");
2129+ } if (args[0].contains("qmlscene")) {
2130+ return generateSessionNameFromQmlFile(args);
2131 } else {
2132- qCWarning(mirclient) << "aboutToStopCallback(): no input context";
2133+ // use the executable name
2134+ QFileInfo fileInfo(args[0]);
2135+ return fileInfo.fileName().toLocal8Bit();
2136 }
2137- integration->appStateController()->setSuspended();
2138 }
2139
2140+MirConnection *make_mir_connection()
2141+{
2142+ auto sessionName = generateSessionName(QCoreApplication::arguments());
2143+ auto mirConnection = mir_connect_sync(nullptr, sessionName.data());
2144+ if (!mir_connection_is_valid(mirConnection))
2145+ {
2146+ qCritical("Mir returned: \"%s\"", mir_connection_get_error_message(mirConnection));
2147+ mir_connection_release(mirConnection);
2148+ exit(EXIT_FAILURE);
2149+ }
2150+ return mirConnection;
2151+}
2152+}
2153
2154 QMirClientClientIntegration::QMirClientClientIntegration(int argc, char **argv)
2155 : QPlatformIntegration()
2156 , mNativeInterface(new QMirClientNativeInterface(this))
2157 , mFontDb(new QGenericUnixFontDatabase)
2158- , mServices(new QMirClientPlatformServices)
2159 , mAppStateController(new QMirClientAppStateController)
2160 , mScaleFactor(1.0)
2161+ , mMirConnection(make_mir_connection())
2162 {
2163- QByteArray sessionName;
2164- {
2165- QStringList args = QCoreApplication::arguments();
2166- setupOptions(args);
2167- sessionName = generateSessionName(args);
2168- setupDescription(sessionName);
2169- }
2170-
2171- // Create new application instance
2172- mInstance = u_application_instance_new_from_description_with_options(mDesc, mOptions);
2173-
2174- if (mInstance == nullptr) {
2175- qCritical("[QPA] QMirClientClientIntegration: connection to Mir server failed.\n");
2176-
2177- // TODO: add API to platform-api to fetch Mir's error message (bug:1655970).
2178- // Workaround by retrying the connection here in order to get the message.
2179- auto mirConnection = mir_connect_sync(nullptr, sessionName.data());
2180- qCritical("Mir returned: \"%s\"", mir_connection_get_error_message(mirConnection));
2181- mir_connection_release(mirConnection);
2182- exit(EXIT_FAILURE);
2183- }
2184-
2185- mMirConnection = u_application_instance_get_mir_connection(mInstance);
2186-
2187 // Choose the default surface format suited to the Mir platform
2188 QSurfaceFormat defaultFormat;
2189 defaultFormat.setRedBufferSize(8);
2190@@ -184,70 +217,7 @@
2191 eglTerminate(mEglDisplay);
2192 delete mInput;
2193 delete mInputContext;
2194- delete mServices;
2195-}
2196-
2197-QPlatformServices *QMirClientClientIntegration::services() const
2198-{
2199- return mServices;
2200-}
2201-
2202-void QMirClientClientIntegration::setupOptions(QStringList &args)
2203-{
2204- int argc = args.size() + 1;
2205- char **argv = new char*[argc];
2206- for (int i = 0; i < argc - 1; i++)
2207- argv[i] = qstrdup(args.at(i).toLocal8Bit());
2208- argv[argc - 1] = nullptr;
2209-
2210- mOptions = u_application_options_new_from_cmd_line(argc - 1, argv);
2211-
2212- for (int i = 0; i < argc; i++)
2213- delete [] argv[i];
2214- delete [] argv;
2215-}
2216-
2217-void QMirClientClientIntegration::setupDescription(QByteArray &sessionName)
2218-{
2219- mDesc = u_application_description_new();
2220-
2221- UApplicationId* id = u_application_id_new_from_stringn(sessionName.data(), sessionName.count());
2222- u_application_description_set_application_id(mDesc, id);
2223-
2224- UApplicationLifecycleDelegate* delegate = u_application_lifecycle_delegate_new();
2225- u_application_lifecycle_delegate_set_application_resumed_cb(delegate, &resumedCallback);
2226- u_application_lifecycle_delegate_set_application_about_to_stop_cb(delegate, &aboutToStopCallback);
2227- u_application_lifecycle_delegate_set_context(delegate, this);
2228- u_application_description_set_application_lifecycle_delegate(mDesc, delegate);
2229-}
2230-
2231-QByteArray QMirClientClientIntegration::generateSessionName(QStringList &args)
2232-{
2233- // Try to come up with some meaningful session name to uniquely identify this session,
2234- // helping with shell debugging
2235-
2236- if (args.count() == 0) {
2237- return QByteArray("QtUbuntu");
2238- } if (args[0].contains("qmlscene")) {
2239- return generateSessionNameFromQmlFile(args);
2240- } else {
2241- // use the executable name
2242- QFileInfo fileInfo(args[0]);
2243- return fileInfo.fileName().toLocal8Bit();
2244- }
2245-}
2246-
2247-QByteArray QMirClientClientIntegration::generateSessionNameFromQmlFile(QStringList &args)
2248-{
2249- Q_FOREACH (QString arg, args) {
2250- if (arg.endsWith(".qml")) {
2251- QFileInfo fileInfo(arg);
2252- return fileInfo.fileName().toLocal8Bit();
2253- }
2254- }
2255-
2256- // give up
2257- return "qmlscene";
2258+ mir_connection_release(mMirConnection);
2259 }
2260
2261 QPlatformWindow* QMirClientClientIntegration::createPlatformWindow(QWindow* window) const
2262
2263=== modified file 'src/ubuntumirclient/qmirclientintegration.h'
2264--- src/ubuntumirclient/qmirclientintegration.h 2017-05-31 19:29:51 +0000
2265+++ src/ubuntumirclient/qmirclientintegration.h 2017-05-31 19:29:52 +0000
2266@@ -45,13 +45,8 @@
2267 #include <QSharedPointer>
2268
2269 #include "qmirclientappstatecontroller.h"
2270-#include "qmirclientplatformservices.h"
2271 #include "qmirclientscreenobserver.h"
2272
2273-// platform-api
2274-#include <ubuntu/application/description.h>
2275-#include <ubuntu/application/instance.h>
2276-
2277 #include <EGL/egl.h>
2278
2279 class QMirClientDebugExtension;
2280@@ -78,7 +73,6 @@
2281 QStringList themeNames() const override;
2282 QPlatformTheme* createPlatformTheme(const QString& name) const override;
2283 QVariant styleHint(StyleHint hint) const override;
2284- QPlatformServices *services() const override;
2285 QPlatformWindow* createPlatformWindow(QWindow* window) const override;
2286 QPlatformInputContext* inputContext() const override { return mInputContext; }
2287 QPlatformClipboard* clipboard() const override;
2288@@ -100,14 +94,10 @@
2289 private:
2290 void setupOptions(QStringList &args);
2291 void setupDescription(QByteArray &sessionName);
2292- static QByteArray generateSessionName(QStringList &args);
2293- static QByteArray generateSessionNameFromQmlFile(QStringList &args);
2294
2295 QMirClientNativeInterface* mNativeInterface;
2296 QPlatformFontDatabase* mFontDb;
2297
2298- QMirClientPlatformServices* mServices;
2299-
2300 QMirClientInput* mInput;
2301 QPlatformInputContext* mInputContext;
2302 mutable QScopedPointer<QPlatformAccessibility> mAccessibility;
2303@@ -118,11 +108,6 @@
2304
2305 MirConnection *mMirConnection;
2306
2307- // Platform API stuff
2308- UApplicationOptions* mOptions;
2309- UApplicationDescription* mDesc;
2310- UApplicationInstance* mInstance;
2311-
2312 // EGL related
2313 EGLDisplay mEglDisplay{EGL_NO_DISPLAY};
2314 };
2315
2316=== removed file 'src/ubuntumirclient/qmirclientplatformservices.cpp'
2317--- src/ubuntumirclient/qmirclientplatformservices.cpp 2017-02-07 15:37:20 +0000
2318+++ src/ubuntumirclient/qmirclientplatformservices.cpp 1970-01-01 00:00:00 +0000
2319@@ -1,75 +0,0 @@
2320-/****************************************************************************
2321-**
2322-** Copyright (C) 2016 Canonical, Ltd.
2323-** Contact: https://www.qt.io/licensing/
2324-**
2325-** This file is part of the plugins of the Qt Toolkit.
2326-**
2327-** $QT_BEGIN_LICENSE:LGPL$
2328-** Commercial License Usage
2329-** Licensees holding valid commercial Qt licenses may use this file in
2330-** accordance with the commercial license agreement provided with the
2331-** Software or, alternatively, in accordance with the terms contained in
2332-** a written agreement between you and The Qt Company. For licensing terms
2333-** and conditions see https://www.qt.io/terms-conditions. For further
2334-** information use the contact form at https://www.qt.io/contact-us.
2335-**
2336-** GNU Lesser General Public License Usage
2337-** Alternatively, this file may be used under the terms of the GNU Lesser
2338-** General Public License version 3 as published by the Free Software
2339-** Foundation and appearing in the file LICENSE.LGPL3 included in the
2340-** packaging of this file. Please review the following information to
2341-** ensure the GNU Lesser General Public License version 3 requirements
2342-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
2343-**
2344-** GNU General Public License Usage
2345-** Alternatively, this file may be used under the terms of the GNU
2346-** General Public License version 2.0 or (at your option) the GNU General
2347-** Public license version 3 or any later version approved by the KDE Free
2348-** Qt Foundation. The licenses are as published by the Free Software
2349-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
2350-** included in the packaging of this file. Please review the following
2351-** information to ensure the GNU General Public License requirements will
2352-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
2353-** https://www.gnu.org/licenses/gpl-3.0.html.
2354-**
2355-** $QT_END_LICENSE$
2356-**
2357-****************************************************************************/
2358-
2359-
2360-#include "qmirclientplatformservices.h"
2361-
2362-#include <QUrl>
2363-
2364-#include <ubuntu/application/url_dispatcher/service.h>
2365-#include <ubuntu/application/url_dispatcher/session.h>
2366-
2367-bool QMirClientPlatformServices::openUrl(const QUrl &url)
2368-{
2369- return callDispatcher(url);
2370-}
2371-
2372-bool QMirClientPlatformServices::openDocument(const QUrl &url)
2373-{
2374- return callDispatcher(url);
2375-}
2376-
2377-bool QMirClientPlatformServices::callDispatcher(const QUrl &url)
2378-{
2379- UAUrlDispatcherSession* session = ua_url_dispatcher_session();
2380- if (!session)
2381- return false;
2382-
2383- ua_url_dispatcher_session_open(session, url.toEncoded().constData(), NULL, NULL);
2384-
2385- free(session);
2386-
2387- // We are returning true here because the other option
2388- // is spawning a nested event loop and wait for the
2389- // callback. But there is no guarantee on how fast
2390- // the callback is going to be so we prefer to avoid the
2391- // nested event loop. Long term plan is improve Qt API
2392- // to support an async openUrl
2393- return true;
2394-}
2395
2396=== removed file 'src/ubuntumirclient/qmirclientplatformservices.h'
2397--- src/ubuntumirclient/qmirclientplatformservices.h 2017-02-07 15:37:20 +0000
2398+++ src/ubuntumirclient/qmirclientplatformservices.h 1970-01-01 00:00:00 +0000
2399@@ -1,57 +0,0 @@
2400-/****************************************************************************
2401-**
2402-** Copyright (C) 2016 Canonical, Ltd.
2403-** Contact: https://www.qt.io/licensing/
2404-**
2405-** This file is part of the plugins of the Qt Toolkit.
2406-**
2407-** $QT_BEGIN_LICENSE:LGPL$
2408-** Commercial License Usage
2409-** Licensees holding valid commercial Qt licenses may use this file in
2410-** accordance with the commercial license agreement provided with the
2411-** Software or, alternatively, in accordance with the terms contained in
2412-** a written agreement between you and The Qt Company. For licensing terms
2413-** and conditions see https://www.qt.io/terms-conditions. For further
2414-** information use the contact form at https://www.qt.io/contact-us.
2415-**
2416-** GNU Lesser General Public License Usage
2417-** Alternatively, this file may be used under the terms of the GNU Lesser
2418-** General Public License version 3 as published by the Free Software
2419-** Foundation and appearing in the file LICENSE.LGPL3 included in the
2420-** packaging of this file. Please review the following information to
2421-** ensure the GNU Lesser General Public License version 3 requirements
2422-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
2423-**
2424-** GNU General Public License Usage
2425-** Alternatively, this file may be used under the terms of the GNU
2426-** General Public License version 2.0 or (at your option) the GNU General
2427-** Public license version 3 or any later version approved by the KDE Free
2428-** Qt Foundation. The licenses are as published by the Free Software
2429-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
2430-** included in the packaging of this file. Please review the following
2431-** information to ensure the GNU General Public License requirements will
2432-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
2433-** https://www.gnu.org/licenses/gpl-3.0.html.
2434-**
2435-** $QT_END_LICENSE$
2436-**
2437-****************************************************************************/
2438-
2439-
2440-#ifndef QMIRCLIENTPLATFORMSERVICES_H
2441-#define QMIRCLIENTPLATFORMSERVICES_H
2442-
2443-#include <qpa/qplatformservices.h>
2444-#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
2445-#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
2446-
2447-class QMirClientPlatformServices : public QPlatformServices {
2448-public:
2449- bool openUrl(const QUrl &url) override;
2450- bool openDocument(const QUrl &url) override;
2451-
2452-private:
2453- bool callDispatcher(const QUrl &url);
2454-};
2455-
2456-#endif // QMIRCLIENTPLATFORMSERVICES_H
2457
2458=== modified file 'src/ubuntumirclient/ubuntumirclient.pro'
2459--- src/ubuntumirclient/ubuntumirclient.pro 2017-05-31 19:29:51 +0000
2460+++ src/ubuntumirclient/ubuntumirclient.pro 2017-05-31 19:29:52 +0000
2461@@ -24,7 +24,6 @@
2462 qmirclientinput.cpp \
2463 qmirclientintegration.cpp \
2464 qmirclientnativeinterface.cpp \
2465- qmirclientplatformservices.cpp \
2466 qmirclientplugin.cpp \
2467 qmirclientscreen.cpp \
2468 qmirclientscreenobserver.cpp \
2469@@ -42,7 +41,6 @@
2470 qmirclientintegration.h \
2471 qmirclientnativeinterface.h \
2472 qmirclientorientationchangeevent_p.h \
2473- qmirclientplatformservices.h \
2474 qmirclientplugin.h \
2475 qmirclientscreenobserver.h \
2476 qmirclientscreen.h \

Subscribers

People subscribed via source and target branches