2015-06-19 00:50:12 +00:00
|
|
|
/*
|
2021-03-01 20:03:25 +00:00
|
|
|
* SPDX-FileCopyrightText: 2015 Vishesh Handa <vhanda@kde.org>
|
2015-06-19 00:50:12 +00:00
|
|
|
*
|
2021-03-01 20:03:25 +00:00
|
|
|
* SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
2015-06-19 00:50:12 +00:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import QtQuick 2.0
|
|
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
|
import QtQuick.Window 2.1
|
|
|
|
|
|
|
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
|
|
|
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
|
|
|
|
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
|
|
|
|
|
|
|
|
|
import org.kde.milou 0.1 as Milou
|
|
|
|
|
|
2015-06-19 17:33:56 +00:00
|
|
|
Rectangle {
|
|
|
|
|
id: krunner
|
|
|
|
|
height: childrenRect.height
|
|
|
|
|
color: listView.visible ? Qt.rgba(0, 0, 0, 0.8) : "transparent"
|
|
|
|
|
property alias showingResults: listView.visible
|
2015-06-22 23:41:23 +00:00
|
|
|
property int inputHeight: queryField.height + background.fixedMargins.top/2 + background.fixedMargins.bottom
|
2019-10-04 10:59:58 +00:00
|
|
|
property int topPadding: 0
|
2015-06-19 00:50:12 +00:00
|
|
|
|
2015-06-19 17:33:56 +00:00
|
|
|
MouseArea {
|
|
|
|
|
enabled: listView.visible
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
preventStealing: true
|
|
|
|
|
onClicked: queryField.text = "";
|
|
|
|
|
}
|
|
|
|
|
PlasmaCore.FrameSvgItem {
|
|
|
|
|
id: background
|
2015-06-19 00:50:12 +00:00
|
|
|
anchors {
|
|
|
|
|
left: parent.left
|
|
|
|
|
right: parent.right
|
|
|
|
|
top: parent.top
|
|
|
|
|
}
|
2015-06-19 17:33:56 +00:00
|
|
|
clip: true
|
|
|
|
|
imagePath: "widgets/background"
|
|
|
|
|
enabledBorders: PlasmaCore.FrameSvg.BottomBorder
|
2019-09-04 16:39:31 +00:00
|
|
|
height: Math.min(krunner.height, childrenRect.height + fixedMargins.top/2 + fixedMargins.bottom)
|
2015-06-19 17:33:56 +00:00
|
|
|
Behavior on height {
|
|
|
|
|
NumberAnimation {
|
|
|
|
|
duration: units.longDuration
|
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
transform: Translate {
|
2015-06-20 23:08:46 +00:00
|
|
|
y: root.locked || editOverlay.visible ? -background.height : 0
|
2015-06-19 17:33:56 +00:00
|
|
|
Behavior on y {
|
|
|
|
|
NumberAnimation {
|
|
|
|
|
duration: units.longDuration
|
|
|
|
|
easing.type: Easing.InOutQuad
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-06-19 00:50:12 +00:00
|
|
|
}
|
|
|
|
|
|
2015-06-19 17:33:56 +00:00
|
|
|
ColumnLayout {
|
2019-10-04 10:59:58 +00:00
|
|
|
height: Qt.inputMethod.keyboardRectangle.height > 0 ? (Math.min(implicitHeight, background.height, Qt.inputMethod.keyboardRectangle.y - plasmoid.availableScreenRect.y)) : implicitHeight + anchors.topMargin
|
2015-06-19 17:33:56 +00:00
|
|
|
anchors {
|
|
|
|
|
left: parent.left
|
|
|
|
|
right: parent.right
|
|
|
|
|
top: parent.top
|
2019-10-04 10:59:58 +00:00
|
|
|
topMargin: background.fixedMargins.top / 2 + krunner.topPadding
|
|
|
|
|
leftMargin: background.fixedMargins.left
|
|
|
|
|
rightMargin: background.fixedMargins.right
|
2015-06-19 17:33:56 +00:00
|
|
|
}
|
|
|
|
|
PlasmaComponents.TextField {
|
|
|
|
|
id: queryField
|
|
|
|
|
clearButtonShown: true
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.alignment: Qt.AlignTop
|
2015-06-19 00:50:12 +00:00
|
|
|
|
2015-06-19 17:33:56 +00:00
|
|
|
Keys.onEscapePressed: runnerWindow.visible = false
|
2021-02-10 17:00:51 +00:00
|
|
|
placeholderText: i18n("Search...")
|
2015-06-19 17:33:56 +00:00
|
|
|
}
|
2015-06-19 00:50:12 +00:00
|
|
|
|
2015-07-08 20:31:24 +00:00
|
|
|
PlasmaExtras.ScrollArea {
|
|
|
|
|
visible: listView.count > 0
|
2015-06-19 17:33:56 +00:00
|
|
|
Layout.fillWidth: true
|
2015-07-08 20:31:24 +00:00
|
|
|
Layout.fillHeight: true
|
2015-06-19 17:33:56 +00:00
|
|
|
Layout.preferredHeight: listView.contentHeight
|
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
|
|
2015-09-28 15:41:12 +00:00
|
|
|
Milou.ResultsListView {
|
2015-07-08 20:31:24 +00:00
|
|
|
id: listView
|
|
|
|
|
queryString: queryField.text
|
2015-09-28 15:41:12 +00:00
|
|
|
highlight: null
|
2015-07-08 20:31:24 +00:00
|
|
|
|
|
|
|
|
onActivated: queryField.text = ""
|
|
|
|
|
onUpdateQueryString: {
|
|
|
|
|
queryField.text = text
|
|
|
|
|
queryField.cursorPosition = cursorPosition
|
|
|
|
|
}
|
2015-06-19 17:33:56 +00:00
|
|
|
}
|
2015-06-19 00:50:12 +00:00
|
|
|
}
|
|
|
|
|
|
2015-06-19 17:33:56 +00:00
|
|
|
Keys.onReturnPressed: {
|
|
|
|
|
if (queryField.texr.length == 0)
|
|
|
|
|
runnerWindow.visible = false;
|
|
|
|
|
}
|
|
|
|
|
Keys.onEnterPressed: {
|
|
|
|
|
if (queryField.texr.length == 0)
|
|
|
|
|
runnerWindow.visible = false;
|
|
|
|
|
}
|
2015-06-19 00:50:12 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|