blob: 9665eb62450de008089ecd280b30de1a0e659f5d (
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick 2.1
import QtQuick.Window 2.1
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
import QtQuick.Controls.Private 1.0
import "." as Desktop
Style {
readonly property ComboBox control: __control
property int drowDownButtonWidth: 24
property Component panel: Item {
property bool popup: !!styleItem.styleHint("comboboxpopup")
implicitWidth: 125
implicitHeight: styleItem.implicitHeight
baselineOffset: styleItem.baselineOffset
anchors.fill: parent
StyleItem {
id: styleItem
height: parent.height
width: parent.width
elementType: "combobox"
sunken: control.pressed
raised: !sunken
hover: control.hovered
enabled: control.enabled
// The style makes sure the text rendering won't overlap the decoration.
// In that case, 35 pixels margin in this case looks good enough. Worst
// case, the ellipsis will be truncated (2nd worst, not visible at all).
text: elidedText(control.currentText, Text.ElideRight, parent.width - 35)
hasFocus: control.activeFocus
// contentHeight as in QComboBox
contentHeight: Math.max(Math.ceil(textHeight("")), 14) + 2
hints: control.styleHints
properties: {
"popup": control.__popup,
"editable" : control.editable
}
}
}
property Component __popupStyle: MenuStyle {
__menuItemType: "comboboxitem"
}
property Component __dropDownStyle: Style {
property Component frame: StyleItem {
elementType: "frame"
width: (parent ? parent.contentWidth : 0)
height: (parent ? parent.contentHeight : 0) + 2 * pixelMetric("defaultframewidth")
property real maxHeight: 600
property int margin: pixelMetric("menuvmargin") + pixelMetric("menupanelwidth")
}
property Component menuItem: StyleItem {
elementType: "itemrow"
selected: parent ? parent.selected : false
x: pixelMetric("defaultframewidth")
y: pixelMetric("defaultframewidth")
implicitWidth: textItem.contentWidth
implicitHeight: textItem.contentHeight
StyleItem {
id: textItem
elementType: "item"
contentWidth: textWidth(text)
contentHeight: textHeight(text)
text: parent && parent.parent ? parent.parent.text : ""
selected: parent ? parent.selected : false
}
}
property Component scrollerStyle: Desktop.ScrollViewStyle {
property bool useScrollers: false
}
}
}
|