Verified Commit 0bb9bd34 authored by Carl Schwan's avatar Carl Schwan 🌈

Use Kirigami.ActionTextField for the SearchField

Summary: Need Kirigami latest version (master)

Test Plan: A regression found (need D19300)

Reviewers: #discover_software_store, ngraham

Reviewed By: #discover_software_store, ngraham

Subscribers: ngraham, apol, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D19301
parent f9b14da7
......@@ -24,7 +24,7 @@ include(ECMQtDeclareLoggingCategory)
find_package(PkgConfig REQUIRED)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED CoreAddons Config Crash DBusAddons I18n Archive XmlGui ItemModels KIO Declarative)
find_package(KF5Kirigami2 2.1.0)
find_package(KF5Kirigami2 2.7.0)
find_package(packagekitqt5 1.0.1 CONFIG)
find_package(AppStreamQt 0.11.1 CONFIG)
......
/***************************************************************************
* Copyright © 2017 Aleix Pol Gonzalez <aleixpol@blue-systems.com> *
* Copyright © 2019 Carl Schwan <carl@carlschwan.eu> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
......@@ -20,51 +21,34 @@
import QtQuick 2.5
import QtQuick.Controls 2.1
import org.kde.kirigami 2.1 as Kirigami
import org.kde.kirigami 2.7 as Kirigami
TextField
Kirigami.ActionTextField
{
id: searchField
focusSequence: "Ctrl+F"
rightActions: [
Kirigami.Action {
iconName: "edit-clear"
visible: root.text.length !== 0
onTriggered: searchField.clearText()
}
]
property QtObject page
property string currentSearchText
placeholderText: (!enabled || !page || page.hasOwnProperty("isHome") || page.title.length === 0) ? i18n("Search...") : i18n("Search in '%1'...", window.leftPage.title)
Shortcut {
sequence: "Ctrl+F"
onActivated: {
searchField.forceActiveFocus()
searchField.selectAll()
}
}
onAccepted: {
currentSearchText = text
}
hoverEnabled: true
ToolTip {
delay: Kirigami.Units.longDuration
visible: hovered && searchField.text.length === 0
text: searchAction.shortcut
}
function clearText() {
searchField.text = ""
searchField.accepted()
}
ToolButton {
anchors {
top: parent.top
right: parent.right
bottom: parent.bottom
margins: Kirigami.Units.smallSpacing
}
icon.name: "edit-clear"
visible: searchField.text != ""
onClicked: clearText()
}
Connections {
ignoreUnknownSignals: true
target: page
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment