1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-13 00:42:49 -05:00

launcher: re-create grid on open

This commit is contained in:
bbedward
2025-11-18 18:50:42 -05:00
parent 6ef9ddd4f3
commit 208d92aa06
5 changed files with 100 additions and 81 deletions

View File

@@ -61,7 +61,6 @@ PanelWindow {
} }
function close() { function close() {
console.log("DankModal.close() called on:", layerNamespace, "Stack trace:", new Error().stack)
shouldBeVisible = false shouldBeVisible = false
shouldHaveFocus = false shouldHaveFocus = false
closeTimer.restart() closeTimer.restart()

View File

@@ -139,7 +139,7 @@ Rectangle {
} }
StyledText { StyledText {
text: UserInfoService.hostname || "Linux" text: DgopService.hostname || "DMS"
font.pixelSize: Theme.fontSizeMedium font.pixelSize: Theme.fontSizeMedium
color: Theme.surfaceVariantText color: Theme.surfaceVariantText
elide: Text.ElideRight elide: Text.ElideRight

View File

@@ -12,7 +12,9 @@ Rectangle {
function resetScroll() { function resetScroll() {
resultsList.contentY = 0 resultsList.contentY = 0
resultsGrid.contentY = 0 if (gridLoader.item) {
gridLoader.item.contentY = 0
}
} }
radius: Theme.cornerRadius radius: Theme.cornerRadius
@@ -92,88 +94,106 @@ Rectangle {
} }
} }
DankGridView { Loader {
id: resultsGrid id: gridLoader
property int currentIndex: appLauncher ? appLauncher.selectedIndex : -1 property real _lastWidth: 0
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
}
anchors.fill: parent anchors.fill: parent
anchors.margins: Theme.spacingS anchors.margins: Theme.spacingS
visible: appLauncher && appLauncher.viewMode === "grid" visible: appLauncher && appLauncher.viewMode === "grid"
model: appLauncher ? appLauncher.model : null active: appLauncher && appLauncher.viewMode === "grid"
clip: true onWidthChanged: {
cellWidth: baseCellWidth if (visible && Math.abs(width - _lastWidth) > 1) {
cellHeight: baseCellHeight _lastWidth = width
leftMargin: Math.max(Theme.spacingS, remainingSpace / 2) active = false
rightMargin: leftMargin Qt.callLater(() => {
focus: true active = true
interactive: true })
cacheBuffer: Math.max(0, Math.min(height * 2, 1000)) }
reuseItems: true }
onCurrentIndexChanged: { sourceComponent: Component {
if (keyboardNavigationActive) DankGridView {
ensureVisible(currentIndex) id: resultsGrid
}
onItemClicked: (index, modelData) => { property int currentIndex: appLauncher ? appLauncher.selectedIndex : -1
if (appLauncher) property int columns: appLauncher ? appLauncher.gridColumns : 4
appLauncher.launchApp(modelData) property bool adaptiveColumns: false
} property int minCellWidth: 120
onItemRightClicked: (index, modelData, mouseX, mouseY) => { property int maxCellWidth: 160
if (contextMenu) property int cellPadding: 8
contextMenu.show(mouseX, mouseY, modelData) property real iconSizeRatio: 0.55
} property int maxIconSize: 48
onKeyboardNavigationReset: () => { property int minIconSize: 32
if (appLauncher) property bool hoverUpdatesSelection: false
appLauncher.keyboardNavigationActive = 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
delegate: AppLauncherGridDelegate { property int actualColumns: adaptiveColumns ? Math.floor(width / cellWidth) : columns
gridView: resultsGrid property int remainingSpace: width - (actualColumns * cellWidth)
cellWidth: resultsGrid.cellWidth
cellHeight: resultsGrid.cellHeight signal keyboardNavigationReset
cellPadding: resultsGrid.cellPadding signal itemClicked(int index, var modelData)
minIconSize: resultsGrid.minIconSize signal itemRightClicked(int index, var modelData, real mouseX, real mouseY)
maxIconSize: resultsGrid.maxIconSize
iconSizeRatio: resultsGrid.iconSizeRatio function ensureVisible(index) {
hoverUpdatesSelection: resultsGrid.hoverUpdatesSelection if (index < 0 || index >= count)
keyboardNavigationActive: resultsGrid.keyboardNavigationActive return
currentIndex: resultsGrid.currentIndex
onItemClicked: (idx, modelData) => resultsGrid.itemClicked(idx, modelData) const itemY = Math.floor(index / actualColumns) * cellHeight
onItemRightClicked: (idx, modelData, mouseX, mouseY) => { const itemBottom = itemY + cellHeight
const modalPos = resultsContainer.parent.mapFromItem(null, mouseX, mouseY) if (itemY < contentY)
resultsGrid.itemRightClicked(idx, modelData, modalPos.x, modalPos.y) 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
} }
} }
} }

View File

@@ -765,7 +765,7 @@
"Enter password for ": "パスワードを入力" "Enter password for ": "パスワードを入力"
}, },
"Enter this passkey on ": { "Enter this passkey on ": {
"Enter this passkey on ": "" "Enter this passkey on ": "ここでパスキーを入力してください "
}, },
"Error": { "Error": {
"Error": "エラー" "Error": "エラー"

View File

@@ -765,7 +765,7 @@
"Enter password for ": "输入密码" "Enter password for ": "输入密码"
}, },
"Enter this passkey on ": { "Enter this passkey on ": {
"Enter this passkey on ": "" "Enter this passkey on ": "在该处输入此通行密钥 "
}, },
"Error": { "Error": {
"Error": "错误" "Error": "错误"