From 6898f640d5a95ab9c175388f22c4c846b8dbe5ab Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Sun, 14 Aug 2011 17:55:45 +0000 Subject: fixed "subwins steal focus" bug this can be seen as an incomplete POC again :) TODO: - save and restore toolbar positions - handle closing windows --- muse2/muse/app.cpp | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp index c7636c12..74eda773 100644 --- a/muse2/muse/app.cpp +++ b/muse2/muse/app.cpp @@ -716,6 +716,7 @@ MusE::MusE(int argc, char** argv) : QMainWindow() // create the menu with new QMenu and add it afterwards. // the menu's owner must be this and not this->menuBar()! + //------------------------------------------------------------- // popup File //------------------------------------------------------------- @@ -2961,7 +2962,7 @@ void MusE::focusChanged(QWidget*, QWidget* now) } // ptr is either NULL, this or the pointer to a TopWin - if (ptr==this) + /*if (ptr==this) FINDMICHJETZT { QMdiSubWindow* subwin=mdiArea->currentSubWindow(); if (subwin) @@ -2975,15 +2976,17 @@ void MusE::focusChanged(QWidget*, QWidget* now) } else ptr=NULL; - } - - TopWin* win=dynamic_cast(ptr); - - // now 'win' is either NULL or the pointer to the active TopWin - if (win!=activeTopWin) + }*/ + if (ptr!=this) // if the main win is selected, don't treat that as "none", but also don't handle it { - activeTopWin=win; - emit activeTopWinChanged(activeTopWin); + TopWin* win=dynamic_cast(ptr); + + // now 'win' is either NULL or the pointer to the active TopWin + if (win!=activeTopWin) + { + activeTopWin=win; + emit activeTopWinChanged(activeTopWin); + } } } @@ -3014,6 +3017,25 @@ void MusE::activeTopWinChangedSlot(TopWin* win) { if (debugMsg) printf("ACTIVE TOPWIN CHANGED to '%s' (%p)\n", win ? win->windowTitle().toAscii().data() : "", win); + if ((win==NULL) || (win->isMdiWin()==false)) + { + if (debugMsg) printf(" that's out of the MDI area\n"); + menuBar()->setFocus(Qt::MenuBarFocusReason); + } + if (win && false) //FINDMICHJETZT + { + if (win->isMdiWin()) + { + if (debugMsg) printf(" that's a mdiSubWin\n"); + } + else + { + if (debugMsg) printf(" that's a free floating window\n"); + mdiArea->setActiveSubWindow(NULL); + mdiArea->clearFocus(); + } + } + if (win && (win->sharesToolsAndMenu())) setCurrentMenuSharingTopwin(win); } @@ -3080,6 +3102,7 @@ void MusE::setCurrentMenuSharingTopwin(TopWin* win) addToolBar(*it); foreignToolbars.push_back(*it); + (*it)->show(); //FINDMICHJETZT } else { -- cgit v1.2.3