ElisaConfigurationDialog.qml 11.7 KB
Newer Older
1
/*
Matthieu Gallien's avatar
Matthieu Gallien committed
2
   SPDX-FileCopyrightText: 2017 (c) Matthieu Gallien <matthieu_gallien@yahoo.fr>
Nate Graham's avatar
Nate Graham committed
3
   SPDX-FileCopyrightText: 2020 (c) Nate Graham <nate@kde.org>
Matthieu Gallien's avatar
Matthieu Gallien committed
4
5

   SPDX-License-Identifier: LGPL-3.0-or-later
6
7
 */

8
import QtQuick 2.11
9
10
import QtQuick.Layouts 1.12
import QtQuick.Window 2.12
Nate Graham's avatar
Nate Graham committed
11
12
13
14
import QtQuick.Controls 2.4 as QQC2
import QtQuick.Dialogs 1.3 as Dialogs

import org.kde.kirigami 2.14 as Kirigami
15

16
17
import org.kde.elisa 1.0

18
Window {
19
    id: dialog
20
21

    title: i18n("Configure")
22

23
24
    visible: true
    modality: Qt.ApplicationModal
25

Nate Graham's avatar
Nate Graham committed
26
27
    minimumWidth: Kirigami.Units.gridUnit * 36
    minimumHeight: Kirigami.Units.gridUnit * 29
28

Nate Graham's avatar
Nate Graham committed
29
    // Close when pressing Esc key
30
31
32
33
34
    Shortcut {
        sequence: StandardKey.Cancel
        onActivated: close()
    }

35
36
37
38
39
    SystemPalette {
        id: myPalette
        colorGroup: SystemPalette.Active
    }

Nate Graham's avatar
Nate Graham committed
40
    // Draw standard window backround
41
    Rectangle {
42
        anchors.fill: parent
43

44
        color: myPalette.window
45

46
47
        ColumnLayout {
            anchors.fill: parent
Nate Graham's avatar
Nate Graham committed
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
            anchors.margins: Kirigami.Units.smallSpacing


            // General settings
            // ================
            Kirigami.FormLayout {

                QQC2.CheckBox {
                    Kirigami.FormData.label: i18n("General:")

                    text: i18n("Show progress on Task Manager entries")

                    checked: ElisaConfigurationDialog.showProgressInTaskBar
                    onToggled: ElisaConfigurationDialog.showProgressInTaskBar = checked
                    Accessible.onToggleAction: onToggled
                    Accessible.onPressAction: onToggled
                }

                QQC2.CheckBox {
                    text: i18n("Keep running in System Tray when main window is closed")

                    checked: ElisaConfigurationDialog.showSystemTrayIcon
                    onToggled: ElisaConfigurationDialog.showSystemTrayIcon = checked
                    Accessible.onToggleAction: onToggled
                    Accessible.onPressAction: onToggled
                }

                QQC2.CheckBox {
                    text: i18n("Start playing on startup")

                    checked: ElisaConfigurationDialog.playAtStartup
                    onToggled: ElisaConfigurationDialog.playAtStartup = checked
                    Accessible.onToggleAction: onToggled
                    Accessible.onPressAction: onToggled
                }


                Item {
                    Kirigami.FormData.isSection: true
                }


                QQC2.ComboBox {
                    id: embeddedCategoryCombo

                    Kirigami.FormData.label: i18n("Embed category in sidebar:")

                    model: [i18nc("Configure dialog, embed no category in views navigation list", "Nothing"),
                        i18nc("Configure dialog, embed all albums in views navigation list", "Albums"),
                        i18nc("Configure dialog, embed all artists in views navigation list", "Artists"),
                        i18nc("Configure dialog, embed all genres in views navigation list", "Genres")]

                    editable: false
                    currentIndex: (ElisaConfigurationDialog.embeddedView === ElisaUtils.Genre ? 3 : (ElisaConfigurationDialog.embeddedView === ElisaUtils.Album ? 1 : (ElisaConfigurationDialog.embeddedView === ElisaUtils.Artist ? 2 : 0)))

                    onActivated: {
                        ElisaConfigurationDialog.embeddedView = (currentIndex === 0 ? ElisaUtils.Unknown : (currentIndex === 1 ? ElisaUtils.Album : (currentIndex === 2 ? ElisaUtils.Artist : ElisaUtils.Genre)))
                    }

                    Connections {
                        target: ElisaConfigurationDialog

                        onEmbeddedViewChanged:
                        {
                            if (ElisaConfigurationDialog.embeddedView == ElisaUtils.Unknown) {
                                embeddedCategoryCombo.currentIndex = 0
                            } else if (ElisaConfigurationDialog.embeddedView == ElisaUtils.Album) {
                                embeddedCategoryCombo.currentIndex = 1
                            } else if (ElisaConfigurationDialog.embeddedView == ElisaUtils.Artist) {
                                embeddedCategoryCombo.currentIndex = 2
                            } else if (ElisaConfigurationDialog.embeddedView == ElisaUtils.Genre) {
                                embeddedCategoryCombo.currentIndex = 3
                            }
                        }
                    }
                }


                Item {
                    Kirigami.FormData.isSection: true
                }


                QQC2.ComboBox {
                    id: initialViewCombo

                    Kirigami.FormData.label: i18n("Initial view on startup:")

                    model: [i18nc("Title of the view of the playlist", "Now Playing"),
                        i18nc("Title of the view of recently played tracks", "Recently Played"),
                        i18nc("Title of the view of frequently played tracks", "Frequently Played"),
                        i18nc("Title of the view of all albums", "Albums"),
                        i18nc("Title of the view of all artists", "Artists"),
                        i18nc("Title of the view of all tracks", "Tracks"),
                        i18nc("Title of the view of all genres", "Genres"),
                        i18nc("Title of the file browser view", "Files"),
                        i18nc("Title of the file radios browser view", "Radios"),
                    ]

                    editable: false
                    currentIndex: ElisaConfigurationDialog.initialViewIndex

                    onActivated: {
                        ElisaConfigurationDialog.initialViewIndex = currentIndex
                    }

                    Connections {
                        target: ElisaConfigurationDialog

                        onInitialViewIndexChanged: initialViewCombo.currentIndex = ElisaConfigurationDialog.initialViewIndex
                    }
                }

161

Nate Graham's avatar
Nate Graham committed
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
                Item {
                    Kirigami.FormData.isSection: true
                }


                // Indexing settings
                // =================
                QQC2.ComboBox {
                    id: indexingTypeCombo
                    Kirigami.FormData.label: i18n("Music indexing:")

                    // Work around https://bugs.kde.org/show_bug.cgi?id=403153
                    implicitWidth: Kirigami.Units.gridUnit * 12

                    editable: false

                    model: [i18nc("Configure dialog, indexing type", "Use fast native indexer"),
                            i18nc("Configure dialog, indexing type", "Scan the filesystem directly")]
180

Nate Graham's avatar
Nate Graham committed
181
182
183
184
185
                    currentIndex: ElisaConfigurationDialog.forceUsageOfFastFileSearch ? 1 : 0
                    onActivated: {
                        ElisaConfigurationDialog.forceUsageOfFastFileSearch = currentIndex === 0 ? false : true
                    }
                }
186
187
            }

Nate Graham's avatar
Nate Graham committed
188
            Kirigami.InlineMessage {
189
                Layout.fillWidth: true
Nate Graham's avatar
Nate Graham committed
190
191
                Layout.leftMargin: Kirigami.Units.largeSpacing * 5
                Layout.rightMargin: Kirigami.Units.largeSpacing * 5
192

Nate Graham's avatar
Nate Graham committed
193
                visible: indexingTypeCombo.currentIndex === 1
194

Nate Graham's avatar
Nate Graham committed
195
196
                type: Kirigami.MessageType.Warning
                text: xi18n("This is slower than the fast indexer. Please activate it only if Elisa cannot find your music and searching for one of the missing music files using your file manager also does not work. Please report this as a bug.")
197

Nate Graham's avatar
Nate Graham committed
198
199
200
201
202
203
204
                actions: [
                    Kirigami.Action {
                        text: i18n("Report Bug")
                        iconName: "tools-report-bug"
                        onTriggered: Qt.openUrlExternally("https://bugs.kde.org/enter_bug.cgi?product=frameworks-baloo")
                    }
                ]
205
            }
Alexander Stippich's avatar
Alexander Stippich committed
206

Nate Graham's avatar
Nate Graham committed
207
208
209
210

            // Music locations list
            // ====================
            ColumnLayout {
211
212
                Layout.fillWidth: true
                Layout.fillHeight: true
Nate Graham's avatar
Nate Graham committed
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
                Layout.leftMargin: Kirigami.Units.largeSpacing * 5
                Layout.rightMargin: Kirigami.Units.largeSpacing * 5

                Kirigami.Heading {
                    Layout.fillWidth: true
                    text: i18nc("The configured folders where the user's music collection can be found", "Music folders:")
                    level: 4
                }

                QQC2.ScrollView {
                    id: scrollview

                    Layout.fillWidth: true
                    Layout.fillHeight: true

                    // Show the border
                    Component.onCompleted: {
                        scrollview.background.visible = true;
                    }

                    ListView {
                        id:pathList

                        clip: true

                        model: ElisaConfigurationDialog.rootPath

240
                        delegate: Kirigami.SwipeListItem {
Nate Graham's avatar
Nate Graham committed
241
                            // Don't need a highlight effect on hover
242
                            hoverEnabled: false
Nate Graham's avatar
Nate Graham committed
243

244
245
246
                            QQC2.Label {
                                text: modelData
                            }
Nate Graham's avatar
Nate Graham committed
247

248
249
250
                            actions: Kirigami.Action {
                                iconName: "edit-delete"
                                text: i18n("Stop looking for music here")
Nate Graham's avatar
Nate Graham committed
251
252

                                visible: pathList.count > 1
253
                                onTriggered: ElisaConfigurationDialog.removeMusicLocation(modelData)
Nate Graham's avatar
Nate Graham committed
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
                            }
                        }
                    }
                }


                QQC2.Button {
                    text: i18n("Add New Location")
                    icon.name: "list-add"

                    Layout.alignment: Qt.AlignTop | Qt.AlignLeft

                    onClicked: fileDialog.open()
                    Accessible.onPressAction: onClicked

                    Dialogs.FileDialog {
                        id: fileDialog
                        title: i18n("Choose a Folder")
                        folder: shortcuts.home
                        selectFolder: true

                        visible: false

                        onAccepted: {
                            var oldPaths = ElisaConfigurationDialog.rootPath
                            oldPaths.push(fileDialog.fileUrls)
                            ElisaConfigurationDialog.rootPath = oldPaths
                        }
                    }
                }
284
            }
285

Nate Graham's avatar
Nate Graham committed
286
            QQC2.DialogButtonBox {
287
                Layout.fillWidth: true
288

Nate Graham's avatar
Nate Graham committed
289
                QQC2.Button {
290
                    text: i18n("OK")
Alexander Stippich's avatar
Alexander Stippich committed
291
                    icon.name: 'dialog-ok-apply'
Nate Graham's avatar
Nate Graham committed
292
293
294
295
296
297
                    QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole
                    Accessible.onPressAction: onClicked
                }
                onAccepted: {
                    ElisaConfigurationDialog.save()
                    close()
298
299
                }

Nate Graham's avatar
Nate Graham committed
300
                QQC2.Button {
301
                    text: i18n("Apply")
Alexander Stippich's avatar
Alexander Stippich committed
302
                    icon.name: 'dialog-ok-apply'
Nate Graham's avatar
Nate Graham committed
303
304
                    QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.ApplyRole
                    Accessible.onPressAction: onClicked
305

306
                    enabled: ElisaConfigurationDialog.isDirty
307
                }
Nate Graham's avatar
Nate Graham committed
308
                onApplied: ElisaConfigurationDialog.save()
309

Nate Graham's avatar
Nate Graham committed
310
                QQC2.Button {
311
                    text: i18n("Cancel")
Alexander Stippich's avatar
Alexander Stippich committed
312
                    icon.name: 'dialog-cancel'
Nate Graham's avatar
Nate Graham committed
313
314
                    QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.RejectRole
                    Accessible.onPressAction: onClicked
315
316
                }
                onRejected: close()
317
318
319
320
            }
        }
    }
}