1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef QDBUSVIEWER_H
5#define QDBUSVIEWER_H
6
7#include <QtWidgets/QWidget>
8#include <QtDBus/QDBusConnection>
9#include <QtCore/QRegularExpression>
10
11class ServicesProxyModel;
12
13QT_FORWARD_DECLARE_CLASS(QTableView)
14QT_FORWARD_DECLARE_CLASS(QTreeView)
15QT_FORWARD_DECLARE_CLASS(QTreeWidget)
16QT_FORWARD_DECLARE_CLASS(QStringListModel)
17QT_FORWARD_DECLARE_CLASS(QLineEdit)
18QT_FORWARD_DECLARE_CLASS(QTextBrowser)
19QT_FORWARD_DECLARE_CLASS(QDomDocument)
20QT_FORWARD_DECLARE_CLASS(QDomElement)
21QT_FORWARD_DECLARE_CLASS(QSplitter)
22QT_FORWARD_DECLARE_CLASS(QSettings)
23
24struct BusSignature
25{
26 QString mService, mPath, mInterface, mName;
27 QString mTypeSig;
28};
29
30class QDBusViewer: public QWidget
31{
32 Q_OBJECT
33public:
34 QDBusViewer(const QDBusConnection &connection, QWidget *parent = 0);
35
36 void saveState(QSettings *settings) const;
37 void restoreState(const QSettings *settings);
38
39public slots:
40 void refresh();
41
42private slots:
43 void serviceChanged(const QModelIndex &index);
44 void showContextMenu(const QPoint &);
45 void connectionRequested(const BusSignature &sig);
46 void callMethod(const BusSignature &sig);
47 void getProperty(const BusSignature &sig);
48 void setProperty(const BusSignature &sig);
49 void dumpMessage(const QDBusMessage &msg);
50 void dumpError(const QDBusError &error);
51 void refreshChildren();
52
53 void serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
54
55 void serviceFilterReturnPressed();
56 void activate(const QModelIndex &item);
57
58 void logError(const QString &msg);
59 void anchorClicked(const QUrl &url);
60
61private:
62 void serviceRegistered(const QString &service);
63 void logMessage(const QString &msg);
64 void showEvent(QShowEvent *) override;
65 bool eventFilter(QObject *obj, QEvent *event) override;
66
67 QDBusConnection c;
68 QString currentService;
69 QTreeView *tree;
70 QAction *refreshAction;
71 QTreeWidget *services;
72 QStringListModel *servicesModel;
73 ServicesProxyModel *servicesProxyModel;
74 QLineEdit *serviceFilterLine;
75 QTableView *servicesView;
76 QTextBrowser *log;
77 QSplitter *topSplitter;
78 QSplitter *splitter;
79 QRegularExpression objectPathRegExp;
80};
81
82#endif
83

source code of qttools/src/qdbus/qdbusviewer/qdbusviewer.h