From f8677334998786627637d08dde7c537730c4d251 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 10 Jun 2014 11:34:23 +0200 Subject: [PATCH] + restore selected numbers in input field after showing it, select numbers if widget gets focus by Tab/Backtab/Shortcut --- src/Gui/InputField.cpp | 13 +++++++++++++ src/Gui/InputField.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/Gui/InputField.cpp b/src/Gui/InputField.cpp index 2bbfb9a11..56b2ae2f1 100644 --- a/src/Gui/InputField.cpp +++ b/src/Gui/InputField.cpp @@ -460,7 +460,20 @@ void InputField::showEvent(QShowEvent * event) { QLineEdit::showEvent(event); + bool selected = this->hasSelectedText(); updateText(actQuantity); + if (selected) + selectNumber(); +} + +void InputField::focusInEvent(QFocusEvent * event) +{ + if (event->reason() == Qt::TabFocusReason || + event->reason() == Qt::BacktabFocusReason || + event->reason() == Qt::ShortcutFocusReason) { + if (!this->hasSelectedText()) + selectNumber(); + } } void InputField::keyPressEvent(QKeyEvent *event) diff --git a/src/Gui/InputField.h b/src/Gui/InputField.h index 344ae0698..2bb2cffd2 100644 --- a/src/Gui/InputField.h +++ b/src/Gui/InputField.h @@ -157,6 +157,7 @@ protected Q_SLOTS: protected: virtual void showEvent(QShowEvent * event); + virtual void focusInEvent(QFocusEvent * event); virtual void keyPressEvent(QKeyEvent * event); virtual void wheelEvent(QWheelEvent * event); virtual void contextMenuEvent(QContextMenuEvent * event);