Skip to content

Commit

Permalink
delay getting initial page source
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhendricks committed Sep 14, 2023
1 parent 63449dc commit 4162874
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,6 @@ void MainWindow::UpdatePage(const QString &filename_url, const QString &source)
}
}


//if isDarkMode is set, inject a local style in head
SettingsStore settings;
if (Utility::IsDarkMode() && settings.previewDark()) {
Expand Down Expand Up @@ -842,21 +841,26 @@ void MainWindow::UpdatePage(const QString &filename_url, const QString &source)

// Wait until the preview is loaded before moving cursor.
while (!m_WebView->IsLoadingFinished()) {
qApp->processEvents();
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
}

if (!m_WebView->WasLoadOkay()) qDebug() << "WV loadFinished with okay set to false!";

DBG qDebug() << "WebViewWindow UpdatePage load is Finished";

UpdateWindowTitle();
m_source = GetSource();
m_WebView->show();
m_WebView->GrabFocus();

// now set the mode: edit or preview
ToggleMode(ui.actionMode->isChecked());
m_UpdatePageInProgress = false;
QTimer::singleShot(50, this, SLOT(SetInitialSource()));
}

void MainWindow::SetInitialSource()
{
m_source = GetSource();
}

void MainWindow::ScrollTo(QList<ElementIndex> location)
Expand Down
1 change: 1 addition & 0 deletions MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public slots:

// General Slots
void DoUpdatePage();
void SetInitialSource();
void UpdatePage(const QString &filename, const QString &source="");
void RefreshPage();
void UpdateWindowTitle();
Expand Down

0 comments on commit 4162874

Please sign in to comment.