| 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 | |
| 11 | class ServicesProxyModel; |
| 12 | |
| 13 | QT_FORWARD_DECLARE_CLASS(QTableView) |
| 14 | QT_FORWARD_DECLARE_CLASS(QTreeView) |
| 15 | QT_FORWARD_DECLARE_CLASS(QTreeWidget) |
| 16 | QT_FORWARD_DECLARE_CLASS(QStringListModel) |
| 17 | QT_FORWARD_DECLARE_CLASS(QLineEdit) |
| 18 | QT_FORWARD_DECLARE_CLASS(QTextBrowser) |
| 19 | QT_FORWARD_DECLARE_CLASS(QDomDocument) |
| 20 | QT_FORWARD_DECLARE_CLASS(QDomElement) |
| 21 | QT_FORWARD_DECLARE_CLASS(QSplitter) |
| 22 | QT_FORWARD_DECLARE_CLASS(QSettings) |
| 23 | |
| 24 | struct BusSignature |
| 25 | { |
| 26 | QString mService, mPath, mInterface, mName; |
| 27 | QString mTypeSig; |
| 28 | }; |
| 29 | |
| 30 | class QDBusViewer: public QWidget |
| 31 | { |
| 32 | Q_OBJECT |
| 33 | public: |
| 34 | QDBusViewer(const QDBusConnection &connection, QWidget *parent = 0); |
| 35 | |
| 36 | void saveState(QSettings *settings) const; |
| 37 | void restoreState(const QSettings *settings); |
| 38 | |
| 39 | public slots: |
| 40 | void refresh(); |
| 41 | |
| 42 | private 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 | |
| 61 | private: |
| 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 | QStringListModel *servicesModel; |
| 72 | ServicesProxyModel *servicesProxyModel; |
| 73 | QLineEdit *serviceFilterLine; |
| 74 | QTableView *servicesView; |
| 75 | QTextBrowser *log; |
| 76 | QSplitter *topSplitter; |
| 77 | QSplitter *splitter; |
| 78 | QRegularExpression objectPathRegExp; |
| 79 | }; |
| 80 | |
| 81 | #endif |
| 82 |
