From 425f9d41cd337133d5677744eef937a8a2a61212 Mon Sep 17 00:00:00 2001 From: "Felix (xq) Queißner" Date: Sun, 7 Jun 2020 10:46:23 +0200 Subject: Adds support for light/dark widget theme, adds experiemental support for http style sheets. --- src/settingsdialog.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'src/settingsdialog.cpp') diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 27a1c12..859f5dd 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -20,6 +20,10 @@ SettingsDialog::SettingsDialog(QWidget *parent) : this->ui->auto_theme->addItem("Dark Theme", QVariant::fromValue(GeminiStyle::AutoDarkTheme)); this->ui->auto_theme->addItem("Light Theme", QVariant::fromValue(GeminiStyle::AutoLightTheme)); + this->ui->ui_theme->clear(); + this->ui->ui_theme->addItem("Light", QVariant::fromValue("light")); + this->ui->ui_theme->addItem("Dark", QVariant::fromValue("dark")); + setGeminiStyle(GeminiStyle { }); } @@ -114,7 +118,23 @@ void SettingsDialog::setProtocols(ProtocolSetup const & protocols) #define M(X) \ this->ui->enable_##X->setChecked(protocols.X); PROTOCOLS(M) -#undef M + #undef M +} + +QString SettingsDialog::uiTheme() const +{ + return this->ui->ui_theme->currentData().toString(); +} + +void SettingsDialog::setUiTheme(const QString &theme) +{ + if(theme == "light") + this->ui->ui_theme->setCurrentIndex(0); + else if(theme == "dark") + this->ui->ui_theme->setCurrentIndex(1); + else + this->ui->ui_theme->setCurrentIndex(0); + } void SettingsDialog::reloadStylePreview() @@ -144,10 +164,13 @@ Plain text document here. if(host.length() == 0) host = "preview"; + QUrl url { QUrl(QString("about://%1/foobar").arg(host)) }; + DocumentOutlineModel outline; - auto doc = GeminiRenderer { current_style }.render( + auto doc = GeminiRenderer::render( document, - QUrl(QString("about://%1/foobar").arg(host)), + url, + current_style.derive(url), outline ); -- cgit v1.2.3