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 DBUSTABLETSERVICE_H 0021 #define DBUSTABLETSERVICE_H 0022 0023 #include "tablethandlerinterface.h" 0024 #include "tabletinformation.h" 0025 0026 #include <QObject> 0027 #include <QString> 0028 #include <QStringList> 0029 0030 namespace Wacom 0031 { 0032 class DBusTabletServicePrivate; 0033 0034 /** 0035 * @brief The D-Bus tablet service. 0036 * 0037 * Handles all D-Bus requests to the tablet daemon and passes them to the 0038 * tablet handler. All work is done by other modules, this class only 0039 * exists to separate the d-bus interface from the business logic and to 0040 * facilitate unit testing. 0041 */ 0042 class DBusTabletService : public QObject 0043 { 0044 Q_OBJECT 0045 Q_CLASSINFO("D-Bus Interface", "org.kde.Wacom") 0046 0047 public: 0048 explicit DBusTabletService(TabletHandlerInterface &tabletHandler); 0049 ~DBusTabletService() override; 0050 0051 // d-bus slots 0052 public Q_SLOTS: 0053 /** 0054 * List all connected tablets (by tabletid) 0055 * 0056 * @return StringList of the connected tablets with their id 0057 */ 0058 Q_SCRIPTABLE const QStringList getTabletList() const; 0059 0060 /** 0061 * List of the internal device names (pad/stylus/eraser) as used by xsetwacom command 0062 * 0063 * @param tabletId the ID of the Tablet to check 0064 * @return StringList of the connected input devices 0065 */ 0066 Q_SCRIPTABLE const QStringList getDeviceList(const QString &tabletId) const; 0067 0068 /** 0069 * Gets the name of a device (pad/stylus/...). 0070 * 0071 * @param tabletId the ID of the Tablet to check 0072 * @param device A device as returned by DeviceType::key() 0073 * 0074 * @return The name of the device. 0075 */ 0076 Q_SCRIPTABLE QString getDeviceName(const QString &tabletId, const QString &device) const; 0077 0078 /** 0079 * Gets information from the tablet. 0080 * 0081 * @param tabletId the ID of the Tablet to check 0082 * @param info The type of information. 0083 * 0084 * @return The information value. 0085 */ 0086 Q_SCRIPTABLE QString getInformation(const QString &tabletId, const QString &info) const; 0087 0088 /** 0089 * Returns the current active profile for this tablet. 0090 * 0091 * This is not necessary the real configuration in case some other program changed the tablet 0092 * behaviour. But this is the name of the profile that was used last. 0093 * Can be used to show in the applet as information or as beginning selection in the kcmodule. 0094 * 0095 * @param tabletId the ID of the Tablet to check 0096 * @return name of the last used profile 0097 */ 0098 Q_SCRIPTABLE QString getProfile(const QString &tabletId) const; 0099 0100 /** 0101 * Returns the current value for a specific tablet device (stylus/eraser/pad/...). 0102 * 0103 * @param tabletId the ID of the Tablet to check 0104 * @param deviceType Type of device (stylus/eraser/...) to get the value from. 0105 * @param property The property we are looking for. 0106 * 0107 * @return the value as string 0108 */ 0109 Q_SCRIPTABLE QString getProperty(const QString &tabletId, const QString &deviceType, const QString &property) const; 0110 0111 /** 0112 * Tells you if the detected tablet has configurable pushbuttons or not 0113 * 0114 * @param tabletId the ID of the Tablet to check 0115 * 0116 * @return @c true if pushbuttons are available and thus the conf dialogue can be shown 0117 * @c false if nothing is available 0118 */ 0119 Q_SCRIPTABLE bool hasPadButtons(const QString &tabletId) const; 0120 0121 /** 0122 * Checks if a tablet is detected and available for further usage 0123 * 0124 * @param tabletId the ID of the Tablet to check 0125 * 0126 * @return @c true if tablet is available, @c false otherwise 0127 */ 0128 Q_SCRIPTABLE bool isAvailable(const QString &tabletId) const; 0129 0130 /** 0131 * Returns a list of all available profiles 0132 * 0133 * This way around the plasma applet does not check the local KConfig file itself 0134 * and can be used as a remote applet. 0135 * 0136 * @param tabletId the ID of the Tablet to check 0137 * 0138 * @return the list of all available profiles 0139 */ 0140 Q_SCRIPTABLE QStringList listProfiles(const QString &tabletId); 0141 0142 /** 0143 * Applies a profile to the tablet device 0144 * 0145 * The profile must exist in the tabletprofilerc file and thus created by the kcmodule. 0146 * Otherwise a notification error is send and shown. 0147 * 0148 * @param tabletId the ID of the Tablet to check 0149 * 0150 * @param profile name of the profile as specified in the tabletprofilesrc file. 0151 */ 0152 Q_SCRIPTABLE void setProfile(const QString &tabletId, const QString &profile); 0153 0154 /** 0155 * Sets the configuration of @p property from @p deviceType to @p value. 0156 * 0157 * @param tabletId the ID of the Tablet to check 0158 * @param deviceType The device type to set the value on. 0159 * @param property The property to set. 0160 * @param value The new value of the property. 0161 */ 0162 Q_SCRIPTABLE void setProperty(const QString &tabletId, const QString &deviceType, const QString &property, const QString &value); 0163 0164 /** 0165 * Returns the list for the device profile rotation 0166 * 0167 * This list will define which profile will be loaded 0168 * via the global next/prev profile shortcut 0169 * 0170 * @param tabletId the ID of the Tablet to check 0171 * 0172 * @return stringlist with profile names in the rotation 0173 */ 0174 Q_SCRIPTABLE QStringList getProfileRotationList(const QString &tabletId); 0175 0176 /** 0177 * Set the Profile rotation list for this Device 0178 * 0179 * @param tabletId the ID of the Tablet to check 0180 * @param rotationList stringlist with profilenames in the right order 0181 */ 0182 Q_SCRIPTABLE void setProfileRotationList(const QString &tabletId, const QStringList &rotationList); 0183 0184 /** 0185 * @brief Get touch sensor device USB ID 0186 * 0187 * Some tablets report devices with multiple USB IDs (e.g. Cintiq Companion Hybrid) 0188 * Primary device (usually the one containing stylus sensor) should have this set 0189 * to the USB ID of the corresponding secondary device (touch sensor) 0190 * 0191 * @param tabletId of the device to check 0192 * @return tabletId of the touch device 0193 */ 0194 Q_SCRIPTABLE QString getTouchSensorId(const QString &tabletId); 0195 0196 /** 0197 * @brief Reports if this device is a secondary touch sensor 0198 * 0199 * Touch sensor devices shouldn't be visible in the KCM 0200 * 0201 * @param tabletId of the device to check 0202 * @return true if it's a touch sensor 0203 */ 0204 Q_SCRIPTABLE bool isTouchSensor(const QString &tabletId); 0205 0206 // d-bus signals 0207 Q_SIGNALS: 0208 0209 /** 0210 * Emitted if a new tablet is connected and detected 0211 * 0212 * This signal is send via DBus to inform other about the recently added device 0213 */ 0214 Q_SCRIPTABLE void tabletAdded(const QString &tabletId); 0215 0216 /** 0217 * Emitted if a known tablet is removed 0218 * 0219 * This signal is send via DBus to inform other about the recently removed device 0220 */ 0221 Q_SCRIPTABLE void tabletRemoved(const QString &tabletId); 0222 0223 /** 0224 * Emitted when the profile of the device is changed 0225 * 0226 * This signal is send via DBus to inform other about the change 0227 */ 0228 Q_SCRIPTABLE void profileChanged(const QString &tabletId, const QString &profile); 0229 0230 // normal Qt slots 0231 public slots: 0232 0233 //! Has to be called when the current profile was changed. 0234 void onProfileChanged(const QString &tabletId, const QString &profile); 0235 0236 //! Has to be called when a new tablet is added. 0237 void onTabletAdded(const TabletInformation &info); 0238 0239 //! Has to be called when the current tablet is removed. 0240 void onTabletRemoved(const QString &tabletId); 0241 0242 private: 0243 Q_DECLARE_PRIVATE(DBusTabletService) 0244 DBusTabletServicePrivate *const d_ptr; /**< d-pointer for this class */ 0245 0246 }; // CLASS 0247 } // NAMESPACE 0248 #endif // HEADER PROTECTION