Move all qml files to qml/ dir

This commit is contained in:
ItsDrike 2024-12-05 01:22:18 +01:00
parent 26561ec350
commit cb75fde6d7
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
9 changed files with 49 additions and 50 deletions

View file

@ -19,16 +19,17 @@ qt_add_qml_module(appSolitare
URI Solitare URI Solitare
VERSION 1.0 VERSION 1.0
QML_FILES QML_FILES
Main.qml qml/Main.qml
QML_FILES ScoreBar.qml qml/CardModel.qml
QML_FILES CardModel.qml qml/DrawPile.qml
QML_FILES Tableau.qml qml/FoundationPiles.qml
QML_FILES ThrowawayPile.qml qml/ScoreBar.qml
QML_FILES DrawPile.qml qml/Tableau.qml
QML_FILES FoundationPiles.qml qml/ThrowawayPile.qml
SOURCES playingcard.h playingcard.cpp SOURCES
SOURCES gamestate.h gamestate.cpp playingcard.h playingcard.cpp
SOURCES columnslot.h columnslot.cpp gamestate.h gamestate.cpp
columnslot.h columnslot.cpp
) )
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.

View file

@ -1,28 +0,0 @@
import QtQuick
Item {
id: cardModel
width: 80
height: width * 1.4 // Maintian the aspect ratio of a playing card
required property PlayingCard card;
required property bool isFaceDown;
property string backStyle: "red"
signal clicked();
Image {
id: cardImage
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"
fillMode: Image.PreserveAspectFit
MouseArea {
anchors.fill: parent
onClicked: cardModel.clicked()
}
}
}

25
qml/CardModel.qml Normal file
View file

@ -0,0 +1,25 @@
import QtQuick
import Solitare
Item {
id: cardModel
width: 80
height: width * 1.4 // Maintian the aspect ratio of a playing card
required property PlayingCard card
required property bool isFaceDown
property string backStyle: "red"
signal clicked
Image {
id: cardImage
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"
fillMode: Image.PreserveAspectFit
MouseArea {
anchors.fill: parent
onClicked: cardModel.clicked()
}
}
}

View file

@ -1,4 +1,5 @@
import QtQuick import QtQuick
import Solitare
// Shows the top card facing down // Shows the top card facing down
// (or a blank card if the pile is empty) // (or a blank card if the pile is empty)
@ -7,6 +8,6 @@ CardModel {
card: GameState.drawPile.length > 0 ? GameState.drawPile[GameState.drawPile.length - 1] : null card: GameState.drawPile.length > 0 ? GameState.drawPile[GameState.drawPile.length - 1] : null
isFaceDown: GameState.drawPile.length > 0 ? true : false isFaceDown: GameState.drawPile.length > 0 ? true : false
onClicked: { onClicked: {
GameState.drawNextCard() GameState.drawNextCard();
} }
} }

View file

@ -1,4 +1,5 @@
import QtQuick import QtQuick
import Solitare
Row { Row {
spacing: 15 spacing: 15
@ -6,7 +7,7 @@ Row {
Repeater { Repeater {
model: 4 // Each of the 4 suits model: 4 // Each of the 4 suits
CardModel { CardModel {
required property int index; // passed from repeater required property int index // passed from repeater
card: GameState.foundation[index].length > 0 ? GameState.foundation[index][0] : null card: GameState.foundation[index].length > 0 ? GameState.foundation[index][0] : null
isFaceDown: false isFaceDown: false
} }

View file

@ -1,6 +1,7 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import Solitare
ApplicationWindow { ApplicationWindow {
width: 750 width: 750

View file

@ -1,4 +1,5 @@
import QtQuick import QtQuick
import Solitare
// In solitare, Tableau refers to the part of the board where all of the columns are placed // In solitare, Tableau refers to the part of the board where all of the columns are placed
@ -13,20 +14,16 @@ Row {
spacing: -80 // Overlap spacing: -80 // Overlap
Repeater { Repeater {
model: GameState.columns[parent.index].length > 0 model: GameState.columns[parent.index].length > 0 ? GameState.columns[parent.index].length : 1 // Render an empty slot for an empty column
? GameState.columns[parent.index].length
: 1 // Render an empty slot for an empty column
delegate: CardModel { delegate: CardModel {
required property int index required property int index
property ColumnSlot col: GameState.columns[parent.index].length > 0 property ColumnSlot col: GameState.columns[parent.index].length > 0 ? GameState.columns[parent.index][index] : null // empty column (single empty slot)
? GameState.columns[parent.index][index]
: null // empty column (single empty slot)
card: col ? col.card : null card: col ? col.card : null
isFaceDown: col ? !col.revealed : false isFaceDown: col ? !col.revealed : false
onClicked: { onClicked: {
if (col && col.revealed) { if (col && col.revealed) {
GameState.autoMoveColumnCard(parent.index, index) GameState.autoMoveColumnCard(parent.index, index);
} }
} }
} }

View file

@ -1,4 +1,5 @@
import QtQuick import QtQuick
import Solitare
// The throwaway pile (shows last 3 cards) // The throwaway pile (shows last 3 cards)
@ -10,14 +11,14 @@ Row {
model: Math.min(GameState.throwawayPile.length, 3) model: Math.min(GameState.throwawayPile.length, 3)
delegate: CardModel { delegate: CardModel {
required property int index // passed from repeater required property int index // passed from repeater
property int reversedIndex: Math.min(GameState.throwawayPile.length, 3) - 1 - index; property int reversedIndex: Math.min(GameState.throwawayPile.length, 3) - 1 - index
card: GameState.throwawayPile[GameState.throwawayPile.length - 1 - reversedIndex] card: GameState.throwawayPile[GameState.throwawayPile.length - 1 - reversedIndex]
isFaceDown: false isFaceDown: false
onClicked: { onClicked: {
// Only auto-move the last card in the throwaway pile // Only auto-move the last card in the throwaway pile
// cards below it are shown, but shouldn't have a click effect // cards below it are shown, but shouldn't have a click effect
if (reversedIndex == 0) { if (reversedIndex == 0) {
GameState.autoMoveThrownCard() GameState.autoMoveThrownCard();
} }
} }
} }