mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
fix main window blinking issue caused by OpenGL on Qt6
This commit is contained in:
parent
2ebb210c57
commit
889026bece
@ -20,6 +20,7 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QProgressDialog>
|
#include <QProgressDialog>
|
||||||
#include <QHotkey>
|
#include <QHotkey>
|
||||||
|
#include <QWebEngineView>
|
||||||
|
|
||||||
#include "notebookexplorer.h"
|
#include "notebookexplorer.h"
|
||||||
#include "vnotex.h"
|
#include "vnotex.h"
|
||||||
@ -74,8 +75,6 @@ MainWindow::MainWindow(QWidget *p_parent)
|
|||||||
|
|
||||||
setupShortcuts();
|
setupShortcuts();
|
||||||
|
|
||||||
loadStateAndGeometry();
|
|
||||||
|
|
||||||
m_dockWidgetHelper.postSetup();
|
m_dockWidgetHelper.postSetup();
|
||||||
|
|
||||||
// The signal is particularly useful if your application has to do some last-second cleanup.
|
// The signal is particularly useful if your application has to do some last-second cleanup.
|
||||||
@ -97,8 +96,12 @@ MainWindow::~MainWindow()
|
|||||||
void MainWindow::kickOffOnStart(const QStringList &p_paths)
|
void MainWindow::kickOffOnStart(const QStringList &p_paths)
|
||||||
{
|
{
|
||||||
QTimer::singleShot(300, [this, p_paths]() {
|
QTimer::singleShot(300, [this, p_paths]() {
|
||||||
// Need to load the state of dock widgets again after the main window is shown.
|
if (m_dummyWebView) {
|
||||||
loadStateAndGeometry(true);
|
delete m_dummyWebView;
|
||||||
|
m_dummyWebView = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadStateAndGeometry();
|
||||||
|
|
||||||
{
|
{
|
||||||
QProgressDialog proDlg(tr("Initializing core components..."),
|
QProgressDialog proDlg(tr("Initializing core components..."),
|
||||||
@ -174,6 +177,11 @@ void MainWindow::setupUI()
|
|||||||
setupSystemTray();
|
setupSystemTray();
|
||||||
|
|
||||||
m_dockWidgetHelper.activateDock(DockWidgetHelper::NavigationDock);
|
m_dockWidgetHelper.activateDock(DockWidgetHelper::NavigationDock);
|
||||||
|
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
m_dummyWebView = new QWebEngineView(this);
|
||||||
|
m_dummyWebView->setFixedSize(1, 1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setupStatusBar()
|
void MainWindow::setupStatusBar()
|
||||||
@ -452,12 +460,12 @@ void MainWindow::saveStateAndGeometry()
|
|||||||
sessionConfig.setMainWindowStateGeometry(sg);
|
sessionConfig.setMainWindowStateGeometry(sg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::loadStateAndGeometry(bool p_stateOnly)
|
void MainWindow::loadStateAndGeometry()
|
||||||
{
|
{
|
||||||
const auto& sessionConfig = ConfigMgr::getInst().getSessionConfig();
|
const auto& sessionConfig = ConfigMgr::getInst().getSessionConfig();
|
||||||
const auto sg = sessionConfig.getMainWindowStateGeometry();
|
const auto sg = sessionConfig.getMainWindowStateGeometry();
|
||||||
|
|
||||||
if (!p_stateOnly && !sg.m_mainGeometry.isEmpty()) {
|
if (!sg.m_mainGeometry.isEmpty()) {
|
||||||
restoreGeometry(sg.m_mainGeometry);
|
restoreGeometry(sg.m_mainGeometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,12 +474,10 @@ void MainWindow::loadStateAndGeometry(bool p_stateOnly)
|
|||||||
restoreState(sg.m_mainState);
|
restoreState(sg.m_mainState);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!p_stateOnly) {
|
m_visibleDocksBeforeExpand = sg.m_visibleDocksBeforeExpand;
|
||||||
m_visibleDocksBeforeExpand = sg.m_visibleDocksBeforeExpand;
|
if (m_visibleDocksBeforeExpand.isEmpty()) {
|
||||||
if (m_visibleDocksBeforeExpand.isEmpty()) {
|
// Init (or init again if there is no visible dock).
|
||||||
// Init (or init again if there is no visible dock).
|
m_visibleDocksBeforeExpand = m_dockWidgetHelper.getVisibleDocks();
|
||||||
m_visibleDocksBeforeExpand = m_dockWidgetHelper.getVisibleDocks();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sg.m_tagExplorerState.isEmpty()) {
|
if (!sg.m_tagExplorerState.isEmpty()) {
|
||||||
|
@ -14,6 +14,7 @@ class QSystemTrayIcon;
|
|||||||
class QTimer;
|
class QTimer;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QTextEdit;
|
class QTextEdit;
|
||||||
|
class QWebEngineView;
|
||||||
|
|
||||||
namespace vnotex
|
namespace vnotex
|
||||||
{
|
{
|
||||||
@ -137,7 +138,7 @@ namespace vnotex
|
|||||||
|
|
||||||
void saveStateAndGeometry();
|
void saveStateAndGeometry();
|
||||||
|
|
||||||
void loadStateAndGeometry(bool p_stateOnly = false);
|
void loadStateAndGeometry();
|
||||||
|
|
||||||
// Used to test widget in development.
|
// Used to test widget in development.
|
||||||
void demoWidget();
|
void demoWidget();
|
||||||
@ -160,6 +161,9 @@ namespace vnotex
|
|||||||
|
|
||||||
void loadWidgetsData();
|
void loadWidgetsData();
|
||||||
|
|
||||||
|
// WebView to handle OpenGL blinking on Windows.
|
||||||
|
QWebEngineView *m_dummyWebView = nullptr;
|
||||||
|
|
||||||
DockWidgetHelper m_dockWidgetHelper;
|
DockWidgetHelper m_dockWidgetHelper;
|
||||||
|
|
||||||
NotebookExplorer *m_notebookExplorer = nullptr;
|
NotebookExplorer *m_notebookExplorer = nullptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user