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: [PATCH] NOISSUE select modpack field content on focus in new instance dialog --- application/CMakeLists.txt | 2 ++ application/dialogs/NewInstanceDialog.ui | 11 +++++++++-- application/widgets/FocusLineEdit.cpp | 25 ++++++++++++++++++++++++ application/widgets/FocusLineEdit.h | 17 ++++++++++++++++ 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 application/widgets/FocusLineEdit.cpp create mode 100644 application/widgets/FocusLineEdit.h diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt index 65bee8c9..c3325055 100644 --- a/application/CMakeLists.txt +++ b/application/CMakeLists.txt @@ -200,6 +200,8 @@ SET(MULTIMC_SOURCES # GUI - widgets widgets/Common.cpp widgets/Common.h + widgets/FocusLineEdit.cpp + widgets/FocusLineEdit.h widgets/IconLabel.cpp widgets/IconLabel.h widgets/LabeledToolButton.cpp diff --git a/application/dialogs/NewInstanceDialog.ui b/application/dialogs/NewInstanceDialog.ui index f9d59a56..6b875ff4 100644 --- a/application/dialogs/NewInstanceDialog.ui +++ b/application/dialogs/NewInstanceDialog.ui @@ -9,7 +9,7 @@ 0 0 - 277 + 281 404 @@ -118,7 +118,7 @@ - + false @@ -192,6 +192,13 @@ + + + FocusLineEdit + QLineEdit +
widgets/FocusLineEdit.h
+
+
instNameTextBox groupBox 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; +};