From 0fcdfadddc484c508c82cdd0ce0d56262d2a1fb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Fri, 27 Apr 2018 08:26:44 +0200 Subject: [PATCH] #2813 Origin summary dialog. 'Ok to all' button --- .../Commands/RicSummaryCaseRestartDialog.cpp | 43 ++++++++----------- .../Commands/RicSummaryCaseRestartDialog.h | 8 ++-- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp index 4d6fdd66d7..d3cd23924c 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -107,13 +107,11 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) m_summaryNotReadBtn = new QRadioButton(this); m_gridSeparateCasesBtn = new QRadioButton(this); m_gridNotReadBtn = new QRadioButton(this); - m_applyToAllCheckBox = new QCheckBox(this); m_warnings = new QListWidget(this); - m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply); // Connect to signals - connect(m_buttons, SIGNAL(accepted()), this, SLOT(slotDialogOkClicked())); - connect(m_buttons, SIGNAL(rejected()), this, SLOT(slotDialogCancelClicked())); + connect(m_buttons, SIGNAL(clicked(QAbstractButton*)), this, SLOT(slotDialogButtonClicked(QAbstractButton*))); // Set widget properties m_summaryReadAllBtn->setText("Unified"); @@ -121,8 +119,7 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) m_summaryNotReadBtn->setText("Skip"); m_gridSeparateCasesBtn->setText("Separate Cases"); m_gridNotReadBtn->setText("Skip"); - m_applyToAllCheckBox->setText("OK to All"); - m_applyToAllCheckBox->setLayoutDirection(Qt::RightToLeft); + m_buttons->button(QDialogButtonBox::Apply)->setText("OK to All"); // Define layout QVBoxLayout* dialogLayout = new QVBoxLayout(); @@ -171,7 +168,6 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) // Apply to all checkbox and buttons QHBoxLayout* buttonsLayout = new QHBoxLayout(); buttonsLayout->addStretch(1); - buttonsLayout->addWidget(m_applyToAllCheckBox); buttonsLayout->addWidget(m_buttons); dialogLayout->addWidget(m_currentFilesGroup); @@ -181,6 +177,8 @@ RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) dialogLayout->addLayout(buttonsLayout); setLayout(dialogLayout); + + m_okToAllPressed = false; } //-------------------------------------------------------------------------------------------------- @@ -331,7 +329,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const // Set properties and show dialog dialog.setWindowTitle("Restart Files"); - dialog.m_applyToAllCheckBox->setVisible(showApplyToAllWidget); + dialog.m_buttons->button(QDialogButtonBox::Apply)->setVisible(showApplyToAllWidget); dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); dialog.exec(); @@ -347,7 +345,7 @@ RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const dialog.selectedGridImportOption(), {}, {}, - dialog.applyToAllSelected()); + dialog.okToAllSelected()); } if (dialogResult.status != RicSummaryCaseRestartDialogResult::SUMMARY_OK) @@ -403,9 +401,9 @@ RicSummaryCaseRestartDialog::ImportOptions RicSummaryCaseRestartDialog::selected //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicSummaryCaseRestartDialog::applyToAllSelected() const +bool RicSummaryCaseRestartDialog::okToAllSelected() const { - return m_applyToAllCheckBox->isChecked(); + return m_okToAllPressed; } //-------------------------------------------------------------------------------------------------- @@ -476,20 +474,13 @@ void RicSummaryCaseRestartDialog::displayWarningsIfAny(const QStringList& warnin //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicSummaryCaseRestartDialog::slotDialogOkClicked() +void RicSummaryCaseRestartDialog::slotDialogButtonClicked(QAbstractButton* button) { - accept(); + bool okButtonClicked = m_buttons->button(QDialogButtonBox::Ok) == button; + bool cancelButtonClicked = m_buttons->button(QDialogButtonBox::Cancel) == button; + bool okToAllButtonClicked = m_buttons->button(QDialogButtonBox::Apply) == button; + + m_okToAllPressed = okToAllButtonClicked; + if (cancelButtonClicked) reject(); + else accept(); } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicSummaryCaseRestartDialog::slotDialogCancelClicked() -{ - reject(); -} - -//-------------------------------------------------------------------------------------------------- -/// Internal functions -//-------------------------------------------------------------------------------------------------- - diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h index 9dfc7f98a4..63856868d0 100644 --- a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -38,6 +38,7 @@ class QGridLayout; class QCheckBox; class QGroupBox; class RicSummaryCaseRestartDialogResult; +class QAbstractButton; //================================================================================================== /// @@ -63,7 +64,7 @@ public: ImportOptions selectedSummaryImportOption() const; ImportOptions selectedGridImportOption() const; - bool applyToAllSelected() const; + bool okToAllSelected() const; private: void populateFileList(QGridLayout* gridLayout, const std::vector& fileInfos); @@ -72,8 +73,7 @@ private: void displayWarningsIfAny(const QStringList& warnings); private slots: - void slotDialogOkClicked(); - void slotDialogCancelClicked(); + void slotDialogButtonClicked(QAbstractButton* button); private: QGroupBox* m_currentFilesGroup; @@ -91,9 +91,9 @@ private: QRadioButton* m_gridNotReadBtn; QRadioButton* m_gridSeparateCasesBtn; - QCheckBox* m_applyToAllCheckBox; QDialogButtonBox* m_buttons; + bool m_okToAllPressed; QListWidget* m_warnings; };