2024-12-05 00:22:18 +00:00
|
|
|
import QtQuick
|
|
|
|
import Solitare
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: cardModel
|
|
|
|
|
|
|
|
required property PlayingCard card
|
|
|
|
required property bool isFaceDown
|
|
|
|
property string backStyle: "red"
|
2024-12-05 02:24:09 +00:00
|
|
|
|
2024-12-05 00:22:18 +00:00
|
|
|
signal clicked
|
|
|
|
|
2024-12-05 02:24:09 +00:00
|
|
|
width: 80
|
|
|
|
height: width * 1.4 // Maintian the aspect ratio of a playing card
|
|
|
|
|
2024-12-05 00:22:18 +00:00
|
|
|
Image {
|
|
|
|
id: cardImage
|
2024-12-05 02:24:09 +00:00
|
|
|
|
2024-12-05 00:22:18 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
source: cardModel.isFaceDown ? "qrc:/img/playing_cards/backs/" + cardModel.backStyle + ".svg" : cardModel.card ? "qrc:/img/playing_cards/fronts/" + cardModel.card.suitString + "_" + cardModel.card.valueString + ".svg" : "qrc:/img/playing_cards/backs/blue.svg"
|
2024-12-09 19:57:48 +00:00
|
|
|
|
|
|
|
// This makes sure the SVG scales properly, otherwise it would
|
|
|
|
// attempt to scale the image from the original source size, which
|
|
|
|
// can end up being blurry.
|
|
|
|
sourceSize: Qt.size(width, height)
|
2024-12-05 00:22:18 +00:00
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: cardModel.clicked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|