Warning, file /plasma/plasma-workspace/kcms/colors/colors.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2019 Kai Uwe Broulik <kde@privat.broulik.de> 0003 SPDX-FileCopyrightText: 2019 Cyril Rossi <cyril.rossi@enioka.com> 0004 0005 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0006 */ 0007 0008 #pragma once 0009 0010 #include <KConfigWatcher> 0011 #include <KNSCore/EntryWrapper> 0012 #include <QColor> 0013 #include <QDBusPendingCallWatcher> 0014 #include <QPointer> 0015 0016 #include <KSharedConfig> 0017 0018 #include <KQuickAddons/ManagedConfigModule> 0019 0020 #include <optional> 0021 0022 #include "colorsmodel.h" 0023 #include "colorssettings.h" 0024 0025 class QProcess; 0026 class QTemporaryFile; 0027 0028 namespace KIO 0029 { 0030 class FileCopyJob; 0031 } 0032 0033 class FilterProxyModel; 0034 class ColorsData; 0035 0036 class KCMColors : public KQuickAddons::ManagedConfigModule 0037 { 0038 Q_OBJECT 0039 0040 Q_PROPERTY(ColorsModel *model READ model CONSTANT) 0041 Q_PROPERTY(FilterProxyModel *filteredModel READ filteredModel CONSTANT) 0042 Q_PROPERTY(ColorsSettings *colorsSettings READ colorsSettings CONSTANT) 0043 Q_PROPERTY(bool downloadingFile READ downloadingFile NOTIFY downloadingFileChanged) 0044 Q_PROPERTY(QColor accentColor READ accentColor WRITE setAccentColor NOTIFY accentColorChanged) 0045 Q_PROPERTY(QColor lastUsedCustomAccentColor READ lastUsedCustomAccentColor WRITE setLastUsedCustomAccentColor NOTIFY lastUsedCustomAccentColorChanged) 0046 Q_PROPERTY(bool accentColorFromWallpaper READ accentColorFromWallpaper WRITE setAccentColorFromWallpaper NOTIFY accentColorFromWallpaperChanged) 0047 0048 public: 0049 KCMColors(QObject *parent, const KPluginMetaData &data, const QVariantList &args); 0050 ~KCMColors() override; 0051 0052 enum SchemeFilter { 0053 AllSchemes, 0054 LightSchemes, 0055 DarkSchemes, 0056 }; 0057 Q_ENUM(SchemeFilter) 0058 0059 ColorsModel *model() const; 0060 FilterProxyModel *filteredModel() const; 0061 ColorsSettings *colorsSettings() const; 0062 bool downloadingFile() const; 0063 0064 Q_INVOKABLE void loadSelectedColorScheme(); 0065 Q_INVOKABLE void knsEntryChanged(KNSCore::EntryWrapper *entry); 0066 0067 QColor accentColor() const; 0068 void setAccentColor(const QColor &accentColor); 0069 void resetAccentColor(); 0070 Q_SIGNAL void accentColorChanged(); 0071 0072 QColor lastUsedCustomAccentColor() const; 0073 void setLastUsedCustomAccentColor(const QColor &accentColor); 0074 Q_SIGNAL void lastUsedCustomAccentColorChanged(); 0075 0076 bool accentColorFromWallpaper() const; 0077 void setAccentColorFromWallpaper(bool boolean); 0078 Q_SIGNAL void accentColorFromWallpaperChanged(); 0079 0080 Q_INVOKABLE void installSchemeFromFile(const QUrl &url); 0081 0082 Q_INVOKABLE void editScheme(const QString &schemeName, QQuickItem *ctx); 0083 0084 // we take an extraneous reference to the accent colour here in order to have the bindings 0085 // re-evaluate when it changes 0086 Q_INVOKABLE QColor tinted(const QColor &color, const QColor &accent, bool tints, qreal tintFactor); 0087 Q_INVOKABLE QColor accentBackground(const QColor &accent, const QColor &background); 0088 Q_INVOKABLE QColor accentForeground(const QColor &accent, const bool &isActive); 0089 0090 public Q_SLOTS: 0091 void load() override; 0092 void save() override; 0093 0094 private Q_SLOTS: 0095 void wallpaperAccentColorArrivedSlot(QDBusPendingCallWatcher *call); 0096 0097 Q_SIGNALS: 0098 void downloadingFileChanged(); 0099 0100 void showSuccessMessage(const QString &message); 0101 void showErrorMessage(const QString &message); 0102 0103 void showSchemeNotInstalledWarning(const QString &schemeName); 0104 0105 private: 0106 bool isSaveNeeded() const override; 0107 0108 void saveColors(); 0109 void processPendingDeletions(); 0110 0111 void applyWallpaperAccentColor(); 0112 0113 void installSchemeFile(const QString &path); 0114 0115 ColorsModel *m_model; 0116 FilterProxyModel *m_filteredModel; 0117 ColorsData *m_data; 0118 0119 bool m_selectedSchemeDirty = false; 0120 bool m_activeSchemeEdited = false; 0121 0122 QProcess *m_editDialogProcess = nullptr; 0123 0124 KSharedConfigPtr m_config; 0125 KConfigWatcher::Ptr m_configWatcher; 0126 0127 std::unique_ptr<QTemporaryFile> m_tempInstallFile; 0128 QPointer<KIO::FileCopyJob> m_tempCopyJob; 0129 };