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
72 enabled: control.editable
73 autoScroll: control.editable
75 readOnly: control.down || !control.editable
76 inputMethodHints: control.inputMethodHints
77 validator: control.validator
79 selectionColor:
Kirigami.Theme.highlightColor
80 selectedTextColor:
Kirigami.Theme.highlightedTextColor
82 selectByMouse: !
Kirigami.Settings.tabletMode
83 cursorDelegate:
Kirigami.Settings.tabletMode ? mobileCursor : null
86 horizontalAlignment: Text.AlignLeft
87 verticalAlignment: Text.AlignVCenter
88 opacity: control.enabled ? 1 : 0.3
91 MobileTextSelection.MobileTextActionsToolBar.controlRoot = textField;
95 onTextChanged: MobileTextSelection.MobileTextActionsToolBar.shouldBeVisible =
false;
96 onPressed:
event => MobileTextSelection.MobileTextActionsToolBar.shouldBeVisible =
true;
98 onPressAndHold:
event => {
103 cursorPosition = positionAt(event.x, event.y);
110 MobileTextSelection.MobileCursor {
115 MobileTextSelection.MobileCursor {
117 selectionStartHandle:
true
118 property var rect: textField.positionToRectangle(textField.selectionStart)
129 imagePath: control.editable ?
"widgets/lineedit" :
"widgets/button"
130 prefix: control.editable
132 : (control.down ?
"pressed" :
"normal")
134 Private.ButtonShadow {
136 showShadow: !control.editable && !control.down
139 Private.TextFieldFocus {
140 visible: control.editable
142 state: control.activeFocus ?
"focus" : (control.hovered ?
"hover" :
"hidden")
146 Private.ButtonFocus {
148 showFocus: control.activeFocus && !control.down
151 Private.ButtonHover {
153 showHover: control.hovered && !control.down
159 leftMargin: control.leftPadding
160 rightMargin: control.rightPadding
162 acceptedButtons:
Qt.NoButton
164 if (wheel.pixelDelta.y < 0 || wheel.angleDelta.y < 0) {
165 control.currentIndex = Math.min(control.currentIndex + 1, delegateModel.count -1);
167 control.currentIndex = Math.max(control.currentIndex - 1, 0);
169 control.activated(control.currentIndex);
175 x: control.mirrored ? control.width - width : 0
177 width: Math.max(control.width, 150)
178 implicitHeight: contentItem.implicitHeight
182 contentItem: ListView {
185 implicitHeight: contentHeight
186 model: control.popup.visible ? control.delegateModel : null
187 currentIndex: control.highlightedIndex
188 highlightRangeMode: ListView.ApplyRange
189 highlightMoveDuration: 0
194 LayoutMirroring.enabled:
Qt.application.layoutDirection ===
Qt.RightToLeft
195 LayoutMirroring.childrenInherit:
true
196 T.ScrollBar.vertical:
Controls.ScrollBar { }
198 background:
Kirigami.ShadowedRectangle {
206 color:
Kirigami.Theme.backgroundColor
215 color:
Qt.rgba(0, 0, 0, 0.3)