diff --git a/editor/mainwindow.cpp b/editor/mainwindow.cpp index c096063..4049b7a 100644 --- a/editor/mainwindow.cpp +++ b/editor/mainwindow.cpp @@ -23,6 +23,7 @@ bool worldSpaceTransforms = false; inline bool isDarkMode() { + // https://stackoverflow.com/a/78854851/16255372 #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) const auto scheme = QGuiApplication::styleHints()->colorScheme(); return scheme == Qt::ColorScheme::Dark; @@ -62,7 +63,6 @@ MainWindow::MainWindow(QWidget *parent) ui->setupUi(this); setMouseTracking(true); - // https://stackoverflow.com/a/78854851/16255372 QIcon::setThemeSearchPaths(QIcon::themeSearchPaths() + QStringList { "./assets/icons" }); if (isDarkMode()) QIcon::setFallbackThemeName("editor-dark"); diff --git a/editor/script/scriptdocument.cpp b/editor/script/scriptdocument.cpp index 482f9f9..6e27d61 100644 --- a/editor/script/scriptdocument.cpp +++ b/editor/script/scriptdocument.cpp @@ -17,9 +17,24 @@ #include "mainwindow.h" #include "objects/script.h" #include "datatypes/meta.h" +#include +#include QsciAPIs* makeApis(QsciLexer*); +inline bool isDarkMode() { + // https://stackoverflow.com/a/78854851/16255372 + #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) + const auto scheme = QGuiApplication::styleHints()->colorScheme(); + return scheme == Qt::ColorScheme::Dark; + #else + const QPalette defaultPalette; + const auto text = defaultPalette.color(QPalette::WindowText); + const auto window = defaultPalette.color(QPalette::Window); + return text.lightness() > window.lightness(); + #endif // QT_VERSION +} + std::map DARK_MODE_COLOR_SCHEME = {{ {QsciLexerLua::Comment, QColor("#808080")}, {QsciLexerLua::LineComment, QColor("#808080")}, @@ -156,8 +171,10 @@ ScriptDocument::ScriptDocument(std::shared_ptr