diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-06-07 10:46:23 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-06-07 10:46:23 +0200 |
| commit | 425f9d41cd337133d5677744eef937a8a2a61212 (patch) | |
| tree | 6cd5c2603e1499b89aae4fe5e56c6e650cb2117e /src/mainwindow.cpp | |
| parent | ec95bb371e54116a2627c162eac3357ec13f06ad (diff) | |
| download | kristall-425f9d41cd337133d5677744eef937a8a2a61212.tar.gz | |
Adds support for light/dark widget theme, adds experiemental support for http style sheets.
Diffstat (limited to 'src/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index cf12877..e8dbd23 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -7,9 +7,12 @@ #include <memory> #include <QShortcut> #include <QKeySequence> +#include <QFile> +#include <QTextStream> -MainWindow::MainWindow(QWidget *parent) : +MainWindow::MainWindow(QApplication * app, QWidget *parent) : QMainWindow(parent), + application(app), settings("xqTechnologies", "Kristall"), ui(new Ui::MainWindow), url_status(new QLabel()) @@ -60,6 +63,8 @@ MainWindow::MainWindow(QWidget *parent) : } settings.endGroup(); } + + reloadTheme(); } MainWindow::~MainWindow() @@ -206,6 +211,7 @@ void MainWindow::on_actionSettings_triggered() dialog.setGeminiStyle(this->current_style); dialog.setStartPage(this->settings.value("start_page").toString()); dialog.setProtocols(this->protocols); + dialog.setUiTheme(this->settings.value("theme").toString()); if(dialog.exec() != QDialog::Accepted) return; @@ -214,9 +220,13 @@ void MainWindow::on_actionSettings_triggered() this->settings.setValue("start_page", url.toString()); } + this->settings.setValue("theme", dialog.uiTheme()); + this->protocols = dialog.protocols(); this->current_style = dialog.geminiStyle(); this->saveSettings(); + + this->reloadTheme(); } void MainWindow::on_actionNew_Tab_triggered() @@ -277,3 +287,25 @@ void MainWindow::on_actionAbout_Qt_triggered() { QMessageBox::aboutQt(this, "Kristall"); } + +void MainWindow::reloadTheme() +{ + QString theme = settings.value("theme").toString(); + if(theme.isEmpty()) + theme = "light"; + + if(theme == "light") + { + QFile file(":/light.qss"); + file.open(QFile::ReadOnly | QFile::Text); + QTextStream stream(&file); + application->setStyleSheet(stream.readAll()); + } + else if(theme == "dark") + { + QFile file(":/dark.qss"); + file.open(QFile::ReadOnly | QFile::Text); + QTextStream stream(&file); + application->setStyleSheet(stream.readAll()); + } +} |
