plasmoid: Add button for filter
This commit is contained in:
parent
c523f627da
commit
6c6830936d
|
@ -162,9 +162,10 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaComponents.TextField {
|
PlasmaComponents.TextField {
|
||||||
|
property bool explicitelyShown: false
|
||||||
id: filter
|
id: filter
|
||||||
clearButtonShown: true
|
clearButtonShown: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
visible: text !== ""
|
visible: explicitelyShown || text !== ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,9 +124,10 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case Qt.Key_Escape:
|
case Qt.Key_Escape:
|
||||||
var filter = mainTabGroup.currentTab.item.filter
|
var filter = findCurrentFilter()
|
||||||
if (filter && filter.text !== "") {
|
if (filter && filter.text !== "") {
|
||||||
// reset filter
|
// reset filter
|
||||||
|
filter.explicitelyShown = false
|
||||||
filter.text = ""
|
filter.text = ""
|
||||||
event.accepted = true
|
event.accepted = true
|
||||||
} else {
|
} else {
|
||||||
|
@ -153,12 +154,17 @@ ColumnLayout {
|
||||||
event.accepted = true
|
event.accepted = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function findCurrentFilter() {
|
||||||
|
return mainTabGroup.currentTab.item.filter
|
||||||
|
}
|
||||||
|
|
||||||
function sendKeyEventToFilter(event) {
|
function sendKeyEventToFilter(event) {
|
||||||
var filter = mainTabGroup.currentTab.item.filter
|
var filter = findCurrentFilter()
|
||||||
if (!filter || event.text === "" || filter.activeFocus) {
|
if (!filter || event.text === "" || filter.activeFocus) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (event.key === Qt.Key_Backspace && filter.text === "") {
|
if (event.key === Qt.Key_Backspace && filter.text === "") {
|
||||||
|
filter.explicitelyShown = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (event.matches(StandardKey.Paste)) {
|
if (event.matches(StandardKey.Paste)) {
|
||||||
|
@ -495,30 +501,58 @@ ColumnLayout {
|
||||||
RowLayout {
|
RowLayout {
|
||||||
spacing: 0
|
spacing: 0
|
||||||
|
|
||||||
PlasmaComponents.TabBar {
|
ColumnLayout {
|
||||||
id: tabBar
|
spacing: 0
|
||||||
tabPosition: Qt.LeftEdge
|
|
||||||
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
||||||
|
|
||||||
PlasmaComponents.TabButton {
|
PlasmaComponents.TabBar {
|
||||||
id: dirsTabButton
|
id: tabBar
|
||||||
//text: qsTr("Directories")
|
tabPosition: Qt.LeftEdge
|
||||||
iconSource: "folder-symbolic"
|
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
||||||
tab: dirsPage
|
|
||||||
|
PlasmaComponents.TabButton {
|
||||||
|
id: dirsTabButton
|
||||||
|
//text: qsTr("Directories")
|
||||||
|
iconSource: "folder-symbolic"
|
||||||
|
tab: dirsPage
|
||||||
|
}
|
||||||
|
PlasmaComponents.TabButton {
|
||||||
|
id: devsTabButton
|
||||||
|
//text: qsTr("Devices")
|
||||||
|
iconSource: "network-server-symbolic"
|
||||||
|
tab: devicesPage
|
||||||
|
}
|
||||||
|
PlasmaComponents.TabButton {
|
||||||
|
id: downloadsTabButton
|
||||||
|
//text: qsTr("Downloads")
|
||||||
|
iconSource: "folder-download-symbolic"
|
||||||
|
tab: downloadsPage
|
||||||
|
}
|
||||||
}
|
}
|
||||||
PlasmaComponents.TabButton {
|
Item {
|
||||||
id: devsTabButton
|
Layout.fillHeight: true
|
||||||
//text: qsTr("Devices")
|
|
||||||
iconSource: "network-server-symbolic"
|
|
||||||
tab: devicesPage
|
|
||||||
}
|
}
|
||||||
PlasmaComponents.TabButton {
|
PlasmaComponents.Button {
|
||||||
id: downloadsTabButton
|
id: searchButton
|
||||||
//text: qsTr("Downloads")
|
iconSource: "search"
|
||||||
iconSource: "folder-download-symbolic"
|
enabled: mainTabGroup.currentTab === dirsPage
|
||||||
tab: downloadsPage
|
tooltip: qsTr("Toggle filter")
|
||||||
|
onClicked: {
|
||||||
|
var filter = findCurrentFilter()
|
||||||
|
if (!filter) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!filter.explicitelyShown) {
|
||||||
|
filter.explicitelyShown = true
|
||||||
|
filter.forceActiveFocus()
|
||||||
|
} else {
|
||||||
|
filter.explicitelyShown = false
|
||||||
|
filter.text = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaCore.SvgItem {
|
PlasmaCore.SvgItem {
|
||||||
Layout.preferredWidth: 2
|
Layout.preferredWidth: 2
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
|
|
Loading…
Reference in New Issue