Upon toggling off a window, now attempting to focus SongEditor, then any other visible editors, or finally the parent window if all editors are hidden.

This commit is contained in:
Christopher L. Simons
2014-12-06 03:46:41 -05:00
parent 5675b1a373
commit ca973b9369
2 changed files with 34 additions and 1 deletions

View File

@@ -145,6 +145,7 @@ private:
void finalize();
void toggleWindow( QWidget *window, bool forceShow = false );
void refocus();
QMdiArea * m_workspace;

View File

@@ -879,7 +879,7 @@ void MainWindow::toggleWindow( QWidget *window, bool forceShow )
else
{
parent->hide();
this->setFocus();
refocus();
}
// Workaround for Qt Bug #260116
@@ -892,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 );