forked from tetzank/qmenu_hud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistrar.cpp
66 lines (47 loc) · 1.67 KB
/
registrar.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "registrar.h"
#include <QtDebug>
#include <QDBusMessage>
Registrar::Registrar(QObject* parent)
: QObject(parent)
{
}
Registrar::~Registrar(){
}
QString Registrar::GetMenuForWindow(uint windowId, QDBusObjectPath &menuObjectPath){
// qDebug() << "GetMenuForWindow called: " << windowId;
if(m_map.find(windowId) != m_map.end()){
QString service;
QDBusObjectPath path;
std::tie(service, path) = m_map[windowId];
menuObjectPath = path;
return service;
}else{
// kded appmenu module sends back a default empty QDBusObjectPath when window not registered
//menuObjectPath = QDBusObjectPath();
// (it uses QHash.value())
// this doesn't work, assert in libdbus fails and brings down whole process
sendErrorReply(QDBusError::Failed);
// this works, but error better
menuObjectPath.setPath("/");//ignored, because send error above
return QString(""); //ignored, because send error above
}
}
MenuInfoList Registrar::GetMenus(){
// qDebug() << "GetMenus called";
sendErrorReply(QDBusError::NotSupported);
return MenuInfoList(); //ignored, because send error above
}
void Registrar::RegisterWindow(uint windowId, const QDBusObjectPath &menuObjectPath){
// qDebug() << "RegisterWindow called: " << windowId << "; " << menuObjectPath.path();
//get service name who send this
QString service = message().service();
// qDebug() << service;
m_map[windowId] = std::make_pair(service, menuObjectPath);
emit WindowRegistered(windowId, service, menuObjectPath);
}
void Registrar::UnregisterWindow(uint windowId){
// qDebug() << "UnregisterWindow called: " << windowId;
m_map.erase(windowId);
emit WindowUnregistered(windowId);
}
#include "registrar.moc"