1/*
2    SPDX-FileCopyrightText: 2018 Tomaz Canabrava <tcanabrava@kde.org>
3
4    SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
5*/
6
7import QtQuick 2.9
8import QtQuick.Layouts 1.12
9import QtQuick.Window 2.2
10import QtQuick.Dialogs 1.0 as QtDialogs
11import QtQuick.Controls 2.14 as QQC2
12import org.kde.kirigami 2.4 as Kirigami
13import org.kde.kcm 1.1 as KCM
14
15KCM.SimpleKCM {
16    id: root
17
18    implicitWidth: Kirigami.Units.gridUnit * 44
19    implicitHeight: Kirigami.Units.gridUnit * 25
20
21    KCM.ConfigModule.quickHelp: i18n("This module lets you configure the accessibility features such as a screen reader.")
22
23    property var elements: [
24        {
25            icon: "notifications",
26            title: i18nc("System Bell", "Bell"),
27            defaultnessKey: "bellIsDefaults"
28        },
29        {
30            icon: "input-keyboard",
31            title: i18nc("System Modifier Keys", "Modifier Keys"),
32            defaultnessKey: "keyboardModifiersIsDefaults"
33        },
34        {
35            icon: "view-filter",
36            title: i18nc("System keyboard filters", "Keyboard Filters"),
37            defaultnessKey: "keyboardFiltersIsDefaults"
38        },
39        {
40            icon: "input-mouse",
41            title: i18nc("System mouse navigation", "Mouse Navigation"),
42            defaultnessKey: "mouseIsDefaults"
43        },
44        {
45            icon: "audio-input-microphone",
46            title: i18nc("System mouse navigation", "Screen Reader"),
47            defaultnessKey: "screenReaderIsDefaults"
48        }
49    ]
50
51    RowLayout {
52        id: mainLayout
53        anchors.margins: Kirigami.Units.largeSpacing
54        QQC2.ScrollView {
55            id: leftSidePaneBackground
56            contentHeight: root.contentItem.height -  Kirigami.Units.gridUnit * 4
57            contentWidth: Kirigami.Units.gridUnit * 13
58
59            QQC2.ScrollBar.horizontal.policy: QQC2.ScrollBar.AlwaysOff
60            QQC2.ScrollBar.vertical.policy: QQC2.ScrollBar.AlwaysOff
61
62            Component.onCompleted: leftSidePaneBackground.background.visible = true
63
64            ListView {
65                id: listView
66                activeFocusOnTab: true
67                clip: true
68                keyNavigationEnabled: true
69                model: elements
70
71                onCurrentIndexChanged: stackView.currentIndex = currentIndex
72
73                delegate: Kirigami.BasicListItem {
74                    width: listView.width
75                    icon: modelData.icon
76                    label: modelData.title
77                    onClicked: listView.forceActiveFocus()
78                    Rectangle {
79                        id: defaultIndicator
80                        radius: width * 0.5
81                        implicitWidth: Kirigami.Units.largeSpacing
82                        implicitHeight: Kirigami.Units.largeSpacing
83                        visible: kcm.defaultsIndicatorsVisible
84                        opacity: !kcm[modelData.defaultnessKey]
85                        color: Kirigami.Theme.neutralTextColor
86                    }
87                }
88            }
89        }
90
91        StackLayout {
92            id: stackView
93            Layout.fillWidth: true
94            Layout.fillHeight: true
95
96            Bell {
97                Layout.fillWidth: true
98                Layout.fillHeight: true
99            }
100            ModifierKeys {
101                Layout.fillWidth: true
102                Layout.fillHeight: true
103
104            }
105            KeyboardFilters {
106                Layout.fillWidth: true
107                Layout.fillHeight: true
108
109            }
110            MouseNavigation {
111                Layout.fillWidth: true
112                Layout.fillHeight: true
113
114            }
115            ScreenReader {
116                Layout.fillWidth: true
117                Layout.fillHeight: true
118            }
119        }
120    }
121}
122