From d44b62badc9d3e71bdd274544be3ea55683cbcfe Mon Sep 17 00:00:00 2001 From: RickyRister Date: Wed, 20 Nov 2024 01:32:00 -0800 Subject: [PATCH] implement extra button in confirmation --- cockatrice/src/client/tabs/tab_deck_editor.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/cockatrice/src/client/tabs/tab_deck_editor.cpp b/cockatrice/src/client/tabs/tab_deck_editor.cpp index de024749f..618477205 100644 --- a/cockatrice/src/client/tabs/tab_deck_editor.cpp +++ b/cockatrice/src/client/tabs/tab_deck_editor.cpp @@ -1016,9 +1016,20 @@ TabDeckEditor::DeckOpenLocation TabDeckEditor::confirmOpen(const bool openInSame // do the save confirmation dialogue tabSupervisor->setCurrentWidget(this); - QMessageBox::StandardButton ret = QMessageBox::warning( - this, tr("Are you sure?"), tr("The decklist has been modified.\nDo you want to save the changes?"), - QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); + + QMessageBox msgBox; + msgBox.setIcon(QMessageBox::Warning); + msgBox.setWindowTitle(tr("Are you sure?")); + msgBox.setText(tr("The decklist has been modified.\nDo you want to save the changes?")); + msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); + QPushButton *newTabButton = msgBox.addButton(tr("Open in new tab"), QMessageBox::ApplyRole); + + int ret = msgBox.exec(); + + // `exec()` returns an opaque value if a non-standard button was clicked. + // Directly check if newTabButton was clicked before switching over the standard buttons. + if (msgBox.clickedButton() == newTabButton) + return NEW_TAB; switch (ret) { case QMessageBox::Save: