Merge pull request #1406 from csimons/unbind-keys

Removing focus from child windows upon hiding them.
This commit is contained in:
Vesa V
2014-12-06 11:46:06 +02:00
2 changed files with 34 additions and 0 deletions

View File

@@ -879,6 +879,7 @@ void MainWindow::toggleWindow( QWidget *window, bool forceShow )
else
{
parent->hide();
refocus();
}
// Workaround for Qt Bug #260116
@@ -891,6 +892,38 @@ void MainWindow::toggleWindow( QWidget *window, bool forceShow )
/*
* When an editor window with focus is toggled off, attempt to set focus
* to the next visible editor window, or if none are visible, set focus
* to the parent window.
*/
void MainWindow::refocus()
{
QList<QWidget*> editors;
editors
<< Engine::songEditor()->parentWidget()
<< Engine::getBBEditor()->parentWidget()
<< Engine::pianoRoll()->parentWidget()
<< Engine::automationEditor()->parentWidget();
bool found = false;
QList<QWidget*>::Iterator editor;
for( editor = editors.begin(); editor != editors.end(); ++editor )
{
if( ! (*editor)->isHidden() ) {
(*editor)->setFocus();
found = true;
break;
}
}
if( ! found )
this->setFocus();
}
void MainWindow::toggleBBEditorWin( bool forceShow )
{
toggleWindow( Engine::getBBEditor(), forceShow );