File indexing completed on 2024-09-01 11:44:03
0001 /** 0002 * SPDX-FileCopyrightText: 2022 Suhaas Joshi <joshiesuhaas0@gmail.com> 0003 * SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk> 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "kcm.h" 0008 0009 #include <KLocalizedString> 0010 #include <KPluginFactory> 0011 #include <QFile> 0012 0013 K_PLUGIN_CLASS_WITH_JSON(KCMFlatpak, "kcm_flatpak.json") 0014 0015 KCMFlatpak::KCMFlatpak(QObject *parent, const KPluginMetaData &data, const QVariantList &args) 0016 : KQuickAddons::ManagedConfigModule(parent, data, args) 0017 , m_refsModel(new FlatpakReferencesModel(this)) 0018 { 0019 constexpr const char *uri = "org.kde.plasma.kcm.flatpakpermissions"; 0020 0021 qmlRegisterUncreatableType<KCMFlatpak>(uri, 1, 0, "KCMFlatpak", QString()); 0022 qmlRegisterType<FlatpakPermissionModel>(uri, 1, 0, "FlatpakPermissionModel"); 0023 qmlRegisterUncreatableType<FlatpakReferencesModel>(uri, 1, 0, "FlatpakReferencesModel", QStringLiteral("For enum access only")); 0024 qmlRegisterUncreatableType<FlatpakPermissionsSectionType>(uri, 1, 0, "FlatpakPermissionsSectionType", QStringLiteral("For enum access only")); 0025 0026 connect(m_refsModel, &FlatpakReferencesModel::needsLoad, this, &KCMFlatpak::load); 0027 connect(m_refsModel, &FlatpakReferencesModel::settingsChanged, this, &KCMFlatpak::settingsChanged); 0028 settingsChanged(); // Initialize Reset & Defaults buttons 0029 } 0030 0031 void KCMFlatpak::load() 0032 { 0033 m_refsModel->load(m_index); 0034 setNeedsSave(false); 0035 } 0036 0037 void KCMFlatpak::save() 0038 { 0039 m_refsModel->save(m_index); 0040 } 0041 0042 void KCMFlatpak::defaults() 0043 { 0044 m_refsModel->defaults(m_index); 0045 } 0046 0047 bool KCMFlatpak::isSaveNeeded() const 0048 { 0049 return m_refsModel->isSaveNeeded(m_index); 0050 } 0051 0052 bool KCMFlatpak::isDefaults() const 0053 { 0054 return m_refsModel->isDefaults(m_index); 0055 } 0056 0057 void KCMFlatpak::setIndex(int index) 0058 { 0059 m_index = index; 0060 settingsChanged(); // Because Apply, Reset & Defaults buttons depend on m_index. 0061 } 0062 0063 int KCMFlatpak::currentIndex() const 0064 { 0065 return m_index; 0066 } 0067 0068 #include "kcm.moc"