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.
This commit is contained in:
Matthieu Gautier 2022-02-07 16:42:09 +01:00
parent 1c70f375de
commit 5b49480dd8
2 changed files with 10 additions and 11 deletions

View File

@ -16,6 +16,9 @@
#include <QPrintDialog>
#include <thread>
#include <QMessageBox>
#ifdef Q_OS_WIN
#include <QtPlatformHeaders\QWindowsWindowFunctions>
#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);

View File

@ -7,9 +7,7 @@
#include "kconstants.h"
#include <QDesktopServices>
#ifdef Q_OS_WIN
#include <QtPlatformHeaders\QWindowsWindowFunctions>
#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,