mirror of
https://invent.kde.org/marcoa/a-la-karte.git
synced 2026-02-09 21:13:08 +00:00
Add a bottom hint bar with keyboard/gamepad hints and controller-specific icons. Also add a UI mode setting (auto/desktop/handheld) to improve the adaptive layout on different form factors.
77 lines
2.1 KiB
QML
77 lines
2.1 KiB
QML
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
// SPDX-FileCopyrightText: 2024 A-La-Karte Contributors
|
|
|
|
import QtQuick
|
|
import QtQuick.Controls as QQC2
|
|
import org.kde.kirigami as Kirigami
|
|
import org.kde.alakarte
|
|
|
|
GridView {
|
|
id: gridView
|
|
|
|
property int cardSize: App.config.gridSize
|
|
|
|
readonly property int cellPadding: cardSize < 180 ? Kirigami.Units.mediumSpacing : Kirigami.Units.largeSpacing
|
|
|
|
cellWidth: cardSize + cellPadding
|
|
cellHeight: Math.round(cardSize * 1.4) + cellPadding
|
|
|
|
clip: true
|
|
focus: true
|
|
keyNavigationEnabled: true
|
|
keyNavigationWraps: false
|
|
activeFocusOnTab: true
|
|
|
|
highlightMoveDuration: Kirigami.Units.shortDuration
|
|
highlightFollowsCurrentItem: true
|
|
|
|
Keys.onUpPressed: navigateUp()
|
|
Keys.onDownPressed: navigateDown()
|
|
Keys.onLeftPressed: navigateLeft()
|
|
Keys.onRightPressed: navigateRight()
|
|
|
|
function navigateUp() {
|
|
if (currentIndex >= columns) {
|
|
currentIndex -= columns
|
|
}
|
|
}
|
|
|
|
function navigateDown() {
|
|
if (currentIndex + columns < count) {
|
|
currentIndex += columns
|
|
}
|
|
}
|
|
|
|
function navigateLeft() {
|
|
if (currentIndex > 0) {
|
|
currentIndex--
|
|
}
|
|
}
|
|
|
|
function navigateRight() {
|
|
if (currentIndex < count - 1) {
|
|
currentIndex++
|
|
}
|
|
}
|
|
|
|
Connections {
|
|
target: GamepadManager
|
|
function onNavigateUp() { if (gridView.activeFocus) gridView.navigateUp() }
|
|
function onNavigateDown() { if (gridView.activeFocus) gridView.navigateDown() }
|
|
function onNavigateLeft() { if (gridView.activeFocus) gridView.navigateLeft() }
|
|
function onNavigateRight() { if (gridView.activeFocus) gridView.navigateRight() }
|
|
function onSelectPressed() {
|
|
if (gridView.activeFocus && gridView.currentItem) {
|
|
if (gridView.currentItem.play) {
|
|
gridView.currentItem.play()
|
|
} else {
|
|
gridView.currentItem.clicked()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
readonly property int columns: Math.max(1, Math.floor(width / cellWidth))
|
|
|
|
QQC2.ScrollBar.vertical: QQC2.ScrollBar {}
|
|
}
|