Skip to content

Commit

Permalink
qt: Show the window only once the page is fully loaded
Browse files Browse the repository at this point in the history
The application prints the cookie and exits almost immediately if
there is already a valid session, thus causing the window to flicker.
To prevent that, we now wait for the page to be fully loaded before
showing the window.
  • Loading branch information
Gabriele Mazzotta committed Sep 11, 2024
1 parent 9273bd2 commit 67ea38d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 0 additions & 1 deletion openfortivpn-webview-qt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ int main(int argc, char *argv[])
w.loadUrl(url);
w.resize(1024, 760);
w.move(findScreenWithCursor()->geometry().center() - w.rect().center());
w.show();

return app.exec();
}
4 changes: 4 additions & 0 deletions openfortivpn-webview-qt/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ MainWindow::MainWindow(const bool keepOpen,
&MainWindow::onCookieRemoved);

connect(webEnginePage, &QWebEnginePage::certificateError, this, &MainWindow::onCertificateError);

// Show the window only once the page is fully loaded. In this way we won't even show it if the
// cookie is available immediately because of some existing session.
connect(webEnginePage, &QWebEnginePage::loadFinished, this, [this] { show(); }, Qt::SingleShotConnection);
}

MainWindow::~MainWindow()
Expand Down

0 comments on commit 67ea38d

Please sign in to comment.