File indexing completed on 2025-01-26 05:09:31
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 KCMWACOMTABLETWIDGET_H 0021 #define KCMWACOMTABLETWIDGET_H 0022 0023 #include <QWidget> 0024 0025 namespace Wacom 0026 { 0027 0028 class KCMWacomTabletWidgetPrivate; 0029 0030 /** 0031 * This class implements the tabletwidget.ui designer file 0032 * It is the skeleton for the tablet settings widget and able to show the used tablet 0033 * as image as well as some basic information. Furthermore this widget holds the KConfig profile 0034 * selector and handles all profiles. 0035 * The subgroup setting widgets for the pad/stylus/eraser are grouped together in an KTabWidget 0036 */ 0037 class KCMWacomTabletWidget : public QWidget 0038 { 0039 Q_OBJECT 0040 0041 public: 0042 /** 0043 * default constructor 0044 * 0045 * @param parent Parent widget 0046 */ 0047 explicit KCMWacomTabletWidget(QWidget *parent = nullptr); 0048 0049 /** 0050 * default destructor 0051 */ 0052 ~KCMWacomTabletWidget() override; 0053 0054 /** 0055 * Reloads the profile to its saved values from the config file 0056 * Resets all made changes so far 0057 */ 0058 void reloadProfile(); 0059 0060 /** 0061 * Saves the current active profile 0062 * Takes the values from each widget and saves them 0063 */ 0064 void saveProfile(); 0065 0066 signals: 0067 /** 0068 * Will be emitted whenever the status of the widget changes to inform the KCModule about it 0069 * 0070 * @param change @c true if config changed @c false if not 0071 */ 0072 void changed(bool change); 0073 0074 public slots: 0075 /** 0076 * Check if dbus service is running and tablets are connected 0077 * 0078 * Shows either error message or the configuration for a selected tablet 0079 */ 0080 void showHideConfig(); 0081 0082 void onTabletAdded(const QString &tabletId); 0083 void onTabletRemoved(const QString &tabletId); 0084 void onTabletSelectionChanged(); 0085 0086 /** 0087 * Slot that opens up a dialogue to create a new profile for the connected tablet. 0088 * Starting parameter of the profile will be the default params as detected by xsetwacom. 0089 */ 0090 void addProfile(); 0091 0092 /** 0093 * Deletes the currently selected profile. 0094 * If the last profile was deleted a new default profile will automatically created. 0095 */ 0096 void delProfile(); 0097 0098 /** 0099 * Switch from one profile to another and updates all other widgets. 0100 * This slot will be called from the profile selector combobox. 0101 * 0102 * @param profile The profile name the widget should switch to as written in the KConfig file 0103 */ 0104 void switchProfile(const QString &profile); 0105 0106 /** 0107 * Will be called whenever a parameter of the currently selected profile changed. 0108 * This ensures that changes in the profile will be saved back to the configuration file before 0109 * the program is closed or the profile switched. 0110 * The user is asked if the changes should be saved or thrown away. 0111 */ 0112 void profileChanged(); 0113 0114 private: 0115 /** 0116 * Load all connected tablets on startup 0117 * 0118 * Later on use ontanletAdded and onTabletRemoved 0119 */ 0120 void loadTabletInformation(); 0121 0122 /** 0123 * Activates the current profile for all connected devices (pen/stylus/eraser) 0124 * Happens when the profile is saved/switched/loaded 0125 */ 0126 void applyProfile(); 0127 0128 /** 0129 * Disables the profile selector and hides all configuration tabs. 0130 */ 0131 void hideConfig(); 0132 0133 /** 0134 * Hides an error message which was previously shown using showError(). 0135 * If no error message is active, nothing is done. 0136 */ 0137 void hideError(); 0138 0139 /** 0140 * Initialize the widget 0141 * creates all necessary setting widgets and connects their signals 0142 */ 0143 void setupUi(); 0144 0145 /** 0146 * Reloads profiles from the profile manager and loads them into the profile 0147 * selector. If a profile name is given, it will be selected. If no profile 0148 * is given the default widget selection method applies. 0149 * 0150 * @param profile The profile to select (possibly empty) 0151 * 0152 * @return True if a profile was given and it could be set, else false. 0153 */ 0154 bool refreshProfileSelector(const QString &profile = QString()); 0155 0156 /** 0157 * Activates the profile selector and show all configuration tabs depending 0158 * on the currently loaded profile. If an error message is currently active, 0159 * it will be hidden. 0160 */ 0161 void showConfig(); 0162 0163 /** 0164 * If an error occurs a widget with some additional text is shown instead of the config widget. 0165 * Happens if no tablet device can be found or the kded daemon is not working. 0166 * 0167 * @param errMsg the message that describes the error in more detail 0168 */ 0169 void showError(const QString &errorTitle, const QString &errorMsg, bool showTabletFinderButton = false); 0170 0171 /** 0172 * Shows a dialog which allows the user to save his changes if the currently 0173 * active configuration was changed. 0174 */ 0175 void showSaveChanges(); 0176 0177 void showTabletFinder(); 0178 0179 void addTabletToSelector(const QString &tabletId); 0180 0181 Q_DECLARE_PRIVATE(KCMWacomTabletWidget) 0182 KCMWacomTabletWidgetPrivate *const d_ptr; /**< d-pointer for this class */ 0183 0184 }; // CLASS 0185 } // NAMESPACE 0186 #endif /*KCMWACOMTABLETWIDGET_H*/