summaryrefslogtreecommitdiff
path: root/src/widgets/ChoiceList.qml
blob: 5015fbefbdd92866f81b46faf3a70e32840ff29b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import QtQuick 1.0
import "../../../components" as Components
import "../plugin"

Components.ChoiceList {
    id:choicelist

    property int buttonHeight: buttonitem.sizeFromContents(100, 18).height
    QStyleItem { id:buttonitem; elementType:"combobox" }
    height: buttonHeight
    topMargin:4
    bottomMargin:4

    QStyleItem {
        id:styleitem
        elementType: "combobox"
        sunken: pressed
        raised: !pressed
        hover: containsMouse
        enabled:choicelist.enabled
    }

    background: QStyleBackground {
        anchors.fill:parent
        style: styleitem
    }

    listItem: Item {
        id:item

        height:22
        anchors.left:parent.left
        width:choicelist.width
        QStyleBackground {
            anchors.fill:parent
            style: QStyleItem {
                elementType: "menuitem"
                text: choicelist.model.get(index).text
                selected: highlighted
            }
        }
    }

    popupFrame: QStyleBackground {
        property int fw: styleitem.pixelMetric("menupanelwidth");
        anchors.leftMargin: styleitem.pixelMetric("menuhmargin") + fw
        anchors.rightMargin: styleitem.pixelMetric("menuhmargin") + fw
        anchors.topMargin: styleitem.pixelMetric("menuvmargin") + fw
        anchors.bottomMargin: styleitem.pixelMetric("menuvmargin") + fw
        style:QStyleItem{elementType:"menu"}
    }
}