Gui: fix activating of MDI views via menu commands

This commit is contained in:
wmayer
2023-01-06 14:42:29 +01:00
parent 620aaac90d
commit c18adc2cee
2 changed files with 19 additions and 3 deletions

View File

@@ -330,6 +330,9 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f)
#if QT_VERSION < QT_VERSION_CHECK(5,15,0)
connect(d->windowMapper, qOverload<QWidget*>(&QSignalMapper::mapped),
this, &MainWindow::onSetActiveSubWindow);
#elif QT_VERSION < QT_VERSION_CHECK(6,0,0)
connect(d->windowMapper, &QSignalMapper::mappedWidget,
this, &MainWindow::onSetActiveSubWindow);
#else
connect(d->windowMapper, &QSignalMapper::mappedObject,
this, [=](QObject* object) {
@@ -709,12 +712,20 @@ bool MainWindow::closeAllDocuments (bool close)
void MainWindow::activateNextWindow ()
{
d->mdiArea->activateNextSubWindow();
auto tab = d->mdiArea->findChild<QTabBar*>();
if (tab && tab->count() > 0) {
int index = (tab->currentIndex() + 1) % tab->count();
tab->setCurrentIndex(index);
}
}
void MainWindow::activatePreviousWindow ()
{
d->mdiArea->activatePreviousSubWindow();
auto tab = d->mdiArea->findChild<QTabBar*>();
if (tab && tab->count() > 0) {
int index = (tab->currentIndex() + tab->count() - 1) % tab->count();
tab->setCurrentIndex(index);
}
}
void MainWindow::activateWorkbench(const QString& name)