mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-05-12 15:29:43 -04:00
feat(settings): add expandable search bar to plugins tab (#2377)
This commit is contained in:
@@ -16,6 +16,28 @@ FocusScope {
|
|||||||
property var installedPluginsData: ({})
|
property var installedPluginsData: ({})
|
||||||
property bool isReloading: false
|
property bool isReloading: false
|
||||||
property alias sharedTooltip: sharedTooltip
|
property alias sharedTooltip: sharedTooltip
|
||||||
|
property bool isSearchExpanded: false
|
||||||
|
property string searchQuery: ""
|
||||||
|
property var filteredPlugins: []
|
||||||
|
|
||||||
|
function updateFilteredPlugins() {
|
||||||
|
var query = searchQuery.toLowerCase();
|
||||||
|
filteredPlugins = PluginService.availablePluginsList.filter(plugin => {
|
||||||
|
if (!query) return true;
|
||||||
|
var name = (plugin.name || "").toLowerCase();
|
||||||
|
var desc = (plugin.description || "").toLowerCase();
|
||||||
|
var author = (plugin.author || "").toLowerCase();
|
||||||
|
return name.includes(query) || desc.includes(query) || author.includes(query);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: PluginService
|
||||||
|
function onAvailablePluginsListChanged() {
|
||||||
|
pluginsTab.updateFilteredPlugins();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
focus: true
|
focus: true
|
||||||
|
|
||||||
@@ -296,13 +318,72 @@ FocusScope {
|
|||||||
anchors.margins: Theme.spacingL
|
anchors.margins: Theme.spacingL
|
||||||
spacing: Theme.spacingM
|
spacing: Theme.spacingM
|
||||||
|
|
||||||
StyledText {
|
Row {
|
||||||
text: I18n.tr("Available Plugins")
|
|
||||||
font.pixelSize: Theme.fontSizeLarge
|
|
||||||
color: Theme.surfaceText
|
|
||||||
font.weight: Font.Medium
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
horizontalAlignment: Text.AlignLeft
|
spacing: Theme.spacingM
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
text: I18n.tr("Available Plugins")
|
||||||
|
font.pixelSize: Theme.fontSizeLarge
|
||||||
|
color: Theme.surfaceText
|
||||||
|
font.weight: Font.Medium
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
width: parent.width - parent.children[0].implicitWidth - searchIconBtn.width - parent.spacing * 2
|
||||||
|
height: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
DankActionButton {
|
||||||
|
id: searchIconBtn
|
||||||
|
iconName: "search"
|
||||||
|
iconSize: 20
|
||||||
|
iconColor: pluginsTab.isSearchExpanded ? Theme.primary : Theme.surfaceVariantText
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
onClicked: {
|
||||||
|
pluginsTab.isSearchExpanded = !pluginsTab.isSearchExpanded;
|
||||||
|
if (pluginsTab.isSearchExpanded) {
|
||||||
|
Qt.callLater(() => pluginSearchField.forceActiveFocus());
|
||||||
|
} else {
|
||||||
|
pluginSearchField.text = "";
|
||||||
|
pluginsTab.searchQuery = "";
|
||||||
|
pluginsTab.updateFilteredPlugins();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DankTextField {
|
||||||
|
id: pluginSearchField
|
||||||
|
width: parent.width
|
||||||
|
visible: pluginsTab.isSearchExpanded || height > 0
|
||||||
|
height: pluginsTab.isSearchExpanded ? 48 : 0
|
||||||
|
opacity: pluginsTab.isSearchExpanded ? 1 : 0
|
||||||
|
clip: true
|
||||||
|
placeholderText: I18n.tr("Search installed plugins...")
|
||||||
|
leftIconName: "search"
|
||||||
|
showClearButton: true
|
||||||
|
|
||||||
|
Behavior on height {
|
||||||
|
enabled: Theme.currentAnimationSpeed !== SettingsData.AnimationSpeed.None
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.shortDuration
|
||||||
|
easing.type: Theme.standardEasing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on opacity {
|
||||||
|
enabled: Theme.currentAnimationSpeed !== SettingsData.AnimationSpeed.None
|
||||||
|
NumberAnimation {
|
||||||
|
duration: Theme.shortDuration
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onTextEdited: {
|
||||||
|
pluginsTab.searchQuery = text;
|
||||||
|
pluginsTab.updateFilteredPlugins();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
@@ -311,7 +392,7 @@ FocusScope {
|
|||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: pluginRepeater
|
id: pluginRepeater
|
||||||
model: PluginService.availablePluginsList
|
model: pluginsTab.filteredPlugins
|
||||||
|
|
||||||
PluginListItem {
|
PluginListItem {
|
||||||
pluginData: modelData
|
pluginData: modelData
|
||||||
@@ -415,6 +496,7 @@ FocusScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
updateFilteredPlugins();
|
||||||
if (DMSService.dmsAvailable && DMSService.apiVersion >= 8)
|
if (DMSService.dmsAvailable && DMSService.apiVersion >= 8)
|
||||||
DMSService.listInstalled();
|
DMSService.listInstalled();
|
||||||
if (PopoutService.pendingPluginInstall)
|
if (PopoutService.pendingPluginInstall)
|
||||||
|
|||||||
Reference in New Issue
Block a user