From 5ccfbba435857bfaead6d5d118bcd939cb37dd3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 12 Jan 2016 04:37:30 +0100 Subject: NOISSUE select modpack field content on focus in new instance dialog --- application/widgets/FocusLineEdit.cpp | 25 +++++++++++++++++++++++++ application/widgets/FocusLineEdit.h | 17 +++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 application/widgets/FocusLineEdit.cpp create mode 100644 application/widgets/FocusLineEdit.h (limited to 'application/widgets') 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 + +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 + +class FocusLineEdit : public QLineEdit +{ + Q_OBJECT +public: + FocusLineEdit(QWidget *parent); + virtual ~FocusLineEdit() + { + } + +protected: + void focusInEvent(QFocusEvent *e); + void mousePressEvent(QMouseEvent *me); + + bool _selectOnMousePress; +}; -- cgit v1.2.3