From 7496e79e8c988e98df7f38650f91e0c4a70a9890 Mon Sep 17 00:00:00 2001 From: BruebachL <44814898+BruebachL@users.noreply.github.com> Date: Sun, 5 Jan 2025 23:57:37 +0100 Subject: [PATCH] Add a button to swap the card between mainboard and sideboard to the DeckEditor (#5175) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add a button to swap the card between mainboard and sideboard to the deck editor. * Add new icon to cockatrice.qrc and force update. --------- Co-authored-by: Lukas BrĂ¼bach --- cockatrice/cockatrice.qrc | 1 + cockatrice/resources/icons/swap.svg | 12 ++++++++++++ cockatrice/src/client/tabs/tab_deck_editor.cpp | 10 +++++++++- cockatrice/src/client/tabs/tab_deck_editor.h | 2 +- 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 cockatrice/resources/icons/swap.svg diff --git a/cockatrice/cockatrice.qrc b/cockatrice/cockatrice.qrc index c93499cf3..c9bd6d2bb 100644 --- a/cockatrice/cockatrice.qrc +++ b/cockatrice/cockatrice.qrc @@ -29,6 +29,7 @@ resources/icons/search.svg resources/icons/settings.svg resources/icons/spectator.svg + resources/icons/swap.svg resources/icons/sync.svg resources/icons/tab_changed.svg resources/icons/update.png diff --git a/cockatrice/resources/icons/swap.svg b/cockatrice/resources/icons/swap.svg new file mode 100644 index 000000000..a18ca2f06 --- /dev/null +++ b/cockatrice/resources/icons/swap.svg @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/cockatrice/src/client/tabs/tab_deck_editor.cpp b/cockatrice/src/client/tabs/tab_deck_editor.cpp index 12188dca1..9768c028f 100644 --- a/cockatrice/src/client/tabs/tab_deck_editor.cpp +++ b/cockatrice/src/client/tabs/tab_deck_editor.cpp @@ -114,6 +114,12 @@ void TabDeckEditor::createDeckDock() auto *tbRemoveCard = new QToolButton(this); tbRemoveCard->setDefaultAction(aRemoveCard); + aSwapCard = new QAction(QString(), this); + aSwapCard->setIcon(QPixmap("theme:icons/swap")); + connect(aSwapCard, SIGNAL(triggered()), this, SLOT(actSwapCard())); + auto *tbSwapCard = new QToolButton(this); + tbSwapCard->setDefaultAction(aSwapCard); + auto *upperLayout = new QGridLayout; upperLayout->setObjectName("upperLayout"); upperLayout->addWidget(nameLabel, 0, 0); @@ -139,7 +145,8 @@ void TabDeckEditor::createDeckDock() lowerLayout->addWidget(tbIncrement, 0, 2); lowerLayout->addWidget(tbDecrement, 0, 3); lowerLayout->addWidget(tbRemoveCard, 0, 4); - lowerLayout->addWidget(deckView, 1, 0, 1, 5); + lowerLayout->addWidget(tbSwapCard, 0, 5); + lowerLayout->addWidget(deckView, 1, 0, 1, 6); // Create widgets for both layouts to make splitter work correctly auto *topWidget = new QWidget; @@ -1298,6 +1305,7 @@ void TabDeckEditor::actSwapCard() setModified(true); setSaveStatus(true); + update(); } void TabDeckEditor::actAddCard() diff --git a/cockatrice/src/client/tabs/tab_deck_editor.h b/cockatrice/src/client/tabs/tab_deck_editor.h index 14f96a73c..8340f3b1b 100644 --- a/cockatrice/src/client/tabs/tab_deck_editor.h +++ b/cockatrice/src/client/tabs/tab_deck_editor.h @@ -142,7 +142,7 @@ private: *aSaveDeckToClipboard, *aSaveDeckToClipboardRaw, *aPrintDeck, *aExportDeckDecklist, *aAnalyzeDeckDeckstats, *aAnalyzeDeckTappedout, *aClose; QAction *aClearFilterAll, *aClearFilterOne; - QAction *aAddCard, *aAddCardToSideboard, *aRemoveCard, *aIncrement, *aDecrement; + QAction *aAddCard, *aAddCardToSideboard, *aRemoveCard, *aIncrement, *aDecrement, *aSwapCard; QAction *aResetLayout; QAction *aCardInfoDockVisible, *aCardInfoDockFloating, *aDeckDockVisible, *aDeckDockFloating, *aFilterDockVisible, *aFilterDockFloating, *aPrintingSelectorDockVisible, *aPrintingSelectorDockFloating;