summaryrefslogtreecommitdiffstats
path: root/examples/positioning/satelliteinfo/ViewSwitch.qml
blob: 1b211cea6bd86f8d95111fb52b4ce77713705693 (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
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

pragma ComponentBehavior: Bound
import QtQuick
import QtQuick.Layouts

Rectangle {
    id: root

    property int currentIndex: 0
    readonly property int tableViewIndex: 1
    readonly property int settingsIndex: 3

    implicitHeight: rootLayout.implicitHeight + 2 * rootLayout.anchors.margins
    color: Theme.backgroundColor

    RowLayout {
        id: rootLayout
        anchors {
            fill: parent
            margins: Theme.defaultSpacing
        }
        spacing: 0
        property real itemWidth: rootLayout.width / repeater.model.length
        Repeater {
            id: repeater
            model: [
                {"name" : qsTr("Sky View"), "source": "icons/skyview.svg"},
                {"name" : qsTr("Table View"), "source": "icons/tableview.svg"},
                {"name" : qsTr("RSSI View"), "source": "icons/rssiview.svg"},
                {"name" : qsTr("Settings"), "source": "icons/settings.svg"},
            ]
            PageButton {
                required property var modelData
                required property int index
                implicitWidth: rootLayout.itemWidth
                text: modelData.name
                source: modelData.source
                selected: root.currentIndex === index
                onClicked: root.currentIndex = index
            }
        }
    }
}