From 767292d0639924c20db3ae943a0585c36df3e3a7 Mon Sep 17 00:00:00 2001 From: RickyRister Date: Sun, 2 Mar 2025 18:49:10 -0800 Subject: [PATCH] add option for not annotated --- .../menus/deck_editor/deck_editor_menu.cpp | 15 +++++++++++++-- .../client/menus/deck_editor/deck_editor_menu.h | 6 +++--- .../src/client/tabs/abstract_tab_deck_editor.cpp | 14 ++++++++++++-- .../src/client/tabs/abstract_tab_deck_editor.h | 4 ++++ .../src/dialogs/dlg_load_deck_from_clipboard.cpp | 16 +++++++++------- .../src/dialogs/dlg_load_deck_from_clipboard.h | 3 ++- cockatrice/src/settings/shortcuts_settings.h | 11 ++++++++--- 7 files changed, 51 insertions(+), 18 deletions(-) diff --git a/cockatrice/src/client/menus/deck_editor/deck_editor_menu.cpp b/cockatrice/src/client/menus/deck_editor/deck_editor_menu.cpp index 426195bc9..be4d50d58 100644 --- a/cockatrice/src/client/menus/deck_editor/deck_editor_menu.cpp +++ b/cockatrice/src/client/menus/deck_editor/deck_editor_menu.cpp @@ -33,6 +33,9 @@ DeckEditorMenu::DeckEditorMenu(QWidget *parent, AbstractTabDeckEditor *_deckEdit aEditDeckInClipboard = new QAction(QString(), this); connect(aEditDeckInClipboard, SIGNAL(triggered()), deckEditor, SLOT(actEditDeckInClipboard())); + aEditDeckInClipboardRaw = new QAction(QString(), this); + connect(aEditDeckInClipboardRaw, SIGNAL(triggered()), deckEditor, SLOT(actEditDeckInClipboardRaw())); + aSaveDeckToClipboard = new QAction(QString(), this); connect(aSaveDeckToClipboard, SIGNAL(triggered()), deckEditor, SLOT(actSaveDeckToClipboard())); @@ -67,6 +70,10 @@ DeckEditorMenu::DeckEditorMenu(QWidget *parent, AbstractTabDeckEditor *_deckEdit aClose = new QAction(QString(), this); connect(aClose, &QAction::triggered, deckEditor, &AbstractTabDeckEditor::closeRequest); + editDeckInClipboardMenu = new QMenu(this); + editDeckInClipboardMenu->addAction(aEditDeckInClipboard); + editDeckInClipboardMenu->addAction(aEditDeckInClipboardRaw); + saveDeckToClipboardMenu = new QMenu(this); saveDeckToClipboardMenu->addAction(aSaveDeckToClipboard); saveDeckToClipboardMenu->addAction(aSaveDeckToClipboardNoSetNameAndNumber); @@ -80,7 +87,7 @@ DeckEditorMenu::DeckEditorMenu(QWidget *parent, AbstractTabDeckEditor *_deckEdit addAction(aSaveDeckAs); addSeparator(); addAction(aLoadDeckFromClipboard); - addAction(aEditDeckInClipboard); + addMenu(editDeckInClipboardMenu); addMenu(saveDeckToClipboardMenu); addSeparator(); addAction(aPrintDeck); @@ -139,7 +146,10 @@ void DeckEditorMenu::retranslateUi() aSaveDeckAs->setText(tr("Save deck &as...")); aLoadDeckFromClipboard->setText(tr("Load deck from cl&ipboard...")); - aEditDeckInClipboard->setText(tr("Edit deck in clipboard")); + + editDeckInClipboardMenu->setTitle(tr("Edit deck in clipboard")); + aEditDeckInClipboard->setText(tr("Annotated")); + aEditDeckInClipboardRaw->setText(tr("Not Annotated")); saveDeckToClipboardMenu->setTitle(tr("Save deck to clipboard")); aSaveDeckToClipboard->setText(tr("Annotated")); @@ -167,6 +177,7 @@ void DeckEditorMenu::refreshShortcuts() aSaveDeckAs->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aSaveDeckAs")); aLoadDeckFromClipboard->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aLoadDeckFromClipboard")); aEditDeckInClipboard->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aEditDeckInClipboard")); + aEditDeckInClipboardRaw->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aEditDeckInClipboardRaw")); aPrintDeck->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aPrintDeck")); aAnalyzeDeckDeckstats->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aAnalyzeDeck")); aClose->setShortcuts(shortcuts.getShortcut("TabDeckEditor/aClose")); diff --git a/cockatrice/src/client/menus/deck_editor/deck_editor_menu.h b/cockatrice/src/client/menus/deck_editor/deck_editor_menu.h index de759560b..5d0a3f9e6 100644 --- a/cockatrice/src/client/menus/deck_editor/deck_editor_menu.h +++ b/cockatrice/src/client/menus/deck_editor/deck_editor_menu.h @@ -14,11 +14,11 @@ public: AbstractTabDeckEditor *deckEditor; - QAction *aNewDeck, *aLoadDeck, *aClearRecents, *aSaveDeck, *aSaveDeckAs, *aEditDeckInClipboard, - *aLoadDeckFromClipboard, *aSaveDeckToClipboard, *aSaveDeckToClipboardNoSetNameAndNumber, + QAction *aNewDeck, *aLoadDeck, *aClearRecents, *aSaveDeck, *aSaveDeckAs, *aLoadDeckFromClipboard, + *aEditDeckInClipboard, *aEditDeckInClipboardRaw, *aSaveDeckToClipboard, *aSaveDeckToClipboardNoSetNameAndNumber, *aSaveDeckToClipboardRaw, *aSaveDeckToClipboardRawNoSetNameAndNumber, *aPrintDeck, *aExportDeckDecklist, *aAnalyzeDeckDeckstats, *aAnalyzeDeckTappedout, *aClose; - QMenu *loadRecentDeckMenu, *analyzeDeckMenu, *saveDeckToClipboardMenu; + QMenu *loadRecentDeckMenu, *analyzeDeckMenu, *editDeckInClipboardMenu, *saveDeckToClipboardMenu; void setSaveStatus(bool newStatus); diff --git a/cockatrice/src/client/tabs/abstract_tab_deck_editor.cpp b/cockatrice/src/client/tabs/abstract_tab_deck_editor.cpp index bfdbf39de..4dcc57ea6 100644 --- a/cockatrice/src/client/tabs/abstract_tab_deck_editor.cpp +++ b/cockatrice/src/client/tabs/abstract_tab_deck_editor.cpp @@ -394,9 +394,9 @@ void AbstractTabDeckEditor::actLoadDeckFromClipboard() deckMenu->setSaveStatus(true); } -void AbstractTabDeckEditor::actEditDeckInClipboard() +void AbstractTabDeckEditor::editDeckInClipboard(bool annotated) { - DlgEditDeckInClipboard dlg(*getDeckList(), this); + DlgEditDeckInClipboard dlg(*getDeckList(), annotated, this); if (!dlg.exec()) return; @@ -406,6 +406,16 @@ void AbstractTabDeckEditor::actEditDeckInClipboard() deckMenu->setSaveStatus(true); } +void AbstractTabDeckEditor::actEditDeckInClipboard() +{ + editDeckInClipboard(true); +} + +void AbstractTabDeckEditor::actEditDeckInClipboardRaw() +{ + editDeckInClipboard(false); +} + void AbstractTabDeckEditor::actSaveDeckToClipboard() { getDeckList()->saveToClipboard(true, true); diff --git a/cockatrice/src/client/tabs/abstract_tab_deck_editor.h b/cockatrice/src/client/tabs/abstract_tab_deck_editor.h index 069f1eee4..94fbe9bde 100644 --- a/cockatrice/src/client/tabs/abstract_tab_deck_editor.h +++ b/cockatrice/src/client/tabs/abstract_tab_deck_editor.h @@ -93,6 +93,7 @@ protected slots: bool actSaveDeckAs(); virtual void actLoadDeckFromClipboard(); void actEditDeckInClipboard(); + void actEditDeckInClipboardRaw(); void actSaveDeckToClipboard(); void actSaveDeckToClipboardNoSetNameAndNumber(); void actSaveDeckToClipboardRaw(); @@ -115,6 +116,9 @@ protected slots: virtual void dockVisibleTriggered() = 0; virtual void dockFloatingTriggered() = 0; +private: + void editDeckInClipboard(bool annotated); + protected: /** * @brief Enum for selecting deck open location diff --git a/cockatrice/src/dialogs/dlg_load_deck_from_clipboard.cpp b/cockatrice/src/dialogs/dlg_load_deck_from_clipboard.cpp index 23680dec5..6cecc10bf 100644 --- a/cockatrice/src/dialogs/dlg_load_deck_from_clipboard.cpp +++ b/cockatrice/src/dialogs/dlg_load_deck_from_clipboard.cpp @@ -134,11 +134,12 @@ void DlgLoadDeckFromClipboard::actOK() /** * Creates the dialog window for the "Edit deck in clipboard" action * - * @param deckList The existing deck in the deck editor. + * @param deckList The existing deck in the deck editor. Copies the instance + * @param _annotated Whether to add annotations to the text that is loaded from the deck * @param parent The parent widget */ -DlgEditDeckInClipboard::DlgEditDeckInClipboard(const DeckLoader &deckList, QWidget *parent) - : AbstractDlgDeckTextEdit(parent) +DlgEditDeckInClipboard::DlgEditDeckInClipboard(const DeckLoader &deckList, bool _annotated, QWidget *parent) + : AbstractDlgDeckTextEdit(parent), annotated(_annotated) { setWindowTitle(tr("Edit deck in clipboard")); @@ -149,21 +150,22 @@ DlgEditDeckInClipboard::DlgEditDeckInClipboard(const DeckLoader &deckList, QWidg } /** - * Loads the contents of the DeckList into a String + * Loads the contents of the DeckList into a String. Always loads it with addSetNameAndNumber=true * @param deckList The deck to load + * @param addComments Whether to add annotations * @return A QString */ -static QString deckListToString(const DeckLoader *deckList) +static QString deckListToString(const DeckLoader *deckList, bool addComments) { QString buffer; QTextStream stream(&buffer); - deckList->saveToStream_Plain(stream); + deckList->saveToStream_Plain(stream, addComments); return buffer; } void DlgEditDeckInClipboard::actRefresh() { - setText(deckListToString(deckLoader)); + setText(deckListToString(deckLoader, annotated)); } void DlgEditDeckInClipboard::actOK() diff --git a/cockatrice/src/dialogs/dlg_load_deck_from_clipboard.h b/cockatrice/src/dialogs/dlg_load_deck_from_clipboard.h index 3fdb1ac59..ce2ccf720 100644 --- a/cockatrice/src/dialogs/dlg_load_deck_from_clipboard.h +++ b/cockatrice/src/dialogs/dlg_load_deck_from_clipboard.h @@ -78,9 +78,10 @@ protected slots: private: DeckLoader *deckLoader; + bool annotated; public: - explicit DlgEditDeckInClipboard(const DeckLoader &deckList, QWidget *parent = nullptr); + explicit DlgEditDeckInClipboard(const DeckLoader &deckList, bool _annotated, QWidget *parent = nullptr); DeckLoader *getDeckList() const override { diff --git a/cockatrice/src/settings/shortcuts_settings.h b/cockatrice/src/settings/shortcuts_settings.h index 799715c3b..ce0127d57 100644 --- a/cockatrice/src/settings/shortcuts_settings.h +++ b/cockatrice/src/settings/shortcuts_settings.h @@ -206,9 +206,14 @@ private: ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Load Deck from Clipboard..."), parseSequenceString("Ctrl+Shift+V"), ShortcutGroup::Deck_Editor)}, - {"TabDeckEditor/aEditDeckInClipboard", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Edit Deck in Clipboard"), - parseSequenceString(""), - ShortcutGroup::Deck_Editor)}, + {"TabDeckEditor/aEditDeckInClipboard", + ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Edit Deck in Clipboard, Annotated"), + parseSequenceString(""), + ShortcutGroup::Deck_Editor)}, + {"TabDeckEditor/aEditDeckInClipboardRaw", + ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Edit Deck in Clipboard"), + parseSequenceString(""), + ShortcutGroup::Deck_Editor)}, {"TabDeckEditor/aNewDeck", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "New Deck"), parseSequenceString("Ctrl+N"), ShortcutGroup::Deck_Editor)},