Commit c3a8cc56 authored by Nate Graham's avatar Nate Graham 🔩

[applet] Make search field always visible

Right now the search field is only visible when specifically activated
by clicking on the search button. This was done because there used to be
a ton of buttons on the toolbar row that made the search field's size
and position look odd when sharing the same row. However with other
recent changes, we no longer have this constraint and there is now
plenty of room for the search field even including some generous
padding to separate it from other controls. So let's put it there.
parent 188ba8d3
......@@ -33,10 +33,6 @@ ColumnLayout {
readonly property var displayWwanMessage: !wwanSwitchButton.checked && wwanSwitchButton.visible
readonly property var displayplaneModeMessage: planeModeSwitchButton.checked && planeModeSwitchButton.visible
function closeSearch() {
searchToggleButton.checked = false
}
PlasmaCore.Svg {
id: lineSvg
imagePath: "widgets/line"
......@@ -142,13 +138,11 @@ ColumnLayout {
}
}
Item {
Layout.fillWidth: true
}
PlasmaComponents3.ToolButton {
id: hotspotButton
Layout.leftMargin: PlasmaCore.Units.largeSpacing * 2
visible: handler.hotspotSupported
checkable: true
......@@ -188,15 +182,18 @@ ColumnLayout {
}
}
PlasmaComponents3.ToolButton {
id: searchToggleButton
PlasmaComponents3.TextField {
id: searchTextField
checkable: true
Layout.fillWidth: true
Layout.leftMargin: PlasmaCore.Units.largeSpacing * 2
icon.name: "system-search"
focus: true
clearButtonShown: true
placeholderText: i18ndc("plasma-nm", "text field placeholder text", "Search...")
PlasmaComponents3.ToolTip {
text: i18ndc("plasma-nm", "button tooltip", "Search the connections")
onTextChanged: {
appletProxyModel.setFilterRegExp(text)
}
}
......@@ -217,42 +214,7 @@ ColumnLayout {
}
}
PlasmaComponents3.TextField {
id: searchTextField
Layout.fillWidth: true
Layout.leftMargin: units.smallSpacing
Layout.rightMargin: units.smallSpacing
Layout.topMargin: units.smallSpacing
Layout.bottomMargin: units.smallSpacing
focus: true
clearButtonShown: true
placeholderText: i18ndc("plasma-nm", "text field placeholder text", "Search...")
visible: searchToggleButton.checked
onVisibleChanged: {
if (visible) {
searchTextField.forceActiveFocus()
} else {
text = ""
}
}
Keys.onEscapePressed: {
//Check if the searchbar is actually visible before accepting the escape key. Otherwise, the escape key cannot dismiss the applet until one interacts with some other element.
if (searchToggleButton.checked) {
searchToggleButton.checked = false;
} else {
event.accepted = false;
}
}
onTextChanged: {
// Show search field when starting to type directly
if (text.length && !searchToggleButton.checked) {
searchToggleButton.checked = true
}
appletProxyModel.setFilterRegExp(text)
}
Component.onCompleted: {
searchTextField.forceActiveFocus()
}
}
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