From 66eaf24af0b5e06f47c8f49549ff7edf9162b61d Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sun, 11 Sep 2016 01:09:50 +0000 Subject: [PATCH] Add a configurations button to the rig error message box This button pops up the same context menu as the configurations button on the main window menu bar. This allows the operator to easily escape from an incorrectly configured configuration without changing it. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7075 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- mainwindow.cpp | 34 ++++++++++++++++++++++++---------- mainwindow.h | 1 + 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index b33218159..5f27f4656 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -170,6 +170,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, m_revision {revision ()}, m_multiple {multiple}, m_multi_settings {multi_settings}, + m_configurations_button {0}, m_settings {multi_settings->settings ()}, ui(new Ui::MainWindow), m_config {temp_directory, m_settings, this}, @@ -589,6 +590,8 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, // set up configurations menu m_multi_settings->create_menu_actions (this, ui->menuConfig); + m_configurations_button = m_rigErrorMessageBox.addButton (tr ("Configurations...") + , QMessageBox::ActionRole); // set up message text validators ui->tx1->setValidator (new QRegExpValidator {message_alphabet, this}); @@ -4886,19 +4889,30 @@ void MainWindow::rigFailure (QString const& reason) m_rigErrorMessageBox.setDetailedText (reason); // don't call slot functions directly to avoid recursion - switch (m_rigErrorMessageBox.exec ()) + m_rigErrorMessageBox.exec (); + auto const clicked_button = m_rigErrorMessageBox.clickedButton (); + if (clicked_button == m_configurations_button) { - case MessageBox::Ok: - QTimer::singleShot (0, this, SLOT (on_actionSettings_triggered ())); - break; + ui->menuConfig->exec (QCursor::pos ()); + } + else + { + switch (m_rigErrorMessageBox.standardButton (clicked_button)) + { + case MessageBox::Ok: + QTimer::singleShot (0, this, SLOT (on_actionSettings_triggered ())); + break; - case MessageBox::Retry: - QTimer::singleShot (0, this, SLOT (rigOpen ())); - break; + case MessageBox::Retry: + QTimer::singleShot (0, this, SLOT (rigOpen ())); + break; - case MessageBox::Cancel: - QTimer::singleShot (0, this, SLOT (close ())); - break; + case MessageBox::Cancel: + QTimer::singleShot (0, this, SLOT (close ())); + break; + + default: break; // squashing compile warnings + } } m_first_error = true; // reset } diff --git a/mainwindow.h b/mainwindow.h index 380970715..3f61ae896 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -288,6 +288,7 @@ private: QString m_revision; bool m_multiple; MultiSettings * m_multi_settings; + QPushButton * m_configurations_button; QSettings * m_settings; QScopedPointer ui;