| 1 | /* |
| 2 | * Copyright (C) 2016 Canonical, Ltd. |
| 3 | * |
| 4 | * This program is free software: you can redistribute it and/or modify it under |
| 5 | * the terms of the GNU Lesser General Public License version 3, as published by |
| 6 | * the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 9 | * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
| 10 | * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | * Lesser General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU Lesser General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ |
| 16 | |
| 17 | // Local |
| 18 | #include "gmenumodelexporter.h"cxx . . $ `<file>/src/lomiriappmenu/gmenumodelexporter.h`/ |
| 19 | #include "registry.h"cxx . . $ `<file>/src/lomiriappmenu/registry.h`/ |
| 20 | #include "logging.h"cxx . . $ `<file>/src/lomiriappmenu/logging.h`/ |
| 21 | #include "lomiriappmenuextraactionhandler.h"cxx . . $ `<file>/src/lomiriappmenu/lomiriappmenuextraactionhandler.h`/ |
| 22 | |
| 23 | #include <QDebug> |
| 24 | #include <QTimerEvent> |
| 25 | |
| 26 | #include <functional> |
| 27 | |
| 28 | namespacecxx . . $ `$anonymous_namespace_src/lomiriappmenu/gmenumodelexporter.cpp`/ { |
| 29 | |
| 30 | // Derive an action name from the label by removing spaces and Capitilizing the words. |
| 31 | // Also remove mnemonics from the label. |
| 32 | inline QStringcxx . . $ QString# getActionStringcxx . . $ `$anonymous_namespace_src/lomiriappmenu/gmenumodelexporter.cpp`/getActionString(f7f320d754b8fd09).(QStringcxx . . $ QString# label) |
| 33 | { |
| 34 | QRegExpcxx . . $ QRegExp# recxx . . $ QRegExp#QRegExp(31e086911ff70bd0).("\\W"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 35 | label =cxx . . $ QString#`operator=`(6a89d0b7f4d2681c). label.replacecxx . . $ QString#replace(612862c8abff0ba5).(QRegExpcxx . . $ QRegExp#QRegExp(31e086911ff70bd0).("(&|_)"cxx . . $ QString#QString(85c52e162fed56f9).), ""cxx . . $ QString#QString(85c52e162fed56f9).); |
| 36 | QStringListcxx . . $ QStringList# parts = label.splitcxx . . $ QString#split(1b2294238e90052a).(re, Qtcxx . . $ QFlags#QFlags(9b289cee16747614).::SkipEmptyPartscxx . . $ Qt/SkipEmptyParts.); |
| 37 | |
| 38 | QStringcxx . . $ QString# resultcxx . . $ QString#QString(49f6e7a06ebc5aa8).; |
| 39 | Q_FOREACHcxx . . $ `<external>/15045578679651060896/qglobal.h:1137:9`!(const QString& part, parts) { |
| 40 | result +=cxx . . $ QString#`operator+=`(3a2ffbdf8ecc25e2). part[cxx . . $ QString#`operator[]`(13af7ae5a875439e).0].toUppercxx . . $ QChar#toUpper(ae16b0053a7bf832).(); |
| 41 | result +=cxx . . $ QString#`operator+=`(6a89d0b7f4d2681c). part.rightcxx . . $ QString#right(3f3c3d0e9c0eb37f).(part.lengthcxx . . $ QString#length(455f465bc33b4cdf).()-1); |
| 42 | } |
| 43 | return resultcxx . . $ QString#QString(e1217c004a86c950).; |
| 44 | } |
| 45 | |
| 46 | static void activate_cbcxx . . $ `$anonymous_namespace_src/lomiriappmenu/gmenumodelexporter.cpp`/activate_cb(679672dd5b90f6e2).(GSimpleAction *action, GVariant *, gpointer user_data) |
| 47 | { |
| 48 | qCDebugcxx . . $ `<external>/13903568758641964362/qloggingcategory.h:122:11`!(lomiriappmenu, "Activate menu action '%s'", g_action_get_name(G_ACTIONcxx . . $ `<external>/4927576621387421614/gaction.h:34:9`!(action))); |
| 49 | auto item = static_cast<LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#*>(user_data); |
| 50 | item->activatedcxx . . $ QPlatformMenuItem#activated(49f6e7a06ebc5aa8).(); |
| 51 | } |
| 52 | |
| 53 | static uintcxx . . $ uint# s_menuIdcxx . . $ `$anonymous_namespace_src/lomiriappmenu/gmenumodelexporter.cpp`/s_menuId. = 0; |
| 54 | |
| 55 | #define MENU_OBJECT_PATHcxx . . $ `src/lomiriappmenu/gmenumodelexporter.cpp:55:9`! "/com/lomiri/Menu/%1" |
| 56 | |
| 57 | } // namespace |
| 58 | |
| 59 | |
| 60 | LomiriMenuBarExportercxx . . $ LomiriMenuBarExporter#::LomiriMenuBarExportercxx . . $ LomiriMenuBarExporter#LomiriMenuBarExporter(160b59edbd50934f).(LomiriPlatformMenuBarcxx . . $ LomiriPlatformMenuBar# * bar) |
| 61 | : LomiriGMenuModelExportercxx . . $ LomiriGMenuModelExporter#LomiriGMenuModelExporter(749de1b6ae65bddd).(bar) |
| 62 | { |
| 63 | qCDebugcxx . . $ `<external>/13903568758641964362/qloggingcategory.h:122:11`!(lomiriappmenu, "LomiriMenuBarExporter::LomiriMenuBarExporter"); |
| 64 | |
| 65 | connectcxx . . $ QObject#connect(d9dbe0c0ad4eecec).(bar, &LomiriPlatformMenuBarcxx . . $ LomiriPlatformMenuBar#::structureChangedcxx . . $ LomiriPlatformMenuBar#structureChanged(49f6e7a06ebc5aa8)., this, [this]() { |
| 66 | m_structureTimercxx . . $ LomiriGMenuModelExporter#m_structureTimer..startcxx . . $ QTimer#start(49f6e7a06ebc5aa8).(); |
| 67 | }); |
| 68 | connectcxx . . $ QObject#connect(d9dbe0c0ad4eecec).(&m_structureTimercxx . . $ LomiriGMenuModelExporter#m_structureTimer., &QTimercxx . . $ QTimer#::timeoutcxx . . $ QTimer#timeout(32604d697c0ceadc)., this, [this, bar]() { |
| 69 | clearcxx . . $ LomiriGMenuModelExporter#clear(49f6e7a06ebc5aa8).(); |
| 70 | Q_FOREACHcxx . . $ `<external>/15045578679651060896/qglobal.h:1137:9`!(QPlatformMenu *platformMenu, bar->menus()) { |
| 71 | GMenuItem* item = createSubmenucxx . . $ LomiriGMenuModelExporter#createSubmenu(dd994908ccc0193c).(platformMenu, nullptr); |
| 72 | if (item) { |
| 73 | g_menu_append_item(m_gmainMenucxx . . $ LomiriGMenuModelExporter#m_gmainMenu., item); |
| 74 | g_object_unref(item); |
| 75 | } |
| 76 | |
| 77 | LomiriPlatformMenucxx . . $ LomiriPlatformMenu#* gplatformMenu = static_cast<LomiriPlatformMenucxx . . $ LomiriPlatformMenu#*>(platformMenu); |
| 78 | if (gplatformMenu) { |
| 79 | // Sadly we don't have a better way to propagate a enabled change in a top level menu |
| 80 | // than reseting the whole menubar |
| 81 | connectcxx . . $ QObject#connect(835f87066c895669).(gplatformMenu, &LomiriPlatformMenucxx . . $ LomiriPlatformMenu#::enabledChangedcxx . . $ LomiriPlatformMenu#enabledChanged(b45ddcbc8423892c)., bar, &LomiriPlatformMenuBarcxx . . $ LomiriPlatformMenuBar#::structureChangedcxx . . $ LomiriPlatformMenuBar#structureChanged(49f6e7a06ebc5aa8).); |
| 82 | } |
| 83 | } |
| 84 | }); |
| 85 | |
| 86 | connectcxx . . $ QObject#connect(d9dbe0c0ad4eecec).(bar, &LomiriPlatformMenuBarcxx . . $ LomiriPlatformMenuBar#::readycxx . . $ LomiriPlatformMenuBar#ready(49f6e7a06ebc5aa8)., this, [this]() { |
| 87 | exportModelscxx . . $ LomiriGMenuModelExporter#exportModels(49f6e7a06ebc5aa8).(); |
| 88 | }); |
| 89 | } |
| 90 | |
| 91 | LomiriMenuBarExportercxx . . $ LomiriMenuBarExporter#::~cxx . . $ LomiriMenuBarExporter#`~LomiriMenuBarExporter`(49f6e7a06ebc5aa8).LomiriMenuBarExportercxx . . $ LomiriMenuBarExporter#() |
| 92 | { |
| 93 | qCDebugcxx . . $ `<external>/13903568758641964362/qloggingcategory.h:122:11`!(lomiriappmenu, "LomiriMenuBarExporter::~LomiriMenuBarExporter"); |
| 94 | } |
| 95 | |
| 96 | LomiriMenuExportercxx . . $ LomiriMenuExporter#::LomiriMenuExportercxx . . $ LomiriMenuExporter#LomiriMenuExporter(3d7a177ea62bda99).(LomiriPlatformMenucxx . . $ LomiriPlatformMenu# *menu) |
| 97 | : LomiriGMenuModelExportercxx . . $ LomiriGMenuModelExporter#LomiriGMenuModelExporter(749de1b6ae65bddd).(menu) |
| 98 | { |
| 99 | qCDebugcxx . . $ `<external>/13903568758641964362/qloggingcategory.h:122:11`!(lomiriappmenu, "LomiriMenuExporter::LomiriMenuExporter"); |
| 100 | |
| 101 | connectcxx . . $ QObject#connect(d9dbe0c0ad4eecec).(menu, &LomiriPlatformMenucxx . . $ LomiriPlatformMenu#::structureChangedcxx . . $ LomiriPlatformMenu#structureChanged(49f6e7a06ebc5aa8)., this, [this]() { |
| 102 | m_structureTimercxx . . $ LomiriGMenuModelExporter#m_structureTimer..startcxx . . $ QTimer#start(49f6e7a06ebc5aa8).(); |
| 103 | }); |
| 104 | connectcxx . . $ QObject#connect(d9dbe0c0ad4eecec).(&m_structureTimercxx . . $ LomiriGMenuModelExporter#m_structureTimer., &QTimercxx . . $ QTimer#::timeoutcxx . . $ QTimer#timeout(32604d697c0ceadc)., this, [this, menu]() { |
| 105 | clearcxx . . $ LomiriGMenuModelExporter#clear(49f6e7a06ebc5aa8).(); |
| 106 | addSubmenuItemscxx . . $ LomiriGMenuModelExporter#addSubmenuItems(f42684d8d844e395).(menu, m_gmainMenucxx . . $ LomiriGMenuModelExporter#m_gmainMenu.); |
| 107 | }); |
| 108 | addSubmenuItemscxx . . $ LomiriGMenuModelExporter#addSubmenuItems(f42684d8d844e395).(menu, m_gmainMenucxx . . $ LomiriGMenuModelExporter#m_gmainMenu.); |
| 109 | } |
| 110 | |
| 111 | LomiriMenuExportercxx . . $ LomiriMenuExporter#::~cxx . . $ LomiriMenuExporter#`~LomiriMenuExporter`(49f6e7a06ebc5aa8).LomiriMenuExportercxx . . $ LomiriMenuExporter#() |
| 112 | { |
| 113 | qCDebugcxx . . $ `<external>/13903568758641964362/qloggingcategory.h:122:11`!(lomiriappmenu, "LomiriMenuExporter::~LomiriMenuExporter"); |
| 114 | } |
| 115 | |
| 116 | LomiriGMenuModelExportercxx . . $ LomiriGMenuModelExporter#::LomiriGMenuModelExportercxx . . $ LomiriGMenuModelExporter#LomiriGMenuModelExporter(749de1b6ae65bddd).(QObjectcxx . . $ QObject# *parent) |
| 117 | : QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(parent) |
| 118 | , m_connectioncxx . . $ LomiriGMenuModelExporter#m_connection.(nullptr) |
| 119 | , m_gmainMenucxx . . $ LomiriGMenuModelExporter#m_gmainMenu.(g_menu_new()) |
| 120 | , m_gactionGroupcxx . . $ LomiriGMenuModelExporter#m_gactionGroup.(g_simple_action_group_new()) |
| 121 | , m_exportedModelcxx . . $ LomiriGMenuModelExporter#m_exportedModel.(0) |
| 122 | , m_exportedActionscxx . . $ LomiriGMenuModelExporter#m_exportedActions.(0) |
| 123 | , m_lomiriAppMenuExtraHandlercxx . . $ LomiriGMenuModelExporter#m_lomiriAppMenuExtraHandler.(nullptr) |
| 124 | , m_menuPathcxx . . $ LomiriGMenuModelExporter#m_menuPath.(QStringLiteralcxx . . $ `<external>/2817157206922689722/qstringliteral.h:65:9`!(MENU_OBJECT_PATHcxx . . $ `src/lomiriappmenu/gmenumodelexporter.cpp:55:9`!).argcxx . . $ QString#arg(173a29139b43af1f).(s_menuIdcxx . . $ `$anonymous_namespace_src/lomiriappmenu/gmenumodelexporter.cpp`/s_menuId.++)) |
| 125 | { |
| 126 | m_structureTimercxx . . $ LomiriGMenuModelExporter#m_structureTimer..setSingleShotcxx . . $ QTimer#setSingleShot(b45ddcbc8423892c).(true); |
| 127 | m_structureTimercxx . . $ LomiriGMenuModelExporter#m_structureTimer..setIntervalcxx . . $ QTimer#setInterval(d4f767463ce0a6b3).(0); |
| 128 | } |
| 129 | |
| 130 | LomiriGMenuModelExportercxx . . $ LomiriGMenuModelExporter#::~cxx . . $ LomiriGMenuModelExporter#`~LomiriGMenuModelExporter`(49f6e7a06ebc5aa8).LomiriGMenuModelExportercxx . . $ LomiriGMenuModelExporter#() |
| 131 | { |
| 132 | unexportModelscxx . . $ LomiriGMenuModelExporter#unexportModels(49f6e7a06ebc5aa8).(); |
| 133 | clearcxx . . $ LomiriGMenuModelExporter#clear(49f6e7a06ebc5aa8).(); |
| 134 | |
| 135 | g_object_unref(m_gmainMenucxx . . $ LomiriGMenuModelExporter#m_gmainMenu.); |
| 136 | g_object_unref(m_gactionGroupcxx . . $ LomiriGMenuModelExporter#m_gactionGroup.); |
| 137 | } |
| 138 | |
| 139 | // Clear the menu and actions that have been created. |
| 140 | void LomiriGMenuModelExportercxx . . $ LomiriGMenuModelExporter#::clearcxx . . $ LomiriGMenuModelExporter#clear(49f6e7a06ebc5aa8).() |
| 141 | { |
| 142 | Q_FOREACHcxx . . $ `<external>/15045578679651060896/qglobal.h:1137:9`!(const QVector<QMetaObject::Connection>& menuPropertyConnections, m_propertyConnections) { |
| 143 | Q_FOREACHcxx . . $ `<external>/15045578679651060896/qglobal.h:1137:9`!(const QMetaObject::Connection& connection, menuPropertyConnections) { |
| 144 | QObjectcxx . . $ QObject#::disconnectcxx . . $ QObject#disconnect(14933e9feb207a26).(connection); |
| 145 | } |
| 146 | } |
| 147 | m_propertyConnectionscxx . . $ LomiriGMenuModelExporter#m_propertyConnections..clearcxx . . $ QHash#clear(49f6e7a06ebc5aa8).(); |
| 148 | |
| 149 | g_menu_remove_all(m_gmainMenucxx . . $ LomiriGMenuModelExporter#m_gmainMenu.); |
| 150 | |
| 151 | Q_FOREACHcxx . . $ `<external>/15045578679651060896/qglobal.h:1137:9`!(const QSet<QByteArray>& menuActions, m_actions) { |
| 152 | Q_FOREACHcxx . . $ `<external>/15045578679651060896/qglobal.h:1137:9`!(const QByteArray& action, menuActions) { |
| 153 | g_action_map_remove_action(G_ACTION_MAPcxx . . $ `<external>/8692053299015392416/gactionmap.h:35:9`!(m_gactionGroup), action.constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).()); |
| 154 | } |
| 155 | } |
| 156 | m_actionscxx . . $ LomiriGMenuModelExporter#m_actions..clearcxx . . $ QHash#clear(49f6e7a06ebc5aa8).(); |
| 157 | |
| 158 | m_gmenusForMenuscxx . . $ LomiriGMenuModelExporter#m_gmenusForMenus..clearcxx . . $ QHash#clear(49f6e7a06ebc5aa8).(); |
| 159 | } |
| 160 | |
| 161 | void LomiriGMenuModelExportercxx . . $ LomiriGMenuModelExporter#::timerEventcxx . . $ LomiriGMenuModelExporter#timerEvent(b9e57d1150f23bf5).(QTimerEventcxx . . $ QTimerEvent# *e) |
| 162 | { |
| 163 | // Find the menu, it's a very short list |
| 164 | auto it = m_reloadMenuTimerscxx . . $ LomiriGMenuModelExporter#m_reloadMenuTimers..begincxx . . $ QHash#begin(7fee0616348ed702).(); |
| 165 | for (; it !=cxx . . $ QHash#iterator#`operator!=`(d41b528a217b928). m_reloadMenuTimerscxx . . $ LomiriGMenuModelExporter#m_reloadMenuTimers..endcxx . . $ QHash#end(7fee0616348ed702).(); ++cxx . . $ QHash#iterator#operator++(61354937c9e9ad6b).it) { |
| 166 | if (e->timerIdcxx . . $ QTimerEvent#timerId(455f465bc33b4cdf).() == it.valuecxx . . $ QHash#iterator#value(51f62fb05f27f6a2).()) |
| 167 | break; |
| 168 | } |
| 169 | |
| 170 | if (it !=cxx . . $ QHash#iterator#`operator!=`(d41b528a217b928). m_reloadMenuTimerscxx . . $ LomiriGMenuModelExporter#m_reloadMenuTimers..endcxx . . $ QHash#end(7fee0616348ed702).()) { |
| 171 | LomiriPlatformMenucxx . . $ LomiriPlatformMenu#* gplatformMenu = it.keycxx . . $ QHash#iterator#key(ea465e50d690edfe).(); |
| 172 | GMenu *menu = m_gmenusForMenuscxx . . $ LomiriGMenuModelExporter#m_gmenusForMenus..valuecxx . . $ QHash#value(bfda1f1f965926d4).(gplatformMenu); |
| 173 | if (menu) { |
| 174 | Q_FOREACHcxx . . $ `<external>/15045578679651060896/qglobal.h:1137:9`!(const QMetaObject::Connection& connection, m_propertyConnections[menu]) { |
| 175 | QObjectcxx . . $ QObject#::disconnectcxx . . $ QObject#disconnect(14933e9feb207a26).(connection); |
| 176 | } |
| 177 | m_propertyConnectionscxx . . $ LomiriGMenuModelExporter#m_propertyConnections..removecxx . . $ QHash#remove(dd8e59d271e40448).(menu); |
| 178 | Q_FOREACHcxx . . $ `<external>/15045578679651060896/qglobal.h:1137:9`!(const QByteArray& action, m_actions[menu]) { |
| 179 | g_action_map_remove_action(G_ACTION_MAPcxx . . $ `<external>/8692053299015392416/gactionmap.h:35:9`!(m_gactionGroup), action.constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).()); |
| 180 | } |
| 181 | m_actionscxx . . $ LomiriGMenuModelExporter#m_actions..removecxx . . $ QHash#remove(dd8e59d271e40448).(menu); |
| 182 | g_menu_remove_all(menu); |
| 183 | addSubmenuItemscxx . . $ LomiriGMenuModelExporter#addSubmenuItems(f42684d8d844e395).(gplatformMenu, menu); |
| 184 | } else { |
| 185 | qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Got an update timer for a menu that has no GMenu" <<cxx . . $ `operator<<`(31d1e923961dacbd). gplatformMenu; |
| 186 | } |
| 187 | |
| 188 | m_reloadMenuTimerscxx . . $ LomiriGMenuModelExporter#m_reloadMenuTimers..erasecxx . . $ QHash#erase(e2b42d54101aa4fd).(it); |
| 189 | } else { |
| 190 | qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Got an update timer for a timer that was not running"; |
| 191 | } |
| 192 | killTimercxx . . $ QObject#killTimer(d4f767463ce0a6b3).(e->timerIdcxx . . $ QTimerEvent#timerId(455f465bc33b4cdf).()); |
| 193 | } |
| 194 | |
| 195 | // Export the model on dbus |
| 196 | void LomiriGMenuModelExportercxx . . $ LomiriGMenuModelExporter#::exportModelscxx . . $ LomiriGMenuModelExporter#exportModels(49f6e7a06ebc5aa8).() |
| 197 | { |
| 198 | GError *error = nullptr; |
| 199 | m_connectioncxx . . $ LomiriGMenuModelExporter#m_connection. = g_bus_get_sync (G_BUS_TYPE_SESSION, nullptr, &error); |
| 200 | if (!m_connectioncxx . . $ LomiriGMenuModelExporter#m_connection.) { |
| 201 | qCWarningcxx . . $ `<external>/13903568758641964362/qloggingcategory.h:138:11`!(lomiriappmenu, "Failed to retrieve session bus - %s", error ? error->message : "unknown error"); |
| 202 | g_error_free (error); |
| 203 | return; |
| 204 | } |
| 205 | |
| 206 | QByteArraycxx . . $ QByteArray# menuPathcxx . . $ QByteArray#QByteArray(3203d9f8f38841a4).(m_menuPathcxx . . $ LomiriGMenuModelExporter#m_menuPath..toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).()); |
| 207 | |
| 208 | if (m_exportedModelcxx . . $ LomiriGMenuModelExporter#m_exportedModel. == 0) { |
| 209 | m_exportedModelcxx . . $ LomiriGMenuModelExporter#m_exportedModel. = g_dbus_connection_export_menu_model(m_connectioncxx . . $ LomiriGMenuModelExporter#m_connection., menuPath.constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).(), G_MENU_MODELcxx . . $ `<external>/17783962342109199441/gmenumodel.h:116:9`!(m_gmainMenu), &error); |
| 210 | if (m_exportedModelcxx . . $ LomiriGMenuModelExporter#m_exportedModel. == 0) { |
| 211 | qCWarningcxx . . $ `<external>/13903568758641964362/qloggingcategory.h:138:11`!(lomiriappmenu, "Failed to export menu - %s", error ? error->message : "unknown error"); |
| 212 | g_error_free (error); |
| 213 | error = nullptr; |
| 214 | } else { |
| 215 | qCDebugcxx . . $ `<external>/13903568758641964362/qloggingcategory.h:122:11`!(lomiriappmenu, "Exported menu on %s", g_dbus_connection_get_unique_name(m_connection)); |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | if (m_exportedActionscxx . . $ LomiriGMenuModelExporter#m_exportedActions. == 0) { |
| 220 | m_exportedActionscxx . . $ LomiriGMenuModelExporter#m_exportedActions. = g_dbus_connection_export_action_group(m_connectioncxx . . $ LomiriGMenuModelExporter#m_connection., menuPath.constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).(), G_ACTION_GROUPcxx . . $ `<external>/9094338887107483362/gactiongroup.h:35:9`!(m_gactionGroup), &error); |
| 221 | if (m_exportedActionscxx . . $ LomiriGMenuModelExporter#m_exportedActions. == 0) { |
| 222 | qCWarningcxx . . $ `<external>/13903568758641964362/qloggingcategory.h:138:11`!(lomiriappmenu, "Failed to export actions - %s", error ? error->message : "unknown error"); |
| 223 | g_error_free (error); |
| 224 | error = nullptr; |
| 225 | } else { |
| 226 | qCDebugcxx . . $ `<external>/13903568758641964362/qloggingcategory.h:122:11`!(lomiriappmenu, "Exported actions on %s", g_dbus_connection_get_unique_name(m_connection)); |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | if (!m_lomiriAppMenuExtraHandlercxx . . $ LomiriGMenuModelExporter#m_lomiriAppMenuExtraHandler.) { |
| 231 | m_lomiriAppMenuExtraHandlercxx . . $ LomiriGMenuModelExporter#m_lomiriAppMenuExtraHandler. = new LomiriAppMenuExtraActionHandlercxx . . $ LomiriAppMenuExtraActionHandler#LomiriAppMenuExtraActionHandler(49f6e7a06ebc5aa8).(); |
| 232 | if (!m_lomiriAppMenuExtraHandlercxx . . $ LomiriGMenuModelExporter#m_lomiriAppMenuExtraHandler.->connectcxx . . $ LomiriAppMenuExtraActionHandler#connect(41d31289457d7a6e).(m_connectioncxx . . $ LomiriGMenuModelExporter#m_connection., menuPath, this)) { |
| 233 | delete m_lomiriAppMenuExtraHandlercxx . . $ LomiriGMenuModelExporter#m_lomiriAppMenuExtraHandler.; |
| 234 | m_lomiriAppMenuExtraHandlercxx . . $ LomiriGMenuModelExporter#m_lomiriAppMenuExtraHandler. = nullptr; |
| 235 | } |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | void LomiriGMenuModelExportercxx . . $ LomiriGMenuModelExporter#::aboutToShowcxx . . $ LomiriGMenuModelExporter#aboutToShow(891dc3055356b409).(quint64cxx . . $ quint64# tag) |
| 240 | { |
| 241 | LomiriPlatformMenucxx . . $ LomiriPlatformMenu#* gplatformMenu = m_submenusWithTagcxx . . $ LomiriGMenuModelExporter#m_submenusWithTag..valuecxx . . $ QMap#value(866b0a4e5fb46e14).(tag); |
| 242 | if (!gplatformMenu) { |
| 243 | qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Got an aboutToShow call with an unknown tag"; |
| 244 | return; |
| 245 | } |
| 246 | |
| 247 | gplatformMenu->aboutToShowcxx . . $ QPlatformMenu#aboutToShow(49f6e7a06ebc5aa8).(); |
| 248 | } |
| 249 | |
| 250 | // Unexport the model |
| 251 | void LomiriGMenuModelExportercxx . . $ LomiriGMenuModelExporter#::unexportModelscxx . . $ LomiriGMenuModelExporter#unexportModels(49f6e7a06ebc5aa8).() |
| 252 | { |
| 253 | GError *error = nullptr; |
| 254 | if (!m_connectioncxx . . $ LomiriGMenuModelExporter#m_connection.) { |
| 255 | qCWarningcxx . . $ `<external>/13903568758641964362/qloggingcategory.h:138:11`!(lomiriappmenu, "Failed to retrieve session bus - %s", error ? error->message : "unknown error"); |
| 256 | return; |
| 257 | } |
| 258 | |
| 259 | if (m_exportedModelcxx . . $ LomiriGMenuModelExporter#m_exportedModel. != 0) { |
| 260 | g_dbus_connection_unexport_menu_model(m_connectioncxx . . $ LomiriGMenuModelExporter#m_connection., m_exportedModelcxx . . $ LomiriGMenuModelExporter#m_exportedModel.); |
| 261 | m_exportedModelcxx . . $ LomiriGMenuModelExporter#m_exportedModel. = 0; |
| 262 | } |
| 263 | if (m_exportedActionscxx . . $ LomiriGMenuModelExporter#m_exportedActions. != 0) { |
| 264 | g_dbus_connection_unexport_action_group(m_connectioncxx . . $ LomiriGMenuModelExporter#m_connection., m_exportedActionscxx . . $ LomiriGMenuModelExporter#m_exportedActions.); |
| 265 | m_exportedActionscxx . . $ LomiriGMenuModelExporter#m_exportedActions. = 0; |
| 266 | } |
| 267 | if (m_lomiriAppMenuExtraHandlercxx . . $ LomiriGMenuModelExporter#m_lomiriAppMenuExtraHandler.) { |
| 268 | m_lomiriAppMenuExtraHandlercxx . . $ LomiriGMenuModelExporter#m_lomiriAppMenuExtraHandler.->disconnectcxx . . $ LomiriAppMenuExtraActionHandler#disconnect(8f9d48b3906dd9bd).(m_connectioncxx . . $ LomiriGMenuModelExporter#m_connection.); |
| 269 | delete m_lomiriAppMenuExtraHandlercxx . . $ LomiriGMenuModelExporter#m_lomiriAppMenuExtraHandler.; |
| 270 | m_lomiriAppMenuExtraHandlercxx . . $ LomiriGMenuModelExporter#m_lomiriAppMenuExtraHandler. = nullptr; |
| 271 | } |
| 272 | g_object_unref(m_connectioncxx . . $ LomiriGMenuModelExporter#m_connection.); |
| 273 | m_connectioncxx . . $ LomiriGMenuModelExporter#m_connection. = nullptr; |
| 274 | } |
| 275 | |
| 276 | // Create a submenu for the given platform menu. |
| 277 | // Returns a gmenuitem entry for the menu, which must be cleaned up using g_object_unref. |
| 278 | // If forItem is suplied, use it's label. |
| 279 | GMenuItem *LomiriGMenuModelExportercxx . . $ LomiriGMenuModelExporter#::createSubmenucxx . . $ LomiriGMenuModelExporter#createSubmenu(dd994908ccc0193c).(QPlatformMenucxx . . $ QPlatformMenu# *platformMenu, LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem# *forItem) |
| 280 | { |
| 281 | LomiriPlatformMenucxx . . $ LomiriPlatformMenu#* gplatformMenu = static_cast<LomiriPlatformMenucxx . . $ LomiriPlatformMenu#*>(platformMenu); |
| 282 | if (!gplatformMenu) return nullptr; |
| 283 | GMenu* menu = g_menu_new(); |
| 284 | |
| 285 | m_gmenusForMenuscxx . . $ LomiriGMenuModelExporter#m_gmenusForMenus..insertcxx . . $ QHash#insert(d77b19c31d2eb147).(gplatformMenu, menu); |
| 286 | |
| 287 | QByteArraycxx . . $ QByteArray# labelcxx . . $ QByteArray#QByteArray(49f6e7a06ebc5aa8).; |
| 288 | bool enabled; |
| 289 | if (forItem) { |
| 290 | label =cxx . . $ QByteArray#`operator=`(d0b0ff031ded1fc3). LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#::get_textcxx . . $ LomiriPlatformMenuItem#get_text(f7378141d7f4f469).(forItem).toUtf8cxx . . $ QString#toUtf8(7c2073558a834e49).(); |
| 291 | enabled = LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#::get_enabledcxx . . $ LomiriPlatformMenuItem#get_enabled(6c3d7e91ff9788da).(forItem); |
| 292 | } else { |
| 293 | label =cxx . . $ QByteArray#`operator=`(d0b0ff031ded1fc3). LomiriPlatformMenucxx . . $ LomiriPlatformMenu#::get_textcxx . . $ LomiriPlatformMenu#get_text(ceb1df88f86d5a12).(gplatformMenu).toUtf8cxx . . $ QString#toUtf8(7c2073558a834e49).(); |
| 294 | enabled = LomiriPlatformMenucxx . . $ LomiriPlatformMenu#::get_enabledcxx . . $ LomiriPlatformMenu#get_enabled(9c9a944a8a85a8d9).(gplatformMenu); |
| 295 | } |
| 296 | |
| 297 | addSubmenuItemscxx . . $ LomiriGMenuModelExporter#addSubmenuItems(f42684d8d844e395).(gplatformMenu, menu); |
| 298 | |
| 299 | Q_FOREACHcxx . . $ `<external>/15045578679651060896/qglobal.h:1137:9`!(QPlatformMenuItem *childItem, gplatformMenu->menuItems()) { |
| 300 | LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#* gplatformMenuItem = static_cast<LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#*>(childItem); |
| 301 | if (!gplatformMenuItem) continue; |
| 302 | |
| 303 | // Sadly we don't have a better way to propagate a enabled change in a item-that-is-submenu |
| 304 | // than reseting the whole parent menu |
| 305 | if (gplatformMenuItem->menucxx . . $ LomiriPlatformMenuItem#menu(15223643a8dbaac4).()) { |
| 306 | connectcxx . . $ QObject#connect(835f87066c895669).(gplatformMenuItem, &LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#::enabledChangedcxx . . $ LomiriPlatformMenuItem#enabledChanged(b45ddcbc8423892c)., gplatformMenu, &LomiriPlatformMenucxx . . $ LomiriPlatformMenu#::structureChangedcxx . . $ LomiriPlatformMenu#structureChanged(49f6e7a06ebc5aa8).); |
| 307 | } |
| 308 | connectcxx . . $ QObject#connect(835f87066c895669).(gplatformMenuItem, &LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#::visibleChangedcxx . . $ LomiriPlatformMenuItem#visibleChanged(b45ddcbc8423892c)., gplatformMenu, &LomiriPlatformMenucxx . . $ LomiriPlatformMenu#::structureChangedcxx . . $ LomiriPlatformMenu#structureChanged(49f6e7a06ebc5aa8).); |
| 309 | } |
| 310 | |
| 311 | GMenuItem* gmenuItem = g_menu_item_new_submenu(label.constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).(), G_MENU_MODELcxx . . $ `<external>/17783962342109199441/gmenumodel.h:116:9`!(menu)); |
| 312 | const quint64cxx . . $ quint64# tag = gplatformMenu->tagcxx . . $ LomiriPlatformMenu#tag(1c5fc1fd41a99ae7).(); |
| 313 | if (tag != 0) { |
| 314 | g_menu_item_set_attribute_value(gmenuItem, "qtubuntu-tag", g_variant_new_uint64 (tag)); |
| 315 | m_submenusWithTagcxx . . $ LomiriGMenuModelExporter#m_submenusWithTag..insertcxx . . $ QMap#insert(929a1ed410fe8423).(gplatformMenu->tagcxx . . $ LomiriPlatformMenu#tag(1c5fc1fd41a99ae7).(), gplatformMenu); |
| 316 | } |
| 317 | g_object_unref(menu); |
| 318 | |
| 319 | g_menu_item_set_attribute_value(gmenuItem, "submenu-enabled", g_variant_new_boolean(enabled)); |
| 320 | |
| 321 | connectcxx . . $ QObject#connect(d9dbe0c0ad4eecec).(gplatformMenu, &LomiriPlatformMenucxx . . $ LomiriPlatformMenu#::structureChangedcxx . . $ LomiriPlatformMenu#structureChanged(49f6e7a06ebc5aa8)., this, [this, gplatformMenu] |
| 322 | { |
| 323 | if (!m_reloadMenuTimerscxx . . $ LomiriGMenuModelExporter#m_reloadMenuTimers..containscxx . . $ QHash#contains(8877ebe272b9620d).(gplatformMenu)) { |
| 324 | const int timerId = startTimercxx . . $ QObject#startTimer(cf5d4a693bb15cf1).(0); |
| 325 | m_reloadMenuTimerscxx . . $ LomiriGMenuModelExporter#m_reloadMenuTimers..insertcxx . . $ QHash#insert(d77b19c31d2eb147).(gplatformMenu, timerId); |
| 326 | } |
| 327 | }); |
| 328 | |
| 329 | connectcxx . . $ QObject#connect(d9dbe0c0ad4eecec).(gplatformMenu, &LomiriPlatformMenucxx . . $ LomiriPlatformMenu#::destroyedcxx . . $ QObject#destroyed(749de1b6ae65bddd)., this, [this, tag, gplatformMenu] |
| 330 | { |
| 331 | m_submenusWithTagcxx . . $ LomiriGMenuModelExporter#m_submenusWithTag..removecxx . . $ QMap#remove(dd8e59d271e40448).(tag); |
| 332 | m_gmenusForMenuscxx . . $ LomiriGMenuModelExporter#m_gmenusForMenus..removecxx . . $ QHash#remove(dd8e59d271e40448).(gplatformMenu); |
| 333 | auto timerIdIt = m_reloadMenuTimerscxx . . $ LomiriGMenuModelExporter#m_reloadMenuTimers..findcxx . . $ QHash#find(1cadc8f6e24105ba).(gplatformMenu); |
| 334 | if (timerIdIt !=cxx . . $ QHash#iterator#`operator!=`(d41b528a217b928). m_reloadMenuTimerscxx . . $ LomiriGMenuModelExporter#m_reloadMenuTimers..endcxx . . $ QHash#end(7fee0616348ed702).()) { |
| 335 | killTimercxx . . $ QObject#killTimer(d4f767463ce0a6b3).(*cxx . . $ QHash#iterator#`operator*`(51f62fb05f27f6a2).timerIdIt); |
| 336 | m_reloadMenuTimerscxx . . $ LomiriGMenuModelExporter#m_reloadMenuTimers..erasecxx . . $ QHash#erase(e2b42d54101aa4fd).(timerIdIt); |
| 337 | } |
| 338 | }); |
| 339 | |
| 340 | return gmenuItem; |
| 341 | } |
| 342 | |
| 343 | // Add a platform menu's items to the given gmenu. |
| 344 | // The items are inserted into menus sections, split by the menu separators. |
| 345 | void LomiriGMenuModelExportercxx . . $ LomiriGMenuModelExporter#::addSubmenuItemscxx . . $ LomiriGMenuModelExporter#addSubmenuItems(f42684d8d844e395).(LomiriPlatformMenucxx . . $ LomiriPlatformMenu#* gplatformMenu, GMenu* menu) |
| 346 | { |
| 347 | auto iter = gplatformMenucxx . . $ QList#const_iterator#const_iterator(55f75f4ca60f2214).->menuItemscxx . . $ LomiriPlatformMenu#menuItems(70857b704fa91c2a).().begincxx . . $ QList#begin(40053b5cd9814e26).(); |
| 348 | auto lastSectionStart = itercxx . . $ QList#const_iterator#const_iterator(55f75f4ca60f2214).; |
| 349 | // Iterate through all the menu items adding sections when a separator is found. |
| 350 | for (; iter !=cxx . . $ QList#const_iterator#`operator!=`(b1b1a9635a1c4a8). gplatformMenu->menuItemscxx . . $ LomiriPlatformMenu#menuItems(70857b704fa91c2a).().endcxx . . $ QList#end(40053b5cd9814e26).(); ++cxx . . $ QList#const_iterator#operator++(b8ec5848ade221bd).iter) { |
| 351 | LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#* gplatformMenuItem = static_cast<LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#*>(*cxx . . $ QList#const_iterator#`operator*`(ea465e50d690edfe).iter); |
| 352 | if (!gplatformMenuItem) continue; |
| 353 | |
| 354 | // don't add a section until we have separator |
| 355 | if (LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#::get_separatorcxx . . $ LomiriPlatformMenuItem#get_separator(6c3d7e91ff9788da).(gplatformMenuItem)) { |
| 356 | if (lastSectionStart !=cxx . . $ QList#const_iterator#`operator!=`(b1b1a9635a1c4a8). gplatformMenu->menuItemscxx . . $ LomiriPlatformMenu#menuItems(70857b704fa91c2a).().begincxx . . $ QList#begin(40053b5cd9814e26).()) { |
| 357 | GMenuItem* section = createSectioncxx . . $ LomiriGMenuModelExporter#createSection(503cdeef0c91802f).(lastSectionStartcxx . . $ QList#const_iterator#const_iterator(55f75f4ca60f2214)., itercxx . . $ QList#const_iterator#const_iterator(55f75f4ca60f2214).); |
| 358 | g_menu_append_item(menu, section); |
| 359 | g_object_unref(section); |
| 360 | } |
| 361 | lastSectionStart =cxx . . $ QList#const_iterator#`operator=`(e229fc22af365439). iter +cxx . . $ QList#const_iterator#operator+(ea13aa307aab05cc). 1; |
| 362 | } else if (lastSectionStart ==cxx . . $ QList#const_iterator#`operator==`(b1b1a9635a1c4a8). gplatformMenu->menuItemscxx . . $ LomiriPlatformMenu#menuItems(70857b704fa91c2a).().begincxx . . $ QList#begin(40053b5cd9814e26).()) { |
| 363 | processItemForGMenucxx . . $ LomiriGMenuModelExporter#processItemForGMenu(c1aa227cdccb768).(gplatformMenuItem, menu); |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | // Add the last section |
| 368 | if (lastSectionStart !=cxx . . $ QList#const_iterator#`operator!=`(b1b1a9635a1c4a8). gplatformMenu->menuItemscxx . . $ LomiriPlatformMenu#menuItems(70857b704fa91c2a).().begincxx . . $ QList#begin(40053b5cd9814e26).() && |
| 369 | lastSectionStart !=cxx . . $ QList#const_iterator#`operator!=`(b1b1a9635a1c4a8). gplatformMenu->menuItemscxx . . $ LomiriPlatformMenu#menuItems(70857b704fa91c2a).().endcxx . . $ QList#end(40053b5cd9814e26).()) { |
| 370 | GMenuItem* gsectionItem = createSectioncxx . . $ LomiriGMenuModelExporter#createSection(503cdeef0c91802f).(lastSectionStartcxx . . $ QList#const_iterator#const_iterator(55f75f4ca60f2214)., gplatformMenucxx . . $ QList#const_iterator#const_iterator(55f75f4ca60f2214).->menuItemscxx . . $ LomiriPlatformMenu#menuItems(70857b704fa91c2a).().endcxx . . $ QList#end(40053b5cd9814e26).()); |
| 371 | g_menu_append_item(menu, gsectionItem); |
| 372 | g_object_unref(gsectionItem); |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | // Create and return a gmenu item for the given platform menu item. |
| 377 | // Returned GMenuItem must be cleaned up using g_object_unref |
| 378 | GMenuItem *LomiriGMenuModelExportercxx . . $ LomiriGMenuModelExporter#::createMenuItemcxx . . $ LomiriGMenuModelExporter#createMenuItem(8d82dffb65a6448e).(QPlatformMenuItemcxx . . $ QPlatformMenuItem# *platformMenuItem, GMenu *parentMenu) |
| 379 | { |
| 380 | LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#* gplatformMenuItem = static_cast<LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#*>(platformMenuItem); |
| 381 | if (!gplatformMenuItem) return nullptr; |
| 382 | |
| 383 | if (!LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#::get_visiblecxx . . $ LomiriPlatformMenuItem#get_visible(6c3d7e91ff9788da).(gplatformMenuItem)) |
| 384 | return nullptr; |
| 385 | |
| 386 | QByteArraycxx . . $ QByteArray# labelcxx . . $ QByteArray#QByteArray(3203d9f8f38841a4).(LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#::get_textcxx . . $ LomiriPlatformMenuItem#get_text(f7378141d7f4f469).(gplatformMenuItem).toUtf8cxx . . $ QString#toUtf8(7c2073558a834e49).()); |
| 387 | QByteArraycxx . . $ QByteArray# actionLabelcxx . . $ QByteArray#QByteArray(3203d9f8f38841a4).(getActionStringcxx . . $ `$anonymous_namespace_src/lomiriappmenu/gmenumodelexporter.cpp`/getActionString(f7f320d754b8fd09).(LomiriPlatformMenuItemcxx . . $ QString#QString(e1217c004a86c950).::get_textcxx . . $ LomiriPlatformMenuItem#get_text(f7378141d7f4f469).(gplatformMenuItem)).toUtf8cxx . . $ QString#toUtf8(7c2073558a834e49).()); |
| 388 | QByteArraycxx . . $ QByteArray# shortcutcxx . . $ QByteArray#QByteArray(3203d9f8f38841a4).(LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#::get_shortcutcxx . . $ LomiriPlatformMenuItem#get_shortcut(2334f19b2a87d10c).(gplatformMenuItem).toStringcxx . . $ QKeySequence#toString(ec3c6f9720e8edf6).(QKeySequencecxx . . $ QKeySequence#::NativeTextcxx . . $ QKeySequence#NativeText.).toUtf8cxx . . $ QString#toUtf8(7c2073558a834e49).()); |
| 389 | |
| 390 | GMenuItem* gmenuItem = g_menu_item_new(label.constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).(), nullptr); |
| 391 | g_menu_item_set_attribute(gmenuItem, "accel", "s", shortcut.constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).()); |
| 392 | g_menu_item_set_detailed_action(gmenuItem, ("unity." +cxx . . $ operator+(c76e440e68d4afec). actionLabel).constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).()); |
| 393 | |
| 394 | addActioncxx . . $ LomiriGMenuModelExporter#addAction(69192ff8ee5ec3f5).(actionLabel, gplatformMenuItem, parentMenu); |
| 395 | return gmenuItem; |
| 396 | } |
| 397 | |
| 398 | // Create a menu section for a section of separated menu items. |
| 399 | // Returned GMenuItem must be cleaned up using g_object_unref |
| 400 | GMenuItem *LomiriGMenuModelExportercxx . . $ LomiriGMenuModelExporter#::createSectioncxx . . $ LomiriGMenuModelExporter#createSection(503cdeef0c91802f).(QListcxx . . $ QList#<QPlatformMenuItem *>::const_iteratorcxx . . $ QList#const_iterator# iter, QListcxx . . $ QList#<QPlatformMenuItem *>::const_iteratorcxx . . $ QList#const_iterator# end) |
| 401 | { |
| 402 | GMenu* gsectionMenu = g_menu_new(); |
| 403 | for (; iter !=cxx . . $ QList#const_iterator#`operator!=`(b1b1a9635a1c4a8). end; ++cxx . . $ QList#const_iterator#operator++(b8ec5848ade221bd).iter) { |
| 404 | processItemForGMenucxx . . $ LomiriGMenuModelExporter#processItemForGMenu(c1aa227cdccb768).(*cxx . . $ QList#const_iterator#`operator*`(ea465e50d690edfe).iter, gsectionMenu); |
| 405 | } |
| 406 | GMenuItem* gsectionItem = g_menu_item_new_section("", G_MENU_MODELcxx . . $ `<external>/17783962342109199441/gmenumodel.h:116:9`!(gsectionMenu)); |
| 407 | g_object_unref(gsectionMenu); |
| 408 | return gsectionItem; |
| 409 | } |
| 410 | |
| 411 | // Add the given platform menu item to the menu. |
| 412 | // If it has an attached submenu, then create and add the submenu. |
| 413 | void LomiriGMenuModelExportercxx . . $ LomiriGMenuModelExporter#::processItemForGMenucxx . . $ LomiriGMenuModelExporter#processItemForGMenu(c1aa227cdccb768).(QPlatformMenuItemcxx . . $ QPlatformMenuItem# *platformMenuItem, GMenu *gmenu) |
| 414 | { |
| 415 | LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#* gplatformMenuItem = static_cast<LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#*>(platformMenuItem); |
| 416 | if (!gplatformMenuItem) return; |
| 417 | |
| 418 | GMenuItem* gmenuItem = gplatformMenuItem->menucxx . . $ LomiriPlatformMenuItem#menu(15223643a8dbaac4).() ? createSubmenucxx . . $ LomiriGMenuModelExporter#createSubmenu(dd994908ccc0193c).(gplatformMenuItem->menucxx . . $ LomiriPlatformMenuItem#menu(15223643a8dbaac4).(), gplatformMenuItem) : |
| 419 | createMenuItemcxx . . $ LomiriGMenuModelExporter#createMenuItem(8d82dffb65a6448e).(gplatformMenuItem, gmenu); |
| 420 | if (gmenuItem) { |
| 421 | g_menu_append_item(gmenu, gmenuItem); |
| 422 | g_object_unref(gmenuItem); |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | // Create and add an action for a menu item. |
| 427 | void LomiriGMenuModelExportercxx . . $ LomiriGMenuModelExporter#::addActioncxx . . $ LomiriGMenuModelExporter#addAction(69192ff8ee5ec3f5).(const QByteArraycxx . . $ QByteArray# &name, LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem# *gplatformMenuItem, GMenu *parentMenu) |
| 428 | { |
| 429 | disconnectcxx . . $ QObject#disconnect(bea847693c2a9ff4).(gplatformMenuItem, &LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#::checkedChangedcxx . . $ LomiriPlatformMenuItem#checkedChanged(b45ddcbc8423892c)., this, 0); |
| 430 | disconnectcxx . . $ QObject#disconnect(bea847693c2a9ff4).(gplatformMenuItem, &LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#::enabledChangedcxx . . $ LomiriPlatformMenuItem#enabledChanged(b45ddcbc8423892c)., this, 0); |
| 431 | |
| 432 | QSetcxx . . $ QSet#<QByteArraycxx . . $ QByteArray#> &actions = m_actionscxx . . $ LomiriGMenuModelExporter#m_actions.[cxx . . $ QHash#`operator[]`(bbd415b616967878).parentMenu]; |
| 433 | QVectorcxx . . $ QVector#<QMetaObjectcxx . . $ QMetaObject#::Connectioncxx . . $ QMetaObject#Connection#> &propertyConnections = m_propertyConnectionscxx . . $ LomiriGMenuModelExporter#m_propertyConnections.[cxx . . $ QHash#`operator[]`(bbd415b616967878).parentMenu]; |
| 434 | |
| 435 | if (actions.containscxx . . $ QSet#contains(8877ebe272b9620d).(name)) { |
| 436 | g_action_map_remove_action(G_ACTION_MAPcxx . . $ `<external>/8692053299015392416/gactionmap.h:35:9`!(m_gactionGroup), name.constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).()); |
| 437 | actions.removecxx . . $ QSet#remove(fe1ba53999e710f3).(name); |
| 438 | } |
| 439 | |
| 440 | bool checkable = LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#::get_checkablecxx . . $ LomiriPlatformMenuItem#get_checkable(6c3d7e91ff9788da).(gplatformMenuItem); |
| 441 | |
| 442 | GSimpleAction* action = nullptr; |
| 443 | if (checkable) { |
| 444 | bool checked = LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#::get_checkedcxx . . $ LomiriPlatformMenuItem#get_checked(6c3d7e91ff9788da).(gplatformMenuItem); |
| 445 | action = g_simple_action_new_stateful(name.constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).(), nullptr, g_variant_new_boolean(checked)); |
| 446 | |
| 447 | stdcxx . . $ std/::functioncxx . . $ std/function#<void(bool)> updateCheckedcxx . . $ std/function#function(a4b4b0c4acad1616). = [cxx . . $ std/function#function(4f6c0277e8680150).gplatformMenuItem, action](bool checked) { |
| 448 | auto type = g_action_get_state_type(G_ACTIONcxx . . $ `<external>/4927576621387421614/gaction.h:34:9`!(action)); |
| 449 | if (type && g_variant_type_equal(type, G_VARIANT_TYPE_BOOLEANcxx . . $ `<external>/14064154155447831270/gvarianttype.h:41:9`!)) { |
| 450 | g_simple_action_set_state(action, g_variant_new_boolean(checked ? TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`! : FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!)); |
| 451 | } |
| 452 | }; |
| 453 | // save the connection to disconnect in LomiriGMenuModelExporter::clear() |
| 454 | propertyConnections <<cxx . . $ QVector#`operator<<`(a67f761fa76cec1d). connectcxx . . $ QObject#connect(d9dbe0c0ad4eecec).(gplatformMenuItem, &LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#::checkedChangedcxx . . $ LomiriPlatformMenuItem#checkedChanged(b45ddcbc8423892c)., this, updateCheckedcxx . . $ std/function#function(ec20bd20f4acba43).); |
| 455 | } else { |
| 456 | action = g_simple_action_new(name.constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).(), nullptr); |
| 457 | } |
| 458 | |
| 459 | // Enabled update |
| 460 | stdcxx . . $ std/::functioncxx . . $ std/function#<void(bool)> updateEnabledcxx . . $ std/function#function(a4b4b0c4acad1616). = [cxx . . $ std/function#function(4f6c0277e8680150).gplatformMenuItem, action](bool enabled) { |
| 461 | GValue value = G_VALUE_INITcxx . . $ `<external>/17218264759549183453/gvalue.h:250:9`!; |
| 462 | g_value_init (&value, G_TYPE_BOOLEANcxx . . $ `<external>/9567554376676449156/gtype.h:99:9`!); |
| 463 | g_value_set_boolean(&value, enabled ? TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`! : FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!); |
| 464 | g_object_set_property(G_OBJECTcxx . . $ `<external>/1341695927569185362/gobject.h:54:9`!(action), "enabled", &value); |
| 465 | }; |
| 466 | updateEnabled(cxx . . $ std/function#`operator()`(39e0826ffb540481).LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#::get_enabledcxx . . $ LomiriPlatformMenuItem#get_enabled(6c3d7e91ff9788da).(gplatformMenuItem)); |
| 467 | // save the connection to disconnect in LomiriGMenuModelExporter::clear() |
| 468 | propertyConnections <<cxx . . $ QVector#`operator<<`(a67f761fa76cec1d). connectcxx . . $ QObject#connect(d9dbe0c0ad4eecec).(gplatformMenuItem, &LomiriPlatformMenuItemcxx . . $ LomiriPlatformMenuItem#::enabledChangedcxx . . $ LomiriPlatformMenuItem#enabledChanged(b45ddcbc8423892c)., this, updateEnabledcxx . . $ std/function#function(ec20bd20f4acba43).); |
| 469 | |
| 470 | g_signal_connectcxx . . $ `<external>/15952772511652638895/gsignal.h:548:9`!(action, "activate", G_CALLBACKcxx . . $ `<external>/16473872192229286895/gclosure.h:73:9`!(activate_cb), gplatformMenuItem); |
| 471 | |
| 472 | actions.insertcxx . . $ QSet#insert(b1720532d625d779).(name); |
| 473 | g_action_map_add_action(G_ACTION_MAPcxx . . $ `<external>/8692053299015392416/gactionmap.h:35:9`!(m_gactionGroup), G_ACTIONcxx . . $ `<external>/4927576621387421614/gaction.h:34:9`!(action)); |
| 474 | g_object_unref(action); |
| 475 | } |