aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorFelix (xq) Queißner <git@mq32.de>2020-06-29 00:08:56 +0200
committerFelix (xq) Queißner <git@mq32.de>2020-06-29 00:08:56 +0200
commit741c71adff886f590081501932ec1520058d7def (patch)
tree28009a20d9f15f682b694e794d09eaceb88a5022 /src/main.cpp
parent6edd9e7a12a3827fb6aac62a88be01085e41e176 (diff)
downloadkristall-741c71adff886f590081501932ec1520058d7def.tar.gz
Changes theme initialization a tad.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 555734e..ef204a0 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -31,6 +31,7 @@ QString toFingerprintString(QSslCertificate const & certificate)
}
static QSettings * app_settings_ptr;
+static QApplication * app;
#define SSTR(X) STR(X)
#define STR(X) #X
@@ -49,11 +50,15 @@ static QDir derive_dir(QDir const & parent, QString subdir)
return child;
}
+
+
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
app.setApplicationVersion(SSTR(KRISTALL_VERSION));
+ ::app = &app;
+
kristall::clipboard = app.clipboard();
QCommandLineParser cli_parser;
@@ -177,6 +182,8 @@ int main(int argc, char *argv[])
kristall::favourites.load(app_settings);
+ kristall::setTheme(kristall::options.theme);
+
MainWindow w(&app);
auto urls = cli_parser.positionalArguments();
@@ -301,3 +308,31 @@ void kristall::saveSettings()
app_settings.sync();
}
+
+void kristall::setTheme(Theme theme)
+{
+ assert(app != nullptr);
+ if(theme == Theme::os_default)
+ {
+ app->setStyleSheet("");
+ QIcon::setThemeName("light");
+ }
+ if(theme == Theme::light)
+ {
+ QFile file(":/light.qss");
+ file.open(QFile::ReadOnly | QFile::Text);
+ QTextStream stream(&file);
+ app->setStyleSheet(stream.readAll());
+
+ QIcon::setThemeName("light");
+ }
+ else if(theme == Theme::dark)
+ {
+ QFile file(":/dark.qss");
+ file.open(QFile::ReadOnly | QFile::Text);
+ QTextStream stream(&file);
+ app->setStyleSheet(stream.readAll());
+
+ QIcon::setThemeName("dark");
+ }
+}