diff --git a/cockatrice/src/dialogs/dlg_load_deck_from_clipboard.cpp b/cockatrice/src/dialogs/dlg_load_deck_from_clipboard.cpp index 26d9c7ab0..609461604 100644 --- a/cockatrice/src/dialogs/dlg_load_deck_from_clipboard.cpp +++ b/cockatrice/src/dialogs/dlg_load_deck_from_clipboard.cpp @@ -13,7 +13,10 @@ #include #include -DlgLoadDeckFromClipboard::DlgLoadDeckFromClipboard(QWidget *parent) : QDialog(parent), deckList(nullptr) +/** + * Creates the main layout and connects the signals that are common to all versions of this window + */ +void DlgLoadDeckFromClipboard::createMainLayout() { contentsEdit = new QPlainTextEdit; @@ -38,7 +41,6 @@ DlgLoadDeckFromClipboard::DlgLoadDeckFromClipboard(QWidget *parent) : QDialog(pa setLayout(mainLayout); - setWindowTitle(tr("Load deck from clipboard")); resize(500, 500); actRefresh(); @@ -46,6 +48,18 @@ DlgLoadDeckFromClipboard::DlgLoadDeckFromClipboard(QWidget *parent) : QDialog(pa refreshShortcuts(); } +/** + * Creates the dialog window for the "Load deck from clipboard" action + * + * @param parent The parent widget + */ +DlgLoadDeckFromClipboard::DlgLoadDeckFromClipboard(QWidget *parent) : QDialog(parent), deckList(nullptr) +{ + createMainLayout(); + + setWindowTitle(tr("Load deck from clipboard")); +} + /** * Loads the contents of the DeckList into a String * @param deckList The deck to load @@ -60,14 +74,18 @@ static QString deckListToString(const DeckLoader *deckList) } /** - * Creates a dialogue window that already has the contents of the deck loaded into the textEdit + * Creates the dialog window for the "Edit deck in clipboard" action * - * @param deck The deck to load + * @param deck The existing deck in the deck editor * @param parent The parent widget */ DlgLoadDeckFromClipboard::DlgLoadDeckFromClipboard(const DeckLoader &deck, QWidget *parent) : DlgLoadDeckFromClipboard(parent) { + createMainLayout(); + + setWindowTitle(tr("Edit deck in clipboard")); + deckList = new DeckLoader(deck); deckList->setParent(this); diff --git a/cockatrice/src/dialogs/dlg_load_deck_from_clipboard.h b/cockatrice/src/dialogs/dlg_load_deck_from_clipboard.h index d54b1a098..ee447f4f1 100644 --- a/cockatrice/src/dialogs/dlg_load_deck_from_clipboard.h +++ b/cockatrice/src/dialogs/dlg_load_deck_from_clipboard.h @@ -8,6 +8,9 @@ class DeckLoader; class QPlainTextEdit; class QPushButton; +/** + * Dialog window for actions that involve loading decks from text input. + */ class DlgLoadDeckFromClipboard : public QDialog { Q_OBJECT @@ -17,11 +20,17 @@ private slots: void refreshShortcuts(); private: + /** + * before actOK has been called, null deckList indicates "load deck from clipboard" action, and nonnull deckList + * indicates "edit deck in clipboard" action + */ DeckLoader *deckList; QPlainTextEdit *contentsEdit; QPushButton *refreshButton; QCheckBox *loadSetNameAndNumberCheckBox; + void createMainLayout(); + public: explicit DlgLoadDeckFromClipboard(QWidget *parent = nullptr); explicit DlgLoadDeckFromClipboard(const DeckLoader &deck, QWidget *parent = nullptr);