diff options
-rw-r--r-- | src/mainwindow/mainwindow.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index cabc94b..1f81b86 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -191,7 +191,10 @@ MainWindow::MainWindow(const std::unique_ptr<Configuration> &config, QWidget *pa connect(subwindowMenuAction, &QAction::triggered, this, [this]() { QMdiSubWindow *window = mdiArea->currentSubWindow(); if(window) { - window->systemMenu()->exec(); + // show the menu at the subwindow position + // position has to be global, and mapped by the mdiArea (parentWidget() of the subwindow) + const auto position = mdiArea->mapToGlobal(window->pos()); + window->systemMenu()->exec(position); } }); } @@ -351,10 +354,20 @@ SubWindow *MainWindow::currentSubWindow() const SubWindow *MainWindow::createSubWindow(const std::unique_ptr<Configuration> &config, WebProfile *profile) { + bool shouldMaximize = true; + // if there is a current window, use its maximize state + if(auto *currentWindow = qobject_cast<SubWindow *>(mdiArea->currentSubWindow()); currentWindow != nullptr) { + shouldMaximize = currentWindow->isMaximized(); + } + auto *w = new SubWindow(config, this); w->setProfile(profile); mdiArea->addSubWindow(w); - w->showMaximized(); + if(shouldMaximize) + w->showMaximized(); + else + w->show(); + w->setFocus(); return w; } |