| 1 | /* |
|---|---|
| 2 | * SPDX-FileCopyrightText: 2023 Volker Krause <vkrause@kde.org> |
| 3 | * SPDX-License-Identifier: LGPL-2.0-or-later |
| 4 | */ |
| 5 | |
| 6 | #include "kcolorschemewatcher_qt.h" |
| 7 | |
| 8 | #include <QGuiApplication> |
| 9 | #include <QStyleHints> |
| 10 | |
| 11 | KColorSchemeWatcherQt::KColorSchemeWatcherQt() |
| 12 | { |
| 13 | connect(sender: QGuiApplication::styleHints(), signal: &QStyleHints::colorSchemeChanged, context: this, slot: &KColorSchemeWatcherBackend::systemPreferenceChanged); |
| 14 | } |
| 15 | |
| 16 | KColorSchemeWatcher::ColorPreference KColorSchemeWatcherQt::systemPreference() const |
| 17 | { |
| 18 | switch (QGuiApplication::styleHints()->colorScheme()) { |
| 19 | case Qt::ColorScheme::Unknown: |
| 20 | return KColorSchemeWatcher::NoPreference; |
| 21 | case Qt::ColorScheme::Light: |
| 22 | return KColorSchemeWatcher::PreferLight; |
| 23 | case Qt::ColorScheme::Dark: |
| 24 | return KColorSchemeWatcher::PreferDark; |
| 25 | } |
| 26 | return KColorSchemeWatcher::NoPreference; |
| 27 | } |
| 28 | |
| 29 | #include "moc_kcolorschemewatcher_qt.cpp" |
| 30 |
