solitare/CardModel.qml
ItsDrike 868699979d
Improve PlayingCard class
- Move to using enums to represent the suit & value
- This changes the badly named color to more appropriate suit.
- Add createDeck static method
2024-12-01 21:17:45 +01:00

25 lines
823 B
QML

import Solitare
import QtQuick
Item {
id: cardModel
width: 100
height: width * 1.4 // Maintian the aspect ratio of a playing card
required property PlayingCard card;
property string backStyle: "red"
// 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
source: cardModel.card.isFaceDown
? "qrc:/img/playing_cards/backs/" + cardModel.backStyle + ".svg"
: "qrc:/img/playing_cards/fronts/" + cardModel.card.suitString + "_" + cardModel.card.valueString + ".svg"
fillMode: Image.PreserveAspectFit
}
}