Seamly2D
Code documentation
vshortcutpropertyeditor.h
Go to the documentation of this file.
1 /************************************************************************
2  **
3  ** @file vshortcutpropertyeditor.h
4  ** @author hedgeware <internal(at)hedgeware.net>
5  ** @date
6  **
7  ** @brief
8  ** @copyright
9  ** All rights reserved. This program and the accompanying materials
10  ** are made available under the terms of the GNU Lesser General Public License
11  ** (LGPL) version 2.1 which accompanies this distribution, and is available at
12  ** http://www.gnu.org/licenses/lgpl-2.1.html
13  **
14  ** This library is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  ** Lesser General Public License for more details.
18  **
19  *************************************************************************/
20 
21 #ifndef VSHORTCUTPROPERTYEDITOR_H
22 #define VSHORTCUTPROPERTYEDITOR_H
23 
24 #include <qcompilerdetection.h>
25 #include <QKeySequence>
26 #include <QLineEdit>
27 #include <QMetaObject>
28 #include <QMimeData>
29 #include <QObject>
30 #include <QString>
31 #include <QToolButton>
32 #include <QWidget>
33 #include <QtGlobal>
34 
35 namespace VPE
36 {
37 
38 
39 class VShortcutEditWidget : public QWidget
40 {
41  Q_OBJECT
42 
43 public:
44  explicit VShortcutEditWidget(QWidget* parent);
45  virtual ~VShortcutEditWidget() Q_DECL_OVERRIDE;
46 
47  //! Needed for proper event handling
48  virtual bool eventFilter(QObject* obj, QEvent* event) Q_DECL_OVERRIDE;
49 
50  //! Returns the currently set shortcut
51  QString getShortcutAsString() const;
52 
53  //! Returns the currently set shortcut
54  QKeySequence getShortcut();
55 
56 signals:
57  //! This signal is emitted when the user changed the current shortcut
58  void dataChangedByUser(const QKeySequence& sequence, VShortcutEditWidget* editor);
59 
60  //! This signal is emitted whenever dataChangedByUser() gets emmitted
61  //! and is connected to the delegate's commitData() signal
62  void commitData(QWidget* editor);
63 
64 public slots:
65  //! Sets the shortcut
66  //! \param shortcut The new shortcut
67  //! \emit_signal If true, this will emit the dataChangedByUser()-signal
68  void setShortcut(const QString &shortcut, bool emit_signal);
69 
70  //! Sets the shortcut
71  //! \param shortcut The new shortcut
72  //! \emit_signal If true, this will emit the dataChangedByUser()-signal
73  void setShortcut(const QKeySequence &shortcut, bool emit_signal);
74 
75 private slots:
76  //! This slot is called when the user edits the line edit (e.g. by removing or pasting text using the mouse)
77  void onTextEdited(const QString& text);
78 
79 protected:
80  //! The current key sequence
81  QKeySequence CurrentKeySequence;
82 
83  //! The line to display and edit the key sequence
84  QLineEdit* LineEdit;
85 
86 private:
87  Q_DISABLE_COPY(VShortcutEditWidget)
88 };
89 
90 }
91 
92 #endif // VFILEPROPERTYEDITOR_H
void setShortcut(const QString &shortcut, bool emit_signal)
Sets the shortcut.
void commitData(QWidget *editor)
This signal is emitted whenever dataChangedByUser() gets emmitted and is connected to the delegate's ...
QLineEdit * LineEdit
The line to display and edit the key sequence.
void onTextEdited(const QString &text)
This slot is called when the user edits the line edit (e.g. by removing or pasting text using the mou...
virtual ~VShortcutEditWidget() Q_DECL_OVERRIDE
virtual bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE
Needed for proper event handling.
QKeySequence getShortcut()
Returns the currently set shortcut.
QString getShortcutAsString() const
Returns the currently set shortcut.
QKeySequence CurrentKeySequence
The current key sequence.
void dataChangedByUser(const QKeySequence &sequence, VShortcutEditWidget *editor)
This signal is emitted when the user changed the current shortcut.