aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Skec <skec@protonmail.ch>2020-12-24 18:27:04 +1100
committerFelix Queißner <felix@ib-queissner.de>2020-12-24 09:21:59 +0100
commit9ee987f8216b412957ffcb46c01bbe268b282746 (patch)
tree971602fd748c29f5a9e4defe555f9d581430ebb3 /src
parent237d3a8bc9ed6be7196115e0c7b640ca59349b1d (diff)
downloadkristall-9ee987f8216b412957ffcb46c01bbe268b282746.tar.gz
theme changes are now reflected instantly upon confirmation.
Diffstat (limited to 'src')
-rw-r--r--src/browsertab.cpp38
-rw-r--r--src/browsertab.hpp6
-rw-r--r--src/mainwindow.cpp16
3 files changed, 47 insertions, 13 deletions
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();
diff --git a/src/browsertab.hpp b/src/browsertab.hpp
index 59e4d0c..7ddd843 100644
--- a/src/browsertab.hpp
+++ b/src/browsertab.hpp
@@ -73,6 +73,10 @@ public:
void openSourceView();
+ void renderPage(const QByteArray & data, const MimeType & mime);
+
+ void rerenderPage();
+
signals:
void titleChanged(QString const & title);
void locationChanged(QUrl const & url);
@@ -183,6 +187,8 @@ public:
QTimer network_timeout_timer;
QTextCursor current_search_position;
+
+ bool needs_rerender;
};
#endif // BROWSERTAB_HPP
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 6d1964a..b129414 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -163,6 +163,11 @@ void MainWindow::on_browser_tabs_currentChanged(int index)
this->ui->history_view->setModel(&tab->history);
this->setFileStatus(tab->current_stats);
+
+ if (tab->needs_rerender)
+ {
+ tab->rerenderPage();
+ }
} else {
this->ui->outline_view->setModel(nullptr);
this->ui->history_view->setModel(nullptr);
@@ -252,6 +257,17 @@ void MainWindow::on_actionSettings_triggered()
kristall::saveSettings();
kristall::setTheme(kristall::options.theme);
+
+ // Flag open tabs for re-render so theme
+ // changes are instantly applied.
+ for (int i = 0; i < this->ui->browser_tabs->count(); ++i)
+ {
+ qobject_cast<BrowserTab*>(this->ui->browser_tabs->widget(i))
+ ->needs_rerender = true;
+ }
+ // Re-render the currently-open tab if we have one.
+ BrowserTab * tab = qobject_cast<BrowserTab*>(this->ui->browser_tabs->currentWidget());
+ if (tab) tab->rerenderPage();
}
void MainWindow::on_actionNew_Tab_triggered()