mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-03 20:32:07 -04:00
launcher/dsearch: support for folder search and extra filters
This commit is contained in:
@@ -549,8 +549,151 @@ FocusScope {
|
||||
}
|
||||
|
||||
Item {
|
||||
id: fileFilterRow
|
||||
width: parent.width
|
||||
height: parent.height - searchField.height - categoryRow.height - actionPanel.height - Theme.spacingXS * (categoryRow.visible ? 3 : 2)
|
||||
height: showFileFilters ? fileFilterContent.height : 0
|
||||
visible: showFileFilters
|
||||
|
||||
readonly property bool showFileFilters: controller.searchMode === "files"
|
||||
|
||||
Behavior on height {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
id: fileFilterContent
|
||||
width: parent.width
|
||||
spacing: Theme.spacingS
|
||||
|
||||
Row {
|
||||
id: typeChips
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: 2
|
||||
visible: DSearchService.supportsTypeFilter
|
||||
|
||||
Repeater {
|
||||
model: [
|
||||
{
|
||||
id: "all",
|
||||
label: I18n.tr("All"),
|
||||
icon: "search"
|
||||
},
|
||||
{
|
||||
id: "file",
|
||||
label: I18n.tr("Files"),
|
||||
icon: "insert_drive_file"
|
||||
},
|
||||
{
|
||||
id: "dir",
|
||||
label: I18n.tr("Folders"),
|
||||
icon: "folder"
|
||||
}
|
||||
]
|
||||
|
||||
Rectangle {
|
||||
required property var modelData
|
||||
required property int index
|
||||
|
||||
width: chipContent.width + Theme.spacingM * 2
|
||||
height: sortDropdown.height
|
||||
radius: Theme.cornerRadius
|
||||
color: controller.fileSearchType === modelData.id || chipArea.containsMouse ? Theme.primaryContainer : "transparent"
|
||||
|
||||
Row {
|
||||
id: chipContent
|
||||
anchors.centerIn: parent
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
DankIcon {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
name: modelData.icon
|
||||
size: 14
|
||||
color: controller.fileSearchType === modelData.id ? Theme.primary : Theme.surfaceVariantText
|
||||
}
|
||||
|
||||
StyledText {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: modelData.label
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: controller.fileSearchType === modelData.id ? Theme.primary : Theme.surfaceText
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: chipArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: controller.setFileSearchType(modelData.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: 1
|
||||
height: 20
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: Theme.outlineMedium
|
||||
visible: typeChips.visible
|
||||
}
|
||||
|
||||
DankDropdown {
|
||||
id: sortDropdown
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: Math.min(130, parent.width / 3)
|
||||
compactMode: true
|
||||
dropdownWidth: 130
|
||||
popupWidth: 150
|
||||
maxPopupHeight: 200
|
||||
currentValue: {
|
||||
switch (controller.fileSearchSort) {
|
||||
case "score":
|
||||
return I18n.tr("Score");
|
||||
case "name":
|
||||
return I18n.tr("Name");
|
||||
case "modified":
|
||||
return I18n.tr("Modified");
|
||||
case "size":
|
||||
return I18n.tr("Size");
|
||||
default:
|
||||
return I18n.tr("Score");
|
||||
}
|
||||
}
|
||||
options: [I18n.tr("Score"), I18n.tr("Name"), I18n.tr("Modified"), I18n.tr("Size")]
|
||||
|
||||
onValueChanged: value => {
|
||||
var sortMap = {};
|
||||
sortMap[I18n.tr("Score")] = "score";
|
||||
sortMap[I18n.tr("Name")] = "name";
|
||||
sortMap[I18n.tr("Modified")] = "modified";
|
||||
sortMap[I18n.tr("Size")] = "size";
|
||||
controller.setFileSearchSort(sortMap[value] || "score");
|
||||
}
|
||||
}
|
||||
|
||||
DankTextField {
|
||||
id: extFilterField
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: Math.min(100, parent.width / 4)
|
||||
height: sortDropdown.height
|
||||
placeholderText: I18n.tr("ext")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
showClearButton: text.length > 0
|
||||
|
||||
onTextChanged: {
|
||||
controller.setFileSearchExt(text.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
width: parent.width
|
||||
height: parent.height - searchField.height - categoryRow.height - fileFilterRow.height - actionPanel.height - Theme.spacingXS * ((categoryRow.visible ? 1 : 0) + (fileFilterRow.visible ? 1 : 0) + 2)
|
||||
opacity: root.parentModal?.isClosing ? 0 : 1
|
||||
|
||||
ResultsList {
|
||||
@@ -586,6 +729,9 @@ FocusScope {
|
||||
function onSearchQueryRequested(query) {
|
||||
searchField.text = query;
|
||||
}
|
||||
function onModeChanged() {
|
||||
extFilterField.text = "";
|
||||
}
|
||||
}
|
||||
|
||||
FocusScope {
|
||||
|
||||
Reference in New Issue
Block a user