File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- #pragma once
1+ #pragma once
2+
3+ inline bool isDarkMode () {
4+ // https://stackoverflow.com/a/78854851/16255372
5+ #if defined(_WIN32 )
6+ // Never read dark theme on Windows as the app currently renders with white color palette regardless
7+ return false;
8+ #elif QT_VERSION >= QT_VERSION_CHECK (6 , 5 , 0 )
9+ const auto scheme = QGuiApplication ::styleHints ()-> colorScheme ();
10+ return scheme == Qt ::ColorScheme ::Dark ;
11+ #else
12+ const QPalette defaultPalette ;
13+ const auto text = defaultPalette .color (QPalette ::WindowText );
14+ const auto window = defaultPalette .color (QPalette ::Window );
15+ return text .lightness () > window .lightness ();
16+ #endif // QT_VERSION
17+ }
Original file line number Diff line number Diff line change @@ -74,10 +74,16 @@ MainWindow::MainWindow(QWidget *parent)
7474 ui->actionRedo ->setShortcuts ({QKeySequence (" Ctrl+Shift+Z" ), QKeySequence (" Ctrl+Y" )});
7575
7676 QIcon::setThemeSearchPaths (QIcon::themeSearchPaths () + QStringList { " ./assets/icons" });
77+
78+ // Force theme under windows
79+ #ifdef _WIN32
80+ QIcon::setThemeName (" editor" );
81+ #else
7782 if (isDarkMode ())
7883 QIcon::setFallbackThemeName (" editor-dark" );
7984 else
80- QIcon::setThemeName (" editor" );
85+ QIcon::setFallbackThemeName (" editor" );
86+ #endif
8187
8288 // qApp->setStyle(QStyleFactory::create("fusion"));
8389 defaultMessageHandler = qInstallMessageHandler (logQtMessage);
Original file line number Diff line number Diff line change 1414#include < qglobal.h>
1515#include < qlayout.h>
1616#include < qtextformat.h>
17+ #include < QPalette>
18+ #include < QStyleHints>
1719#include " mainwindow.h"
20+ #include " editorcommon.h"
1821#include " objects/script.h"
1922#include " datatypes/variant.h"
20- #include < QPalette>
21- #include < QStyleHints>
2223
2324QsciAPIs* makeApis (QsciLexer*);
2425
25- inline bool isDarkMode () {
26- // https://stackoverflow.com/a/78854851/16255372
27- #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
28- const auto scheme = QGuiApplication::styleHints ()->colorScheme ();
29- return scheme == Qt::ColorScheme::Dark;
30- #else
31- const QPalette defaultPalette;
32- const auto text = defaultPalette.color (QPalette::WindowText);
33- const auto window = defaultPalette.color (QPalette::Window);
34- return text.lightness () > window.lightness ();
35- #endif // QT_VERSION
36- }
37-
3826std::map<int , const QColor> DARK_MODE_COLOR_SCHEME = {{
3927 {QsciLexerLua::Comment, QColor (" #808080" )},
4028 {QsciLexerLua::LineComment, QColor (" #808080" )},
You can’t perform that action at this time.
0 commit comments