mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-07 14:05:38 -05:00
Make recent apps a category
This commit is contained in:
@@ -65,7 +65,9 @@ PanelWindow {
|
||||
target: AppSearchService
|
||||
function onReadyChanged() {
|
||||
if (AppSearchService.ready) {
|
||||
categories = AppSearchService.getAllCategories()
|
||||
var allCategories = AppSearchService.getAllCategories()
|
||||
// Insert "Recents" after "All"
|
||||
categories = ["All", "Recents"].concat(allCategories.filter(cat => cat !== "All"))
|
||||
updateFilteredModel()
|
||||
}
|
||||
}
|
||||
@@ -101,13 +103,20 @@ PanelWindow {
|
||||
// Search across all apps or category
|
||||
var baseApps = selectedCategory === "All" ?
|
||||
AppSearchService.applications :
|
||||
AppSearchService.getAppsInCategory(selectedCategory)
|
||||
selectedCategory === "Recents" ?
|
||||
recentApps.map(recentApp => AppSearchService.getAppByExec(recentApp.exec)).filter(app => app !== null) :
|
||||
AppSearchService.getAppsInCategory(selectedCategory)
|
||||
apps = AppSearchService.searchApplications(searchField.text).filter(app =>
|
||||
baseApps.includes(app)
|
||||
)
|
||||
} else {
|
||||
// Just category filter
|
||||
apps = AppSearchService.getAppsInCategory(selectedCategory)
|
||||
if (selectedCategory === "Recents") {
|
||||
// For recents, use the recent apps from Prefs
|
||||
apps = recentApps.map(recentApp => AppSearchService.getAppByExec(recentApp.exec)).filter(app => app !== null)
|
||||
} else {
|
||||
apps = AppSearchService.getAppsInCategory(selectedCategory)
|
||||
}
|
||||
}
|
||||
|
||||
// Add to model
|
||||
@@ -406,69 +415,6 @@ PanelWindow {
|
||||
}
|
||||
}
|
||||
|
||||
// Recent apps section
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingS
|
||||
visible: recentApps.length > 0 && searchField.text.length === 0
|
||||
|
||||
Text {
|
||||
text: "Recently Used"
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
font.weight: Font.Medium
|
||||
color: Theme.surfaceText
|
||||
}
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingM
|
||||
|
||||
Repeater {
|
||||
model: Math.min(recentApps.length, 5)
|
||||
|
||||
Rectangle {
|
||||
width: 56
|
||||
height: 56
|
||||
radius: Theme.cornerRadius
|
||||
color: recentAppMouseArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.1)
|
||||
border.color: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.2)
|
||||
border.width: 1
|
||||
|
||||
IconImage {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 8
|
||||
source: recentApps[index] ? Quickshell.iconPath(recentApps[index].icon, "") : ""
|
||||
smooth: true
|
||||
asynchronous: true
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: recentAppMouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
if (recentApps[index]) {
|
||||
var recentApp = recentApps[index]
|
||||
// Find the desktop entry for this recent app
|
||||
var foundApp = AppSearchService.getAppByExec(recentApp.exec)
|
||||
if (foundApp) {
|
||||
Prefs.addRecentApp(foundApp)
|
||||
AppSearchService.launchApp(foundApp)
|
||||
} else {
|
||||
// Fallback to direct execution
|
||||
var cleanExec = recentApp.exec.replace(/%[fFuU]/g, "").trim()
|
||||
Quickshell.execDetached(["sh", "-c", cleanExec])
|
||||
}
|
||||
launcher.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Category filter and view mode controls
|
||||
Row {
|
||||
width: parent.width
|
||||
@@ -592,7 +538,6 @@ PanelWindow {
|
||||
// Calculate more precise remaining height
|
||||
let usedHeight = 40 + Theme.spacingL // Header
|
||||
usedHeight += 52 + Theme.spacingL // Search container
|
||||
usedHeight += (recentApps.length > 0 && searchField.text.length === 0 ? 56 + Theme.spacingS + Theme.spacingL : 0) // Recent apps when visible
|
||||
usedHeight += (searchField.text.length === 0 ? 40 + Theme.spacingL : 0) // Category/controls when visible
|
||||
return parent.height - usedHeight
|
||||
}
|
||||
@@ -966,7 +911,9 @@ PanelWindow {
|
||||
|
||||
Component.onCompleted: {
|
||||
if (AppSearchService.ready) {
|
||||
categories = AppSearchService.getAllCategories()
|
||||
var allCategories = AppSearchService.getAllCategories()
|
||||
// Insert "Recents" after "All"
|
||||
categories = ["All", "Recents"].concat(allCategories.filter(cat => cat !== "All"))
|
||||
updateFilteredModel()
|
||||
}
|
||||
recentApps = Prefs.getRecentApps() // Load recent apps on startup
|
||||
|
||||
Reference in New Issue
Block a user