qdbusmenubar.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/platformsupport/dbusmenu/qdbusmenubar.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10QDBusMenuBar::QDBusMenuBar()-
11 : QPlatformMenuBar()-
12 , m_menu(new QDBusPlatformMenu())-
13 , m_menuAdaptor(new QDBusMenuAdaptor(m_menu))-
14 , m_windowId(0)-
15{-
16 QDBusMenuItem::registerDBusTypes();-
17 connect(m_menu, &QDBusPlatformMenu::propertiesUpdated,-
18 m_menuAdaptor, &QDBusMenuAdaptor::ItemsPropertiesUpdated);-
19 connect(m_menu, &QDBusPlatformMenu::updated,-
20 m_menuAdaptor, &QDBusMenuAdaptor::LayoutUpdated);-
21}
never executed: end of block
0
22-
23QDBusMenuBar::~QDBusMenuBar()-
24{-
25 unregisterMenuBar();-
26 delete m_menuAdaptor;-
27 delete m_menu;-
28 qDeleteAll(m_menuItems);-
29}
never executed: end of block
0
30-
31QDBusPlatformMenuItem *QDBusMenuBar::menuItemForMenu(QPlatformMenu *menu)-
32{-
33 if (!menu
!menuDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
34 return
never executed: return nullptr;
nullptr;
never executed: return nullptr;
0
35 quintptr tag = menu->tag();-
36 const auto it = m_menuItems.constFind(tag);-
37 if (it != m_menuItems.cend()
it != m_menuItems.cend()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
38 return
never executed: return *it;
*it;
never executed: return *it;
0
39 } else {-
40 QDBusPlatformMenuItem *item = new QDBusPlatformMenuItem;-
41 updateMenuItem(item, menu);-
42 m_menuItems.insert(tag, item);-
43 return
never executed: return item;
item;
never executed: return item;
0
44 }-
45}-
46-
47void QDBusMenuBar::updateMenuItem(QDBusPlatformMenuItem *item, QPlatformMenu *menu)-
48{-
49 const QDBusPlatformMenu *ourMenu = qobject_cast<const QDBusPlatformMenu *>(menu);-
50 item->setText(ourMenu->text());-
51 item->setIcon(ourMenu->icon());-
52 item->setEnabled(ourMenu->isEnabled());-
53 item->setVisible(ourMenu->isVisible());-
54 item->setMenu(menu);-
55}
never executed: end of block
0
56-
57void QDBusMenuBar::insertMenu(QPlatformMenu *menu, QPlatformMenu *before)-
58{-
59 QDBusPlatformMenuItem *menuItem = menuItemForMenu(menu);-
60 QDBusPlatformMenuItem *beforeItem = menuItemForMenu(before);-
61 m_menu->insertMenuItem(menuItem, beforeItem);-
62 m_menu->emitUpdated();-
63}
never executed: end of block
0
64-
65void QDBusMenuBar::removeMenu(QPlatformMenu *menu)-
66{-
67 QDBusPlatformMenuItem *menuItem = menuItemForMenu(menu);-
68 m_menu->removeMenuItem(menuItem);-
69 m_menu->emitUpdated();-
70}
never executed: end of block
0
71-
72void QDBusMenuBar::syncMenu(QPlatformMenu *menu)-
73{-
74 QDBusPlatformMenuItem *menuItem = menuItemForMenu(menu);-
75 updateMenuItem(menuItem, menu);-
76}
never executed: end of block
0
77-
78void QDBusMenuBar::handleReparent(QWindow *newParentWindow)-
79{-
80 if (newParentWindow
newParentWindowDescription
TRUEnever evaluated
FALSEnever evaluated
&& newParentWindow->winId() != m_windowId
newParentWindo... != m_windowIdDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
81 unregisterMenuBar();-
82 m_windowId = newParentWindow->winId();-
83 registerMenuBar();-
84 }
never executed: end of block
0
85}
never executed: end of block
0
86-
87QPlatformMenu *QDBusMenuBar::menuForTag(quintptr tag) const-
88{-
89 QDBusPlatformMenuItem *menuItem = m_menuItems.value(tag);-
90 if (menuItem
menuItemDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
91 return
never executed: return const_cast<QPlatformMenu *>(menuItem->menu());
const_cast<QPlatformMenu *>(menuItem->menu());
never executed: return const_cast<QPlatformMenu *>(menuItem->menu());
0
92 return
never executed: return nullptr;
nullptr;
never executed: return nullptr;
0
93}-
94-
95QPlatformMenu *QDBusMenuBar::createMenu() const-
96{-
97 return
never executed: return new QDBusPlatformMenu;
new QDBusPlatformMenu;
never executed: return new QDBusPlatformMenu;
0
98}-
99-
100void QDBusMenuBar::registerMenuBar()-
101{-
102 static uint menuBarId = 0;-
103-
104 QDBusConnection connection = QDBusConnection::sessionBus();-
105 m_objectPath = ([]() -> QString { enum { Size = sizeof(u"" "/MenuBar/%1")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "/MenuBar/%1" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}()).arg(++menuBarId);
0
106 if (!connection.registerObject(m_objectPath, m_menu)
!connection.re...tPath, m_menu)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
107 return;
never executed: return;
0
108-
109 QDBusMenuRegistrarInterface registrar(QLatin1String("com.canonical.AppMenu.Registrar"), QLatin1String("/com/canonical/AppMenu/Registrar"), connection, this);-
110 QDBusPendingReply<> r = registrar.RegisterWindow(m_windowId, QDBusObjectPath(m_objectPath));-
111 r.waitForFinished();-
112 if (r.isError()
r.isError()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
113 QMessageLogger(__FILE__, 154, __PRETTY_FUNCTION__).warning("Failed to register window menu, reason: %s (\"%s\")",-
114 QString(r.error().name()).toUtf8().constData(), QString(r.error().message()).toUtf8().constData());-
115 connection.unregisterObject(m_objectPath);-
116 }
never executed: end of block
0
117}
never executed: end of block
0
118-
119void QDBusMenuBar::unregisterMenuBar()-
120{-
121 QDBusConnection connection = QDBusConnection::sessionBus();-
122-
123 if (m_windowId
m_windowIdDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
124 QDBusMenuRegistrarInterface registrar(QLatin1String("com.canonical.AppMenu.Registrar"), QLatin1String("/com/canonical/AppMenu/Registrar"), connection, this);-
125 QDBusPendingReply<> r = registrar.UnregisterWindow(m_windowId);-
126 r.waitForFinished();-
127 if (r.isError()
r.isError()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
128 QMessageLogger(__FILE__, 169, __PRETTY_FUNCTION__).warning("Failed to unregister window menu, reason: %s (\"%s\")",
never executed: QMessageLogger(__FILE__, 169, __PRETTY_FUNCTION__).warning("Failed to unregister window menu, reason: %s (\"%s\")", QString(r.error().name()).toUtf8().constData(), QString(r.error().message()).toUtf8().constData());
0
129 QString(r.error().name()).toUtf8().constData(), QString(r.error().message()).toUtf8().constData());
never executed: QMessageLogger(__FILE__, 169, __PRETTY_FUNCTION__).warning("Failed to unregister window menu, reason: %s (\"%s\")", QString(r.error().name()).toUtf8().constData(), QString(r.error().message()).toUtf8().constData());
0
130 }
never executed: end of block
0
131-
132 if (!m_objectPath.isEmpty()
!m_objectPath.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
133 connection.unregisterObject(m_objectPath);
never executed: connection.unregisterObject(m_objectPath);
0
134}
never executed: end of block
0
135-
136-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9