widgets/krunner: Fix keyboard focus

This commit is contained in:
Devin Lin 2022-01-03 11:49:18 -05:00
parent 6607c8e6a7
commit db8ab82778

View file

@ -65,13 +65,19 @@ Item {
opacity: root.openFactor opacity: root.openFactor
} }
onOpacityChanged: {
if (opacity === 0) {
close();
}
}
Flickable { Flickable {
id: flickable id: flickable
anchors.fill: parent anchors.fill: parent
anchors.topMargin: MobileShell.TaskPanelControls.isPortrait ? MobileShell.TaskPanelControls.panelHeight : 0 anchors.topMargin: MobileShell.TopPanelControls.panelHeight
anchors.bottomMargin: MobileShell.TaskPanelControls.isPortrait ? MobileShell.TaskPanelControls.panelHeight : 0
anchors.rightMargin: MobileShell.TaskPanelControls.isPortrait ? 0 : MobileShell.TaskPanelControls.panelWidth anchors.rightMargin: MobileShell.TaskPanelControls.isPortrait ? 0 : MobileShell.TaskPanelControls.panelWidth
anchors.bottomMargin: MobileShell.TaskPanelControls.panelHeight
contentHeight: flickable.height + root.closedContentY + 999999 contentHeight: flickable.height + root.closedContentY + 999999
contentY: root.closedContentY contentY: root.closedContentY
@ -81,6 +87,10 @@ Item {
onContentYChanged: { onContentYChanged: {
opening = contentY < oldContentY; opening = contentY < oldContentY;
oldContentY = contentY; oldContentY = contentY;
if (contentY !== root.openedContentY) {
queryField.focus = false;
}
} }
onMovementEnded: root.endGesture() onMovementEnded: root.endGesture()
@ -96,7 +106,7 @@ Item {
duration: PlasmaCore.Units.longDuration * 2 duration: PlasmaCore.Units.longDuration * 2
easing.type: Easing.OutQuad easing.type: Easing.OutQuad
onFinished: { onFinished: {
if (root.openedContentY) { if (anim.to === root.openedContentY) {
queryField.forceActiveFocus(); queryField.forceActiveFocus();
} }
} }
@ -110,6 +120,9 @@ Item {
Controls.Control { Controls.Control {
opacity: root.openFactor opacity: root.openFactor
Layout.fillWidth: true Layout.fillWidth: true
Layout.maximumWidth: PlasmaCore.Units.gridUnit * 30
Layout.alignment: Qt.AlignHCenter
Layout.topMargin: PlasmaCore.Units.gridUnit
Layout.leftMargin: PlasmaCore.Units.gridUnit Layout.leftMargin: PlasmaCore.Units.gridUnit
Layout.rightMargin: PlasmaCore.Units.gridUnit Layout.rightMargin: PlasmaCore.Units.gridUnit
@ -168,6 +181,7 @@ Item {
id: listView id: listView
queryString: queryField.text queryString: queryField.text
highlight: null highlight: null
clip: true
PlasmaCore.ColorScope.colorGroup: PlasmaCore.Theme.NormalColorGroup PlasmaCore.ColorScope.colorGroup: PlasmaCore.Theme.NormalColorGroup
onActivated: queryField.text = ""; onActivated: queryField.text = "";