QGCComboBox.qml 2.14 KB
Newer Older
1 2
import QtQuick 2.3
import QtQuick.Controls 1.2
3
import QtQuick.Controls.Styles 1.4
4 5

import QGroundControl.Palette 1.0
6
import QGroundControl.ScreenTools 1.0
7 8

ComboBox {
9 10
    property var    _qgcPal:        QGCPalette { colorGroupEnabled: enabled }
    property bool   _showHighlight: pressed | hovered
11
    property bool   _showBorder:    _qgcPal.globalTheme === QGCPalette.Light
12 13

    style: ComboBoxStyle {
14
        font.pointSize: ScreenTools.defaultFontPointSize
15 16 17
        textColor: _showHighlight ?
                    control._qgcPal.buttonHighlightText :
                    control._qgcPal.buttonText
18 19

        background: Item {
20 21
            implicitWidth:  ScreenTools.implicitComboBoxWidth
            implicitHeight: ScreenTools.implicitComboBoxHeight
22 23

            Rectangle {
24 25 26 27
                anchors.fill:   parent
                color:          _showHighlight ? control._qgcPal.buttonHighlight : control._qgcPal.button
                border.width:   _showBorder ? 1: 0
                border.color:  control._qgcPal.buttonText
28 29
            }

30 31 32 33
            QGCColoredImage {
                id:                     image
                width:                  ScreenTools.defaultFontPixelHeight / 2
                height:                 width
34
                anchors.verticalCenter: parent.verticalCenter
35 36 37 38
                anchors.right:          parent.right
                anchors.rightMargin:    dropDownButtonWidth / 2
                source:                 "/qmlimages/arrow-down.png"
                color:                  qgcPal.text
39 40 41
            }
        }
    }
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

    // Capture Wheel events to disable scrolling options in ComboBox.
    // As a side effect, this also prevents scrolling the page when
    // mouse is over a ComboBox, but this would also the case when
    // scrolling items in the ComboBox is enabled.
    MouseArea {
        anchors.fill: parent
        onWheel: {
            // do nothing
            wheel.accepted = true;
        }
        onPressed: {
            // propogate to ComboBox
            mouse.accepted = false;
        }
        onReleased: {
            // propogate to ComboBox
            mouse.accepted = false;
        }
    }
62
}