solitare/Main.qml

81 lines
2.3 KiB
QML
Raw Normal View History

2024-12-01 18:43:49 +00:00
import Solitare
2024-11-30 18:23:45 +00:00
import QtQuick
2024-11-30 19:56:20 +00:00
import QtQuick.Controls
import QtQuick.Layouts
2024-11-30 18:23:45 +00:00
2024-11-30 19:56:20 +00:00
ApplicationWindow {
width: 800
height: 600
2024-11-30 18:23:45 +00:00
visible: true
title: qsTr("Solitaire")
2024-11-30 19:56:20 +00:00
ScoreBar {
id: scoreBar
height: 50
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
2024-11-30 19:56:20 +00:00
}
2024-12-01 00:01:37 +00:00
// Show the foundation piles, throwaway pile & the draw stack on the first row
Item {
height: 120
anchors.top: scoreBar.bottom
anchors.left: parent.left
anchors.right: parent.right
Row {
spacing: 0
anchors.fill: parent
anchors.margins: 10
// Left row (with the foundation piles)
Row {
spacing: 15
anchors.left: parent.left
Repeater {
model: 4 // Each of the 4 suits
CardModel {
required property int index; // passed from repeater
card: gameState.foundation[index].length > 0 ? gameState.foundation[index] : null
isFaceDown: false
}
}
}
// Spacer to push the second row to the right
Item {
Layout.fillWidth: true
}
// Right row (with throwaway and draw piles)
Row {
spacing: 20
anchors.right: parent.right
// Throwaway pile (last 3 cards visible with overlap)
Row {
// This allows makes the cards overlap
spacing: -60
Repeater {
model: Math.min(gameState.throwawayPile.length, 3)
delegate: CardModel {
required property int index // passed from repeater
card: gameState.throwawayPile[gameState.throwawayPile.length - 1 - index]
isFaceDown: false
}
}
}
// Draw pile (only the top card is shown)
CardModel {
card: gameState.drawPile.length > 0 ? gameState.drawPile[gameState.drawPile.length - 1] : null
isFaceDown: true
}
}
}
2024-12-01 00:01:37 +00:00
}
2024-11-30 18:23:45 +00:00
}