1/*
2    SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
3    SPDX-FileCopyrightText: 2020 Harald Sitter <sitter@kde.org>
4*/
5
6import QtQuick 2.12
7import QtQuick.Controls 2.5 as QQC2
8import QtQuick.Layouts 1.14
9import org.kde.kirigami 2.12 as Kirigami
10import org.kde.filesharing.samba 1.0 as Samba
11
12Item {
13    Samba.Installer {
14        id: installer
15
16        onInstalledChanged: {
17            if (!installer.installed) {
18                return
19            }
20            // Installation is a bit special because it eventually ends in a reboot. So we push that page onto the
21            // pending pages and move to the group page. The group page in turn will either explicitly
22            // go to the reboot page (if group changes were made) or pop a pending page if groups are already cool.
23            // In either event it'll end up on the reboot page because of our pending meddling here.
24            pendingStack.push("RebootPage.qml")
25            stackReplace("GroupPage.qml")
26        }
27    }
28
29    Kirigami.PlaceholderMessage {
30        anchors.centerIn: parent
31        width: parent.width
32
33        text: i18nc("@label", "Samba must be installed before folders can be shared.")
34        helpfulAction: Kirigami.Action {
35            iconName: "install"
36            text: i18nc("@button", "Install Samba")
37            onTriggered: installer.install()
38            enabled: !installer.installing && !installer.installed
39        }
40
41        QQC2.Label {
42            Layout.alignment: Qt.AlignHCenter
43            Layout.fillWidth: true
44            text: i18nc("@label", "The Samba package failed to install.")
45            wrapMode: Text.Wrap
46            visible: installer.failed
47        }
48        QQC2.ProgressBar {
49            Layout.alignment: Qt.AlignHCenter
50            Layout.fillWidth: true
51            Layout.margins: Kirigami.Units.largeSpacing * 2
52            indeterminate: true
53            visible: installer.installing
54        }
55    }
56}
57