8import QtQuick.Templates as T
9import QtQuick.Controls as Controls
10import org.kde.ksvg as KSvg
12import org.kde.plasma.core as PlasmaCore
13import org.kde.kirigami as Kirigami
14import "private" as Private
15import "mobiletextselection" as MobileTextSelection
20 property real __indicatorMargin: control.indicator && control.indicator.visible && control.indicator.width > 0 ? control.spacing + indicator.width : 0
22 implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
23 implicitContentWidth + leftPadding + rightPadding)
24 implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
25 implicitContentHeight + topPadding + bottomPadding,
26 implicitIndicatorHeight + topPadding + bottomPadding)
28 baselineOffset: contentItem.y + contentItem.baselineOffset
32 topPadding: surfaceNormal.margins.top
33 leftPadding: surfaceNormal.margins.left + (!control.mirrored ? 0 : __indicatorMargin)
34 rightPadding: surfaceNormal.margins.right + (control.mirrored ? 0 : __indicatorMargin)
35 bottomPadding: surfaceNormal.margins.bottom
39 width: control.popup.width
40 text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] : model[control.textRole]) : modelData
41 highlighted: control.highlightedIndex == index
42 property bool separatorVisible:
false
46 implicitWidth:
Kirigami.Units.iconSizes.small
47 implicitHeight: implicitWidth
50 rightMargin: surfaceNormal.margins.right
51 verticalCenter: parent.verticalCenter
54 imagePath:
"widgets/arrows"
57 elementId:
"down-arrow"
60 contentItem: T.TextField {
62 implicitWidth: Math.ceil(contentWidth) + leftPadding + rightPadding
63 implicitHeight: Math.ceil(contentHeight) + topPadding + bottomPadding
65 text: control.editable ? control.editText : control.displayText
67 enabled: control.editable
68 autoScroll: control.editable
70 readOnly: control.down || !control.editable
71 inputMethodHints: control.inputMethodHints
72 validator: control.validator
74 selectionColor:
Kirigami.Theme.highlightColor
75 selectedTextColor:
Kirigami.Theme.highlightedTextColor
77 selectByMouse: !
Kirigami.Settings.tabletMode
78 cursorDelegate:
Kirigami.Settings.tabletMode ? mobileCursor : null
81 horizontalAlignment: Text.AlignLeft
82 verticalAlignment: Text.AlignVCenter
83 opacity: control.enabled ? 1 : 0.3
86 MobileTextSelection.MobileTextActionsToolBar.controlRoot = textField;
90 onTextChanged: MobileTextSelection.MobileTextActionsToolBar.shouldBeVisible =
false;
91 onPressed:
event => MobileTextSelection.MobileTextActionsToolBar.shouldBeVisible =
true;
93 onPressAndHold:
event => {
98 cursorPosition = positionAt(event.x, event.y);
105 MobileTextSelection.MobileCursor {
110 MobileTextSelection.MobileCursor {
112 selectionStartHandle:
true
113 property var rect: textField.positionToRectangle(textField.selectionStart)
124 imagePath: control.editable ?
"widgets/lineedit" :
"widgets/button"
125 prefix: control.editable
127 : (control.down ?
"pressed" :
"normal")
129 Private.ButtonShadow {
131 showShadow: !control.editable && !control.down
134 Private.TextFieldFocus {
135 visible: control.editable
137 state: control.activeFocus ?
"focus" : (control.hovered ?
"hover" :
"hidden")
141 Private.ButtonFocus {
143 showFocus: control.activeFocus && !control.down
146 Private.ButtonHover {
148 showHover: control.hovered && !control.down
154 leftMargin: control.leftPadding
155 rightMargin: control.rightPadding
157 acceptedButtons:
Qt.NoButton
159 if (wheel.pixelDelta.y < 0 || wheel.angleDelta.y < 0) {
160 control.currentIndex = Math.min(control.currentIndex + 1, delegateModel.count -1);
162 control.currentIndex = Math.max(control.currentIndex - 1, 0);
164 control.activated(control.currentIndex);
170 x: control.mirrored ? control.width - width : 0
172 width: Math.max(control.width, 150)
173 implicitHeight: contentItem.implicitHeight
177 contentItem: ListView {
180 implicitHeight: contentHeight
181 model: control.popup.visible ? control.delegateModel : null
182 currentIndex: control.highlightedIndex
183 highlightRangeMode: ListView.ApplyRange
184 highlightMoveDuration: 0
189 LayoutMirroring.enabled:
Qt.application.layoutDirection ===
Qt.RightToLeft
190 LayoutMirroring.childrenInherit:
true
191 T.ScrollBar.vertical:
Controls.ScrollBar { }
193 background:
Kirigami.ShadowedRectangle {
201 color:
Kirigami.Theme.backgroundColor
210 color:
Qt.rgba(0, 0, 0, 0.3)