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
VERSION 1.0
QML_FILES
Main.qml
QML_FILES ScoreBar.qml
QML_FILES CardModel.qml
QML_FILES Tableau.qml
QML_FILES ThrowawayPile.qml
QML_FILES DrawPile.qml
QML_FILES FoundationPiles.qml
SOURCES playingcard.h playingcard.cpp
SOURCES gamestate.h gamestate.cpp
SOURCES columnslot.h columnslot.cpp
qml/Main.qml
qml/CardModel.qml
qml/DrawPile.qml
qml/FoundationPiles.qml
qml/ScoreBar.qml
qml/Tableau.qml
qml/ThrowawayPile.qml
SOURCES
playingcard.h playingcard.cpp
gamestate.h gamestate.cpp
columnslot.h columnslot.cpp
)
# 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 Solitare
// Shows the top card facing down
// (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
isFaceDown: GameState.drawPile.length > 0 ? true : false
onClicked: {
GameState.drawNextCard()
GameState.drawNextCard();
}
}

View file

@ -1,4 +1,5 @@
import QtQuick
import Solitare
Row {
spacing: 15
@ -6,7 +7,7 @@ Row {
Repeater {
model: 4 // Each of the 4 suits
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
isFaceDown: false
}

View file

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

View file

@ -1,4 +1,5 @@
import QtQuick
import Solitare
// 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
Repeater {
model: GameState.columns[parent.index].length > 0
? GameState.columns[parent.index].length
: 1 // Render an empty slot for an empty column
model: GameState.columns[parent.index].length > 0 ? GameState.columns[parent.index].length : 1 // Render an empty slot for an empty column
delegate: CardModel {
required property int index
property ColumnSlot col: GameState.columns[parent.index].length > 0
? GameState.columns[parent.index][index]
: null // empty column (single empty slot)
property ColumnSlot col: GameState.columns[parent.index].length > 0 ? GameState.columns[parent.index][index] : null // empty column (single empty slot)
card: col ? col.card : null
isFaceDown: col ? !col.revealed : false
onClicked: {
if (col && col.revealed) {
GameState.autoMoveColumnCard(parent.index, index)
GameState.autoMoveColumnCard(parent.index, index);
}
}
}

View file

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