diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f2ab2c..54c2036 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ qt_add_qml_module(appSolitare QML_FILES ScoreBar.qml QML_FILES CardModel.qml QML_FILES Tableau.qml + QML_FILES ThrowawayPile.qml SOURCES playingcard.h playingcard.cpp SOURCES gamestate.h gamestate.cpp SOURCES columnslot.h columnslot.cpp diff --git a/Main.qml b/Main.qml index f2fadaf..b78460f 100644 --- a/Main.qml +++ b/Main.qml @@ -54,28 +54,7 @@ ApplicationWindow { spacing: 20 anchors.right: parent.right - // Throwaway pile (last 3 cards visible with overlap) - Row { - // This allows makes the cards overlap - spacing: -60 - - Repeater { - 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; - 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() - } - } - } - } - } + ThrowawayPile {} // Draw pile (only the top card is shown) CardModel { diff --git a/ThrowawayPile.qml b/ThrowawayPile.qml new file mode 100644 index 0000000..f73b750 --- /dev/null +++ b/ThrowawayPile.qml @@ -0,0 +1,25 @@ +import QtQuick + +// The throwaway pile (shows last 3 cards) + +Row { + // This allows makes the cards overlap + spacing: -60 + + Repeater { + 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; + 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() + } + } + } + } +}