7pragma ComponentBehavior: Bound
10import QtQuick.Templates as T
11import QtQuick.Controls as Controls
12import org.kde.ksvg as KSvg
14import org.kde.plasma.core as PlasmaCore
15import org.kde.kirigami as Kirigami
16import "private" as Private
17import "mobiletextselection" as MobileTextSelection
22 property real __indicatorMargin: control.indicator && control.indicator.visible && control.indicator.width > 0 ? control.spacing + indicator.width : 0
24 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
25 implicitContentWidth + leftPadding + rightPadding)
26 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
27 implicitContentHeight + topPadding + bottomPadding,
28 implicitIndicatorHeight + topPadding + bottomPadding)
30 baselineOffset: contentItem.y + contentItem.baselineOffset
34 topPadding: surfaceNormal.margins.top
35 leftPadding: surfaceNormal.margins.left + (!control.mirrored ? 0 : __indicatorMargin)
36 rightPadding: surfaceNormal.margins.right + (control.mirrored ? 0 : __indicatorMargin)
37 bottomPadding: surfaceNormal.margins.bottom
41 required
property var model
42 required
property int index
44 width: ListView.view.width
45 text: model[control.textRole]
46 highlighted: control.highlightedIndex == index
47 property bool separatorVisible:
false
51 implicitWidth:
Kirigami.Units.iconSizes.small
52 implicitHeight: implicitWidth
55 rightMargin: surfaceNormal.margins.right
56 verticalCenter: parent.verticalCenter
59 imagePath:
"widgets/arrows"
62 elementId:
"down-arrow"
65 contentItem: T.TextField {
67 implicitWidth: Math.ceil(contentWidth) + leftPadding + rightPadding
68 implicitHeight: Math.ceil(contentHeight) + topPadding + bottomPadding
70 text: control.editable ? control.editText : control.displayText
73 Kirigami.Theme.textColor: control.Kirigami.Theme.textColor
74 enabled: control.editable
75 autoScroll: control.editable
77 readOnly: control.down || !control.editable
78 inputMethodHints: control.inputMethodHints
79 validator: control.validator
81 selectionColor:
Kirigami.Theme.highlightColor
82 selectedTextColor:
Kirigami.Theme.highlightedTextColor
84 selectByMouse: !
Kirigami.Settings.tabletMode
85 cursorDelegate:
Kirigami.Settings.tabletMode ? mobileCursor : null
88 horizontalAlignment: Text.AlignLeft
89 verticalAlignment: Text.AlignVCenter
90 opacity: control.enabled ? 1 : 0.3
93 MobileTextSelection.MobileTextActionsToolBar.controlRoot = textField;
97 onTextChanged: MobileTextSelection.MobileTextActionsToolBar.shouldBeVisible =
false;
98 onPressed:
event => MobileTextSelection.MobileTextActionsToolBar.shouldBeVisible =
true;
100 onPressAndHold:
event => {
101 if (!
Kirigami.Settings.tabletMode) {
105 cursorPosition = positionAt(event.x, event.y);
112 MobileTextSelection.MobileCursor {
117 MobileTextSelection.MobileCursor {
119 selectionStartHandle:
true
120 property var rect: textField.positionToRectangle(textField.selectionStart)
131 imagePath: control.editable ?
"widgets/lineedit" :
"widgets/button"
132 prefix: control.editable
134 : (control.down ?
"pressed" :
"normal")
136 Private.ButtonShadow {
138 showShadow: !control.editable && !control.down
141 Private.TextFieldFocus {
142 visible: control.editable
144 state: control.activeFocus ?
"focus" : (control.enabled && control.hovered ?
"hover" :
"hidden")
148 Private.ButtonFocus {
150 showFocus: control.activeFocus && !control.down
153 Private.ButtonHover {
155 showHover: control.enabled && control.hovered && !control.down
161 leftMargin: control.leftPadding
162 rightMargin: control.rightPadding
164 acceptedButtons:
Qt.NoButton
166 if (wheel.pixelDelta.y < 0 || wheel.angleDelta.y < 0) {
167 control.currentIndex = Math.min(control.currentIndex + 1, delegateModel.count -1);
169 control.currentIndex = Math.max(control.currentIndex - 1, 0);
171 control.activated(control.currentIndex);
177 x: control.mirrored ? control.width - width : 0
179 width: Math.max(control.width, 150)
180 implicitHeight: contentItem.implicitHeight
184 contentItem: ListView {
187 implicitHeight: contentHeight
188 model: control.popup.visible ? control.delegateModel : null
189 currentIndex: control.highlightedIndex
190 highlightRangeMode: ListView.ApplyRange
191 highlightMoveDuration: 0
196 LayoutMirroring.enabled:
Qt.application.layoutDirection ===
Qt.RightToLeft
197 LayoutMirroring.childrenInherit:
true
198 T.ScrollBar.vertical:
Controls.ScrollBar { }
200 background:
Kirigami.ShadowedRectangle {
208 color:
Kirigami.Theme.backgroundColor
217 color:
Qt.rgba(0, 0, 0, 0.3)