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 # GUI - widgets
widgets/Common.cpp widgets/Common.cpp
widgets/Common.h widgets/Common.h
widgets/FocusLineEdit.cpp
widgets/FocusLineEdit.h
widgets/IconLabel.cpp widgets/IconLabel.cpp
widgets/IconLabel.h widgets/IconLabel.h
widgets/LabeledToolButton.cpp widgets/LabeledToolButton.cpp

View File

@ -9,7 +9,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>277</width> <width>281</width>
<height>404</height> <height>404</height>
</rect> </rect>
</property> </property>
@ -118,7 +118,7 @@
</widget> </widget>
</item> </item>
<item row="4" column="0" colspan="2"> <item row="4" column="0" colspan="2">
<widget class="QLineEdit" name="modpackEdit"> <widget class="FocusLineEdit" name="modpackEdit">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
@ -192,6 +192,13 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>FocusLineEdit</class>
<extends>QLineEdit</extends>
<header>widgets/FocusLineEdit.h</header>
</customwidget>
</customwidgets>
<tabstops> <tabstops>
<tabstop>instNameTextBox</tabstop> <tabstop>instNameTextBox</tabstop>
<tabstop>groupBox</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;
};