Warning, file /plasma/plasma-workspace/kcms/icons/main.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     main.h
0003 
0004     SPDX-FileCopyrightText: 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
0005     SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <kde@privat.broulik.de>
0006     SPDX-FileCopyrightText: 2019 Benjamin Port <benjamin.port@enioka.com>
0007 
0008     KDE Frameworks 5 port:
0009     SPDX-FileCopyrightText: 2013 Jonathan Riddell <jr@jriddell.org>
0010 
0011     SPDX-License-Identifier: GPL-2.0-or-later
0012 */
0013 
0014 #pragma once
0015 
0016 #include <KQuickAddons/ManagedConfigModule>
0017 
0018 #include <QCache>
0019 
0020 class KIconTheme;
0021 class IconsSettings;
0022 class IconsData;
0023 
0024 class QQuickItem;
0025 class QTemporaryFile;
0026 
0027 namespace KIO
0028 {
0029 class FileCopyJob;
0030 }
0031 
0032 class IconsModel;
0033 class IconSizeCategoryModel;
0034 
0035 class IconModule : public KQuickAddons::ManagedConfigModule
0036 {
0037     Q_OBJECT
0038     Q_PROPERTY(IconsSettings *iconsSettings READ iconsSettings CONSTANT)
0039     Q_PROPERTY(IconsModel *iconsModel READ iconsModel CONSTANT)
0040     Q_PROPERTY(IconSizeCategoryModel *iconSizeCategoryModel READ iconSizeCategoryModel CONSTANT)
0041     Q_PROPERTY(bool downloadingFile READ downloadingFile NOTIFY downloadingFileChanged)
0042 
0043 public:
0044     IconModule(QObject *parent, const KPluginMetaData &data, const QVariantList &args);
0045     ~IconModule() override;
0046 
0047     enum Roles {
0048         ThemeNameRole = Qt::UserRole + 1,
0049         DescriptionRole,
0050         RemovableRole,
0051         PendingDeletionRole,
0052     };
0053 
0054     IconsSettings *iconsSettings() const;
0055     IconsModel *iconsModel() const;
0056     IconSizeCategoryModel *iconSizeCategoryModel() const;
0057 
0058     bool downloadingFile() const;
0059 
0060     void load() override;
0061     Q_INVOKABLE void reloadConfig()
0062     {
0063         ManagedConfigModule::load();
0064     }
0065 
0066     void save() override;
0067     void defaults() override;
0068 
0069     Q_INVOKABLE void ghnsEntriesChanged();
0070     Q_INVOKABLE void installThemeFromFile(const QUrl &url);
0071 
0072     Q_INVOKABLE QList<int> availableIconSizes(int group) const;
0073 
0074     Q_INVOKABLE int pluginIndex(const QString &pluginName) const;
0075 
0076     // QML doesn't understand QList<QPixmap>, hence wrapped in a QVariantList
0077     Q_INVOKABLE QVariantList previewIcons(const QString &themeName, int size, qreal dpr, int limit = -1);
0078 
0079 Q_SIGNALS:
0080     void downloadingFileChanged();
0081 
0082     void showSuccessMessage(const QString &message);
0083     void showErrorMessage(const QString &message);
0084 
0085     void showProgress(const QString &message);
0086     void hideProgress();
0087 
0088 private:
0089     bool isSaveNeeded() const override;
0090 
0091     void processPendingDeletions();
0092 
0093     static QStringList findThemeDirs(const QString &archiveName);
0094     bool installThemes(const QStringList &themes, const QString &archiveName);
0095     void installThemeFile(const QString &path);
0096 
0097     static QPixmap getBestIcon(KIconTheme &theme, const QStringList &iconNames, int size, qreal dpr);
0098 
0099     IconsData *m_data;
0100     IconsModel *m_model;
0101     IconSizeCategoryModel *m_iconSizeCategoryModel;
0102 
0103     mutable QCache<QString, KIconTheme> m_kiconThemeCache;
0104 
0105     std::unique_ptr<QTemporaryFile> m_tempInstallFile;
0106     QPointer<KIO::FileCopyJob> m_tempCopyJob;
0107 };