Fix empty editor windows (#7515)
Fix the problem with empty windows as described in issue #7412. The `refocus` method in `MainWindow` is made public so that it can be called from `Editor::closeEvent`. It has also been refactored for better readability. --------- Co-authored-by: Michael Gregorius <michael.gregorius.git@arcor.de> Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
This commit is contained in:
@@ -975,26 +975,21 @@ void MainWindow::toggleFullscreen()
|
||||
*/
|
||||
void MainWindow::refocus()
|
||||
{
|
||||
QList<QWidget*> editors;
|
||||
editors
|
||||
<< getGUI()->songEditor()->parentWidget()
|
||||
<< getGUI()->patternEditor()->parentWidget()
|
||||
<< getGUI()->pianoRoll()->parentWidget()
|
||||
<< getGUI()->automationEditor()->parentWidget();
|
||||
const auto gui = getGUI();
|
||||
|
||||
bool found = false;
|
||||
QList<QWidget*>::Iterator editor;
|
||||
for( editor = editors.begin(); editor != editors.end(); ++editor )
|
||||
// Attempt to set the focus on the first of these editors that is not hidden...
|
||||
for (auto editorParent : { gui->songEditor()->parentWidget(), gui->patternEditor()->parentWidget(),
|
||||
gui->pianoRoll()->parentWidget(), gui->automationEditor()->parentWidget() })
|
||||
{
|
||||
if( ! (*editor)->isHidden() ) {
|
||||
(*editor)->setFocus();
|
||||
found = true;
|
||||
break;
|
||||
if (!editorParent->isHidden())
|
||||
{
|
||||
editorParent->setFocus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if( ! found )
|
||||
this->setFocus();
|
||||
// ... otherwise set the focus on the main window.
|
||||
this->setFocus();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
#include "Editor.h"
|
||||
|
||||
#include "GuiApplication.h"
|
||||
#include "MainWindow.h"
|
||||
#include "Song.h"
|
||||
|
||||
#include "embed.h"
|
||||
@@ -138,7 +140,7 @@ QAction *Editor::playAction() const
|
||||
return m_playAction;
|
||||
}
|
||||
|
||||
void Editor::closeEvent( QCloseEvent * _ce )
|
||||
void Editor::closeEvent(QCloseEvent * event)
|
||||
{
|
||||
if( parentWidget() )
|
||||
{
|
||||
@@ -148,7 +150,8 @@ void Editor::closeEvent( QCloseEvent * _ce )
|
||||
{
|
||||
hide();
|
||||
}
|
||||
_ce->accept();
|
||||
getGUI()->mainWindow()->refocus();
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
DropToolBar::DropToolBar(QWidget* parent) : QToolBar(parent)
|
||||
|
||||
Reference in New Issue
Block a user