Commit 51dbf70f authored by jan.koester's avatar jan.koester
Browse files

test

parent dae0f182
Loading
Loading
Loading
Loading
+7 −0
Changes for client/main.cpp: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@

#include <QApplication>
#include <QCommandLineParser>
#include <QPalette>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QtWebEngineQuick>
@@ -64,6 +65,12 @@ int main(int argc, char *argv[]) {

    QQmlApplicationEngine engine;
    engine.rootContext()->setContextProperty("localApi", &localApi);

    /* Detect system dark mode via actual palette window color brightness */
    QColor winColor = app.palette().color(QPalette::Window);
    bool isDark = winColor.lightnessF() < 0.5;
    engine.rootContext()->setContextProperty("systemDarkMode", isDark);

    engine.loadFromModule("BlogiEditor", "Main");

    if (engine.rootObjects().isEmpty())
+3 −5
Changes for client/qml/Theme.qml: 3 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -3,12 +3,10 @@ import QtQuick

QtObject {
    /*
     * Detect system dark/light theme by checking the actual system
     * window color brightness.  This works reliably on Linux/KDE/GNOME
     * where Qt.styleHints.colorScheme often returns Unknown.
     * Dark mode is detected in C++ from QPalette and passed as
     * the context property "systemDarkMode".
     */
    property SystemPalette _sys: SystemPalette {}
    readonly property bool dark: _sys.window.hslLightness < 0.5
    readonly property bool dark: typeof systemDarkMode !== "undefined" ? systemDarkMode : true

    readonly property color bgPrimary:   dark ? "#1e1e2e" : "#f5f5f7"
    readonly property color bgSecondary: dark ? "#2b2b3d" : "#e8e8ec"