diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-01-12 04:37:30 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-01-12 04:37:30 +0100 |
commit | 5ccfbba435857bfaead6d5d118bcd939cb37dd3a (patch) | |
tree | a2d77522d85f9be55bddec2fa4fcf61623c577ac /application/widgets | |
parent | 1f0e76a3c1fe9dfb702adbd8a1357abe06e22c35 (diff) | |
download | MultiMC-5ccfbba435857bfaead6d5d118bcd939cb37dd3a.tar MultiMC-5ccfbba435857bfaead6d5d118bcd939cb37dd3a.tar.gz MultiMC-5ccfbba435857bfaead6d5d118bcd939cb37dd3a.tar.lz MultiMC-5ccfbba435857bfaead6d5d118bcd939cb37dd3a.tar.xz MultiMC-5ccfbba435857bfaead6d5d118bcd939cb37dd3a.zip |
NOISSUE select modpack field content on focus in new instance dialog
Diffstat (limited to 'application/widgets')
-rw-r--r-- | application/widgets/FocusLineEdit.cpp | 25 | ||||
-rw-r--r-- | application/widgets/FocusLineEdit.h | 17 |
2 files changed, 42 insertions, 0 deletions
diff --git a/application/widgets/FocusLineEdit.cpp b/application/widgets/FocusLineEdit.cpp new file mode 100644 index 00000000..139126c8 --- /dev/null +++ b/application/widgets/FocusLineEdit.cpp @@ -0,0 +1,25 @@ +#include "FocusLineEdit.h" +#include <QDebug> + +FocusLineEdit::FocusLineEdit(QWidget *parent) : QLineEdit(parent) +{ + _selectOnMousePress = false; +} + +void FocusLineEdit::focusInEvent(QFocusEvent *e) +{ + QLineEdit::focusInEvent(e); + selectAll(); + _selectOnMousePress = true; +} + +void FocusLineEdit::mousePressEvent(QMouseEvent *me) +{ + QLineEdit::mousePressEvent(me); + if (_selectOnMousePress) + { + selectAll(); + _selectOnMousePress = false; + } + qDebug() << selectedText(); +} diff --git a/application/widgets/FocusLineEdit.h b/application/widgets/FocusLineEdit.h new file mode 100644 index 00000000..6d1c78a8 --- /dev/null +++ b/application/widgets/FocusLineEdit.h @@ -0,0 +1,17 @@ +#include <QLineEdit> + +class FocusLineEdit : public QLineEdit +{ + Q_OBJECT +public: + FocusLineEdit(QWidget *parent); + virtual ~FocusLineEdit() + { + } + +protected: + void focusInEvent(QFocusEvent *e); + void mousePressEvent(QMouseEvent *me); + + bool _selectOnMousePress; +}; |