NOISSUE select modpack field content on focus in new instance dialog

This commit is contained in:
Petr Mrázek 2016-01-12 04:37:30 +01:00
parent 1f0e76a3c1
commit 5ccfbba435
4 changed files with 53 additions and 2 deletions

View File

@ -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

View File

@ -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>

View File

@ -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();
}

View File

@ -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;
};