summary refs log tree commit diff
path: root/src/main.cc
diff options
context:
space:
mode:
authorMax Sandholm <max@sandholm.org>2017-11-16 16:33:52 +0200
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2017-11-16 16:33:52 +0200
commit19b526d4533841ca91209929f0d6aef6042a8eeb (patch)
tree596400e11b6275a961b9d57b02b0c0b502df38c4 /src/main.cc
parentDon't send empty messages (diff)
downloadnheko-19b526d4533841ca91209929f0d6aef6042a8eeb.tar.xz
Use system color scheme (using a Qt stylesheet) #104
The color scheme of nheko obeys the default color theme of Qt
(i.e. the system theme). It uses a Qt stylesheet to accomplish this,
which means replacing the color theme with a custom theme would only
be a matter of writing a new style sheet and loading it into the app.
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main.cc b/src/main.cc

index 8bd77254..9ca1d5de 100644 --- a/src/main.cc +++ b/src/main.cc
@@ -17,6 +17,7 @@ #include <QApplication> #include <QDesktopWidget> +#include <QFile> #include <QFontDatabase> #include <QLibraryInfo> #include <QNetworkProxy> @@ -72,6 +73,21 @@ main(int argc, char *argv[]) QSettings settings; + QFile stylefile; + + if (!settings.contains("user/theme")) { + settings.setValue("user/theme", "default"); + } + + if (settings.value("user/theme").toString() == "default") { + stylefile.setFileName(":/styles/styles/nheko.qss"); + } else { + stylefile.setFileName(":/styles/styles/system.qss"); + } + stylefile.open(QFile::ReadOnly); + QString stylesheet = QString(stylefile.readAll()); + + app.setStyleSheet(stylesheet); // Set the default if a value has not been set. if (settings.value("font/size").toInt() == 0) settings.setValue("font/size", 12);