solitare/qml/ThrowawayPile.qml

27 lines
849 B
QML
Raw Normal View History

2024-12-04 18:20:06 +00:00
import QtQuick
2024-12-05 00:22:18 +00:00
import Solitare
2024-12-04 18:20:06 +00:00
// The throwaway pile (shows last 3 cards)
Row {
// This allows makes the cards overlap
spacing: -60
Repeater {
model: Math.min(GameState.throwawayPile.length, 3)
2024-12-05 00:22:18 +00:00
delegate: CardModel {
2024-12-04 18:20:06 +00:00
required property int index // passed from repeater
2024-12-05 00:22:18 +00:00
property int reversedIndex: Math.min(GameState.throwawayPile.length, 3) - 1 - index
2024-12-04 18:20:06 +00:00
card: GameState.throwawayPile[GameState.throwawayPile.length - 1 - reversedIndex]
isFaceDown: false
onClicked: {
// Only auto-move the last card in the throwaway pile
// cards below it are shown, but shouldn't have a click effect
if (reversedIndex == 0) {
2024-12-05 00:22:18 +00:00
GameState.autoMoveThrownCard();
2024-12-04 18:20:06 +00:00
}
}
}
}
}