Warning, /plasma/plasma-mobile/shell/contents/configuration/ConfigurationKcmPage.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
0002 // SPDX-FileCopyrightText: 2020 Nicolas Fella <nicolas.fella@gmx.de>
0003 // SPDX-FileCopyrightText: 2020 Carl Schwan <carlschwan@kde.org>
0004 // SPDX-License-Identifier: GPL-2.0-or-later
0005 
0006 import QtQuick 2.6
0007 import QtQuick.Controls 2.2 as QQC2
0008 import org.kde.kirigami 2.5 as Kirigami
0009 
0010 Kirigami.Page {
0011     id: container
0012 
0013     required property QtObject kcm
0014     required property Item internalPage
0015 
0016     signal settingValueChanged()
0017     onSettingValueChanged: saveConfig(); // we save config immediately on mobile
0018 
0019     title: kcm.name
0020     topPadding: 0
0021     leftPadding: 0
0022     rightPadding: 0
0023     bottomPadding: 0
0024     flickable: internalPage.flickable
0025     actions.main: internalPage.actions.main
0026     actions.contextualActions: internalPage.contextualActions
0027 
0028     onInternalPageChanged: {
0029         internalPage.parent = contentItem;
0030         internalPage.anchors.fill = contentItem;
0031     }
0032     onActiveFocusChanged: {
0033         if (activeFocus) {
0034             internalPage.forceActiveFocus();
0035         }
0036     }
0037 
0038     Component.onCompleted: {
0039         kcm.load()
0040     }
0041 
0042     function saveConfig() {
0043         kcm.save();
0044     }
0045 
0046     data: [
0047         Connections {
0048             target: kcm
0049             onPagePushed: {
0050                 app.pageStack.push(configurationKcmPageComponent.createObject(app.pageStack, {"kcm": kcm, "internalPage": page}));
0051             }
0052             onPageRemoved: app.pageStack.pop();
0053         },
0054         Connections {
0055             target: app.pageStack
0056             onPageRemoved: {
0057                 if (kcm.needsSave) {
0058                     kcm.save()
0059                 }
0060                 if (page == container) {
0061                     page.destroy();
0062                 }
0063             }
0064         }
0065     ]
0066     Connections {
0067         target: kcm
0068         function onNeedsSaveChanged() {
0069             if (kcm.needsSave) {
0070                 container.settingValueChanged()
0071             }
0072         }
0073     }
0074 }