From 4ec9b013684458bdf77a7a5a11d0a3cfa1f62b86 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Sun, 7 Oct 2018 11:01:44 +0200 Subject: mainwindow: keep maximized state when adding subwindows Only maximize added subwindow when there is no current subwindow, or when the current subwindow is maximized. --- src/mainwindow/mainwindow.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/mainwindow') diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index d191fac..1f81b86 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -354,10 +354,20 @@ SubWindow *MainWindow::currentSubWindow() const SubWindow *MainWindow::createSubWindow(const std::unique_ptr &config, WebProfile *profile) { + bool shouldMaximize = true; + // if there is a current window, use its maximize state + if(auto *currentWindow = qobject_cast(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; } -- cgit v1.2.1