1 /* 2 * Copyright (C) 2009-2015 by Stephen Allewell 3 * steve.allewell@gmail.com 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 */ 10 11 12 #ifndef KeycodeLineEdit_H 13 #define KeycodeLineEdit_H 14 15 16 #include <KLineEdit> 17 #include <QString> 18 19 20 class QKeyEvent; 21 22 23 class KeycodeLineEdit : public KLineEdit 24 { 25 Q_OBJECT 26 27 public: 28 explicit KeycodeLineEdit(QWidget *parent); 29 30 int key(); 31 Qt::KeyboardModifiers modifiers(); 32 void setKeyModifiers(int key, Qt::KeyboardModifiers modifiers); 33 static QString keyString(int qtKey, Qt::KeyboardModifiers modifiers); 34 35 protected: 36 virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; 37 38 private: 39 static QString findQtText(int qtKey); 40 int m_key; 41 Qt::KeyboardModifiers m_modifiers; 42 }; 43 44 45 #endif // KeycodeLineEdit_H 46