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 KEYSEQUENCEINPUTWIDGET_H
0021 #define KEYSEQUENCEINPUTWIDGET_H
0022 
0023 #include <QScopedPointer>
0024 #include <QWidget>
0025 #include <QtGlobal>
0026 
0027 // forward declarations
0028 class QKeySequence;
0029 
0030 namespace Wacom
0031 {
0032 
0033 // forward declarations
0034 class KeySequenceInputWidgetPrivate;
0035 
0036 /**
0037  * @class KeySequenceInputWidget
0038  *
0039  * @brief A keyboard shortcut input widget similar to KKeySequence.
0040  *
0041  * This class is mostly copied from KKeySequence. However this implementation
0042  * only supports one shortcut and it will not suppress the shift modifier.
0043  * To set a key sequence on a wacom tablet the full sequence is required. The
0044  * original KKeySequence implementation suppresses the shift modifier which
0045  * makes the shortcut useless for xsetwacom.
0046  */
0047 class KeySequenceInputWidget : public QWidget
0048 {
0049     Q_OBJECT
0050 
0051 public:
0052     //! Default Constructor
0053     KeySequenceInputWidget(QWidget *parent = nullptr);
0054 
0055     //! Destructor
0056     ~KeySequenceInputWidget() override;
0057 
0058     //! Returns the current key sequence.
0059     const QKeySequence &keySequence() const;
0060 
0061 public Q_SLOTS:
0062 
0063     //! Clears the current key sequence.
0064     void clearKeySequence();
0065 
0066     //! Sets the key sequence.
0067     void setKeySequence(const QKeySequence &sequence);
0068 
0069 Q_SIGNALS:
0070 
0071     //! Emitted when the key sequence changes.
0072     void keySequenceChanged(const QKeySequence &sequence);
0073 
0074 private Q_SLOTS:
0075 
0076     void onKeySequenceChanged(const QKeySequence &sequence);
0077 
0078 private:
0079     //! Copy Constructor
0080     KeySequenceInputWidget(const KeySequenceInputWidget &other) = delete;
0081 
0082     //! Copy Operator
0083     KeySequenceInputWidget &operator=(const KeySequenceInputWidget &other) = delete;
0084 
0085     Q_DECLARE_PRIVATE(KeySequenceInputWidget)
0086     const QScopedPointer<KeySequenceInputWidgetPrivate> d_ptr; //!< D-Pointer to private members.
0087 
0088 }; // CLASS KeySequenceInputWidget
0089 } // NAMESPACE Wacom
0090 #endif // KEYSEQUENCEINPUTWIDGET_H