2023-10-22 03:59:27 +00:00
|
|
|
// SPDX-FileCopyrightText: 2021-2023 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-License-Identifier: LGPL-2.0-or-later
|
|
|
|
|
|
|
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls as QQC2
|
|
|
|
|
import QtQuick.Layouts
|
|
|
|
|
|
|
|
|
|
import org.kde.kirigami as Kirigami
|
|
|
|
|
|
|
|
|
|
import org.kde.plasma.components 3.0 as PlasmaComponents
|
2025-07-16 17:02:18 +00:00
|
|
|
import plasma.applet.org.kde.plasma.mobile.homescreen.folio as Folio
|
2024-07-01 16:04:32 +00:00
|
|
|
import './delegate'
|
2023-10-22 03:59:27 +00:00
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: root
|
2024-07-01 16:04:32 +00:00
|
|
|
property Folio.HomeScreen folio
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2026-04-27 12:28:21 +00:00
|
|
|
// Do not override the colorset: in mobile mode we inherit Complementary
|
|
|
|
|
// from the containment (wallpaper context, white text); in convergence mode
|
|
|
|
|
// the drawerOverlay Window gives us Window context (system-adaptive).
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2025-07-10 16:54:01 +00:00
|
|
|
function addSearchText(text: string) {
|
|
|
|
|
searchField.text += text;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-01 16:04:32 +00:00
|
|
|
function clearSearchText(): void {
|
|
|
|
|
searchField.text = '';
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-10 16:54:01 +00:00
|
|
|
// Request to not focus on the search bar
|
|
|
|
|
signal releaseFocusRequested()
|
|
|
|
|
|
|
|
|
|
onFocusChanged: {
|
|
|
|
|
if (focus) {
|
|
|
|
|
searchField.focus = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Keyboard navigation
|
|
|
|
|
Keys.onPressed: (event) => {
|
|
|
|
|
if (event.key === Qt.Key_Escape || event.key === Qt.Key_Back) {
|
|
|
|
|
root.releaseFocusRequested();
|
|
|
|
|
event.accepted = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
RowLayout {
|
2024-07-01 16:04:32 +00:00
|
|
|
anchors.topMargin: Kirigami.Units.largeSpacing
|
2023-10-22 03:59:27 +00:00
|
|
|
anchors.leftMargin: Kirigami.Units.gridUnit + Kirigami.Units.largeSpacing
|
|
|
|
|
anchors.rightMargin: Kirigami.Units.gridUnit + Kirigami.Units.largeSpacing
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
2026-05-17 06:57:06 +00:00
|
|
|
QQC2.TextField {
|
2024-07-01 16:04:32 +00:00
|
|
|
id: searchField
|
|
|
|
|
onTextChanged: folio.ApplicationListSearchModel.setFilterFixedString(text)
|
|
|
|
|
Layout.maximumWidth: Kirigami.Units.gridUnit * 30
|
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2026-05-17 06:57:06 +00:00
|
|
|
leftPadding: Kirigami.Units.iconSizes.small + Kirigami.Units.largeSpacing * 2
|
|
|
|
|
rightPadding: clearSearchArea.visible ? clearSearchArea.width + Kirigami.Units.largeSpacing : Kirigami.Units.largeSpacing
|
2024-07-01 16:04:32 +00:00
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
|
radius: Kirigami.Units.cornerRadius
|
2026-04-27 12:28:21 +00:00
|
|
|
color: Qt.rgba(Kirigami.Theme.textColor.r, Kirigami.Theme.textColor.g,
|
|
|
|
|
Kirigami.Theme.textColor.b,
|
|
|
|
|
(searchField.hovered || searchField.focus) ? 0.2 : 0.1)
|
2024-07-01 16:04:32 +00:00
|
|
|
|
|
|
|
|
Behavior on color { ColorAnimation {} }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
topPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
|
|
|
|
|
bottomPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
|
|
horizontalAlignment: QQC2.TextField.AlignHCenter
|
|
|
|
|
placeholderText: i18nc("@info:placeholder", "Search applications…")
|
2026-04-27 12:28:21 +00:00
|
|
|
placeholderTextColor: Kirigami.Theme.disabledTextColor
|
|
|
|
|
color: Kirigami.Theme.textColor
|
2024-07-01 16:04:32 +00:00
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
font.weight: Font.Bold
|
2024-07-01 16:04:32 +00:00
|
|
|
|
2026-05-17 06:57:06 +00:00
|
|
|
Kirigami.Icon {
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.leftMargin: Kirigami.Units.largeSpacing
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
width: Kirigami.Units.iconSizes.small
|
|
|
|
|
height: width
|
|
|
|
|
source: "search"
|
|
|
|
|
isMask: true
|
|
|
|
|
color: Kirigami.Theme.textColor
|
|
|
|
|
opacity: 0.65
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
|
id: clearSearchArea
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.rightMargin: Kirigami.Units.smallSpacing
|
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
|
width: Kirigami.Units.iconSizes.smallMedium
|
|
|
|
|
height: width
|
|
|
|
|
visible: searchField.text.length > 0
|
|
|
|
|
hoverEnabled: true
|
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
|
|
|
|
|
|
onClicked: searchField.clear()
|
|
|
|
|
|
|
|
|
|
Kirigami.Icon {
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
width: Kirigami.Units.iconSizes.small
|
|
|
|
|
height: width
|
|
|
|
|
source: "window-close-symbolic"
|
|
|
|
|
isMask: true
|
|
|
|
|
color: Kirigami.Theme.textColor
|
|
|
|
|
opacity: clearSearchArea.containsMouse ? 0.9 : 0.65
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-01 16:04:32 +00:00
|
|
|
Connections {
|
|
|
|
|
target: folio.HomeScreenState
|
|
|
|
|
function onViewStateChanged(): void {
|
|
|
|
|
if (folio.HomeScreenState.viewState !== Folio.HomeScreenState.AppDrawerView) {
|
|
|
|
|
// Reset search field if the app drawer is not shown
|
|
|
|
|
if (searchField.text !== '') {
|
|
|
|
|
searchField.text = '';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
2026-04-09 08:41:42 +00:00
|
|
|
|
|
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
}
|