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 | |
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')
-rw-r--r-- | application/CMakeLists.txt | 2 | ||||
-rw-r--r-- | application/dialogs/NewInstanceDialog.ui | 11 | ||||
-rw-r--r-- | application/widgets/FocusLineEdit.cpp | 25 | ||||
-rw-r--r-- | application/widgets/FocusLineEdit.h | 17 |
4 files changed, 53 insertions, 2 deletions
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 @@ <rect> <x>0</x> <y>0</y> - <width>277</width> + <width>281</width> <height>404</height> </rect> </property> @@ -118,7 +118,7 @@ </widget> </item> <item row="4" column="0" colspan="2"> - <widget class="QLineEdit" name="modpackEdit"> + <widget class="FocusLineEdit" name="modpackEdit"> <property name="enabled"> <bool>false</bool> </property> @@ -192,6 +192,13 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>FocusLineEdit</class> + <extends>QLineEdit</extends> + <header>widgets/FocusLineEdit.h</header> + </customwidget> + </customwidgets> <tabstops> <tabstop>instNameTextBox</tabstop> <tabstop>groupBox</tabstop> 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; +}; |