From 273ebb22e4b00bf4fa380f3eabbdf0216f188085 Mon Sep 17 00:00:00 2001 From: Impyrical <105748541+Impyrical@users.noreply.github.com> Date: Fri, 20 May 2022 19:22:08 -0400 Subject: [PATCH] Tackling #4041 (#4625) Copy contents of selected cell from card database when ctrl-c is pressed, mimicking the behavior of ctrl-c in the deck editor. --- cockatrice/src/keysignals.cpp | 5 +++++ cockatrice/src/keysignals.h | 1 + cockatrice/src/tab_deck_editor.cpp | 7 +++++++ cockatrice/src/tab_deck_editor.h | 1 + 4 files changed, 14 insertions(+) diff --git a/cockatrice/src/keysignals.cpp b/cockatrice/src/keysignals.cpp index 394c655fb..c8f75aab5 100644 --- a/cockatrice/src/keysignals.cpp +++ b/cockatrice/src/keysignals.cpp @@ -60,6 +60,11 @@ bool KeySignals::eventFilter(QObject * /*object*/, QEvent *event) if (kevent->modifiers() & Qt::ShiftModifier) emit onShiftS(); + break; + case Qt::Key_C: + if (kevent->modifiers() & Qt::ControlModifier) + emit onCtrlC(); + break; default: return false; diff --git a/cockatrice/src/keysignals.h b/cockatrice/src/keysignals.h index 0546393ad..e0808fb0c 100644 --- a/cockatrice/src/keysignals.h +++ b/cockatrice/src/keysignals.h @@ -20,6 +20,7 @@ signals: void onCtrlAltLBracket(); void onCtrlAltRBracket(); void onShiftS(); + void onCtrlC(); protected: virtual bool eventFilter(QObject *, QEvent *event); diff --git a/cockatrice/src/tab_deck_editor.cpp b/cockatrice/src/tab_deck_editor.cpp index ac72a17db..70fea767c 100644 --- a/cockatrice/src/tab_deck_editor.cpp +++ b/cockatrice/src/tab_deck_editor.cpp @@ -394,6 +394,7 @@ void TabDeckEditor::createCentralFrame() connect(&searchKeySignals, SIGNAL(onCtrlAltLBracket()), this, SLOT(actDecrementCardFromSideboard())); connect(&searchKeySignals, SIGNAL(onCtrlAltEnter()), this, SLOT(actAddCardToSideboard())); connect(&searchKeySignals, SIGNAL(onCtrlEnter()), this, SLOT(actAddCardToSideboard())); + connect(&searchKeySignals, SIGNAL(onCtrlC()), this, SLOT(copyDatabaseCellContents())); connect(help, &QAction::triggered, this, &TabDeckEditor::showSearchSyntaxHelp); databaseModel = new CardDatabaseModel(db, true, this); @@ -1073,6 +1074,12 @@ void TabDeckEditor::actDecrementCardFromSideboard() decrementCardHelper(DECK_ZONE_SIDE); } +void TabDeckEditor::copyDatabaseCellContents() +{ + QVariant data = databaseView->selectionModel()->currentIndex().data(); + QApplication::clipboard()->setText(data.toString()); +} + void TabDeckEditor::actIncrement() { const QModelIndex ¤tIndex = deckView->selectionModel()->currentIndex(); diff --git a/cockatrice/src/tab_deck_editor.h b/cockatrice/src/tab_deck_editor.h index bc40c408f..2eb643178 100644 --- a/cockatrice/src/tab_deck_editor.h +++ b/cockatrice/src/tab_deck_editor.h @@ -80,6 +80,7 @@ private slots: void actDecrement(); void actDecrementCard(); void actDecrementCardFromSideboard(); + void copyDatabaseCellContents(); void saveDeckRemoteFinished(const Response &r); void filterViewCustomContextMenu(const QPoint &point);