Stellarium 0.12.4
ShortcutLineEdit.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2012 Anton Samoylov
4  * Copyright (C) 2012 Bogdan Marinov
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
19  */
20 #ifndef SHORTCUTLINEEDIT_H
21 #define SHORTCUTLINEEDIT_H
22 
23 #include <QLineEdit>
24 #include <QKeySequence>
25 
35 class ShortcutLineEdit : public QLineEdit
36 {
37  Q_OBJECT
38 
39 public:
40  ShortcutLineEdit(QWidget* parent = 0);
41 
42  QKeySequence getKeySequence();
43  bool isEmpty() const;
44 
45 public slots:
47  void clear();
49  void backspace();
51  void setContents(QKeySequence ks);
52 
53 signals:
57  void focusChanged(bool focus);
58  void contentsChanged();
59 
60 protected:
61  void keyPressEvent(QKeyEvent *e);
62  void focusInEvent(QFocusEvent *e);
63  void focusOutEvent(QFocusEvent *e);
64 
65 private:
67  static int getModifiers(Qt::KeyboardModifiers state, const QString &text);
68 
70  QList<int> keys;
71 };
72 
73 #endif // SHORTCUTLINEEDIT_H