summaryrefslogtreecommitdiffstats
path: root/application/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'application/widgets')
-rw-r--r--application/widgets/FocusLineEdit.cpp25
-rw-r--r--application/widgets/FocusLineEdit.h17
2 files changed, 42 insertions, 0 deletions
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;
+};