File indexing completed on 2024-10-13 12:46:00
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 <QObject> 0007 0008 class QAbstractItemModel; 0009 class KColorSchemeManager; 0010 0011 /** 0012 * @class ColorSchemer 0013 * 0014 * A class to provide a wrapper around KColorSchemeManager to make it available in 0015 * QML. 0016 * 0017 * @sa KColorSchemeManager 0018 */ 0019 class ColorSchemer : public QObject 0020 { 0021 Q_OBJECT 0022 0023 /** 0024 * @brief A QAbstractItemModel of all available color schemes. 0025 * 0026 * @sa QAbstractItemModel 0027 */ 0028 Q_PROPERTY(QAbstractItemModel *model READ model CONSTANT) 0029 0030 public: 0031 explicit ColorSchemer(QObject *parent = nullptr); 0032 ~ColorSchemer(); 0033 0034 QAbstractItemModel *model() const; 0035 0036 /** 0037 * @brief Activates the KColorScheme identified by the provided index. 0038 * 0039 * @sa KColorScheme 0040 */ 0041 Q_INVOKABLE void apply(int idx); 0042 0043 /** 0044 * @brief Activates the KColorScheme with the given name. 0045 * 0046 * @sa KColorScheme 0047 */ 0048 Q_INVOKABLE void apply(const QString &name); 0049 0050 /** 0051 * @brief Returns the index for the scheme with the given name. 0052 */ 0053 Q_INVOKABLE int indexForScheme(const QString &name) const; 0054 0055 /** 0056 * @brief Returns the name for the scheme with the given index. 0057 */ 0058 Q_INVOKABLE QString nameForIndex(int index) const; 0059 0060 private: 0061 KColorSchemeManager *c; 0062 };