File indexing completed on 2024-05-05 05:37:32

0001 /*
0002     SPDX-FileCopyrightText: 2011 Lionel Chauvin <megabigbug@yahoo.fr>
0003     SPDX-FileCopyrightText: 2011, 2012 Cédric Bellegarde <gnumdk@gmail.com>
0004 
0005     SPDX-License-Identifier: MIT
0006 */
0007 
0008 #pragma once
0009 
0010 // Qt
0011 #include <QDBusContext>
0012 #include <QDBusObjectPath>
0013 #include <QDebug>
0014 #include <QObject>
0015 #include <qwindowdefs.h>
0016 
0017 class AppmenuDBus : public QObject, protected QDBusContext
0018 {
0019     Q_OBJECT
0020 
0021 public:
0022     explicit AppmenuDBus(QObject *);
0023     ~AppmenuDBus() override;
0024 
0025     bool connectToBus(const QString &service = QString(), const QString &path = QString());
0026 
0027     /**
0028      * DBus method showing menu at QPoint(x,y) for given DBus service name and menuObjectPath
0029      * if x or y == -1, show in application window
0030      */
0031     void showMenu(int x, int y, const QString &serviceName, const QDBusObjectPath &menuObjectPath, int actionId);
0032     /**
0033      * DBus method reconfiguring kded module
0034      */
0035     void reconfigure();
0036 
0037 Q_SIGNALS:
0038     /**
0039      * This signal is emitted on showMenu() request
0040      */
0041     void appShowMenu(int x, int y, const QString &serviceName, const QDBusObjectPath &menuObjectPath, int actionId);
0042     /**
0043      * This signal is emitted on reconfigure() request
0044      */
0045     void reconfigured();
0046 
0047     // Dbus signals
0048     /**
0049      * This signal is emitted whenever kded want to show menu
0050      * We do not know where is menu decoration button, so tell kwin to show menu
0051      */
0052     void showRequest(const QString &serviceName, const QDBusObjectPath &menuObjectPath, int actionId);
0053     /**
0054      * This signal is emitted whenever popup menu/menubar is shown
0055      * Useful for decorations to know if menu button should look pressed
0056      */
0057     void menuShown(const QString &serviceName, const QDBusObjectPath &menuObjectPath);
0058     /**
0059      * This signal is emitted whenever popup menu/menubar is hidden
0060      * Useful for decorations to know if menu button should be release
0061      */
0062     void menuHidden(const QString &serviceName, const QDBusObjectPath &menuObjectPath);
0063 
0064 private:
0065     QString m_service;
0066 };