From eb115ca49a08b96af0c6564f856a0b99f3f5c0c2 Mon Sep 17 00:00:00 2001 From: apl Date: Tue, 12 Mar 2013 08:12:54 +0000 Subject: [PATCH] add tab window programmatically activation methods for QtxWorkstack, STD_TabDesktop --- src/Qtx/QtxWorkstack.cxx | 25 +++++++++++++++++++++++++ src/Qtx/QtxWorkstack.h | 1 + src/STD/STD_TabDesktop.cxx | 9 +++++++++ src/STD/STD_TabDesktop.h | 3 +++ 4 files changed, 38 insertions(+) diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index 5f0909694..efd9859c5 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -2542,6 +2542,31 @@ void QtxWorkstack::splitHorizontal() split( Qt::Vertical ); } +/*! + \brief Activates window, make its container tab active. + \param theWnd window to activate. +*/ +void QtxWorkstack::setActiveWindow( QWidget* theWnd ) +{ + QtxWorkstackArea* aWndArea = wgArea( theWnd ); + if ( aWndArea == 0 ) + return; + + aWndArea->setActiveWidget( theWnd ); + + QWidget* aCurrFocus = QApplication::focusWidget(); + if ( !theWnd->isAncestorOf( aCurrFocus ) ) + { + QWidget* aLastSubFocus = theWnd->focusWidget(); + if ( aLastSubFocus ) + aLastSubFocus->setFocus(); + else + theWnd->setFocus(); + } + + setActiveArea( aWndArea ); +} + /*! \brief Called when user activates "Rename" menu item. diff --git a/src/Qtx/QtxWorkstack.h b/src/Qtx/QtxWorkstack.h index 36a40ed0c..7648704dc 100644 --- a/src/Qtx/QtxWorkstack.h +++ b/src/Qtx/QtxWorkstack.h @@ -126,6 +126,7 @@ signals: public slots: void splitVertical(); void splitHorizontal(); + void setActiveWindow( QWidget* ); private slots: void onRename(); diff --git a/src/STD/STD_TabDesktop.cxx b/src/STD/STD_TabDesktop.cxx index 780359e02..9d0d5cc6c 100644 --- a/src/STD/STD_TabDesktop.cxx +++ b/src/STD/STD_TabDesktop.cxx @@ -174,6 +174,15 @@ QtxWorkstack* STD_TabDesktop::workstack() const return myWorkstack; } +/*! + \brief set subwindow of the desktop to be the active one. + \param theWnd the window to be set as active. +*/ +void STD_TabDesktop::setActiveWindow( QWidget* theWnd ) +{ + workstack()->setActiveWindow( theWnd ); +} + /*! Emit window activated. */ diff --git a/src/STD/STD_TabDesktop.h b/src/STD/STD_TabDesktop.h index f05bbe399..d08caa6f8 100644 --- a/src/STD/STD_TabDesktop.h +++ b/src/STD/STD_TabDesktop.h @@ -55,6 +55,9 @@ public: QtxWorkstack* workstack() const; +public slots: + void setActiveWindow( QWidget* ); + private slots: void onWindowActivated( QWidget* ); -- 2.39.2