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

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 DIALOG_H
0021 #define DIALOG_H
0022 
0023 #include <QDialog>
0024 
0025 #include "tabletinformation.h"
0026 
0027 namespace Ui
0028 {
0029 class Dialog;
0030 }
0031 
0032 class QAbstractButton;
0033 
0034 namespace Wacom
0035 {
0036 class HWButtonDialog;
0037 
0038 /**
0039  * @brief Main dialog windows that allows the user to detect and specify the tablet
0040  */
0041 class Dialog : public QDialog
0042 {
0043     Q_OBJECT
0044 
0045 public:
0046     explicit Dialog(QWidget *parent = nullptr);
0047     ~Dialog() override;
0048 
0049 private slots:
0050     // tablet detection and user selection
0051     void refreshTabletList();
0052     void changeTabletSelection(int index);
0053 
0054     // update internal representation on user changes
0055     void onHasStatusLEDsLeftChanged(bool toggled);
0056     void onhasStatusLEDsRightChanged(bool toggled);
0057     void onhasTouchRingChanged(bool toggled);
0058     void onhasTouchStripLeftChanged(bool toggled);
0059     void onhasTouchStripRightChanged(bool toggled);
0060     void onhasWheelChanged(bool toggled);
0061 
0062     void onExpressKeyNumbersChanged(int buttons);
0063     void buttonBoxClicked(QAbstractButton *button);
0064 
0065     void onPairedIdChanged(int index);
0066     void onNormalTabletSet(bool enabled);
0067     void onParentTabletSet(bool enabled);
0068     void onTouchSensorSet(bool enabled);
0069 
0070     /**
0071      * @brief Open the dialog that allows the user to detect hardware key mappings
0072      */
0073     void onMapButtons();
0074 
0075 private:
0076     bool validIndex();
0077     void showHWButtonMap();
0078 
0079     Ui::Dialog *m_ui = nullptr;
0080 
0081     struct Tablet {
0082         int serialID = 0;
0083         QString company;
0084         QString name;
0085         QString layout = QString::fromLatin1("unknown");
0086         QString model = QString::fromLatin1("unknown");
0087         QStringList devices;
0088         bool hasWheel = false;
0089         bool hasTouchRing = false;
0090         bool hasTouchStripLeft = false;
0091         bool hasTouchStripRight = false;
0092         bool hasStatusLEDsLeft = false;
0093         bool hasStatusLEDsRight = false;
0094         int buttonNumber = 0;
0095         QList<unsigned int> hwMapping;
0096 
0097         QString pairedID;
0098         bool hasPairedID = false;
0099         bool isTouchSensor = false;
0100     };
0101 
0102     void saveTabletInfo(const Tablet &t);
0103 
0104     QList<TabletInformation> m_tabletInformation;
0105     QList<Tablet> m_tabletList;
0106     Wacom::HWButtonDialog *m_hwbDialog;
0107 };
0108 }
0109 #endif // DIALOG_H