FindDevicesPage.qml 2.42 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * Copyright 2016 Aleix Pol Gonzalez <aleixpol@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) version 3 or any later version
 * accepted by the membership of KDE e.V. (or its successor approved
 * by the membership of KDE e.V.), which shall act as a proxy
 * defined in Section 14 of version 3 of the license.
 *
 * 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
18
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19 20 21
 */

import QtQuick 2.2
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
22
import QtQuick.Controls 2.3
23
import QtQuick.Layouts 1.1
24
import org.kde.kirigami 2.12 as Kirigami
25 26
import org.kde.kdeconnect 1.0

27
Kirigami.ScrollablePage
28
{
29 30 31 32 33
    Component {
        id: deviceComp
        DevicePage {}
    }

Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
34
    objectName: "FindDevices"
35
    title: i18nd("kdeconnect-app", "Pair")
36

37
    Kirigami.PlaceholderMessage {
38
        text: i18nd("kdeconnect-app", "No devices found")
39 40 41 42
        anchors.centerIn: parent
        visible: devices.count === 0
    }

43
    ListView {
44
        id: devices
45 46
        section {
            property: "status"
Nicolas Fella's avatar
Nicolas Fella committed
47
            delegate: Kirigami.ListSectionHeader {
48 49 50
                text: switch (parseInt(section))
                {
                    case DevicesModel.Paired:
51
                        return i18nd("kdeconnect-app", "Remembered")
52
                    case DevicesModel.Reachable:
53
                        return i18nd("kdeconnect-app", "Available")
54
                    case (DevicesModel.Reachable | DevicesModel.Paired):
55
                        return i18nd("kdeconnect-app", "Connected")
56 57
                }
            }
58 59 60
        }

        model: DevicesSortProxyModel {
61
            sourceModel: DevicesModel {}
62 63 64
        }
        delegate: Kirigami.BasicListItem {
            icon: iconName
Nicolas Fella's avatar
Nicolas Fella committed
65
            iconColor: "transparent"
66 67
            label: display
            subtitle: toolTip
68
            highlighted: false
69 70 71 72 73
            onClicked: {
                pageStack.push(
                    deviceComp,
                    {currentDevice: device}
                );
74 75 76 77
            }
        }
    }
}