-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
377 lines (305 loc) · 9.26 KB
/
main.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.3
import QtQml 2.14
import Qt.labs.settings 1.0
import org.kde.kirigami 2.7 as Kirigami
import org.kde.mauikit 1.3 as Maui
import org.maui.vvave 1.0
import "utils"
import "widgets"
import "widgets/PlaylistsView"
import "widgets/MainPlaylist"
import "widgets/SettingsView"
import "widgets/CloudView"
import "widgets/FoldersView"
import "view_models"
import "view_models/BabeTable"
import "view_models/BabeGrid"
//import "widgets/InfoView"
import "db/Queries.js" as Q
import "utils/Help.js" as H
import "utils/Player.js" as Player
Maui.ApplicationWindow
{
id: root
title: currentTrack.url ? currentTrack.title + " - " + currentTrack.artist + " | " + currentTrack.album : ""
/***************************************************/
/******************** ALIASES ********************/
/*************************************************/
property alias selectionBar: _selectionBar
property alias dialog : _dialogLoader.item
/***************************************************/
/******************** PLAYBACK ********************/
/*************************************************/
readonly property alias currentTrack : playlist.currentTrack
property alias currentTrackIndex: playlist.currentIndex
readonly property string progressTimeLabel: player.transformTime((player.duration/1000) * (player.pos/player.duration))
readonly property string durationTimeLabel: player.transformTime((player.duration/1000))
readonly property alias isPlaying: player.playing
property int onQueue: 0
readonly property bool mainlistEmpty: mainPlaylist.listModel.list.count ===0
/***************************************************/
/******************** HANDLERS ********************/
/*************************************************/
readonly property var viewsIndex: ({ tracks: 0,
albums: 1,
artists: 2,
playlists: 3,
folders: 4,
cloud: 5 })
property string syncPlaylist: ""
property bool sync: false
readonly property bool focusView : _stackView.depth === 2
property bool selectionMode : false
/***************************************************/
/******************** UI COLORS *******************/
/*************************************************/
readonly property color babeColor: "#f84172"
altHeader: Kirigami.Settings.isMobile
headBar.visible: !focusView
/*HANDLE EVENTS*/
onClosing: Player.savePlaylist()
Settings
{
id: settings
category: "Settings"
property bool fetchArtwork: true
property bool autoScan: true
}
Mpris2
{
id: mpris2Interface
playListModel: playlist
audioPlayer: player
playerName: 'vvave'
onRaisePlayer:
{
root.raise()
}
}
Playlist
{
id: playlist
model: mainPlaylist.listModel.list
onCurrentTrackChanged: Player.playTrack()
onMissingFile:
{
var message = i18n("Missing file")
var messageBody = track.title + " by " + track.artist + " is missing.\nDo you want to remove it from your collection?"
notify("dialog-question", message, messageBody, function ()
{
mainPlaylist.listModel.list.remove(mainPlaylist.table.currentIndex)
})
}
}
Player
{
id: player
volume: 100
onFinished: if (!mainlistEmpty)
{
if (currentTrack && currentTrack.url)
mainPlaylist.listModel.list.countUp(currentTrackIndex)
Player.nextTrack()
}
}
Loader
{
id: _dialogLoader
}
Component
{
id: _fileDialogComponent
Maui.FileDialog
{
}
}
Component
{
id: _settingsDialogComponent
SettingsDialog {}
}
Component
{
id: _removeDialogComponent
Maui.FileListingDialog
{
id: _removeDialog
urls: selectionBar.uris
title: i18n("Remove %1 tracks", urls.length)
message: i18n("Are you sure you want to remove this files? This action can not be undone.")
rejectButton.text: i18n("Delete")
acceptButton.text: i18n("Cancel")
onAccepted: close()
onRejected:
{
Maui.FM.removeFiles(_removeDialog.urls)
close()
}
}
}
Component
{
id: _focusViewComponent
FocusView { }
}
FloatingDisk
{
id: _floatingDisk
}
Playlists
{
id: playlistsList
}
Maui.TagsDialog
{
id: playlistDialog
onTagsReady: composerList.updateToUrls(tags)
composerList.strict: false
}
mainMenu: [
Action
{
text: i18n("Settings")
icon.name: "settings-configure"
onTriggered:
{
_dialogLoader.sourceComponent = _settingsDialogComponent
dialog.open()
}
}
]
sideBar: Maui.AbstractSideBar
{
id: _drawer
visible: true
preferredWidth: Kirigami.Units.gridUnit * 16
collapsed: !isWide
collapsible: true
onContentDropped:
{
if(drop.urls)
{
var urls = drop.urls.join(",")
Vvave.openUrls(urls.split(","))
}
}
MainPlaylist
{
id: mainPlaylist
anchors.fill: parent
}
}
footer: PlaybackBar
{
visible: !focusView
width: parent.width
}
StackView
{
id: _stackView
anchors.fill: parent
initialItem: Maui.Page
{
floatingFooter: true
headBar.visible: false
flickable: swipeView.currentItem.flickable || swipeView.currentItem.item.flickable
Maui.AppViews
{
id: swipeView
anchors.fill: parent
TracksView
{
id: tracksView
Maui.AppView.title: i18n("Tracks")
Maui.AppView.iconName: "view-media-track"
}
AlbumsView
{
id: albumsView
Maui.AppView.title: i18n("Albums")
Maui.AppView.iconName: "view-media-album-cover"
holder.title : i18n("No Albums!")
holder.body: i18n("Add new music sources")
list.query: Albums.ALBUMS
}
AlbumsView
{
id: artistsView
Maui.AppView.title: i18n("Artists")
Maui.AppView.iconName: "view-media-artist"
holder.title : i18n("No Artists!")
holder.body: i18n("Add new music sources")
list.query : Albums.ARTISTS
}
Maui.AppViewLoader
{
Maui.AppView.title: i18n("Playlists")
Maui.AppView.iconName: "view-media-playlist"
PlaylistsView
{
id: playlistsView
}
}
Maui.AppViewLoader
{
Maui.AppView.title: i18n("Folders")
Maui.AppView.iconName: "folder"
FoldersView
{
id: foldersView
}
}
Maui.AppViewLoader
{
Maui.AppView.title: i18n("Cloud")
Maui.AppView.iconName: "folder-cloud"
CloudView
{
id: cloudView
}
}
}
footer: SelectionBar
{
id: _selectionBar
anchors.horizontalCenter: parent.horizontalCenter
width: Math.min(parent.width-(Maui.Style.space.medium*2), implicitWidth)
padding: Maui.Style.space.big
maxListHeight: swipeView.height - Maui.Style.space.medium
onExitClicked:
{
root.selectionMode = false
clear()
}
}
}
}
Component.onCompleted:
{
Vvave.autoScan = settings.autoScan
Vvave.fetchArtwork = settings.fetchArtwork
}
/*CONNECTIONS*/
Connections
{
target: Vvave
ignoreUnknownSignals: true
function onOpenFiles(tracks)
{
Player.appendTracksAt(tracks, 0)
Player.playAt(0)
}
}
function toggleFocusView()
{
if(focusView)
{
_stackView.pop(StackView.Immediate)
}else
{
_stackView.push(_focusViewComponent, StackView.Immediate)
}
}
}