QmlTest.qml 15.8 KB
Newer Older
Don Gagne's avatar
Don Gagne committed
1 2 3 4 5 6 7 8 9
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 {

10
    property var palette: QGCPalette { colorGroupEnabled: true }
Don Gagne's avatar
Don Gagne committed
11 12
    color: palette.window

Don Gagne's avatar
Don Gagne committed
13
    Column {
Don Gagne's avatar
Don Gagne committed
14

Don Gagne's avatar
Don Gagne committed
15 16
        Row {
            ExclusiveGroup { id: themeGroup }
Don Gagne's avatar
Don Gagne committed
17

Don Gagne's avatar
Don Gagne committed
18 19 20 21 22
            QGCRadioButton {
                text: "Light"
                exclusiveGroup: themeGroup
                onClicked: { palette.globalTheme = QGCPalette.Light }
            }
Don Gagne's avatar
Don Gagne committed
23

Don Gagne's avatar
Don Gagne committed
24 25 26 27
            QGCRadioButton {
                text: "Dark"
                exclusiveGroup: themeGroup
                onClicked: { palette.globalTheme = QGCPalette.Dark }
Don Gagne's avatar
Don Gagne committed
28
            }
Don Gagne's avatar
Don Gagne committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
        }

        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
62 63


Don Gagne's avatar
Don Gagne committed
64 65 66 67 68
                // Header row
                Loader {
                    sourceComponent: rowHeader
                    property var text: ""
                }
Don Gagne's avatar
Don Gagne committed
69
                Text {
Don Gagne's avatar
Don Gagne committed
70
                    width: 80
Don Gagne's avatar
Don Gagne committed
71
                    height: 20
72
                    color: palette.text
Don Gagne's avatar
Don Gagne committed
73 74 75 76 77 78 79 80 81
                    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
82 83
                }

Don Gagne's avatar
Don Gagne committed
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
                // 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
99

Don Gagne's avatar
Don Gagne committed
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
                // 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
115

Don Gagne's avatar
Don Gagne committed
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
                // 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
131

Don Gagne's avatar
Don Gagne committed
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
                // 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
147

Don Gagne's avatar
Don Gagne committed
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
                // 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
163

Don Gagne's avatar
Don Gagne committed
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
                // 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
                }
179

Don Gagne's avatar
Don Gagne committed
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
                // 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
195

Don Gagne's avatar
Don Gagne committed
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
                // 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
211

Don Gagne's avatar
Don Gagne committed
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
                // 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
227

Don Gagne's avatar
Don Gagne committed
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
                // 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
243

Don Gagne's avatar
Don Gagne committed
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
                // 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
                }
259

Don Gagne's avatar
Don Gagne committed
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
                // 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
                }
275

Don Gagne's avatar
Don Gagne committed
276
            }
277

Don Gagne's avatar
Don Gagne committed
278 279 280
            Grid {
                columns: 3
                spacing: 10
Don Gagne's avatar
Don Gagne committed
281

Don Gagne's avatar
Don Gagne committed
282 283
                Component {
                    id: ctlRowHeader
Don Gagne's avatar
Don Gagne committed
284

Don Gagne's avatar
Don Gagne committed
285 286 287 288 289 290 291 292 293
                    Text {
                        width: 120
                        height: 20
                        horizontalAlignment: Text.AlignRight
                        verticalAlignment: Text.AlignVCenter
                        color: palette.text
                        text: parent.text
                    }
                }
Don Gagne's avatar
Don Gagne committed
294 295


Don Gagne's avatar
Don Gagne committed
296 297 298 299 300
                // Header row
                Loader {
                    sourceComponent: ctlRowHeader
                    property var text: ""
                }
Don Gagne's avatar
Don Gagne committed
301
                Text {
Don Gagne's avatar
Don Gagne committed
302
                    width: 100
Don Gagne's avatar
Don Gagne committed
303
                    height: 20
304
                    color: palette.text
Don Gagne's avatar
Don Gagne committed
305 306 307 308 309 310 311 312 313
                    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
314 315
                }

Don Gagne's avatar
Don Gagne committed
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
                // 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
332

Don Gagne's avatar
Don Gagne committed
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
                // 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
349

Don Gagne's avatar
Don Gagne committed
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
                // 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
                }
368

369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
                // 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
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415
                // 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
416

Don Gagne's avatar
Don Gagne committed
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432
                // 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
433

Don Gagne's avatar
Don Gagne committed
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
                // QGCTextField
                Loader {
                    sourceComponent: ctlRowHeader
                    property var text: "QGCTextField"
                }
                QGCTextField {
                    width: 100
                    height: 20
                    text: "QGCTextField"
                }
                QGCTextField {
                    width: 100
                    height: 20
                    text: "QGCTextField"
                    enabled: false
                }
450

451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467
                // 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
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483
                // 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
                }
484
            }
Don Gagne's avatar
Don Gagne committed
485 486 487
        }
    }
}