import QtCore
import QtQuick
import QtQuick.Controls
import QtQuick.Dialogs
import QtQuick.Layouts
import Analyser

Item {
    id: root
    ColumnLayout {
        anchors.fill: parent
        ConnectionItem {}
        Column {
            Text{
                width: 50
                text: "烧录版本: "+ (App.module!==null? App.module.verison:"")
            }
            Text{
                width: 50
                text: "OTA版本: "+(App.module!==null?App.module.otaVerison:"")
            }
        }
        TabBar {
            id: operationBar
            Layout.fillWidth: true
            TabButton {
                text: "注册/识别"
            }
            TabButton {
                text: "删除/其它"
            }
        }
        StackLayout {
            currentIndex: operationBar.currentIndex
            EnrollVerifyOperations {
                enabled: App.connected
            }
            ExtendedOperations {
            }
        }

    }
    FileDialog {
        id: fileDialog
        nameFilters: ["图片 (*.jpg *.yuv)"]
        currentFolder: StandardPaths.standardLocations(
                           StandardPaths.DesktopLocation)[0]
        onAccepted: {
            var fileUrl = fileDialog.selectedFile.toString()
            var localFilePath = fileUrl.startsWith(
                        "file:///") ? fileUrl.substring(8) : fileUrl
            imagePath.text = localFilePath
        }
    }

    Loader {
        id: loader
        source: "OtaPage.qml"
        active: false
        onLoaded: {
            if (loader.item && loader.item.open) {
                loader.item.open()
                loader.item.onClose = () => {
                    loader.active = false
                }
            }
        }
    }
}
