Skip to content
Snippets Groups Projects
QmlTest.qml 15.8 KiB
Newer Older
  • Learn to ignore specific revisions
  • Don Gagne's avatar
    Don Gagne committed
    import QtQuick 2.2
    import QtQuick.Controls 1.2
    import QtQuick.Controls.Styles 1.2
    
    import QGroundControl.Palette 1.0
    import QGroundControl.Controls 1.0
    
    Rectangle {
    
    
        property var palette: QGCPalette { colorGroupEnabled: true }
    
    Don Gagne's avatar
    Don Gagne committed
        color: palette.window
    
    
    Don Gagne's avatar
    Don Gagne committed
        Column {
    
    Don Gagne's avatar
    Don Gagne committed
    
    
    Don Gagne's avatar
    Don Gagne committed
            Row {
                ExclusiveGroup { id: themeGroup }
    
    Don Gagne's avatar
    Don Gagne committed
    
    
    Don Gagne's avatar
    Don Gagne committed
                QGCRadioButton {
                    text: "Light"
                    exclusiveGroup: themeGroup
                    onClicked: { palette.globalTheme = QGCPalette.Light }
                }
    
    Don Gagne's avatar
    Don Gagne committed
    
    
    Don Gagne's avatar
    Don Gagne committed
                QGCRadioButton {
                    text: "Dark"
                    exclusiveGroup: themeGroup
                    onClicked: { palette.globalTheme = QGCPalette.Dark }
    
    Don Gagne's avatar
    Don Gagne committed
                }
    
    Don Gagne's avatar
    Don Gagne committed
            }
    
            Row {
                spacing: 30
    
                Grid {
                    columns: 3
                    spacing: 5
    
                    Component {
                        id: colorSquare
    
                        Rectangle {
                            width: 80
                            height: 20
                            border.width: 1
                            border.color: "white"
                            color: parent.color
                        }
                    }
    
                    Component {
                        id: rowHeader
    
                        Text {
                            width: 180
                            height: 20
                            horizontalAlignment: Text.AlignRight
                            verticalAlignment: Text.AlignVCenter
                            color: palette.text
                            text: parent.text
                        }
                    }
    
    Don Gagne's avatar
    Don Gagne committed
                    // Header row
                    Loader {
                        sourceComponent: rowHeader
                        property var text: ""
                    }
    
    Don Gagne's avatar
    Don Gagne committed
                    Text {
    
    Don Gagne's avatar
    Don Gagne committed
                        width: 80
    
    Don Gagne's avatar
    Don Gagne committed
                        height: 20
    
                        color: palette.text
    
    Don Gagne's avatar
    Don Gagne committed
                        horizontalAlignment: Text.AlignHCenter
                        text: "Disabled"
                    }
                    Text {
                        width: 80
                        height: 20
                        color: palette.text
                        horizontalAlignment: Text.AlignHCenter
                        text: "Enabled"
    
    Don Gagne's avatar
    Don Gagne committed
                    // window
                    Loader {
                        sourceComponent: rowHeader
                        property var text: "window"
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: false }
                        property var color: palette.window
                        sourceComponent: colorSquare
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: true }
                        property var color: palette.window
                        sourceComponent: colorSquare
                    }
    
    Don Gagne's avatar
    Don Gagne committed
    
    
    Don Gagne's avatar
    Don Gagne committed
                    // windowShade
                    Loader {
                        sourceComponent: rowHeader
                        property var text: "windowShade"
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: false }
                        property var color: palette.windowShade
                        sourceComponent: colorSquare
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: true }
                        property var color: palette.windowShade
                        sourceComponent: colorSquare
                    }
    
    Don Gagne's avatar
    Don Gagne committed
    
    
    Don Gagne's avatar
    Don Gagne committed
                    // windowShadeDark
                    Loader {
                        sourceComponent: rowHeader
                        property var text: "windowShadeDark"
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: false }
                        property var color: palette.windowShadeDark
                        sourceComponent: colorSquare
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: true }
                        property var color: palette.windowShadeDark
                        sourceComponent: colorSquare
                    }
    
    Don Gagne's avatar
    Don Gagne committed
    
    
    Don Gagne's avatar
    Don Gagne committed
                    // text
                    Loader {
                        sourceComponent: rowHeader
                        property var text: "text"
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: false }
                        property var color: palette.text
                        sourceComponent: colorSquare
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: true }
                        property var color: palette.text
                        sourceComponent: colorSquare
                    }
    
    Don Gagne's avatar
    Don Gagne committed
    
    
    Don Gagne's avatar
    Don Gagne committed
                    // button
                    Loader {
                        sourceComponent: rowHeader
                        property var text: "button"
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: false }
                        property var color: palette.button
                        sourceComponent: colorSquare
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: true }
                        property var color: palette.button
                        sourceComponent: colorSquare
                    }
    
    Don Gagne's avatar
    Don Gagne committed
    
    
    Don Gagne's avatar
    Don Gagne committed
                    // buttonText
                    Loader {
                        sourceComponent: rowHeader
                        property var text: "buttonText"
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: false }
                        property var color: palette.buttonText
                        sourceComponent: colorSquare
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: true }
                        property var color: palette.buttonText
                        sourceComponent: colorSquare
                    }
    
    Don Gagne's avatar
    Don Gagne committed
                    // buttonHighlight
                    Loader {
                        sourceComponent: rowHeader
                        property var text: "buttonHighlight"
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: false }
                        property var color: palette.buttonHighlight
                        sourceComponent: colorSquare
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: true }
                        property var color: palette.buttonHighlight
                        sourceComponent: colorSquare
                    }
    
    Don Gagne's avatar
    Don Gagne committed
    
    
    Don Gagne's avatar
    Don Gagne committed
                    // buttonHighlightText
                    Loader {
                        sourceComponent: rowHeader
                        property var text: "buttonHighlightText"
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: false }
                        property var color: palette.buttonHighlightText
                        sourceComponent: colorSquare
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: true }
                        property var color: palette.buttonHighlightText
                        sourceComponent: colorSquare
                    }
    
    Don Gagne's avatar
    Don Gagne committed
    
    
    Don Gagne's avatar
    Don Gagne committed
                    // primaryButton
                    Loader {
                        sourceComponent: rowHeader
                        property var text: "primaryButton"
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: false }
                        property var color: palette.primaryButton
                        sourceComponent: colorSquare
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: true }
                        property var color: palette.primaryButton
                        sourceComponent: colorSquare
                    }
    
    Don Gagne's avatar
    Don Gagne committed
    
    
    Don Gagne's avatar
    Don Gagne committed
                    // primaryButtonText
                    Loader {
                        sourceComponent: rowHeader
                        property var text: "primaryButtonText"
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: false }
                        property var color: palette.primaryButtonText
                        sourceComponent: colorSquare
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: true }
                        property var color: palette.primaryButtonText
                        sourceComponent: colorSquare
                    }
    
    Don Gagne's avatar
    Don Gagne committed
    
    
    Don Gagne's avatar
    Don Gagne committed
                    // textField
                    Loader {
                        sourceComponent: rowHeader
                        property var text: "textField"
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: false }
                        property var color: palette.textField
                        sourceComponent: colorSquare
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: true }
                        property var color: palette.textField
                        sourceComponent: colorSquare
                    }
    
    Don Gagne's avatar
    Don Gagne committed
                    // textFieldText
                    Loader {
                        sourceComponent: rowHeader
                        property var text: "textFieldText"
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: false }
                        property var color: palette.textFieldText
                        sourceComponent: colorSquare
                    }
                    Loader {
                        property var palette: QGCPalette { colorGroupEnabled: true }
                        property var color: palette.textFieldText
                        sourceComponent: colorSquare
                    }
    
    Don Gagne's avatar
    Don Gagne committed
                }
    
    Don Gagne's avatar
    Don Gagne committed
                Grid {
                    columns: 3
                    spacing: 10
    
    Don Gagne's avatar
    Don Gagne committed
    
    
    Don Gagne's avatar
    Don Gagne committed
                    Component {
                        id: ctlRowHeader
    
    Don Gagne's avatar
    Don Gagne committed
    
    
    Don Gagne's avatar
    Don Gagne committed
                        Text {
                            width: 120
                            height: 20
                            horizontalAlignment: Text.AlignRight
                            verticalAlignment: Text.AlignVCenter
                            color: palette.text
                            text: parent.text
                        }
                    }
    
    Don Gagne's avatar
    Don Gagne committed
                    // Header row
                    Loader {
                        sourceComponent: ctlRowHeader
                        property var text: ""
                    }
    
    Don Gagne's avatar
    Don Gagne committed
                    Text {
    
    Don Gagne's avatar
    Don Gagne committed
                        width: 100
    
    Don Gagne's avatar
    Don Gagne committed
                        height: 20
    
                        color: palette.text
    
    Don Gagne's avatar
    Don Gagne committed
                        horizontalAlignment: Text.AlignHCenter
                        text: "Enabled"
                    }
                    Text {
                        width: 100
                        height: 20
                        color: palette.text
                        horizontalAlignment: Text.AlignHCenter
                        text: "Disabled"
    
    Don Gagne's avatar
    Don Gagne committed
                    // QGCLabel
                    Loader {
                        sourceComponent: ctlRowHeader
                        property var text: "QGCLabel"
                    }
                    QGCLabel {
                        width: 100
                        height: 20
                        text: "Label"
                    }
                    QGCLabel {
                        width: 100
                        height: 20
                        text: "Label"
                        enabled: false
                    }
    
    Don Gagne's avatar
    Don Gagne committed
    
    
    Don Gagne's avatar
    Don Gagne committed
                    // QGCButton
                    Loader {
                        sourceComponent: ctlRowHeader
                        property var text: "QGCButton"
                    }
                    QGCButton {
                        width: 100
                        height: 20
                        text: "Button"
                    }
                    QGCButton {
                        width: 100
                        height: 20
                        text: "Button"
                        enabled: false
                    }
    
    Don Gagne's avatar
    Don Gagne committed
    
    
    Don Gagne's avatar
    Don Gagne committed
                    // QGCButton - primary
                    Loader {
                        sourceComponent: ctlRowHeader
                        property var text: "QGCButton(primary)"
                    }
                    QGCButton {
                        width: 100
                        height: 20
                        primary: true
                        text: "Button"
                    }
                    QGCButton {
                        width: 100
                        height: 20
                        text: "Button"
                        primary: true
                        enabled: false
                    }
    
                    // QGCButton - menu
                    Loader {
                        sourceComponent: ctlRowHeader
                        property var text: "QGCButton(menu)"
                    }
                    Menu {
                        id: buttonMenu
                        MenuItem {
                            text: "Item 1"
                        }
                        MenuItem {
                            text: "Item 2"
                        }
                        MenuItem {
                            text: "Item 3"
                        }
                    }
                    QGCButton {
                        width: 100
                        height: 20
                        text: "Button"
                        menu: buttonMenu
                    }
                    QGCButton {
                        width: 100
                        height: 20
                        text: "Button"
                        enabled: false
                        menu: buttonMenu
                    }
    
    
    Don Gagne's avatar
    Don Gagne committed
                    // QGCRadioButton
                    Loader {
                        sourceComponent: ctlRowHeader
                        property var text: "QGCRadioButton"
                    }
                    QGCRadioButton {
                        width: 100
                        height: 20
                        text: "Radio"
                    }
                    QGCRadioButton {
                        width: 100
                        height: 20
                        text: "Radio"
                        enabled: false
                    }
    
    Don Gagne's avatar
    Don Gagne committed
    
    
    Don Gagne's avatar
    Don Gagne committed
                    // QGCCheckBox
                    Loader {
                        sourceComponent: ctlRowHeader
                        property var text: "QGCCheckBox"
                    }
                    QGCCheckBox {
                        width: 100
                        height: 20
                        text: "Check Box"
                    }
                    QGCCheckBox {
                        width: 100
                        height: 20
                        text: "Check Box"
                        enabled: false
                    }
    
    Don Gagne's avatar
    Don Gagne committed
    
    
    Don Gagne's avatar
    Don Gagne committed
                    // QGCTextField
                    Loader {
                        sourceComponent: ctlRowHeader
                        property var text: "QGCTextField"
                    }
                    QGCTextField {
                        width: 100
                        height: 20
                        text: "QGCTextField"
                    }
                    QGCTextField {
                        width: 100
                        height: 20
                        text: "QGCTextField"
                        enabled: false
                    }
    
                    // QGCComboBox
                    Loader {
                        sourceComponent: ctlRowHeader
                        property var text: "QGCComboBox"
                    }
                    QGCComboBox {
                        width: 100
                        height: 20
                        model: [ "Item 1", "Item 2", "Item 3" ]
                    }
                    QGCComboBox {
                        width: 100
                        height: 20
                        model: [ "Item 1", "Item 2", "Item 3" ]
                        enabled: false
                    }
    
    
    Don Gagne's avatar
    Don Gagne committed
                    // SubMenuButton
                    Loader {
                        sourceComponent: ctlRowHeader
                        property var text: "SubMenuButton"
                    }
                    SubMenuButton {
                        width: 100
                        height: 100
                        text: "SUB MENU"
                    }
                    SubMenuButton {
                        width: 100
                        height: 100
                        text: "SUB MENU"
                        enabled: false
                    }