From 9ee987f8216b412957ffcb46c01bbe268b282746 Mon Sep 17 00:00:00 2001 From: Mike Skec Date: Thu, 24 Dec 2020 18:27:04 +1100 Subject: theme changes are now reflected instantly upon confirmation. --- src/browsertab.cpp | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'src/browsertab.cpp') diff --git a/src/browsertab.cpp b/src/browsertab.cpp index e88225b..22360aa 100644 --- a/src/browsertab.cpp +++ b/src/browsertab.cpp @@ -447,8 +447,23 @@ void BrowserTab::on_requestComplete(const QByteArray &ref_data, const QString &m } } + renderPage(data, mime); + + QString title = this->current_location.toString(); + emit this->titleChanged(title); + + this->current_stats.file_size = ref_data.size(); + this->current_stats.mime_type = mime; + this->current_stats.loading_time = this->timer.elapsed(); + emit this->fileLoaded(this->current_stats); + + this->successfully_loaded = true; +} + +void BrowserTab::renderPage(const QByteArray &data, const MimeType &mime) +{ this->current_mime = mime; - this->current_buffer = ref_data; + this->current_buffer = data; this->graphics_scene.clear(); this->ui->text_browser->setText(""); @@ -574,7 +589,7 @@ void BrowserTab::on_requestComplete(const QByteArray &ref_data, const QString &m else if (mime.is("video") or mime.is("audio")) { doc_type = Media; - this->ui->media_browser->setMedia(data, this->current_location, mime_text); + this->ui->media_browser->setMedia(data, this->current_location, mime.type); } else { @@ -590,7 +605,7 @@ Info: MIME Type: %1 File Size: %2 )md") - .arg(mime_text) + .arg(mime.type) .arg(IoUtil::size_human(data.size()))); } @@ -603,21 +618,18 @@ File Size: %2 this->ui->text_browser->setDocument(document.get()); this->current_document = std::move(document); - emit this->locationChanged(this->current_location); + this->needs_rerender = false; - QString title = this->current_location.toString(); - emit this->titleChanged(title); - - this->current_stats.file_size = ref_data.size(); - this->current_stats.mime_type = mime; - this->current_stats.loading_time = this->timer.elapsed(); - emit this->fileLoaded(this->current_stats); - - this->successfully_loaded = true; + emit this->locationChanged(this->current_location); this->updateUI(); } +void BrowserTab::rerenderPage() +{ + this->renderPage(this->current_buffer, this->current_mime); +} + void BrowserTab::on_inputRequired(const QString &query, const bool is_sensitive) { this->network_timeout_timer.stop(); -- cgit v1.2.3