LauncherHome.qml 8.56 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * Copyright 2019 Aditya Mehra <aix.m@outlook.com>
 * Copyright 2015 Marco Martin <mart@kde.org>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  2.010-1301, USA.
 */

Aditya Mehra's avatar
Aditya Mehra committed
20
21
22
23
24
25
26
27
28
import QtQuick 2.9
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.3 as Controls
import QtQuick.Window 2.2
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.kquickcontrolsaddons 2.0
import org.kde.private.biglauncher 1.0 as Launcher
Marco Martin's avatar
Marco Martin committed
29
import org.kde.kirigami 2.11 as Kirigami
Marco Martin's avatar
Marco Martin committed
30
import org.kde.kitemmodels 1.0 as KItemModels
Aditya Mehra's avatar
Aditya Mehra committed
31

Marco Martin's avatar
Marco Martin committed
32
import "delegates" as Delegates
Marco Martin's avatar
Marco Martin committed
33
import org.kde.mycroft.bigscreen 1.0 as BigScreen
Marco Martin's avatar
Marco Martin committed
34
import org.kde.private.biglauncher 1.0
Marco Martin's avatar
Marco Martin committed
35
import org.kde.plasma.private.kicker 0.1 as Kicker
Marco Martin's avatar
Marco Martin committed
36

37
FocusScope {
38
39
    anchors {
        fill: parent
40
41
        leftMargin: Kirigami.Units.largeSpacing * 4
        topMargin: Kirigami.Units.largeSpacing * 3
42
    }
43

44
45
    ColumnLayout {
        id: launcherHomeColumn
Marco Martin's avatar
Marco Martin committed
46
47
48
49
        anchors {
            left: parent.left
            right: parent.right
        }
Marco Martin's avatar
Marco Martin committed
50
        property Item currentSection
Marco Martin's avatar
Marco Martin committed
51
52
        y: currentSection ? -currentSection.y + parent.height/2 - currentSection.height/2 : parent.height/2

Marco Martin's avatar
Marco Martin committed
53
        Behavior on y {
54
            YAnimator {
Marco Martin's avatar
Marco Martin committed
55
56
57
58
                duration: Kirigami.Units.longDuration * 2
                easing.type: Easing.InOutQuad
            }
        }
Marco Martin's avatar
Marco Martin committed
59
        //height: parent.height
60
        spacing: Kirigami.Units.largeSpacing*3
Aditya Mehra's avatar
Aditya Mehra committed
61
        
Marco Martin's avatar
Marco Martin committed
62

Marco Martin's avatar
Marco Martin committed
63
64
        BigScreen.TileRepeater {
            id: recentView
Marco Martin's avatar
Marco Martin committed
65
            title: i18n("Recent")
66
            compactMode: plasmoid.configuration.expandingTiles
Marco Martin's avatar
Marco Martin committed
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
            model: Kicker.RecentUsageModel {
                shownItems: Kicker.RecentUsageModel.OnlyApps
            }

            visible: count > 0
            currentIndex: 0
            focus: true
            onActiveFocusChanged: if (activeFocus) launcherHomeColumn.currentSection = recentView
            delegate: Delegates.AppDelegate {
                property var modelData: typeof model !== "undefined" ? model : null
                iconImage: model.decoration
                text: model.display
                comment: model.description
                onClicked: recentView.model.trigger(index, "", null);
            }

            navigationUp: shutdownIndicator
            navigationDown: voiceAppsView
        }

        BigScreen.TileRepeater {
            id: voiceAppsView
Marco Martin's avatar
Marco Martin committed
89
            title: i18n("Voice Apps")
90
            compactMode: plasmoid.configuration.expandingTiles
Marco Martin's avatar
Marco Martin committed
91
92
93
94
95
96
97
98
            model: KItemModels.KSortFilterProxyModel {
                sourceModel: plasmoid.nativeInterface.applicationListModel
                filterRole: "ApplicationCategoriesRole"
                filterRowCallback: function(source_row, source_parent) {
                    return sourceModel.data(sourceModel.index(source_row, 0, source_parent), ApplicationListModel.ApplicationCategoriesRole).indexOf("VoiceApp") !== -1;
                }
            }

99
            currentIndex: 0
Marco Martin's avatar
Marco Martin committed
100
101
            focus: false
            onActiveFocusChanged: if (activeFocus) launcherHomeColumn.currentSection = voiceAppsView
102
103
            delegate: Delegates.VoiceAppDelegate {
                property var modelData: typeof model !== "undefined" ? model : null
Marco Martin's avatar
Marco Martin committed
104
                
105
            }
Marco Martin's avatar
Marco Martin committed
106

Marco Martin's avatar
Marco Martin committed
107
108
            navigationUp: recentView
            navigationDown: appsView
Aditya Mehra's avatar
Aditya Mehra committed
109
        }
110

Marco Martin's avatar
Marco Martin committed
111
112
        BigScreen.TileRepeater {
            id: appsView
113
            title: i18n("Applications")
114
            compactMode: plasmoid.configuration.expandingTiles
Marco Martin's avatar
Marco Martin committed
115
116
117
118
119
120
121
122
123
            model: KItemModels.KSortFilterProxyModel {
                sourceModel: plasmoid.nativeInterface.applicationListModel
                filterRole: "ApplicationCategoriesRole"
                filterRowCallback: function(source_row, source_parent) {
                    var cats = sourceModel.data(sourceModel.index(source_row, 0, source_parent), ApplicationListModel.ApplicationCategoriesRole);
                    return cats.indexOf("Game") === -1 && cats.indexOf("VoiceApp") === -1;
                }
            }

124
125
            currentIndex: 0
            focus: false
Marco Martin's avatar
Marco Martin committed
126
            onActiveFocusChanged: if (activeFocus) launcherHomeColumn.currentSection = appsView
127
128
            delegate: Delegates.AppDelegate {
                property var modelData: typeof model !== "undefined" ? model : null
129
                comment: model.ApplicationCommentRole
130
            }
Aditya Mehra's avatar
Aditya Mehra committed
131
            
Marco Martin's avatar
Marco Martin committed
132
133
            navigationUp: voiceAppsView
            navigationDown: gamesView
Aditya Mehra's avatar
Aditya Mehra committed
134
        }
135
        
Marco Martin's avatar
Marco Martin committed
136
137
        BigScreen.TileRepeater {
            id: gamesView
138
            title: i18n("Games")
139
            compactMode: plasmoid.configuration.expandingTiles
Marco Martin's avatar
Marco Martin committed
140
141
142
143
144
145
146
147
            model: KItemModels.KSortFilterProxyModel {
                sourceModel: plasmoid.nativeInterface.applicationListModel
                filterRole: "ApplicationCategoriesRole"
                filterRowCallback: function(source_row, source_parent) {
                    return sourceModel.data(sourceModel.index(source_row, 0, source_parent), ApplicationListModel.ApplicationCategoriesRole).indexOf("Game") !== -1;
                }
            }

148
149
            currentIndex: 0
            focus: false
Marco Martin's avatar
Marco Martin committed
150
            onActiveFocusChanged: if (activeFocus) launcherHomeColumn.currentSection = gamesView
151
152
153
154
            delegate: Delegates.AppDelegate {
                property var modelData: typeof model !== "undefined" ? model : null
            }
            
Marco Martin's avatar
Marco Martin committed
155
156
            navigationUp: appsView
            navigationDown: settingsView
157
158
        }
        
Marco Martin's avatar
Marco Martin committed
159
160
        BigScreen.TileRepeater {
            id: settingsView
Marco Martin's avatar
Marco Martin committed
161
            title: i18n("Settings")
162
            model: actions
163
            compactMode: plasmoid.configuration.expandingTiles
164
165
166

            property list<Controls.Action> actions: [
                Controls.Action {
167
168
                    text: i18n("Audio")
                    icon.name: "audio-volume-high"
169
                    onTriggered: plasmoid.nativeInterface.executeCommand("plasma-settings -s -m kcm_audiodevice")
170
                },
171
                Controls.Action {
172
                    text: i18n("Bigscreen Settings")
173
174
175
176
177
                    icon.name: "view-grid-symbolic"
                    onTriggered: {
                        plasmoidConfig.showMaximized();
                    }
                },
Marco Martin's avatar
Marco Martin committed
178
179
180
181
182
                Controls.Action {
                    text: i18n("Mycroft Skill Installer")
                    icon.name: "download"
                    onTriggered: plasmoid.nativeInterface.executeCommand("MycroftSkillInstaller")
                },
183
184
                Controls.Action {
                    text: i18n("Wallpaper")
185
                    icon.name: "preferences-desktop-wallpaper"
186
                    onTriggered: plasmoid.action("configure").trigger();
187
188
                },
                Controls.Action {
Marco Martin's avatar
Marco Martin committed
189
190
191
                    text: i18n("Wireless")
                    icon.name: "network-wireless-connected-100"
                    onTriggered: plasmoid.nativeInterface.executeCommand("plasma-settings -s -m kcm_mediacenter_wifi")
192
193
194
195
196
                },
                Controls.Action {
                    text: i18n("KDE Connect")
                    icon.name: "kdeconnect"
                    onTriggered: plasmoid.nativeInterface.executeCommand("plasma-settings -s -m kcm_mediacenter_kdeconnect")
197
198
                }
            ]
Marco Martin's avatar
Marco Martin committed
199

Marco Martin's avatar
Marco Martin committed
200
            onActiveFocusChanged: if (activeFocus) launcherHomeColumn.currentSection = settingsView
201
202
203
204
            delegate: Delegates.SettingDelegate {
                property var modelData: typeof model !== "undefined" ? model : null
            }
            
Marco Martin's avatar
Marco Martin committed
205
            navigationUp: gamesView
206
            navigationDown: null
207
208
        }

209
        Component.onCompleted: {
Marco Martin's avatar
Marco Martin committed
210
211
212
213
214
            if (recentView.visible) {
                recentView.forceActiveFocus();
            } else {
                voiceAppsView.forceActiveFocus();
            }
215
        }
Aditya Mehra's avatar
Aditya Mehra committed
216

217
        Connections {
Marco Martin's avatar
Marco Martin committed
218
219
            target: root
            onActivateAppView: {
Marco Martin's avatar
Marco Martin committed
220
                voiceAppsView.forceActiveFocus();
221
            }
Aditya Mehra's avatar
Aditya Mehra committed
222
223
224
        }
    }
}
225