QmlTest.qml 17.3 KB
Newer Older
Don Gagne's avatar
Don Gagne committed
1 2 3 4 5 6
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
7
import QGroundControl.FactControls 1.0
Don Gagne's avatar
Don Gagne committed
8 9 10

Rectangle {

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

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

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

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

Don Gagne's avatar
Don Gagne committed
25 26 27 28
            QGCRadioButton {
                text: "Dark"
                exclusiveGroup: themeGroup
                onClicked: { palette.globalTheme = QGCPalette.Dark }
Don Gagne's avatar
Don Gagne committed
29
            }
Don Gagne's avatar
Don Gagne committed
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 62
        }

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


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

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

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

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

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

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

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

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

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

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

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

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

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

Don Gagne's avatar
Don Gagne committed
277
            }
278

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

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

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


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

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

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

Don Gagne's avatar
Don Gagne committed
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368
                // 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
                }
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 400
                // 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
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
                // 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
417

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

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

Don Gagne's avatar
Don Gagne committed
452 453 454 455 456 457 458 459 460 461 462 463 464 465
                // FactLabel
                Loader {
                    sourceComponent: ctlRowHeader
                    property var text: "FactLabel"
                }
                FactLabel {
                    width: 100
                    height: 20
                }
                FactLabel {
                    width: 100
                    height: 20
                    enabled: false
                }
466

Don Gagne's avatar
Don Gagne committed
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482
                // FactCheckBox
                Loader {
                    sourceComponent: ctlRowHeader
                    property var text: "FactCheckBox"
                }
                FactCheckBox {
                    width: 100
                    height: 20
                    text: "Fact CheckBox"
                }
                FactCheckBox {
                    width: 100
                    height: 20
                    text: "Fact CheckBox"
                    enabled: false
                }
483

Don Gagne's avatar
Don Gagne committed
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
                // FactTextField
                Loader {
                    sourceComponent: ctlRowHeader
                    property var text: "FactTextField"
                }
                FactTextField {
                    width: 100
                    height: 20
                    text: "FactTextField"
                }
                FactTextField {
                    width: 100
                    height: 20
                    text: "FactTextField"
                    enabled: false
                }
500

501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517
                // 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
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533
                // 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
                }
534
            }
Don Gagne's avatar
Don Gagne committed
535 536 537
        }
    }
}