~stolowski/+junk/unity-2d-no-results-hint

« back to all changes in this revision

Viewing changes to panel/applets/appmenu/registrar.h

  • Committer: Aurelien Gateau
  • Date: 2010-10-06 13:52:55 UTC
  • Revision ID: aurelien.gateau@canonical.com-20101006135255-j4gsdm7k3grh0ydh
Merged in panel

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Plasma applet to display application window menus
 
3
 *
 
4
 * Copyright 2010 Canonical Ltd.
 
5
 *
 
6
 * Authors:
 
7
 * - Aurélien Gâteau <aurelien.gateau@canonical.com>
 
8
 *
 
9
 * License: GPL v3
 
10
 */
 
11
#ifndef REGISTRAR_H
 
12
#define REGISTRAR_H
 
13
 
 
14
// Qt
 
15
#include <QDBusContext>
 
16
#include <QDBusObjectPath>
 
17
#include <QObject>
 
18
#include <QWidget> // For WId
 
19
 
 
20
class QDBusObjectPath;
 
21
class QDBusServiceWatcher;
 
22
class QMenu;
 
23
 
 
24
struct MenuInfo
 
25
{
 
26
    MenuInfo()
 
27
    : winId(0)
 
28
    , path("/")
 
29
    {}
 
30
 
 
31
    uint winId;
 
32
    QString service;
 
33
    QDBusObjectPath path;
 
34
};
 
35
Q_DECLARE_METATYPE(MenuInfo)
 
36
 
 
37
typedef QList<MenuInfo> MenuInfoList;
 
38
Q_DECLARE_METATYPE(MenuInfoList)
 
39
 
 
40
class Registrar : public QObject, protected QDBusContext
 
41
{
 
42
    Q_OBJECT
 
43
 
 
44
public:
 
45
    Registrar(QObject*);
 
46
    ~Registrar();
 
47
 
 
48
    bool connectToBus(const QString& service = QString(), const QString& objectPath = QString());
 
49
 
 
50
Q_SIGNALS:
 
51
    void WindowRegistered(WId wid, const QString& service, const QDBusObjectPath&);
 
52
public Q_SLOTS:
 
53
    Q_NOREPLY void RegisterWindow(WId wid, const QDBusObjectPath& menuObjectPath);
 
54
    Q_NOREPLY void UnregisterWindow(WId wid);
 
55
    QString GetMenuForWindow(WId wid, QDBusObjectPath& menuObjectPath);
 
56
    MenuInfoList GetMenus();
 
57
 
 
58
private Q_SLOTS:
 
59
    void slotServiceUnregistered(const QString& service);
 
60
 
 
61
private:
 
62
    QDBusServiceWatcher* mServiceWatcher;
 
63
    typedef QHash<WId, MenuInfo> MenuInfoDb;
 
64
    MenuInfoDb mDb;
 
65
    QString mService;
 
66
};
 
67
 
 
68
#endif /* REGISTRAR_H */