KGuiAddons

kcolorschemewatcher_qt.cpp
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
11KColorSchemeWatcherQt::KColorSchemeWatcherQt()
12{
13 connect(QGuiApplication::styleHints(), &QStyleHints::colorSchemeChanged, this, &KColorSchemeWatcherBackend::systemPreferenceChanged);
14}
15
16KColorSchemeWatcher::ColorPreference KColorSchemeWatcherQt::systemPreference() const
17{
18 switch (QGuiApplication::styleHints()->colorScheme()) {
19 case Qt::ColorScheme::Unknown:
20 return KColorSchemeWatcher::NoPreference;
21 case Qt::ColorScheme::Light:
23 case Qt::ColorScheme::Dark:
25 }
26 return KColorSchemeWatcher::NoPreference;
27}
28
29#include "moc_kcolorschemewatcher_qt.cpp"
@ PreferLight
The user prefers a dark color scheme.
@ PreferDark
No preference available.
QStyleHints * styleHints()
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void colorSchemeChanged(Qt::ColorScheme colorScheme)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:02:22 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.