File indexing completed on 2024-09-15 07:24:29
0001 // SPDX-FileCopyrightText: 2021 Carl Schwan <carlschwan@kde.org> 0002 // SPDX-License-Identifier: LGPL-2.1-or-later 0003 0004 #pragma once 0005 0006 #include <QtQml> 0007 0008 class QAbstractItemModel; 0009 class KColorSchemeManager; 0010 0011 class ColorSchemer : public QObject 0012 { 0013 Q_OBJECT 0014 QML_ELEMENT 0015 QML_SINGLETON 0016 0017 Q_PROPERTY(QAbstractItemModel *model READ model CONSTANT) 0018 0019 public: 0020 static ColorSchemer *create(QQmlEngine *, QJSEngine *) 0021 { 0022 auto inst = &instance(); 0023 QJSEngine::setObjectOwnership(inst, QJSEngine::ObjectOwnership::CppOwnership); 0024 return inst; 0025 } 0026 0027 explicit ColorSchemer(QObject *parent = nullptr); 0028 0029 static ColorSchemer &instance(); 0030 0031 QAbstractItemModel *model() const; 0032 Q_INVOKABLE void apply(int idx); 0033 Q_INVOKABLE void apply(const QString &name); 0034 Q_INVOKABLE int indexForScheme(const QString &name) const; 0035 Q_INVOKABLE QString nameForIndex(int index) const; 0036 0037 private: 0038 KColorSchemeManager *c; 0039 };