1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-05 21:15:38 -05:00

Implement grid view on spotlight launcher. Updated navigation response on both lauchers

This commit is contained in:
purian23
2025-07-12 02:46:28 -04:00
parent 307cc8700d
commit e76b0ee443
2 changed files with 512 additions and 250 deletions

View File

@@ -525,7 +525,7 @@ PanelWindow {
anchors.fill: parent anchors.fill: parent
clip: true clip: true
visible: viewMode === "list" visible: viewMode === "list"
ScrollBar.vertical.policy: ScrollBar.AsNeeded ScrollBar.vertical.policy: ScrollBar.AlwaysOn
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
ListView { ListView {
@@ -536,6 +536,27 @@ PanelWindow {
model: filteredModel model: filteredModel
delegate: listDelegate delegate: listDelegate
// Make mouse wheel scrolling more responsive
property real wheelStepSize: 60
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
onWheel: (wheel) => {
var delta = wheel.angleDelta.y
var steps = delta / 120 // Standard wheel step
appList.contentY -= steps * appList.wheelStepSize
// Ensure we stay within bounds
if (appList.contentY < 0) {
appList.contentY = 0
} else if (appList.contentY > appList.contentHeight - appList.height) {
appList.contentY = Math.max(0, appList.contentHeight - appList.height)
}
}
}
} }
} }
@@ -567,6 +588,27 @@ PanelWindow {
model: filteredModel model: filteredModel
delegate: gridDelegate delegate: gridDelegate
// Make mouse wheel scrolling more responsive
property real wheelStepSize: 60
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
onWheel: (wheel) => {
var delta = wheel.angleDelta.y
var steps = delta / 120 // Standard wheel step
appGrid.contentY -= steps * appGrid.wheelStepSize
// Ensure we stay within bounds
if (appGrid.contentY < 0) {
appGrid.contentY = 0
} else if (appGrid.contentY > appGrid.contentHeight - appGrid.height) {
appGrid.contentY = Math.max(0, appGrid.contentHeight - appGrid.height)
}
}
}
} }
} }
} }
@@ -615,6 +657,27 @@ PanelWindow {
model: categories model: categories
spacing: 4 spacing: 4
// Make mouse wheel scrolling more responsive
property real wheelStepSize: 60
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
onWheel: (wheel) => {
var delta = wheel.angleDelta.y
var steps = delta / 120 // Standard wheel step
parent.contentY -= steps * parent.wheelStepSize
// Ensure we stay within bounds
if (parent.contentY < 0) {
parent.contentY = 0
} else if (parent.contentY > parent.contentHeight - parent.height) {
parent.contentY = Math.max(0, parent.contentHeight - parent.height)
}
}
}
delegate: Rectangle { delegate: Rectangle {
width: ListView.view.width width: ListView.view.width
height: 36 height: 36

View File

@@ -15,9 +15,10 @@ PanelWindow {
property var recentApps: [] property var recentApps: []
property var filteredApps: [] property var filteredApps: []
property int selectedIndex: 0 property int selectedIndex: 0
property int maxResults: 12 property int maxResults: 50
property var categories: AppSearchService.getAllCategories() property var categories: AppSearchService.getAllCategories().filter(cat => cat !== "Education" && cat !== "Science")
property string selectedCategory: "All" property string selectedCategory: "All"
property string viewMode: "list" // "list" or "grid"
anchors { anchors {
top: true top: true
@@ -38,6 +39,8 @@ PanelWindow {
} }
color: "transparent" color: "transparent"
// ...existing code...
function show() { function show() {
console.log("SpotlightLauncher: show() called") console.log("SpotlightLauncher: show() called")
spotlightOpen = true spotlightOpen = true
@@ -78,31 +81,61 @@ PanelWindow {
if (searchField.text.length === 0) { if (searchField.text.length === 0) {
// Show recent apps first, then all apps from category // Show recent apps first, then all apps from category
var categoryApps = AppSearchService.getAppsInCategory(selectedCategory) if (selectedCategory === "All") {
var combined = [] // For "All" category, show recent apps first, then all available apps
var allApps = AppSearchService.applications || []
// Add recent apps first if they match category var combined = []
recentApps.forEach(recentApp => {
var found = categoryApps.find(app => app.exec === recentApp.exec) // Add recent apps first
if (found) { recentApps.forEach(recentApp => {
combined.push(found) var found = allApps.find(app => app.exec === recentApp.exec)
} if (found) {
}) combined.push(found)
}
// Add remaining apps not in recent })
var remaining = categoryApps.filter(app => {
return !recentApps.some(recentApp => recentApp.exec === app.exec) // Add remaining apps not in recent
}) var remaining = allApps.filter(app => {
return !recentApps.some(recentApp => recentApp.exec === app.exec)
combined = combined.concat(remaining) })
apps = combined.slice(0, maxResults)
combined = combined.concat(remaining)
apps = combined // Show all apps for "All" category
} else {
// For specific categories, limit results
var categoryApps = AppSearchService.getAppsInCategory(selectedCategory)
var combined = []
// Add recent apps first if they match category
recentApps.forEach(recentApp => {
var found = categoryApps.find(app => app.exec === recentApp.exec)
if (found) {
combined.push(found)
}
})
// Add remaining apps not in recent
var remaining = categoryApps.filter(app => {
return !recentApps.some(recentApp => recentApp.exec === app.exec)
})
combined = combined.concat(remaining)
apps = combined.slice(0, maxResults)
}
} else { } else {
// Search with category filter // Search with category filter
var baseApps = selectedCategory === "All" ? var baseApps = selectedCategory === "All" ?
AppSearchService.applications : AppSearchService.applications :
AppSearchService.getAppsInCategory(selectedCategory) AppSearchService.getAppsInCategory(selectedCategory)
var searchResults = AppSearchService.searchApplications(searchField.text) var searchResults = AppSearchService.searchApplications(searchField.text)
apps = searchResults.filter(app => baseApps.includes(app)).slice(0, maxResults)
if (selectedCategory === "All") {
// For "All" category, show all search results without limit
apps = searchResults.filter(app => baseApps.includes(app))
} else {
// For specific categories, still apply limit
apps = searchResults.filter(app => baseApps.includes(app)).slice(0, maxResults)
}
} }
// Convert to our format // Convert to our format
@@ -133,13 +166,39 @@ PanelWindow {
function selectNext() { function selectNext() {
if (filteredApps.length > 0) { if (filteredApps.length > 0) {
selectedIndex = (selectedIndex + 1) % filteredApps.length if (viewMode === "grid") {
// Grid navigation: move by columns (6 columns)
var columnsCount = 6
selectedIndex = Math.min(selectedIndex + columnsCount, filteredApps.length - 1)
} else {
// List navigation: next item
selectedIndex = (selectedIndex + 1) % filteredApps.length
}
} }
} }
function selectPrevious() { function selectPrevious() {
if (filteredApps.length > 0) { if (filteredApps.length > 0) {
selectedIndex = selectedIndex > 0 ? selectedIndex - 1 : filteredApps.length - 1 if (viewMode === "grid") {
// Grid navigation: move by columns (6 columns)
var columnsCount = 6
selectedIndex = Math.max(selectedIndex - columnsCount, 0)
} else {
// List navigation: previous item
selectedIndex = selectedIndex > 0 ? selectedIndex - 1 : filteredApps.length - 1
}
}
}
function selectNextInRow() {
if (filteredApps.length > 0 && viewMode === "grid") {
selectedIndex = Math.min(selectedIndex + 1, filteredApps.length - 1)
}
}
function selectPreviousInRow() {
if (filteredApps.length > 0 && viewMode === "grid") {
selectedIndex = Math.max(selectedIndex - 1, 0)
} }
} }
@@ -150,252 +209,313 @@ PanelWindow {
} }
ListModel { id: filteredModel } ListModel { id: filteredModel }
Connections { Connections {
target: AppSearchService target: AppSearchService
function onReadyChanged() { function onReadyChanged() {
if (AppSearchService.ready) { if (AppSearchService.ready) {
categories = AppSearchService.getAllCategories() categories = AppSearchService.getAllCategories().filter(cat => cat !== "Education" && cat !== "Science")
if (spotlightOpen) { if (spotlightOpen) updateFilteredApps()
updateFilteredApps()
}
} }
} }
} }
// Dimmed overlay background
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
color: Qt.rgba(0, 0, 0, 0.4) color: Qt.rgba(0, 0, 0, 0.4)
opacity: spotlightOpen ? 1.0 : 0.0 opacity: spotlightOpen ? 1.0 : 0.0
Behavior on opacity { NumberAnimation { duration: Theme.shortDuration; easing.type: Theme.standardEasing } }
Behavior on opacity { MouseArea { anchors.fill: parent; enabled: spotlightOpen; onClicked: hide() }
NumberAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
MouseArea {
anchors.fill: parent
enabled: spotlightOpen
onClicked: hide()
}
} }
// Main container with search and results
Rectangle { Rectangle {
id: mainContainer id: mainContainer
width: 600 width: 600
height: Math.min(600, categoryFlow.height + (categoryFlow.visible ? Theme.spacingL : 0) + searchContainer.height + resultsList.height + Theme.spacingXL * 2 + Theme.spacingL) height: 650
anchors.centerIn: parent anchors.centerIn: parent
color: Theme.surfaceContainer color: Theme.surfaceContainer
radius: Theme.cornerRadiusXLarge radius: Theme.cornerRadiusXLarge
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2) border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
border.width: 1 border.width: 1
transform: Scale {
origin.x: mainContainer.width / 2
origin.y: mainContainer.height / 2
xScale: spotlightOpen ? 1.0 : 0.9
yScale: spotlightOpen ? 1.0 : 0.9
Behavior on xScale {
NumberAnimation {
duration: Theme.mediumDuration
easing.type: Easing.OutBack
easing.overshoot: 1.1
}
}
Behavior on yScale {
NumberAnimation {
duration: Theme.mediumDuration
easing.type: Easing.OutBack
easing.overshoot: 1.1
}
}
}
opacity: spotlightOpen ? 1.0 : 0.0
Behavior on opacity {
NumberAnimation {
duration: Theme.mediumDuration
easing.type: Theme.emphasizedEasing
}
}
layer.enabled: true layer.enabled: true
layer.effect: DropShadow { layer.effect: DropShadow { radius: 32; samples: 64; color: Qt.rgba(0,0,0,0.3); horizontalOffset:0; verticalOffset:8 }
radius: 32 transform: Scale { origin.x: width/2; origin.y: height/2; xScale: spotlightOpen?1:0.9; yScale: spotlightOpen?1:0.9;
samples: 64 Behavior on xScale { NumberAnimation { duration: Theme.mediumDuration; easing.type: Easing.OutBack; easing.overshoot:1.1 } }
color: Qt.rgba(0, 0, 0, 0.3) Behavior on yScale { NumberAnimation { duration: Theme.mediumDuration; easing.type: Easing.OutBack; easing.overshoot:1.1 } }
horizontalOffset: 0
verticalOffset: 8
} }
opacity: spotlightOpen?1:0
Behavior on opacity { NumberAnimation { duration: Theme.mediumDuration; easing.type: Theme.emphasizedEasing } }
Column { Column {
anchors.fill: parent anchors.fill: parent; anchors.margins: Theme.spacingXL; spacing: Theme.spacingL
anchors.margins: Theme.spacingXL
spacing: Theme.spacingL
// Category selector // Combined row for categories and view mode toggle
Flow { Column {
id: categoryFlow width: parent.width
spacing: Theme.spacingM
visible: categories.length > 1 || filteredModel.count > 0
// Categories organized in 2 rows: 4 + 5
Column {
width: parent.width
spacing: Theme.spacingS
// Top row: All, Development, Graphics, Internet (4 items)
Row {
width: parent.width
spacing: Theme.spacingS
property var topRowCategories: ["All", "Development", "Graphics", "Internet"]
Repeater {
model: parent.topRowCategories.filter(cat => categories.includes(cat))
Rectangle {
height: 36
width: (parent.width - (parent.topRowCategories.length - 1) * Theme.spacingS) / parent.topRowCategories.length
radius: Theme.cornerRadiusLarge
color: selectedCategory === modelData ? Theme.primary : "transparent"
border.color: selectedCategory === modelData ? "transparent" : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.3)
Text {
anchors.centerIn: parent
text: modelData
color: selectedCategory === modelData ? Theme.onPrimary : Theme.surfaceText
font.pixelSize: Theme.fontSizeMedium
font.weight: selectedCategory === modelData ? Font.Medium : Font.Normal
elide: Text.ElideRight
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
selectedCategory = modelData
updateFilteredApps()
}
}
}
}
}
// Bottom row: Media, Office, Settings, System, Utilities (5 items)
Row {
width: parent.width
spacing: Theme.spacingS
property var bottomRowCategories: ["Media", "Office", "Settings", "System", "Utilities"]
Repeater {
model: parent.bottomRowCategories.filter(cat => categories.includes(cat))
Rectangle {
height: 36
width: (parent.width - (parent.bottomRowCategories.length - 1) * Theme.spacingS) / parent.bottomRowCategories.length
radius: Theme.cornerRadiusLarge
color: selectedCategory === modelData ? Theme.primary : "transparent"
border.color: selectedCategory === modelData ? "transparent" : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.3)
Text {
anchors.centerIn: parent
text: modelData
color: selectedCategory === modelData ? Theme.onPrimary : Theme.surfaceText
font.pixelSize: Theme.fontSizeMedium
font.weight: selectedCategory === modelData ? Font.Medium : Font.Normal
elide: Text.ElideRight
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
selectedCategory = modelData
updateFilteredApps()
}
}
}
}
}
}
}
// Search field with view toggle buttons
Row {
width: parent.width width: parent.width
height: categories.length > 1 ? implicitHeight : 0
visible: categories.length > 1
spacing: Theme.spacingM spacing: Theme.spacingM
Repeater { Rectangle {
model: categories id: searchContainer
width: parent.width - 80 - Theme.spacingM // Leave space for view toggle buttons
height: 56
radius: Theme.cornerRadiusLarge
color: Theme.surfaceVariant
border.width: searchField.activeFocus ? 2 : 1
border.color: searchField.activeFocus ? Theme.primary : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.3)
Behavior on border.color { ColorAnimation { duration: Theme.shortDuration; easing.type: Theme.standardEasing } }
Row {
anchors.fill: parent
anchors.leftMargin: Theme.spacingL
anchors.rightMargin: Theme.spacingL
spacing: Theme.spacingM
Text {
anchors.verticalCenter: parent.verticalCenter
text: "search"
font.family: Theme.iconFont
font.pixelSize: Theme.iconSize
color: searchField.activeFocus ? Theme.primary : Theme.surfaceVariantText
}
TextInput {
id: searchField
anchors.verticalCenter: parent.verticalCenter
width: parent.width - parent.spacing - Theme.iconSize - 32
height: parent.height - Theme.spacingS
color: Theme.surfaceText
font.pixelSize: Theme.fontSizeLarge
verticalAlignment: Text.AlignVCenter
focus: spotlightOpen
selectByMouse: true
onTextChanged: updateFilteredApps
Keys.onPressed: {
if(event.key === Qt.Key_Escape) { hide(); event.accepted = true }
else if(event.key === Qt.Key_Return || event.key === Qt.Key_Enter) { launchSelected(); event.accepted = true }
else if(event.key === Qt.Key_Down) { selectNext(); event.accepted = true }
else if(event.key === Qt.Key_Up) { selectPrevious(); event.accepted = true }
else if(event.key === Qt.Key_Right && viewMode === "grid") { selectNextInRow(); event.accepted = true }
else if(event.key === Qt.Key_Left && viewMode === "grid") { selectPreviousInRow(); event.accepted = true }
}
Text {
anchors.verticalCenter: parent.verticalCenter
text: recentApps.length > 0 ? "Search applications or select from recent..." : "Search applications..."
color: Theme.surfaceVariantText
font.pixelSize: Theme.fontSizeLarge
visible: searchField.text.length === 0 && !searchField.activeFocus
}
}
}
}
// View mode toggle buttons next to search bar
Row {
spacing: Theme.spacingXS
visible: filteredModel.count > 0
anchors.verticalCenter: parent.verticalCenter
// List view button
Rectangle { Rectangle {
height: 32 width: 36
width: Math.min(categoryText.implicitWidth + Theme.spacingL * 2, parent.width - Theme.spacingM) height: 36
radius: Theme.cornerRadius radius: Theme.cornerRadiusLarge
color: selectedCategory === modelData ? Theme.primary : "transparent" color: viewMode === "list" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) :
border.color: selectedCategory === modelData ? "transparent" : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.3) listViewArea.containsMouse ? Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.08) : "transparent"
border.color: viewMode === "list" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.3) : "transparent"
border.width: 1 border.width: 1
Text { Text {
id: categoryText
anchors.centerIn: parent anchors.centerIn: parent
text: modelData text: "view_list"
color: selectedCategory === modelData ? Theme.onPrimary : Theme.surfaceText font.family: Theme.iconFont
font.pixelSize: Theme.fontSizeMedium font.pixelSize: 18
font.weight: selectedCategory === modelData ? Font.Medium : Font.Normal color: viewMode === "list" ? Theme.primary : Theme.surfaceText
elide: Text.ElideRight
width: Math.min(implicitWidth, parent.width - Theme.spacingS * 2)
} }
MouseArea { MouseArea {
id: listViewArea
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: viewMode = "list"
selectedCategory = modelData
updateFilteredApps()
}
}
Behavior on color {
ColorAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
} }
} }
}
}
Rectangle {
id: searchContainer
width: parent.width
height: 56
radius: Theme.cornerRadiusLarge
color: Theme.surfaceVariant
border.width: searchField.activeFocus ? 2 : 1
border.color: searchField.activeFocus ? Theme.primary :
Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.3)
Behavior on border.color {
ColorAnimation {
duration: Theme.shortDuration
easing.type: Theme.standardEasing
}
}
Row {
anchors.fill: parent
anchors.leftMargin: Theme.spacingL
anchors.rightMargin: Theme.spacingL
spacing: Theme.spacingM
Text { // Grid view button
anchors.verticalCenter: parent.verticalCenter Rectangle {
text: "search" width: 36
font.family: Theme.iconFont height: 36
font.pixelSize: Theme.iconSize radius: Theme.cornerRadiusLarge
color: searchField.activeFocus ? Theme.primary : Theme.surfaceVariantText color: viewMode === "grid" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) :
font.weight: Theme.iconFontWeight gridViewArea.containsMouse ? Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.08) : "transparent"
} border.color: viewMode === "grid" ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.3) : "transparent"
border.width: 1
TextInput {
id: searchField
anchors.verticalCenter: parent.verticalCenter
width: parent.width - parent.spacing - Theme.iconSize - 32
height: parent.height - Theme.spacingS
color: Theme.surfaceText
font.pixelSize: Theme.fontSizeLarge
verticalAlignment: TextInput.AlignVCenter
focus: spotlightOpen
selectByMouse: true
Text { Text {
anchors.verticalCenter: parent.verticalCenter anchors.centerIn: parent
text: searchField.text.length === 0 ? (recentApps.length > 0 ? "Search applications or select from recent..." : "Search applications...") : "" text: "grid_view"
color: Theme.surfaceVariantText font.family: Theme.iconFont
font.pixelSize: Theme.fontSizeLarge font.pixelSize: 18
visible: searchField.text.length === 0 && !searchField.activeFocus color: viewMode === "grid" ? Theme.primary : Theme.surfaceText
} }
onTextChanged: { MouseArea {
updateFilteredApps() id: gridViewArea
} anchors.fill: parent
hoverEnabled: true
Keys.onPressed: function(event) { cursorShape: Qt.PointingHandCursor
if (event.key === Qt.Key_Escape) { onClicked: viewMode = "grid"
hide()
event.accepted = true
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
launchSelected()
event.accepted = true
} else if (event.key === Qt.Key_Down) {
selectNext()
event.accepted = true
} else if (event.key === Qt.Key_Up) {
selectPrevious()
event.accepted = true
}
} }
} }
} }
} }
Column { // Results container
id: resultsList Rectangle {
id: resultsContainer
width: parent.width width: parent.width
height: filteredApps.length > 0 ? Math.min(filteredApps.length * 60, 320) : 0 height: Math.min(filteredModel.count * (viewMode === "grid" ? 100 : 60), 480)
color: "transparent"
visible: filteredApps.length > 0 // List view
ListView {
Repeater { id: resultsList
anchors.fill: parent
visible: viewMode === "list"
model: filteredModel model: filteredModel
currentIndex: selectedIndex
clip: true
focus: spotlightOpen
interactive: true
flickDeceleration: 8000
maximumFlickVelocity: 15000
Rectangle { // Make mouse wheel scrolling more responsive
width: resultsList.width property real wheelStepSize: 60
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
onWheel: (wheel) => {
var delta = wheel.angleDelta.y
var steps = delta / 120 // Standard wheel step
resultsList.contentY -= steps * resultsList.wheelStepSize
// Ensure we stay within bounds
if (resultsList.contentY < 0) {
resultsList.contentY = 0
} else if (resultsList.contentY > resultsList.contentHeight - resultsList.height) {
resultsList.contentY = Math.max(0, resultsList.contentHeight - resultsList.height)
}
}
}
delegate: Rectangle {
width: parent.width
height: 60 height: 60
radius: Theme.cornerRadius radius: Theme.cornerRadius
color: index === selectedIndex ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) : color: ListView.isCurrentItem ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) :
appMouseArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.06) : listMouseArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.06) : "transparent"
"transparent"
border.color: index === selectedIndex ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.3) : "transparent" Row {
border.width: index === selectedIndex ? 1 : 0
Row {
anchors.fill: parent anchors.fill: parent
anchors.margins: Theme.spacingM anchors.margins: Theme.spacingM
spacing: Theme.spacingL spacing: Theme.spacingL
Rectangle { Rectangle {
width: 40 width: 40
height: 40 height: 40
radius: Theme.cornerRadius radius: Theme.cornerRadius
@@ -404,41 +524,18 @@ PanelWindow {
border.width: 1 border.width: 1
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
IconImage { IconImage {
id: appIcon
anchors.fill: parent anchors.fill: parent
anchors.margins: 4 anchors.margins: 4
source: model.icon ? Quickshell.iconPath(model.icon, "") : "" source: model.icon ? Quickshell.iconPath(model.icon, "") : ""
smooth: true
asynchronous: true
onStatusChanged: {
if (status === Image.Error || status === Image.Null) {
fallbackText.visible = true
} else {
fallbackText.visible = false
}
}
}
Text {
id: fallbackText
anchors.centerIn: parent
text: model.name ? model.name.charAt(0).toUpperCase() : "A"
font.pixelSize: 18
color: Theme.primary
font.weight: Font.Bold
visible: false
} }
} }
Column { Column {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: parent.width - 40 - Theme.spacingL
spacing: 2 spacing: 2
Text { Text {
width: parent.width
text: model.name text: model.name
font.pixelSize: Theme.fontSizeLarge font.pixelSize: Theme.fontSizeLarge
color: Theme.surfaceText color: Theme.surfaceText
@@ -446,63 +543,165 @@ PanelWindow {
elide: Text.ElideRight elide: Text.ElideRight
} }
Text { Text {
width: parent.width text: model.comment
text: model.comment || "Application"
font.pixelSize: Theme.fontSizeMedium font.pixelSize: Theme.fontSizeMedium
color: Theme.surfaceVariantText color: Theme.surfaceVariantText
elide: Text.ElideRight
visible: model.comment && model.comment.length > 0 visible: model.comment && model.comment.length > 0
elide: Text.ElideRight
} }
} }
} }
MouseArea { MouseArea {
id: appMouseArea id: listMouseArea
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onEntered: selectedIndex = index
onClicked: launchApp(model)
}
}
ScrollBar.vertical: ScrollBar { policy: ScrollBar.AlwaysOn }
}
// Grid view
GridView {
id: resultsGrid
// Center the grid within the parent space
anchors.centerIn: parent
width: Math.min(parent.width, baseCellWidth * 6 + 16) // Optimal width for 6 columns plus spacing
height: parent.height
visible: viewMode === "grid"
model: filteredModel
clip: true
focus: spotlightOpen
interactive: true
flickDeceleration: 8000
maximumFlickVelocity: 15000
// Optimized cell sizes for maximum space efficiency - 6 columns
property int baseCellWidth: Math.max(85, Math.min(100, width / 6))
property int baseCellHeight: baseCellWidth + 30
cellWidth: baseCellWidth
cellHeight: baseCellHeight
// Use full width with minimal 2px right margin for scrollbar
leftMargin: 0
rightMargin: 2
topMargin: Theme.spacingXS
bottomMargin: Theme.spacingXS
// Make mouse wheel scrolling more responsive
property real wheelStepSize: 60
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.NoButton
onWheel: (wheel) => {
var delta = wheel.angleDelta.y
var steps = delta / 120 // Standard wheel step
resultsGrid.contentY -= steps * resultsGrid.wheelStepSize
onEntered: { // Ensure we stay within bounds
selectedIndex = index if (resultsGrid.contentY < 0) {
} resultsGrid.contentY = 0
} else if (resultsGrid.contentY > resultsGrid.contentHeight - resultsGrid.height) {
onClicked: { resultsGrid.contentY = Math.max(0, resultsGrid.contentHeight - resultsGrid.height)
launchApp(model)
} }
} }
} }
delegate: Rectangle {
width: resultsGrid.cellWidth - 8
height: resultsGrid.cellHeight - 8
radius: Theme.cornerRadius
color: selectedIndex === index ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.12) :
gridMouseArea.containsMouse ? Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.06) : "transparent"
border.color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.08)
border.width: 1
Column {
anchors.centerIn: parent
spacing: Theme.spacingS
Item {
property int iconSize: Math.min(48, Math.max(32, resultsGrid.cellWidth * 0.55))
width: iconSize
height: iconSize
anchors.horizontalCenter: parent.horizontalCenter
Rectangle {
anchors.fill: parent
radius: Theme.cornerRadius
color: 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: 4
source: model.icon ? Quickshell.iconPath(model.icon, "") : ""
}
}
}
Text {
anchors.horizontalCenter: parent.horizontalCenter
width: resultsGrid.cellWidth - 16
text: model.name
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceText
font.weight: Font.Medium
elide: Text.ElideRight
wrapMode: Text.Wrap
maximumLineCount: 2
horizontalAlignment: Text.AlignHCenter
}
}
MouseArea {
id: gridMouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onEntered: selectedIndex = index
onClicked: launchApp(model)
}
}
ScrollBar.vertical: ScrollBar { policy: ScrollBar.AsNeeded }
} }
} }
} }
} }
IpcHandler { IpcHandler {
target: "spotlight" target: "spotlight"
function open() { function open() {
console.log("SpotlightLauncher: IPC open() called") console.log("SpotlightLauncher: IPC open() called")
spotlightLauncher.show() spotlightLauncher.show()
return "SPOTLIGHT_OPEN_SUCCESS" return "SPOTLIGHT_OPEN_SUCCESS"
} }
function close() { function close() {
console.log("SpotlightLauncher: IPC close() called") console.log("SpotlightLauncher: IPC close() called")
spotlightLauncher.hide() spotlightLauncher.hide()
return "SPOTLIGHT_CLOSE_SUCCESS" return "SPOTLIGHT_CLOSE_SUCCESS"
} }
function toggle() { function toggle() {
console.log("SpotlightLauncher: IPC toggle() called") console.log("SpotlightLauncher: IPC toggle() called")
spotlightLauncher.toggle() spotlightLauncher.toggle()
return "SPOTLIGHT_TOGGLE_SUCCESS" return "SPOTLIGHT_TOGGLE_SUCCESS"
} }
} }
Component.onCompleted: { Component.onCompleted: {
console.log("SpotlightLauncher: Component.onCompleted called - component loaded successfully!") console.log("SpotlightLauncher: Component.onCompleted called - component loaded successfully!")
if (AppSearchService.ready) { if (AppSearchService.ready) {
categories = AppSearchService.getAllCategories() categories = AppSearchService.getAllCategories().filter(cat => cat !== "Education" && cat !== "Science")
} }
} }
} }