import QtQuick 2.7
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import EncryptorSettings 1.0

Item {
    property var viewModel: encryptorSettings

    EncryptorSettings {
        id: encryptorSettings
    }

    Column {
        id: settingsColumn
        anchors.fill: parent

        Item {
            height: 10
            width: parent.width
        }

        Button {
            width: parent.width
            text: qsTr("Обновить список портов")

            onClicked: {
                enabled = false;
                viewModel.update();
                enabled = true;
            }
        }

        Item {
            height: 10
            width: parent.width
        }

        Label {
            width: parent.width
            text: qsTr("Порт модема")
        }

        ComboBox {
            id: deviceSerialPort
            width: parent.width
            model: viewModel.outputPortList
        }

        Item {
            height: 10
            width: parent.width
        }

        Label {
            width: parent.width
            text: qsTr("Идентификатор сети")
        }

        SpinBox {
            id: networkIdentifier
            width: parent.width
            editable: true
            value: 1
            to: 255
        }

        Item {
            height: 10
            width: parent.width
        }

        Button {
            id: loadMasterKeyButton
            width: parent.width
            enabled: !encryptorManager.encryptionEnabled
            text: qsTr("Применить настройки")

            onClicked: {
                enabled = false;
                encryptorManager.setNetworkId(deviceSerialPort.currentText, networkIdentifier.value);
                enabled = true;
            }
        }
    }
}
