File indexing completed on 2024-05-12 17:07:20

0001 /*
0002     SPDX-FileCopyrightText: 2014 Marco Martin <mart@kde.org>
0003     SPDX-FileCopyrightText: 2014 Vishesh Handa <me@vhanda.in>
0004     SPDX-FileCopyrightText: 2019 Cyril Rossi <cyril.rossi@enioka.com>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-only
0007 */
0008 
0009 #pragma once
0010 
0011 #include <KNSCore/EntryWrapper>
0012 #include <KPackage/Package>
0013 #include <KQuickAddons/ManagedConfigModule>
0014 
0015 class QStandardItemModel;
0016 class QSortFilterProxyModel;
0017 class SplashScreenSettings;
0018 class SplashScreenData;
0019 
0020 class KCMSplashScreen : public KQuickAddons::ManagedConfigModule
0021 {
0022     Q_OBJECT
0023     Q_PROPERTY(SplashScreenSettings *splashScreenSettings READ splashScreenSettings CONSTANT)
0024     Q_PROPERTY(QAbstractProxyModel *splashSortedModel READ splashSortedModel CONSTANT)
0025     Q_PROPERTY(bool testing READ testing NOTIFY testingChanged)
0026 
0027 public:
0028     enum Roles {
0029         PluginNameRole = Qt::UserRole + 1,
0030         ScreenshotRole,
0031         DescriptionRole,
0032         UninstallableRole,
0033         PendingDeletionRole,
0034     };
0035 
0036     KCMSplashScreen(QObject *parent, const KPluginMetaData &metaData, const QVariantList &args);
0037 
0038     SplashScreenSettings *splashScreenSettings() const;
0039     QAbstractProxyModel *splashSortedModel() const;
0040     bool testing() const;
0041 
0042     Q_INVOKABLE int sortModelPluginIndex(const QString &pluginName) const;
0043     Q_INVOKABLE void ghnsEntryChanged(KNSCore::EntryWrapper *wrapper);
0044     QStringList pendingDeletions();
0045 
0046 public Q_SLOTS:
0047     void save() override;
0048     void load() override;
0049     void defaults() override;
0050     void test(const QString &plugin);
0051 
0052 Q_SIGNALS:
0053     void testingChanged();
0054     void testingFailed(const QString &processErrorOutput);
0055     void error(const QString &message);
0056 
0057 private:
0058     QList<KPackage::Package> availablePackages(const QString &component);
0059     int pluginIndex(const QString &pluginName) const;
0060     void addKPackageToModel(const KPackage::Package &pkg);
0061 
0062     SplashScreenData *const m_data;
0063     QStandardItemModel *const m_model;
0064 
0065     QProcess *m_testProcess = nullptr;
0066     QString m_packageRoot;
0067     QSortFilterProxyModel *m_sortModel = nullptr;
0068 };