From c9d519f36c62611a768936018fe185a011a4d6a0 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 14 May 2015 14:48:29 +0200 Subject: [PATCH] focus search input field when opening search subview (Fixes #2534) --- apps/opencs/view/tools/searchbox.cpp | 7 +++++++ apps/opencs/view/tools/searchbox.hpp | 2 ++ apps/opencs/view/tools/searchsubview.cpp | 8 +++++++- apps/opencs/view/tools/searchsubview.hpp | 4 ++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/tools/searchbox.cpp b/apps/opencs/view/tools/searchbox.cpp index ca5520787..1307c1aab 100644 --- a/apps/opencs/view/tools/searchbox.cpp +++ b/apps/opencs/view/tools/searchbox.cpp @@ -153,6 +153,11 @@ void CSVTools::SearchBox::setEditLock (bool locked) mReplace.setEnabled (!locked); } +void CSVTools::SearchBox::focus() +{ + mInput.currentWidget()->setFocus(); +} + void CSVTools::SearchBox::modeSelected (int index) { switch (index) @@ -172,6 +177,8 @@ void CSVTools::SearchBox::modeSelected (int index) break; } + mInput.currentWidget()->setFocus(); + updateSearchButton(); } diff --git a/apps/opencs/view/tools/searchbox.hpp b/apps/opencs/view/tools/searchbox.hpp index 433c09693..fe56966d1 100644 --- a/apps/opencs/view/tools/searchbox.hpp +++ b/apps/opencs/view/tools/searchbox.hpp @@ -49,6 +49,8 @@ namespace CSVTools void setEditLock (bool locked); + void focus(); + private slots: void modeSelected (int index); diff --git a/apps/opencs/view/tools/searchsubview.cpp b/apps/opencs/view/tools/searchsubview.cpp index 32c26ee96..dc670af40 100644 --- a/apps/opencs/view/tools/searchsubview.cpp +++ b/apps/opencs/view/tools/searchsubview.cpp @@ -60,6 +60,12 @@ void CSVTools::SearchSubView::replace (bool selection) } } +void CSVTools::SearchSubView::showEvent (QShowEvent *event) +{ + CSVDoc::SubView::showEvent (event); + mSearchBox.focus(); +} + CSVTools::SearchSubView::SearchSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document) : CSVDoc::SubView (id), mDocument (document), mLocked (false) { @@ -83,7 +89,7 @@ CSVTools::SearchSubView::SearchSubView (const CSMWorld::UniversalId& id, CSMDoc: SIGNAL (focusId (const CSMWorld::UniversalId&, const std::string&))); connect (mTable, SIGNAL (replaceRequest()), this, SLOT (replaceRequest())); - + connect (&document, SIGNAL (stateChanged (int, CSMDoc::Document *)), this, SLOT (stateChanged (int, CSMDoc::Document *))); diff --git a/apps/opencs/view/tools/searchsubview.hpp b/apps/opencs/view/tools/searchsubview.hpp index 6dedd6ef2..2e96b98b5 100644 --- a/apps/opencs/view/tools/searchsubview.hpp +++ b/apps/opencs/view/tools/searchsubview.hpp @@ -32,6 +32,10 @@ namespace CSVTools private: void replace (bool selection); + + protected: + + void showEvent (QShowEvent *event); public: