aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/sonix/SonixPage.qml
blob: 853e075a58fea43a4a69341b1e936e41ba5eda39 (plain)
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
// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// 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.

import QtQuick
import "../.."

Column {
    id: page
    required property var mod
    signal go(string name)
    property string tab: "device"
    spacing: 14

    Component.onCompleted: Sonix.hold()
    Component.onDestruction: Sonix.release()

    Text {
        visible: !Sonix.present
        text: "The player is not on the network."
        font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 }
        color: Theme.subtext
    }

    Row {
        visible: Sonix.present
        spacing: 6
        Repeater {
            model: [["device", "Device"], ["playlists", "Playlists"], ["folders", "Folders"]]
            delegate: Button {
                required property var modelData
                text: modelData[1]
                border.color: page.tab === modelData[0] ? Theme.accent : Qt.alpha(Theme.text, 0.2)
                onClicked: page.tab = modelData[0]
            }
        }
    }

    Loader {
        width: page.width
        active: Sonix.present
        sourceComponent: page.tab === "device" ? deviceTab
                       : page.tab === "playlists" ? playlistsTab : foldersTab
    }

    Component { id: deviceTab; SonixDevice { onGo: name => page.go(name) } }
    Component { id: playlistsTab; SonixPlaylists { mod: page.mod } }
    Component { id: foldersTab; SonixFolders { mod: page.mod } }
}