From 5b49480dd8ad205d0ac93fab759c4caa39e54eef Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Mon, 7 Feb 2022 16:42:09 +0100 Subject: [PATCH] Set the fullscreen border after the windows is shown. `windowHandle` return a valid value only if the widget has been shown. So we must use it *after* it is shown, not at the end of its construction. This subtle change also avoid a early return in the MainWindow constructor and so, we correctly configure the mainWindow on Windows. The last configuration is setting the content manager of the content manager side. If this is skip, kiwix-desktop crash as soon as we click on "All files" as we use a uninitialized pointer. --- src/kiwixapp.cpp | 9 +++++++++ src/mainwindow.cpp | 12 +----------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/kiwixapp.cpp b/src/kiwixapp.cpp index a22be45..99255ec 100644 --- a/src/kiwixapp.cpp +++ b/src/kiwixapp.cpp @@ -16,6 +16,9 @@ #include #include #include +#ifdef Q_OS_WIN +#include +#endif //////////////////////////////////////////////////////////////////////////////// // KiwixApp @@ -87,6 +90,12 @@ void KiwixApp::init() mp_errorDialog = new QErrorMessage(mp_mainWindow); setActivationWindow(mp_mainWindow); mp_mainWindow->show(); +#ifdef Q_OS_WIN + QWindow *window = mp_mainWindow->windowHandle(); + if (window) { + QWindowsWindowFunctions::setHasBorderInFullScreen(window, true); + } +#endif connect(this, &QtSingleApplication::messageReceived, this, [=](const QString &message) { if (!message.isEmpty()) { this->openZimFile(message); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 155278f..f5f6211 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -7,9 +7,7 @@ #include "kconstants.h" #include -#ifdef Q_OS_WIN -#include -#endif + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), @@ -51,14 +49,6 @@ MainWindow::MainWindow(QWidget *parent) : setWindowFlags(Qt::Window | Qt::CustomizeWindowHint); #endif -#ifdef Q_OS_WIN - QWindow *window = windowHandle(); - if (!window) { - return; - } - QWindowsWindowFunctions::setHasBorderInFullScreen(window, true); -#endif - connect(mp_ui->tabBar, &QTabBar::currentChanged, mp_ui->mainToolBar, &TopWidget::updateBackForwardButtons); connect(mp_ui->tabBar, &TabBar::libraryPageDisplayed,