From 208d92aa0667aeafc03d2d7d787673af760919f8 Mon Sep 17 00:00:00 2001 From: bbedward Date: Tue, 18 Nov 2025 18:50:42 -0500 Subject: [PATCH] launcher: re-create grid on open --- quickshell/Modals/Common/DankModal.qml | 1 - quickshell/Modals/Settings/ProfileSection.qml | 2 +- .../Modals/Spotlight/SpotlightResults.qml | 174 ++++++++++-------- quickshell/translations/poexports/ja.json | 2 +- quickshell/translations/poexports/zh_CN.json | 2 +- 5 files changed, 100 insertions(+), 81 deletions(-) diff --git a/quickshell/Modals/Common/DankModal.qml b/quickshell/Modals/Common/DankModal.qml index 7b8b36cd..06c6fb9d 100644 --- a/quickshell/Modals/Common/DankModal.qml +++ b/quickshell/Modals/Common/DankModal.qml @@ -61,7 +61,6 @@ PanelWindow { } function close() { - console.log("DankModal.close() called on:", layerNamespace, "Stack trace:", new Error().stack) shouldBeVisible = false shouldHaveFocus = false closeTimer.restart() diff --git a/quickshell/Modals/Settings/ProfileSection.qml b/quickshell/Modals/Settings/ProfileSection.qml index 881e7243..a1bd6bcf 100644 --- a/quickshell/Modals/Settings/ProfileSection.qml +++ b/quickshell/Modals/Settings/ProfileSection.qml @@ -139,7 +139,7 @@ Rectangle { } StyledText { - text: UserInfoService.hostname || "Linux" + text: DgopService.hostname || "DMS" font.pixelSize: Theme.fontSizeMedium color: Theme.surfaceVariantText elide: Text.ElideRight diff --git a/quickshell/Modals/Spotlight/SpotlightResults.qml b/quickshell/Modals/Spotlight/SpotlightResults.qml index f46b3a5e..baeb9f3c 100644 --- a/quickshell/Modals/Spotlight/SpotlightResults.qml +++ b/quickshell/Modals/Spotlight/SpotlightResults.qml @@ -12,7 +12,9 @@ Rectangle { function resetScroll() { resultsList.contentY = 0 - resultsGrid.contentY = 0 + if (gridLoader.item) { + gridLoader.item.contentY = 0 + } } radius: Theme.cornerRadius @@ -92,88 +94,106 @@ Rectangle { } } - DankGridView { - id: resultsGrid + Loader { + id: gridLoader - property int currentIndex: appLauncher ? appLauncher.selectedIndex : -1 - property int columns: appLauncher ? appLauncher.gridColumns : 4 - property bool adaptiveColumns: false - property int minCellWidth: 120 - property int maxCellWidth: 160 - property int cellPadding: 8 - property real iconSizeRatio: 0.55 - property int maxIconSize: 48 - property int minIconSize: 32 - property bool hoverUpdatesSelection: false - property bool keyboardNavigationActive: appLauncher ? appLauncher.keyboardNavigationActive : false - property int baseCellWidth: adaptiveColumns ? Math.max(minCellWidth, Math.min(maxCellWidth, width / columns)) : (width - Theme.spacingS * 2) / columns - property int baseCellHeight: baseCellWidth + 20 - property int actualColumns: adaptiveColumns ? Math.floor(width / cellWidth) : columns - property int remainingSpace: width - (actualColumns * cellWidth) - - signal keyboardNavigationReset - signal itemClicked(int index, var modelData) - signal itemRightClicked(int index, var modelData, real mouseX, real mouseY) - - function ensureVisible(index) { - if (index < 0 || index >= count) - return - - const itemY = Math.floor(index / actualColumns) * cellHeight - const itemBottom = itemY + cellHeight - if (itemY < contentY) - contentY = itemY - else if (itemBottom > contentY + height) - contentY = itemBottom - height - } + property real _lastWidth: 0 anchors.fill: parent anchors.margins: Theme.spacingS visible: appLauncher && appLauncher.viewMode === "grid" - model: appLauncher ? appLauncher.model : null - clip: true - cellWidth: baseCellWidth - cellHeight: baseCellHeight - leftMargin: Math.max(Theme.spacingS, remainingSpace / 2) - rightMargin: leftMargin - focus: true - interactive: true - cacheBuffer: Math.max(0, Math.min(height * 2, 1000)) - reuseItems: true - onCurrentIndexChanged: { - if (keyboardNavigationActive) - ensureVisible(currentIndex) - } - onItemClicked: (index, modelData) => { - if (appLauncher) - appLauncher.launchApp(modelData) - } - onItemRightClicked: (index, modelData, mouseX, mouseY) => { - if (contextMenu) - contextMenu.show(mouseX, mouseY, modelData) - } - onKeyboardNavigationReset: () => { - if (appLauncher) - appLauncher.keyboardNavigationActive = false - } - - delegate: AppLauncherGridDelegate { - gridView: resultsGrid - cellWidth: resultsGrid.cellWidth - cellHeight: resultsGrid.cellHeight - cellPadding: resultsGrid.cellPadding - minIconSize: resultsGrid.minIconSize - maxIconSize: resultsGrid.maxIconSize - iconSizeRatio: resultsGrid.iconSizeRatio - hoverUpdatesSelection: resultsGrid.hoverUpdatesSelection - keyboardNavigationActive: resultsGrid.keyboardNavigationActive - currentIndex: resultsGrid.currentIndex - onItemClicked: (idx, modelData) => resultsGrid.itemClicked(idx, modelData) - onItemRightClicked: (idx, modelData, mouseX, mouseY) => { - const modalPos = resultsContainer.parent.mapFromItem(null, mouseX, mouseY) - resultsGrid.itemRightClicked(idx, modelData, modalPos.x, modalPos.y) + active: appLauncher && appLauncher.viewMode === "grid" + onWidthChanged: { + if (visible && Math.abs(width - _lastWidth) > 1) { + _lastWidth = width + active = false + Qt.callLater(() => { + active = true + }) + } + } + sourceComponent: Component { + DankGridView { + id: resultsGrid + + property int currentIndex: appLauncher ? appLauncher.selectedIndex : -1 + property int columns: appLauncher ? appLauncher.gridColumns : 4 + property bool adaptiveColumns: false + property int minCellWidth: 120 + property int maxCellWidth: 160 + property int cellPadding: 8 + property real iconSizeRatio: 0.55 + property int maxIconSize: 48 + property int minIconSize: 32 + property bool hoverUpdatesSelection: false + property bool keyboardNavigationActive: appLauncher ? appLauncher.keyboardNavigationActive : false + property int baseCellWidth: adaptiveColumns ? Math.max(minCellWidth, Math.min(maxCellWidth, width / columns)) : (width - Theme.spacingS * 2) / columns + property int baseCellHeight: baseCellWidth + 20 + property int actualColumns: adaptiveColumns ? Math.floor(width / cellWidth) : columns + property int remainingSpace: width - (actualColumns * cellWidth) + + signal keyboardNavigationReset + signal itemClicked(int index, var modelData) + signal itemRightClicked(int index, var modelData, real mouseX, real mouseY) + + function ensureVisible(index) { + if (index < 0 || index >= count) + return + + const itemY = Math.floor(index / actualColumns) * cellHeight + const itemBottom = itemY + cellHeight + if (itemY < contentY) + contentY = itemY + else if (itemBottom > contentY + height) + contentY = itemBottom - height + } + + model: appLauncher ? appLauncher.model : null + clip: true + cellWidth: baseCellWidth + cellHeight: baseCellHeight + leftMargin: Math.max(Theme.spacingS, remainingSpace / 2) + rightMargin: leftMargin + focus: true + interactive: true + cacheBuffer: Math.max(0, Math.min(height * 2, 1000)) + reuseItems: true + onCurrentIndexChanged: { + if (keyboardNavigationActive) + ensureVisible(currentIndex) + } + onItemClicked: (index, modelData) => { + if (appLauncher) + appLauncher.launchApp(modelData) + } + onItemRightClicked: (index, modelData, mouseX, mouseY) => { + if (contextMenu) + contextMenu.show(mouseX, mouseY, modelData) + } + onKeyboardNavigationReset: () => { + if (appLauncher) + appLauncher.keyboardNavigationActive = false + } + + delegate: AppLauncherGridDelegate { + gridView: resultsGrid + cellWidth: resultsGrid.cellWidth + cellHeight: resultsGrid.cellHeight + cellPadding: resultsGrid.cellPadding + minIconSize: resultsGrid.minIconSize + maxIconSize: resultsGrid.maxIconSize + iconSizeRatio: resultsGrid.iconSizeRatio + hoverUpdatesSelection: resultsGrid.hoverUpdatesSelection + keyboardNavigationActive: resultsGrid.keyboardNavigationActive + currentIndex: resultsGrid.currentIndex + onItemClicked: (idx, modelData) => resultsGrid.itemClicked(idx, modelData) + onItemRightClicked: (idx, modelData, mouseX, mouseY) => { + const modalPos = resultsContainer.parent.mapFromItem(null, mouseX, mouseY) + resultsGrid.itemRightClicked(idx, modelData, modalPos.x, modalPos.y) + } + onKeyboardNavigationReset: resultsGrid.keyboardNavigationReset + } } - onKeyboardNavigationReset: resultsGrid.keyboardNavigationReset } } } diff --git a/quickshell/translations/poexports/ja.json b/quickshell/translations/poexports/ja.json index 5ab4bf01..c0638524 100644 --- a/quickshell/translations/poexports/ja.json +++ b/quickshell/translations/poexports/ja.json @@ -765,7 +765,7 @@ "Enter password for ": "パスワードを入力" }, "Enter this passkey on ": { - "Enter this passkey on ": "" + "Enter this passkey on ": "ここでパスキーを入力してください " }, "Error": { "Error": "エラー" diff --git a/quickshell/translations/poexports/zh_CN.json b/quickshell/translations/poexports/zh_CN.json index 87c1ebfd..160b73f3 100644 --- a/quickshell/translations/poexports/zh_CN.json +++ b/quickshell/translations/poexports/zh_CN.json @@ -765,7 +765,7 @@ "Enter password for ": "输入密码" }, "Enter this passkey on ": { - "Enter this passkey on ": "" + "Enter this passkey on ": "在该处输入此通行密钥 " }, "Error": { "Error": "错误"