2024-12-01 00:01:37 +00:00
|
|
|
import QtQuick
|
|
|
|
|
|
|
|
Item {
|
2024-12-01 18:43:49 +00:00
|
|
|
id: cardModel
|
2024-12-02 14:35:37 +00:00
|
|
|
width: 80
|
2024-12-01 00:01:37 +00:00
|
|
|
height: width * 1.4 // Maintian the aspect ratio of a playing card
|
|
|
|
|
2024-12-01 18:43:49 +00:00
|
|
|
required property PlayingCard card;
|
2024-12-01 21:36:01 +00:00
|
|
|
required property bool isFaceDown;
|
2024-12-01 18:43:49 +00:00
|
|
|
property string backStyle: "red"
|
2024-12-02 18:30:47 +00:00
|
|
|
signal clicked();
|
2024-12-01 18:43:49 +00:00
|
|
|
|
2024-12-01 00:01:37 +00:00
|
|
|
Image {
|
|
|
|
id: cardImage
|
|
|
|
anchors.fill: parent
|
2024-12-01 21:36:01 +00:00
|
|
|
source: cardModel.isFaceDown
|
2024-12-01 18:43:49 +00:00
|
|
|
? "qrc:/img/playing_cards/backs/" + cardModel.backStyle + ".svg"
|
2024-12-02 14:35:37 +00:00
|
|
|
: cardModel.card
|
|
|
|
? "qrc:/img/playing_cards/fronts/" + cardModel.card.suitString + "_" + cardModel.card.valueString + ".svg"
|
|
|
|
: "qrc:/img/playing_cards/backs/blue.svg"
|
2024-12-01 00:01:37 +00:00
|
|
|
fillMode: Image.PreserveAspectFit
|
2024-12-02 18:30:47 +00:00
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: cardModel.clicked()
|
|
|
|
}
|
2024-12-01 00:01:37 +00:00
|
|
|
}
|
|
|
|
}
|