From 9762d7d566ab4901d15f9469e19cd8da3039d59c Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Sun, 1 Dec 2024 01:10:27 +0100 Subject: [PATCH] Add support for face down cards --- Main.qml | 1 + PlayingCard.qml | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Main.qml b/Main.qml index 29ef6a7..f258771 100644 --- a/Main.qml +++ b/Main.qml @@ -20,5 +20,6 @@ ApplicationWindow { PlayingCard { color: "clubs" value: "ace" + isFaceDown: true } } diff --git a/PlayingCard.qml b/PlayingCard.qml index c69f251..3312245 100644 --- a/PlayingCard.qml +++ b/PlayingCard.qml @@ -10,11 +10,15 @@ Item { // anyways, typing these as simple strings is the easiest way to do this. required property string color required property string value + property string backStyle: "red" + property bool isFaceDown: false Image { id: cardImage anchors.fill: parent - source: "qrc:/img/playing_cards/fronts/" + playingCard.color + "_" + playingCard.value + ".svg" + source: playingCard.isFaceDown + ? "qrc:/img/playing_cards/backs/" + playingCard.backStyle + ".svg" + : "qrc:/img/playing_cards/fronts/" + playingCard.color + "_" + playingCard.value + ".svg" fillMode: Image.PreserveAspectFit } }