import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3

ApplicationWindow {
    visible: true
    width: 640
    height: 550
    title: qsTr("Утилита настройки шифрования БПЛА")

    SwipeView {
        id: swipeView
        currentIndex: tabBar.currentIndex
        interactive: false
        clip: true

        anchors {
            top: header.bottom
            left: parent.left
            right: parent.right
            bottom: footer.top
        }

        Item {
            EncryptorSettingsView {
                anchors {
                    fill: parent
                    margins: 20
                }
            }
        }

        Item {
            ModemSettingsView {
                anchors {
                    fill: parent
                    margins: 20
                }
            }
        }
    }

    header: TabBar {
        id: tabBar
        currentIndex: swipeView.currentIndex

        TabButton {
            text: qsTr("Параметры шифратора")
        }

        TabButton {
            text: qsTr("Параметры модема")
        }
    }

    footer: Item {
        width: parent.width
        height: childrenRect.height

        Frame {
            anchors {
                left: parent.left
                right: connectionStatus.left
            }

            padding: 5

            Connections {
                target: encryptorManager
                onNotification : {
                    statusBar.text = message;
                }
            }

            Label {
                id: statusBar
                width: parent.width
            }
        }

        Frame {
            id: connectionStatus
            width: 250
            padding: 5
            anchors.right: parent.right

            Connections {
                target: encryptorManager
                onNetIdChanged : {
                    netIdLabel.text = netId;
                }
            }

            Row {
                spacing: 3
                anchors.centerIn: parent

                Label {
                    text: qsTr("Net ID:")
                }

                Label {
                    id: netIdLabel
                    text: "unknown"
                }
            }
        }
    }
}
