From 57167b9a6b5917daf1efe4f1f15491106276b761 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 23 Apr 2015 17:49:43 +0300 Subject: [PATCH] Fix problem with activating view window programmatically. --- src/LightApp/LightApp_Application.cxx | 2 +- src/STD/STD_TabDesktop.cxx | 12 ++++++++++++ src/STD/STD_TabDesktop.h | 1 + src/SUIT/SUIT_Desktop.cxx | 8 ++++++++ src/SUIT/SUIT_Desktop.h | 1 + 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 4b8c81e65..ef92a88d4 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1423,7 +1423,7 @@ SUIT_ViewManager* LightApp_Application::getViewManager( const QString& vmType, c if ( !aVM->getActiveView() ) aVM->createView(); else - aVM->getActiveView()->setFocus(); + desktop()->setActiveWindow( aVM->getActiveView() ); } else if ( create ) aVM = createViewManager( vmType ); diff --git a/src/STD/STD_TabDesktop.cxx b/src/STD/STD_TabDesktop.cxx index 8e0d6cbd7..6ca5a47db 100644 --- a/src/STD/STD_TabDesktop.cxx +++ b/src/STD/STD_TabDesktop.cxx @@ -97,6 +97,18 @@ SUIT_ViewWindow* STD_TabDesktop::activeWindow() const return wnd; } +/*! + Set active window + \param wnd - view window +*/ +void STD_TabDesktop::setActiveWindow(SUIT_ViewWindow* wnd) +{ + if (wnd) { + myWorkstack->setActiveWindow(wnd); + wnd->setFocus(); + } +} + /*! \retval QPtrList - return const active window list. */ diff --git a/src/STD/STD_TabDesktop.h b/src/STD/STD_TabDesktop.h index e844d8daa..0b75fea13 100644 --- a/src/STD/STD_TabDesktop.h +++ b/src/STD/STD_TabDesktop.h @@ -46,6 +46,7 @@ public: virtual ~STD_TabDesktop(); virtual SUIT_ViewWindow* activeWindow() const; + virtual void setActiveWindow(SUIT_ViewWindow*); virtual QList windows() const; void windowOperation( const int ); diff --git a/src/SUIT/SUIT_Desktop.cxx b/src/SUIT/SUIT_Desktop.cxx index 10fddbfec..e0cbd04a0 100755 --- a/src/SUIT/SUIT_Desktop.cxx +++ b/src/SUIT/SUIT_Desktop.cxx @@ -216,3 +216,11 @@ void SUIT_Desktop::emitMessage( const QString& theMessage ) { emit message( theMessage ); } + +/*! + Activate window (default implementation just sets focus to the window. +*/ +void SUIT_Desktop::setActiveWindow(SUIT_ViewWindow* wnd) +{ + if (wnd) wnd->setFocus(); +} diff --git a/src/SUIT/SUIT_Desktop.h b/src/SUIT/SUIT_Desktop.h index 7e2b961b4..c1f62e4d7 100755 --- a/src/SUIT/SUIT_Desktop.h +++ b/src/SUIT/SUIT_Desktop.h @@ -60,6 +60,7 @@ public: QtxLogoMgr* logoMgr() const; virtual SUIT_ViewWindow* activeWindow() const = 0; + virtual void setActiveWindow(SUIT_ViewWindow*); virtual QList windows() const = 0; int logoCount() const; -- 2.39.2