File indexing completed on 2024-12-22 05:17:20

0001 /*
0002  * This file is part of the KDE wacomtablet project. For copyright
0003  * information and license terms see the AUTHORS and COPYING files
0004  * in the top-level directory of this distribution.
0005  *
0006  * This program is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU General Public License as
0008  * published by the Free Software Foundation; either version 2 of
0009  * the License, or (at your option) any later version.
0010  *
0011  * This program is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  * GNU General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU General Public License
0017  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
0018  */
0019 
0020 #ifndef TABLETDAEMON_H
0021 #define TABLETDAEMON_H
0022 
0023 #include <KDEDModule>
0024 #include <QVariantList>
0025 
0026 class QScreen;
0027 
0028 /**
0029  * The wacom namespace holds all classes regarding the tablet daemon / kcmodule and applet.
0030  */
0031 namespace Wacom
0032 {
0033 class TabletDaemonPrivate;
0034 
0035 /**
0036  * This module manages the tablet device and exports a convenient DBus API
0037  * for tablet configuration and management.
0038  *
0039  * Its task is to monitor Hotpluging devices via solid and the detection of the tablet connected.
0040  * Once a tablet is recognised a default profile will be applied via the wacom::DeviceHandler.
0041  *
0042  * Profiles can be changed with the kcmodule.
0043  * In addition a plasma applet allows easy switching of different profiles.
0044  *
0045  * It registers the service @c "org.kde.Wacom" and exports the following objects on this service:
0046  *
0047  * @li @c /Tablet - this object. Allows one to check if a tablet is available and applies the profile
0048  * @li @c /Device - tablet information. Basic information about the detected tablet
0049  */
0050 class TabletDaemon : public KDEDModule
0051 {
0052     Q_OBJECT
0053 
0054 public:
0055     /**
0056      * Creates a new daemon module.
0057      *
0058      * @param parent The parent object.
0059      * @param args   Ignored, required by KPlugin signature.
0060      */
0061     explicit TabletDaemon(QObject *parent = 0, const QVariantList &args = QVariantList());
0062 
0063     /**
0064      * Destroys this module
0065      */
0066     ~TabletDaemon() override;
0067 
0068 public Q_SLOTS:
0069 
0070     /**
0071      * Uses the KDE notification system to display a notification to the user.
0072      *
0073      * @param eventId The event identifier.
0074      * @param title   The notification title.
0075      * @param message The notification message.
0076      * @param suggestConfigure Defines whether to suggest configuration.
0077      */
0078     void onNotify(const QString &eventId, const QString &title, const QString &message, bool suggestConfigure) const;
0079 
0080     /**
0081      * Called when the profile was changed.
0082      *
0083      * @param tabletId The identifier of the tablet.
0084      * @param profile  The name of the new profile.
0085      */
0086     void onProfileChanged(const QString &tabletId, const QString &profile);
0087 
0088 private:
0089     /**
0090      * Sets up the global shortcut actions.
0091      * This method should only be called by a constructor.
0092      */
0093     void setupActions();
0094 
0095     /**
0096      * Sets up KDE application data, like i18n and the about dialog.
0097      * This method should only be called by a constructor.
0098      */
0099     void setupApplication();
0100 
0101     /**
0102      * Sets up the dbus interfaces.
0103      * This method should only be called by a constructor.
0104      */
0105     void setupDBus();
0106 
0107     /**
0108      * Sets up the X event notifier.
0109      * This method should only be called by a constructor.
0110      */
0111     void setupEventNotifier();
0112 
0113     /**
0114      * Helper function that sets up signals
0115      * monitoring screen rotations and geometry changes
0116      * for every existing and future screens.
0117      */
0118     void monitorAllScreensGeometry();
0119 
0120 private Q_SLOTS:
0121     /**
0122      * Sets up signals for rotation and geometry changes
0123      * for a specific screen
0124      * @param screen Screen to monitor
0125      */
0126     void monitorScreenGeometry(QScreen *screen);
0127 
0128 private:
0129     Q_DECLARE_PRIVATE(TabletDaemon)
0130     TabletDaemonPrivate *const d_ptr; /**< d-pointer for this class */
0131 
0132 }; // CLASS
0133 } // NAMESPACE
0134 #endif // HEADER PROTECTION