Dark mode theme only for Windows

This commit is contained in:
Cacodemon345
2024-01-16 01:39:32 +06:00
parent 2cbfc8e047
commit bf99a1aaad
6 changed files with 2511 additions and 1 deletions

View File

@@ -30,6 +30,8 @@
#include <QFont>
#include <QDialog>
#include <QMessageBox>
#include <QFile>
#include <QTextStream>
#ifdef QT_STATIC
/* Static builds need plugin imports */
@@ -154,6 +156,10 @@ main_thread_fn()
static std::thread *main_thread;
#ifdef Q_OS_WINDOWS
extern bool windows_is_light_theme();
#endif
int
main(int argc, char *argv[])
{
@@ -168,6 +174,22 @@ main(int argc, char *argv[])
QApplication app(argc, argv);
QLocale::setDefault(QLocale::C);
#ifdef Q_OS_WINDOWS
Q_INIT_RESOURCE(darkstyle);
if (!windows_is_light_theme()) {
QFile f(":qdarkstyle/dark/darkstyle.qss");
if (!f.exists()) {
printf("Unable to set stylesheet, file not found\n");
} else {
f.open(QFile::ReadOnly | QFile::Text);
QTextStream ts(&f);
qApp->setStyleSheet(ts.readAll());
}
}
#endif
qt_set_sequence_auto_mnemonic(false);
Q_INIT_RESOURCE(qt_resources);
Q_INIT_RESOURCE(qt_translations);