File indexing completed on 2024-03-03 04:02:17

0001 /*
0002  * SPDX-FileCopyrightText: 2021 Nicolas Fella <nicolas.fella@gmx.de>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 #include <kcolorschemewatcher.h>
0008 
0009 #include <QGuiApplication>
0010 #include <QDebug>
0011 
0012 int main(int argc, char *argv[])
0013 {
0014     QGuiApplication app(argc, argv);
0015     KColorSchemeWatcher w;
0016 
0017     qDebug() << "System color preference:";
0018 
0019     if (w.systemPreference() == KColorSchemeWatcher::NoPreference) {
0020         qDebug() << "no preference";
0021     } else if (w.systemPreference() == KColorSchemeWatcher::PreferDark) {
0022         qDebug() << "dark";
0023     }
0024     if (w.systemPreference() == KColorSchemeWatcher::PreferLight) {
0025         qDebug() << "light";
0026     }
0027 
0028     QObject::connect(&w, &KColorSchemeWatcher::systemPreferenceChanged, &app, [&w] {
0029         qDebug() << "preference changed to:";
0030 
0031         if (w.systemPreference() == KColorSchemeWatcher::NoPreference) {
0032             qDebug() << "no preference";
0033         } else if (w.systemPreference() == KColorSchemeWatcher::PreferDark) {
0034             qDebug() << "dark";
0035         }
0036         if (w.systemPreference() == KColorSchemeWatcher::PreferLight) {
0037             qDebug() << "light";
0038         }
0039     });
0040 
0041     return app.exec();
0042 }