diff --git a/CMakeLists.txt b/CMakeLists.txt index 54c2036..91e1721 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,7 @@ qt_add_qml_module(appSolitare QML_FILES CardModel.qml QML_FILES Tableau.qml QML_FILES ThrowawayPile.qml + QML_FILES DrawPile.qml SOURCES playingcard.h playingcard.cpp SOURCES gamestate.h gamestate.cpp SOURCES columnslot.h columnslot.cpp diff --git a/DrawPile.qml b/DrawPile.qml new file mode 100644 index 0000000..978dacf --- /dev/null +++ b/DrawPile.qml @@ -0,0 +1,12 @@ +import QtQuick + +// Shows the top card facing down +// (or a blank card if the pile is empty) + +CardModel { + card: GameState.drawPile.length > 0 ? GameState.drawPile[GameState.drawPile.length - 1] : null + isFaceDown: GameState.drawPile.length > 0 ? true : false + onClicked: { + GameState.drawNextCard() + } +} diff --git a/Main.qml b/Main.qml index b78460f..52b362e 100644 --- a/Main.qml +++ b/Main.qml @@ -55,15 +55,7 @@ ApplicationWindow { anchors.right: parent.right ThrowawayPile {} - - // Draw pile (only the top card is shown) - CardModel { - card: GameState.drawPile.length > 0 ? GameState.drawPile[GameState.drawPile.length - 1] : null - isFaceDown: GameState.drawPile.length > 0 ? true : false - onClicked: { - GameState.drawNextCard() - } - } + DrawPile {} } } }