2024-12-01 18:43:49 +00:00
|
|
|
import Solitare
|
2024-12-01 00:01:37 +00:00
|
|
|
import QtQuick
|
|
|
|
|
|
|
|
Item {
|
2024-12-01 18:43:49 +00:00
|
|
|
id: cardModel
|
2024-12-01 00:01:37 +00:00
|
|
|
width: 100
|
|
|
|
height: width * 1.4 // Maintian the aspect ratio of a playing card
|
|
|
|
|
2024-12-01 18:43:49 +00:00
|
|
|
required property PlayingCard card;
|
|
|
|
property string backStyle: "red"
|
|
|
|
|
2024-12-01 00:01:37 +00:00
|
|
|
// Annoyingly, there is no easy way to make this type-safe, QML does have enums
|
|
|
|
// but they only act as ints, and since we need the string names for the img paths
|
|
|
|
// anyways, typing these as simple strings is the easiest way to do this.
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: cardImage
|
|
|
|
anchors.fill: parent
|
2024-12-01 18:43:49 +00:00
|
|
|
source: cardModel.card.isFaceDown
|
|
|
|
? "qrc:/img/playing_cards/backs/" + cardModel.backStyle + ".svg"
|
|
|
|
: "qrc:/img/playing_cards/fronts/" + cardModel.card.color + "_" + cardModel.card.value + ".svg"
|
2024-12-01 00:01:37 +00:00
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
}
|
|
|
|
}
|