diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c45d6980..860f71117 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -197,6 +197,7 @@ set (WSJT_QT_CONF_DESTINATION ${QT_CONF_DESTINATION} CACHE PATH "Path for the qt # set (wsjt_qt_CXXSRCS qt_helpers.cpp + MessageBox.cpp MetaDataRegistry.cpp NetworkServerLookup.cpp revision_utils.cpp diff --git a/Configuration.cpp b/Configuration.cpp index 8c761b6f6..40a03df5f 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -141,7 +141,6 @@ #include #include #include -#include #include #include #include @@ -163,6 +162,7 @@ #include #include +#include "pimpl_impl.hpp" #include "qt_helpers.hpp" #include "MetaDataRegistry.hpp" #include "SettingsGroup.hpp" @@ -176,8 +176,7 @@ #include "FrequencyList.hpp" #include "StationList.hpp" #include "NetworkServerLookup.hpp" - -#include "pimpl_impl.hpp" +#include "MessageBox.hpp" #include "ui_Configuration.h" #include "moc_Configuration.cpp" @@ -386,7 +385,6 @@ private: void enumerate_rigs (); void set_rig_invariants (); bool validate (); - void message_box (QString const& reason, QString const& detail = QString ()); void fill_port_combo_box (QComboBox *); Frequency apply_calibration (Frequency) const; Frequency remove_calibration (Frequency) const; @@ -819,7 +817,8 @@ Configuration::impl::impl (Configuration * self, QDir const& temp_directory, QDir data_dir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}; if (!data_dir.mkpath (".")) { - QMessageBox::critical (this, "WSJT-X", tr ("Create data directory error: ") + data_dir.absolutePath ()); + MessageBox::critical_message (this, tr ("Failed to create data directory"), + tr ("path: \"%1\"").arg (data_dir.absolutePath ())); throw std::runtime_error {"Failed to create data directory"}; } @@ -829,8 +828,9 @@ Configuration::impl::impl (Configuration * self, QDir const& temp_directory, default_azel_directory_ = data_dir; if (!default_save_directory_.mkpath (save_dir) || !default_save_directory_.cd (save_dir)) { - QMessageBox::critical (this, "WSJT-X", tr ("Create Directory", "Cannot create directory \"") + - default_save_directory_.absoluteFilePath (save_dir) + "\"."); + MessageBox::critical_message (this, tr ("Failed to create save directory"), + tr ("path: \"%1\%") + .arg (default_save_directory_.absoluteFilePath (save_dir))); throw std::runtime_error {"Failed to create save directory"}; } @@ -840,9 +840,10 @@ Configuration::impl::impl (Configuration * self, QDir const& temp_directory, QString samples_dir {"samples"}; if (!default_save_directory_.mkpath (samples_dir)) { - QMessageBox::critical (this, "WSJT-X", tr ("Create Directory", "Cannot create directory \"") + - default_save_directory_.absoluteFilePath (samples_dir) + "\"."); - throw std::runtime_error {"Failed to create save directory"}; + MessageBox::critical_message (this, tr ("Failed to create samples directory"), + tr ("path: \"%1\"") + .arg (default_save_directory_.absoluteFilePath (samples_dir))); + throw std::runtime_error {"Failed to create samples directory"}; } // copy in any new sample files to the sample directory @@ -1537,20 +1538,20 @@ bool Configuration::impl::validate () if (ui_->sound_input_combo_box->currentIndex () < 0 && !QAudioDeviceInfo::availableDevices (QAudio::AudioInput).empty ()) { - message_box (tr ("Invalid audio input device")); + MessageBox::critical_message (this, tr ("Invalid audio input device")); return false; } if (ui_->sound_output_combo_box->currentIndex () < 0 && !QAudioDeviceInfo::availableDevices (QAudio::AudioOutput).empty ()) { - message_box (tr ("Invalid audio output device")); + MessageBox::critical_message (this, tr ("Invalid audio out device")); return false; } if (!ui_->PTT_method_button_group->checkedButton ()->isEnabled ()) { - message_box (tr ("Invalid PTT method")); + MessageBox::critical_message (this, tr ("Invalid PTT method")); return false; } @@ -1560,7 +1561,7 @@ bool Configuration::impl::validate () && (ptt_port.isEmpty () || combo_box_item_disabled == ui_->PTT_port_combo_box->itemData (ui_->PTT_port_combo_box->findText (ptt_port), Qt::UserRole - 1))) { - message_box (tr ("Invalid PTT port")); + MessageBox::critical_message (this, tr ("Invalid PTT port")); return false; } @@ -1858,20 +1859,6 @@ void Configuration::impl::reject () QDialog::reject (); } -void Configuration::impl::message_box (QString const& reason, QString const& detail) -{ - QMessageBox mb; - mb.setText (reason); - if (!detail.isEmpty ()) - { - mb.setDetailedText (detail); - } - mb.setStandardButtons (QMessageBox::Ok); - mb.setDefaultButton (QMessageBox::Ok); - mb.setIcon (QMessageBox::Critical); - mb.exec (); -} - void Configuration::impl::on_font_push_button_clicked () { next_font_ = QFontDialog::getFont (0, next_font_, this); @@ -2120,10 +2107,10 @@ void Configuration::impl::delete_frequencies () void Configuration::impl::on_reset_frequencies_push_button_clicked (bool /* checked */) { - if (QMessageBox::Yes == QMessageBox::question (this, tr ("Reset Working Frequencies") - , tr ("Are you sure you want to discard your current " - "working frequencies and replace them with default " - "ones?"))) + if (MessageBox::Yes == MessageBox::query_message (this, tr ("Reset Working Frequencies") + , tr ("Are you sure you want to discard your current " + "working frequencies and replace them with default " + "ones?"))) { next_frequencies_.reset_to_defaults (); } @@ -2197,7 +2184,8 @@ bool Configuration::impl::have_rig () { if (!open_rig ()) { - QMessageBox::critical (this, "WSJT-X", tr ("Failed to open connection to rig")); + MessageBox::critical_message (this, tr ("Rig control error") + , tr ("Failed to open connection to rig")); } return rig_active_; } @@ -2401,7 +2389,7 @@ void Configuration::impl::handle_transceiver_failure (QString const& reason) if (isVisible ()) { - message_box (tr ("Rig failure"), reason); + MessageBox::critical_message (this, tr ("Rig failure"), reason); } else { diff --git a/HelpTextWindow.cpp b/HelpTextWindow.cpp index 44d1a6232..84bc1d4ad 100644 --- a/HelpTextWindow.cpp +++ b/HelpTextWindow.cpp @@ -3,11 +3,11 @@ #include #include #include -#include #include #include #include "qt_helpers.hpp" +#include HelpTextWindow::HelpTextWindow (QString const& title, QString const& file_name, QFont const& font, QWidget * parent) : QLabel {parent, Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint} @@ -15,9 +15,9 @@ HelpTextWindow::HelpTextWindow (QString const& title, QString const& file_name, QFile source {file_name}; if (!source.open (QIODevice::ReadOnly | QIODevice::Text)) { - QMessageBox::warning (this, QApplication::applicationName () - , "Cannot open \"" + source.fileName () - + "\" for reading:" + source.errorString ()); + MessageBox::warning_message (this, tr ("Help file error") + , tr ("Cannot open \"%1\" for reading").arg (source.fileName ()) + , tr ("Error: %1").arg (source.errorString ())); return; } setText (QTextStream {&source}.readAll ()); diff --git a/MessageBox.cpp b/MessageBox.cpp new file mode 100644 index 000000000..b96830cec --- /dev/null +++ b/MessageBox.cpp @@ -0,0 +1,101 @@ +#include "MessageBox.hpp" + +#include +#include + +#include "revision_utils.hpp" + +MessageBox::MessageBox (QWidget * parent) + : QMessageBox {parent} +{ + setWindowTitle (program_title ()); +} + +MessageBox::MessageBox (Icon icon, QString const& text, StandardButtons buttons + , QWidget * parent, Qt::WindowFlags flags) + : QMessageBox {icon, program_title (), text, buttons, parent, flags} +{ +} + +void MessageBox::about_message (QWidget * parent, QString const& text) +{ + QMessageBox::about (parent, program_title (), text); +} + +void MessageBox::about_Qt_message (QWidget * parent) +{ + QMessageBox::aboutQt (parent, program_title ()); +} + +namespace +{ + QMessageBox::StandardButton show_it (QWidget *parent, MessageBox::Icon icon + , QString const& text + , QString const& informative + , QString const& detail + , MessageBox::StandardButtons buttons + , MessageBox::StandardButton default_button) + { + MessageBox mb {icon, text, MessageBox::NoButton, parent}; + QDialogButtonBox * button_box = mb.findChild (); + Q_ASSERT (button_box); + + uint mask = MessageBox::FirstButton; + while (mask <= MessageBox::LastButton) { + uint sb = buttons & mask; + mask <<= 1; + if (!sb) + continue; + QPushButton * button = mb.addButton (static_cast (sb)); + // Choose the first accept role as the default + if (mb.defaultButton ()) + continue; + if ((default_button == MessageBox::NoButton + && button_box->buttonRole (button) == QDialogButtonBox::AcceptRole) + || (default_button != MessageBox::NoButton + && sb == static_cast (default_button))) + mb.setDefaultButton (button); + } + mb.setInformativeText (informative); + mb.setDetailedText (detail); + if (mb.exec() == -1) + return MessageBox::Cancel; + return mb.standardButton (mb.clickedButton ()); + } +} + +auto MessageBox::information_message (QWidget * parent, QString const& text + , QString const& informative + , QString const& detail + , StandardButtons buttons + , StandardButton default_button) -> StandardButton +{ + return show_it (parent, Information, text, informative, detail, buttons, default_button); +} + +auto MessageBox::query_message (QWidget * parent, QString const& text + , QString const& informative + , QString const& detail + , StandardButtons buttons + , StandardButton default_button) -> StandardButton +{ + return show_it (parent, Question, text, informative, detail, buttons, default_button); +} + +auto MessageBox::warning_message (QWidget * parent, QString const& text + , QString const& informative + , QString const& detail + , StandardButtons buttons + , StandardButton default_button) -> StandardButton +{ + return show_it (parent, Warning, text, informative, detail, buttons, default_button); +} + +auto MessageBox::critical_message (QWidget * parent, QString const& text + , QString const& informative + , QString const& detail + , StandardButtons buttons + , StandardButton default_button) -> StandardButton +{ + return show_it (parent, Critical, text, informative, detail, buttons, default_button); +} diff --git a/MessageBox.hpp b/MessageBox.hpp new file mode 100644 index 000000000..7290b73a7 --- /dev/null +++ b/MessageBox.hpp @@ -0,0 +1,58 @@ +#ifndef MESSAGE_BOX_HPP__ +#define MESSAGE_BOX_HPP__ + +#include + +// get rid of the nasty MS define +#ifdef MessageBox +#undef MessageBox +#endif + +// +// MessageBox - wrap the Qt QMessageBox class to give a more platform +// neutral and functional interface +// +class MessageBox + : public QMessageBox +{ +public: + explicit MessageBox (QWidget * parent = nullptr); + explicit MessageBox (Icon, QString const& text, StandardButtons = NoButton + , QWidget * parent = nullptr + , Qt::WindowFlags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); + + static void about_message (QWidget * parent, QString const& text); + static void about_Qt_message (QWidget * parent); + static StandardButton information_message (QWidget * parent, QString const& text + , QString const& informative = QString {} + , QString const& detail = QString {} + , StandardButtons buttons = Ok + , StandardButton default_button = NoButton); + static StandardButton query_message (QWidget * parent, QString const& text + , QString const& informative = QString {} + , QString const& detail = QString {} + , StandardButtons buttons = Yes | No + , StandardButton default_button = NoButton); + static StandardButton warning_message (QWidget * parent, QString const& text + , QString const& informative = QString {} + , QString const& detail = QString {} + , StandardButtons buttons = Ok + , StandardButton default_button = NoButton); + static StandardButton critical_message (QWidget * parent, QString const& text + , QString const& informative = QString {} + , QString const& detail = QString {} + , StandardButtons buttons = Ok + , StandardButton default_button = NoButton); +private: + // hide the parent static functions so that users use our versions + // above that are correctly branded and have better platform + // independence + using QMessageBox::about; + using QMessageBox::aboutQt; + using QMessageBox::information; + using QMessageBox::question; + using QMessageBox::warning; + using QMessageBox::critical; +}; + +#endif diff --git a/MultiSettings.cpp b/MultiSettings.cpp index 17bb620f0..8f483849f 100644 --- a/MultiSettings.cpp +++ b/MultiSettings.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -30,6 +29,8 @@ #include "SettingsGroup.hpp" #include "qt_helpers.hpp" +#include "SettingsGroup.hpp" +#include "MessageBox.hpp" #include "pimpl_impl.hpp" @@ -551,11 +552,11 @@ void MultiSettings::impl::clone_into_configuration (QMainWindow * main_window) if (sources.size () && (1 == sources.size () || QDialog::Accepted == dialog.exec ())) { QString source_name {1 == sources.size () ? sources.at (0) : dialog.name ()}; - if (QMessageBox::Yes == QMessageBox::question (main_window, - tr ("Clone Into Configuration"), - tr ("Confirm overwrite of all values for configuration \"%1\" with values from \"%2\"?") - .arg (target_name) - .arg (source_name))) + if (MessageBox::Yes == MessageBox::query_message (main_window, + tr ("Clone Into Configuration"), + tr ("Confirm overwrite of all values for configuration \"%1\" with values from \"%2\"?") + .arg (target_name) + .arg (source_name))) { // grab the data to clone from if (source_name == current_group_name) @@ -597,10 +598,10 @@ void MultiSettings::impl::reset_configuration (QMainWindow * main_window) { auto const& target_name = active_sub_menu_->title (); - if (QMessageBox::Yes != QMessageBox::question (main_window, - tr ("Reset Configuration"), - tr ("Confirm reset to default values for configuration \"%1\"?") - .arg (target_name))) + if (MessageBox::Yes != MessageBox::query_message (main_window, + tr ("Reset Configuration"), + tr ("Confirm reset to default values for configuration \"%1\"?") + .arg (target_name))) { return; } @@ -680,10 +681,10 @@ void MultiSettings::impl::delete_configuration (QMainWindow * main_window) } else { - if (QMessageBox::Yes != QMessageBox::question (main_window, - tr ("Delete Configuration"), - tr ("Confirm deletion of configuration \"%1\"?") - .arg (target_name))) + if (MessageBox::Yes != MessageBox::query_message (main_window, + tr ("Delete Configuration"), + tr ("Confirm deletion of configuration \"%1\"?") + .arg (target_name))) { return; } diff --git a/SampleDownloader.cpp b/SampleDownloader.cpp index b7c6686ac..f096db37b 100644 --- a/SampleDownloader.cpp +++ b/SampleDownloader.cpp @@ -4,10 +4,10 @@ #include #include +#include "pimpl_impl.hpp" #include "SettingsGroup.hpp" #include "SampleDownloader/Directory.hpp" - -#include "pimpl_impl.hpp" +#include "MessageBox.hpp" #include "moc_SampleDownloader.cpp" @@ -124,7 +124,7 @@ SampleDownloader::impl::impl (QSettings * settings } else { - QMessageBox::warning (this, "Input Error", "Invalid URL format"); + MessageBox::warning_message (this, tr ("Input Error"), tr ("Invalid URL format")); } }); } diff --git a/SampleDownloader/Directory.cpp b/SampleDownloader/Directory.cpp index da175c02d..9edf43a04 100644 --- a/SampleDownloader/Directory.cpp +++ b/SampleDownloader/Directory.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -22,6 +21,7 @@ #include "DirectoryNode.hpp" #include "FileNode.hpp" #include "revision_utils.hpp" +#include "MessageBox.hpp" #include "moc_Directory.cpp" @@ -89,7 +89,7 @@ bool Directory::url_root (QUrl root) void Directory::error (QString const& title, QString const& message) { - QMessageBox::warning (this, title, message); + MessageBox::warning_message (this, title, message); } bool Directory::refresh () @@ -107,10 +107,10 @@ bool Directory::refresh () } else { - QMessageBox::warning (this - , tr ("URL Error") - , tr ("Invalid URL:\n\"%1\"") - .arg (url.toDisplayString ())); + MessageBox::warning_message (this + , tr ("URL Error") + , tr ("Invalid URL:\n\"%1\"") + .arg (url.toDisplayString ())); } return false; } @@ -126,16 +126,16 @@ void Directory::download_finished (bool success) auto content = QJsonDocument::fromJson (contents.readAll (), &json_status); if (json_status.error) { - QMessageBox::warning (this - , tr ("JSON Error") - , tr ("Contents file syntax error %1 at character offset %2") - .arg (json_status.errorString ()).arg (json_status.offset)); + MessageBox::warning_message (this + , tr ("JSON Error") + , tr ("Contents file syntax error %1 at character offset %2") + .arg (json_status.errorString ()).arg (json_status.offset)); return; } if (!content.isArray ()) { - QMessageBox::warning (this, tr ("JSON Error") - , tr ("Contents file top level must be a JSON array")); + MessageBox::warning_message (this, tr ("JSON Error") + , tr ("Contents file top level must be a JSON array")); return; } QTreeWidgetItem * parent {invisibleRootItem ()}; @@ -146,11 +146,11 @@ void Directory::download_finished (bool success) } else { - QMessageBox::warning (this, tr ("File System Error") - , tr ("Failed to open \"%1\"\nError: %2 - %3") - .arg (contents.fileName ()) - .arg (contents.error ()) - .arg (contents.errorString ())); + MessageBox::warning_message (this, tr ("File System Error") + , tr ("Failed to open \"%1\"\nError: %2 - %3") + .arg (contents.fileName ()) + .arg (contents.error ()) + .arg (contents.errorString ())); } } } @@ -183,10 +183,10 @@ void Directory::parse_entries (QJsonArray const& entries, QDir const& dir, QTree } else { - QMessageBox::warning (this - , tr ("URL Error") - , tr ("Invalid URL:\n\"%1\"") - .arg (url.toDisplayString ())); + MessageBox::warning_message (this + , tr ("URL Error") + , tr ("Invalid URL:\n\"%1\"") + .arg (url.toDisplayString ())); } } else if ("directory" == type) @@ -202,34 +202,34 @@ void Directory::parse_entries (QJsonArray const& entries, QDir const& dir, QTree } else { - QMessageBox::warning (this, tr ("JSON Error") - , tr ("Contents entries must be a JSON array")); + MessageBox::warning_message (this, tr ("JSON Error") + , tr ("Contents entries must be a JSON array")); } } else { - QMessageBox::warning (this, tr ("JSON Error") - , tr ("Contents entries must have a valid type")); + MessageBox::warning_message (this, tr ("JSON Error") + , tr ("Contents entries must have a valid type")); } } else { - QMessageBox::warning (this, tr ("JSON Error") - , tr ("Contents entries must have a valid name")); + MessageBox::warning_message (this, tr ("JSON Error") + , tr ("Contents entries must have a valid name")); } } else { - QMessageBox::warning (this, tr ("JSON Error") - , tr ("Contents entries must be JSON objects")); + MessageBox::warning_message (this, tr ("JSON Error") + , tr ("Contents entries must be JSON objects")); } } } else { - QMessageBox::warning (this, tr ("JSON Error") - , tr ("Contents directories must be relative and within \"%1\"") - .arg (samples_dir_name)); + MessageBox::warning_message (this, tr ("JSON Error") + , tr ("Contents directories must be relative and within \"%1\"") + .arg (samples_dir_name)); } } @@ -295,5 +295,5 @@ void Directory::update (QTreeWidgetItem * item) void Directory::authentication (QNetworkReply * /* reply */ , QAuthenticator * /* authenticator */) { - QMessageBox::warning (this, "Network Error", "Authentication required"); + MessageBox::warning_message (this, tr ("Network Error"), tr ("Authentication required")); } diff --git a/SampleDownloader/FileNode.cpp b/SampleDownloader/FileNode.cpp index c165c5fb1..3bb6caf2a 100644 --- a/SampleDownloader/FileNode.cpp +++ b/SampleDownloader/FileNode.cpp @@ -4,9 +4,9 @@ #include #include #include -#include #include "Directory.hpp" +#include "MessageBox.hpp" FileNode::FileNode (QTreeWidgetItem * parent , QNetworkAccessManager * network_manager @@ -26,7 +26,7 @@ FileNode::FileNode (QTreeWidgetItem * parent void FileNode::error (QString const& title, QString const& message) { - QMessageBox::warning (treeWidget (), title, message); + MessageBox::warning_message (treeWidget (), title, message); } bool FileNode::sync (bool local) diff --git a/UDPExamples/MessageAggregatorMainWindow.cpp b/UDPExamples/MessageAggregatorMainWindow.cpp index 51598eb45..64be884cd 100644 --- a/UDPExamples/MessageAggregatorMainWindow.cpp +++ b/UDPExamples/MessageAggregatorMainWindow.cpp @@ -81,7 +81,7 @@ MessageAggregatorMainWindow::MessageAggregatorMainWindow () // connect up server connect (server_, &MessageServer::error, [this] (QString const& message) { - QMessageBox::warning (this, tr ("Network Error"), message); + QMessageBox::warning (this, QApplication::applicationName (), tr ("Network Error"), message); }); connect (server_, &MessageServer::client_opened, this, &MessageAggregatorMainWindow::add_client); connect (server_, &MessageServer::client_closed, this, &MessageAggregatorMainWindow::remove_client); diff --git a/astro.cpp b/astro.cpp index 75c4d2433..464d80baa 100644 --- a/astro.cpp +++ b/astro.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -13,6 +12,7 @@ #include #include "commons.h" +#include "MessageBox.hpp" #include "Configuration.hpp" #include "SettingsGroup.hpp" #include "qt_helpers.hpp" @@ -214,8 +214,9 @@ void Astro::check_split () { if (doppler_tracking () && !configuration_->split_mode ()) { - QMessageBox::warning (this, "Doppler Tracking", - "Split operating is required for Doppler tracking"); + MessageBox::warning_message (this, tr ("Doppler Tracking Error"), + tr ("Split operating is required for Doppler tracking"), + tr ("Go to \"Menu->File->Settings->Radio\" to enable split operation")); ui_->rbNoDoppler->click (); } } diff --git a/logqso.cpp b/logqso.cpp index 7c56a2e7c..b605e433e 100644 --- a/logqso.cpp +++ b/logqso.cpp @@ -7,9 +7,9 @@ #include #include "logbook/adif.h" +#include "MessageBox.hpp" #include "ui_logqso.h" - #include "moc_logqso.cpp" LogQSO::LogQSO(QString const& programTitle, QSettings * settings, QWidget *parent) @@ -112,17 +112,16 @@ void LogQSO::accept() adifile.init(adifilePath); if (!adifile.addQSOToFile(hisCall,hisGrid,mode,rptSent,rptRcvd,date,time,band,comments,name,strDialFreq,m_myCall,m_myGrid,m_txPower)) { - QMessageBox m; - m.setText("Cannot open file \"" + adifilePath + "\"."); - m.exec(); + MessageBox::warning_message (this, tr ("Log file error"), + tr ("Cannot open \"%1\"").arg (adifilePath)); } //Log this QSO to file "wsjtx.log" static QFile f {QDir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}.absoluteFilePath ("wsjtx.log")}; if(!f.open(QIODevice::Text | QIODevice::Append)) { - QMessageBox m; - m.setText("Cannot open file \"" + f.fileName () + "\" for append:" + f.errorString ()); - m.exec(); + MessageBox::warning_message (this, tr ("Log file error"), + tr ("Cannot open \"%1\" for append").arg (f.fileName ()), + tr ("Error: %1").arg (f.errorString ())); } else { QString logEntry=m_dateTime.date().toString("yyyy-MMM-dd,") + m_dateTime.time().toString("hh:mm,") + hisCall + "," + diff --git a/main.cpp b/main.cpp index cfc320447..6ceec5e52 100644 --- a/main.cpp +++ b/main.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -36,6 +35,7 @@ #include "lib/init_random_seed.h" #include "Radio.hpp" #include "FrequencyList.hpp" +#include "MessageBox.hpp" // last to avoid nasty MS macro definitions extern "C" { // Fortran procedures we need @@ -127,19 +127,19 @@ int main(int argc, char *argv[]) if (!parser.parse (a.arguments ())) { - QMessageBox::critical (nullptr, a.applicationName (), parser.errorText ()); + MessageBox::critical_message (nullptr, a.translate ("main", "Command line error"), parser.errorText ()); return -1; } else { if (parser.isSet (help_option)) { - QMessageBox::information (nullptr, a.applicationName (), parser.helpText ()); + MessageBox::information_message (nullptr, a.translate ("main", "Command line help"), parser.helpText ()); return 0; } else if (parser.isSet (version_option)) { - QMessageBox::information (nullptr, a.applicationName (), a.applicationVersion ()); + MessageBox::information_message (nullptr, a.translate ("main", "Application version"), a.applicationVersion ()); return 0; } } @@ -181,18 +181,19 @@ int main(int argc, char *argv[]) { if (QLockFile::LockFailedError == instance_lock.error ()) { - auto button = QMessageBox::question (nullptr - , QApplication::applicationName () - , QObject::tr ("Another instance may be running, try to remove stale lock file?") - , QMessageBox::Yes | QMessageBox::Retry | QMessageBox::No - , QMessageBox::Yes); + auto button = MessageBox::query_message (nullptr + , a.translate ("main", "Another instance may be running") + , a.translate ("main", "try to remove stale lock file?") + , QString {} + , MessageBox::Yes | MessageBox::Retry | MessageBox::No + , MessageBox::Yes); switch (button) { - case QMessageBox::Yes: + case MessageBox::Yes: instance_lock.removeStaleLockFile (); break; - case QMessageBox::Retry: + case MessageBox::Retry: break; default: @@ -216,18 +217,19 @@ int main(int argc, char *argv[]) if (!temp_dir.mkpath (unique_directory) || !temp_dir.cd (unique_directory)) { - QMessageBox::critical (nullptr, - "WSJT-X", - QObject::tr ("Create temporary directory error: ") + temp_dir.absolutePath ()); + MessageBox::critical_message (nullptr, + a.translate ("main", "Failed to create a temporary directory"), + a.translate ("main", "Path: \"%1\"").arg (temp_dir.absolutePath ())); throw std::runtime_error {"Failed to create a temporary directory"}; } if (!temp_dir.isReadable () || !(temp_ok = QTemporaryFile {temp_dir.absoluteFilePath ("test")}.open ())) { - if (QMessageBox::Cancel == QMessageBox::critical (nullptr, - "WSJT-X", - QObject::tr ("Create temporary directory error:\n%1\n" - "Another application may be locking the directory").arg (temp_dir.absolutePath ()), - QMessageBox::Retry | QMessageBox::Cancel)) + auto button = MessageBox::critical_message (nullptr, + a.translate ("main", "Failed to create a usable temporary directory"), + a.translate ("main", "Another application may be locking the directory"), + a.translate ("main", "Path: \"%1\"").arg (temp_dir.absolutePath ()), + MessageBox::Retry | MessageBox::Cancel); + if (MessageBox::Cancel == button) { throw std::runtime_error {"Failed to create a usable temporary directory"}; } @@ -270,8 +272,9 @@ int main(int argc, char *argv[]) if(!mem_jt9.attach()) { if (!mem_jt9.create(sizeof(struct dec_data))) { - QMessageBox::critical (nullptr, "Error", "Unable to create shared memory segment."); - exit(1); + MessageBox::critical_message (nullptr, a.translate ("main", "Shared memory error"), + a.translate ("main", "Unable to create shared memory segment")); + throw std::runtime_error {"Shared memory error"}; } } memset(mem_jt9.data(),0,sizeof(struct dec_data)); //Zero all decoding params in shared memory @@ -319,13 +322,13 @@ int main(int argc, char *argv[]) } catch (std::exception const& e) { - QMessageBox::critical (nullptr, a.applicationName (), e.what ()); + MessageBox::critical_message (nullptr, a.translate ("main", "Fatal error"), e.what ()); std::cerr << "Error: " << e.what () << '\n'; } catch (...) { - QMessageBox::critical (nullptr, a.applicationName (), QObject::tr ("Unexpected error")); - std::cerr << "Unexpected error\n"; + MessageBox::critical_message (nullptr, a.translate ("main", "Unexpected fatal error")); + std::cerr << "Unexpected fatal error\n"; throw; // hoping the runtime might tell us more about the exception } return -1; diff --git a/mainwindow.cpp b/mainwindow.cpp index 23ba6e922..30a537967 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -168,6 +168,8 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, m_config {temp_directory, m_settings, this}, m_WSPR_band_hopping {m_settings, &m_config, this}, m_WSPR_tx_next {false}, + m_rigErrorMessageBox {MessageBox::Critical, tr ("Rig Control Error") + , MessageBox::Cancel | MessageBox::Ok | MessageBox::Retry}, m_wideGraph (new WideGraph(m_settings)), m_echoGraph (new EchoGraph(m_settings)), m_fastGraph (new FastGraph(m_settings)), @@ -346,9 +348,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, // parts of the rig error message box that are fixed m_rigErrorMessageBox.setInformativeText (tr ("Do you want to reconfigure the radio interface?")); - m_rigErrorMessageBox.setStandardButtons (QMessageBox::Cancel | QMessageBox::Ok | QMessageBox::Retry); - m_rigErrorMessageBox.setDefaultButton (QMessageBox::Ok); - m_rigErrorMessageBox.setIcon (QMessageBox::Critical); + m_rigErrorMessageBox.setDefaultButton (MessageBox::Ok); // start audio thread and hook up slots & signals for shutdown management // these objects need to be in the audio thread so that invoking @@ -544,7 +544,7 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, auto const& result = m_saveWAVWatcher.future ().result (); if (!result.isEmpty ()) // error { - QMessageBox::critical (this, tr("Error writing WAV file"), result); + MessageBox::critical_message (this, tr("Error Writing WAV File"), result); } }); @@ -665,8 +665,10 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, { int iret=killbyname("jt9.exe"); if(iret == 603) break; - if(iret != 0) msgBox("KillByName return code: " + - QString::number(iret)); + if(iret != 0) + MessageBox::warning_message (this, tr ("Error Killing jt9.exe Process") + , tr ("KillByName return code: %1") + .arg (iret)); } } #endif @@ -682,8 +684,8 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, { if (!quitFile.remove ()) { - msgBox ("Error removing \"" + quitFile.fileName () + - "\" - OK to retry."); + MessageBox::query_message (this, tr ("Error removing \"%1\"").arg (quitFile.fileName ()) + , tr ("Click OK to retry")); } } } @@ -1288,10 +1290,10 @@ void MainWindow::fastSink(qint64 frames) } void MainWindow::showSoundInError(const QString& errorMsg) -{QMessageBox::critical(this, tr("Error in SoundInput"), errorMsg);} +{MessageBox::critical_message (this, tr ("Error in Sound Input"), errorMsg);} void MainWindow::showSoundOutError(const QString& errorMsg) -{QMessageBox::critical(this, tr("Error in SoundOutput"), errorMsg);} +{MessageBox::critical_message (this, tr ("Error in Sound Output"), errorMsg);} void MainWindow::showStatusMessage(const QString& statusMsg) {statusBar()->showMessage(statusMsg);} @@ -1589,7 +1591,9 @@ void MainWindow::statusChanged() << ui->rptSpinBox->value() << ";" << m_modeTx << endl; f.close(); } else { - msgBox (tr ("Cannot open \"%1\" for writing: %2").arg (f.fileName ()).arg (f.errorString ())); + MessageBox::warning_message (this, tr ("Status File Error") + , tr ("Cannot open \"%1\" for writing: %2") + .arg (f.fileName ()).arg (f.errorString ())); } } @@ -1729,10 +1733,12 @@ void MainWindow::subProcessFailed (QProcess * process, int exit_code, QProcess:: if (argument.contains (' ')) argument = '"' + argument + '"'; arguments << argument; } - msgBox (tr ("Subprocess failed with exit code %1\nRunning:%2\n%3") - .arg (exit_code) - .arg (process->program () + ' ' + arguments.join (' ')) - .arg (QString {process->readAllStandardError()})); + MessageBox::critical_message (this, tr ("Subprocess Error") + , tr ("Subprocess failed with exit code %1") + .arg (exit_code) + , tr ("Running: %1\n%2") + .arg (process->program () + ' ' + arguments.join (' ')) + .arg (QString {process->readAllStandardError()})); QTimer::singleShot (0, this, SLOT (close ())); m_valid = false; // ensures exit if still constructing } @@ -1748,9 +1754,10 @@ void MainWindow::subProcessError (QProcess * process, QProcess::ProcessError) if (argument.contains (' ')) argument = '"' + argument + '"'; arguments << argument; } - msgBox (tr ("Subprocess error\nRunning: %1\n%2") - .arg (process->program () + ' ' + arguments.join (' ')) - .arg (process->errorString ())); + MessageBox::critical_message (this, tr ("Subprocess error") + , tr ("Running: %1\n%2") + .arg (process->program () + ' ' + arguments.join (' ')) + .arg (process->errorString ())); QTimer::singleShot (0, this, SLOT (close ())); m_valid = false; // ensures exit if still constructing } @@ -1785,18 +1792,11 @@ void MainWindow::on_stopButton_clicked() //stopButton monitor (false); m_loopall=false; if(m_bRefSpec) { -// msgBox("Reference spectrum saved."); +// MessageBox::information_message (this, tr ("Reference spectrum saved")); m_bRefSpec=false; } } -void MainWindow::msgBox (QString const& text) -{ - msgBox0.setText (text); - QApplication::alert (this); - msgBox0.exec (); -} - void MainWindow::on_actionOnline_User_Guide_triggered() //Display manual { #if defined (CMAKE_BUILD) @@ -1979,10 +1979,10 @@ void MainWindow::diskDat() //diskDat() //Delete ../save/*.wav void MainWindow::on_actionDelete_all_wav_files_in_SaveDir_triggered() { - if (QMessageBox::Yes == QMessageBox::warning(this, "Confirm Delete", - "Are you sure you want to delete all *.wav and *.c2 files in\n" + - QDir::toNativeSeparators(m_config.save_directory ().absolutePath ()) + " ?", - QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)) { + auto button = MessageBox::query_message (this, tr ("Confirm Delete"), + tr ("Are you sure you want to delete all *.wav and *.c2 files in \"%1\"?") + .arg (QDir::toNativeSeparators (m_config.save_directory ().absolutePath ()))); + if (MessageBox::Yes == button) { Q_FOREACH (auto const& file , m_config.save_directory ().entryList ({"*.wav", "*.c2"}, QDir::Files | QDir::Writable)) { m_config.save_directory ().remove (file); @@ -2255,7 +2255,9 @@ void::MainWindow::fast_decode_done() out << message.mid(0,n-2) << endl; f.close(); } else { - msgBox (tr ("Cannot open \"%1\" for append: %2").arg (f.fileName ()).arg (f.errorString ())); + MessageBox::warning_message (this, tr ("File Open Error") + , tr ("Cannot open \"%1\" for append: %2") + .arg (f.fileName ()).arg (f.errorString ())); } if(m_mode=="JT9" or m_mode=="JTMSK" or m_mode=="MSK144") { @@ -2342,7 +2344,9 @@ void MainWindow::readFromStdout() //readFromStdout out << t.mid(0,n-2) << endl; f.close(); } else { - msgBox (tr ("Cannot open \"%1\" for append: %2").arg (f.fileName ()).arg (f.errorString ())); + MessageBox::warning_message (this, tr ("File Open Error") + , tr ("Cannot open \"%1\" for append: %2") + .arg (f.fileName ()).arg (f.errorString ())); } if (m_config.insert_blank () && m_blankLine) @@ -2591,13 +2595,15 @@ void MainWindow::guiUpdate() if (m_auto) auto_tx_mode (false); if(onAirFreq!=m_onAirFreq0) { m_onAirFreq0=onAirFreq; - auto const& message = tr ("Please choose another Tx frequency.\n" - "WSJT-X will not knowingly transmit another\n" - "mode in the WSPR sub-band on 30 m."); + auto const& message = tr ("Please choose another Tx frequency." + " WSJT-X will not knowingly transmit another" + " mode in the WSPR sub-band on 30m."); #if QT_VERSION >= 0x050400 - QTimer::singleShot (0, [=] {msgBox (message);}); // don't block guiUpdate + QTimer::singleShot (0, [=] { // don't block guiUpdate + MessageBox::warning_message (this, tr ("WSPR Guard Band"), message); + }); #else - msgBox (message); + MessageBox::warning_message (this, tr ("WSPR Guard Band"), message); #endif } } @@ -2745,9 +2751,11 @@ void MainWindow::guiUpdate() auto const& message = tr ("Cannot open \"%1\" for append: %2") .arg (f.fileName ()).arg (f.errorString ()); #if QT_VERSION >= 0x050400 - QTimer::singleShot (0, [=] {msgBox (message);}); // don't block guiUpdate + QTimer::singleShot (0, [=] { // don't block guiUpdate + MessageBox::warning_message (this, tr ("Log File Error"), message); + }); #else - msgBox (message); + MessageBox::warning_message (this, tr ("Log File Error"), message); #endif } if (m_config.TX_messages ()) @@ -2849,9 +2857,11 @@ void MainWindow::guiUpdate() auto const& message = tr ("Cannot open \"%1\" for append: %2") .arg (f.fileName ()).arg(f.errorString ()); #if QT_VERSION >= 0x050400 - QTimer::singleShot (0, [=] {msgBox (message);}); // don't block guiUpdate + QTimer::singleShot (0, [=] { // don't block guiUpdate + MessageBox::warning_message (this, tr ("Log File Error"), message); + }); #else - msgBox (message); + MessageBox::warning_message (this, tr ("Log File Error"), message); #endif } } @@ -2971,8 +2981,9 @@ void MainWindow::startTx2() << m_currentMessage << " " + m_mode << endl; f.close(); } else { - msgBox (tr ("Cannot open \"%1\" for append: %2") - .arg (f.fileName ()).arg (f.errorString ())); + MessageBox::warning_message (this, tr ("Log File Error"), + tr ("Cannot open \"%1\" for append: %2") + .arg (f.fileName ()).arg (f.errorString ())); } } } @@ -3095,7 +3106,10 @@ void MainWindow::doubleClickOnCall(bool shift, bool ctrl) { QTextCursor cursor; QString t; //Full contents - if(m_mode=="ISCAT") msgBox("Double-click not presently implemented for ISCAT mode"); + if(m_mode=="ISCAT") { + MessageBox::information_message (this, + "Double-click not presently implemented for ISCAT mode"); + } if(shift) t=""; //Silence compiler warning if(m_decodedText2) { cursor=ui->decodedTextBrowser->textCursor(); @@ -3574,7 +3588,8 @@ void MainWindow::on_lookupButton_clicked() //Lookup button void MainWindow::on_addButton_clicked() //Add button { if(ui->dxGridEntry->text()=="") { - msgBox("Please enter a valid grid locator."); + MessageBox::warning_message (this, tr ("Add to CALL3.TXT") + , tr ("Please enter a valid grid locator")); return; } m_call3Modified=false; @@ -3582,10 +3597,9 @@ void MainWindow::on_addButton_clicked() //Add button QString hisgrid=ui->dxGridEntry->text().trimmed(); QString newEntry=hisCall + "," + hisgrid; - // int ret = QMessageBox::warning(this, "Add", - // newEntry + "\n" + "Is this station known to be active on EME?", - // QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); - // if(ret==QMessageBox::Yes) { + // int ret = MessageBox::query_message(this, tr ("Add to CALL3.TXT"), + // tr ("Is %1 known to be active on EME?").arg (newEntry)); + // if(ret==MessageBox::Yes) { // newEntry += ",EME,,"; // } else { newEntry += ",,,"; @@ -3593,7 +3607,9 @@ void MainWindow::on_addButton_clicked() //Add button QFile f1 {m_dataDir.absoluteFilePath ("CALL3.TXT")}; if(!f1.open(QIODevice::ReadWrite | QIODevice::Text)) { - msgBox("Cannot open \"" + f1.fileName () + "\" for read/write:" + f1.errorString ()); + MessageBox::warning_message (this, tr ("Add to CALL3.TXT") + , tr ("Cannot open \"%1\" for read/write: %2") + .arg (f1.fileName ()).arg (f1.errorString ())); return; } if(f1.size()==0) { @@ -3604,7 +3620,9 @@ void MainWindow::on_addButton_clicked() //Add button } QFile f2 {m_dataDir.absoluteFilePath ("CALL3.TMP")}; if(!f2.open(QIODevice::WriteOnly | QIODevice::Text)) { - msgBox("Cannot open \"" + f2.fileName () + "\" for writing:" + f2.errorString ()); + MessageBox::warning_message (this, tr ("Add to CALL3.TXT") + , tr ("Cannot open \"%1\" for writing: %2") + .arg (f2.fileName ()).arg (f2.errorString ())); return; } QTextStream in(&f1); //Read from CALL3.TXT @@ -3626,11 +3644,10 @@ void MainWindow::on_addButton_clicked() //Add button out << s + "\n"; m_call3Modified=true; } else if(hc==hc2) { - QString t=s + "\n\n is already in CALL3.TXT\n" + - "Do you wish to replace it?"; - int ret = QMessageBox::warning(this, "Add",t, - QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); - if(ret==QMessageBox::Yes) { + QString t {tr ("%1\nis already in CALL3.TXT" + ", do you wish to replace it?").arg (s)}; + int ret = MessageBox::query_message (this, tr ("Add to CALL3.TXT"), t); + if(ret==MessageBox::Yes) { out << newEntry + "\n"; m_call3Modified=true; } @@ -4112,7 +4129,7 @@ void MainWindow::on_actionWSPR_2_triggered() void MainWindow::on_actionWSPR_15_triggered() { - msgBox("WSPR-15 is not yet available"); + MessageBox::information_message (this, tr ("WSPR-15 is not yet available")); switch_mode (Modes::WSPR); } @@ -4315,10 +4332,9 @@ void MainWindow::on_inGain_valueChanged(int n) void MainWindow::on_actionErase_ALL_TXT_triggered() //Erase ALL.TXT { - int ret = QMessageBox::warning(this, "Confirm Erase", - "Are you sure you want to erase file ALL.TXT ?", - QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); - if(ret==QMessageBox::Yes) { + int ret = MessageBox::query_message (this, tr ("Confirm Erase"), + tr ("Are you sure you want to erase file ALL.TXT?")); + if(ret==MessageBox::Yes) { QFile f {m_dataDir.absoluteFilePath ("ALL.TXT")}; f.remove(); m_RxLog=1; @@ -4327,10 +4343,9 @@ void MainWindow::on_actionErase_ALL_TXT_triggered() //Erase ALL.TXT void MainWindow::on_actionErase_wsjtx_log_adi_triggered() { - int ret = QMessageBox::warning(this, "Confirm Erase", - "Are you sure you want to erase file wsjtx_log.adi ?", - QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); - if(ret==QMessageBox::Yes) { + int ret = MessageBox::query_message (this, tr ("Confirm Erase"), + tr ("Are you sure you want to erase file wsjtx_log.adi?")); + if(ret==MessageBox::Yes) { QFile f {m_dataDir.absoluteFilePath ("wsjtx_log.adi")}; f.remove(); } @@ -4742,7 +4757,9 @@ void MainWindow::handle_transceiver_update (Transceiver::TransceiverState const& << m_mode << endl; f2.close(); } else { - msgBox("Cannot open \"" + f2.fileName () + "\" for append:" + f2.errorString ()); + MessageBox::warning_message (this, tr ("File Error") + ,tr ("Cannot open \"%1\" for append: %2") + .arg (f2.fileName ()).arg (f2.errorString ())); } } @@ -4771,10 +4788,10 @@ void MainWindow::handle_transceiver_failure (QString const& reason) update_dynamic_property (ui->readFreq, "state", "error"); ui->readFreq->setEnabled (true); on_stopTxButton_clicked (); - rigFailure ("Rig Control Error", reason); + rigFailure (reason); } -void MainWindow::rigFailure (QString const& reason, QString const& detail) +void MainWindow::rigFailure (QString const& reason) { if (m_first_error) { @@ -4784,21 +4801,20 @@ void MainWindow::rigFailure (QString const& reason, QString const& detail) } else { - m_rigErrorMessageBox.setText (reason); - m_rigErrorMessageBox.setDetailedText (detail); + m_rigErrorMessageBox.setDetailedText (reason); // don't call slot functions directly to avoid recursion switch (m_rigErrorMessageBox.exec ()) { - case QMessageBox::Ok: + case MessageBox::Ok: QTimer::singleShot (0, this, SLOT (on_actionSettings_triggered ())); break; - case QMessageBox::Retry: + case MessageBox::Retry: QTimer::singleShot (0, this, SLOT (rigOpen ())); break; - case QMessageBox::Cancel: + case MessageBox::Cancel: QTimer::singleShot (0, this, SLOT (close ())); break; } @@ -5287,12 +5303,14 @@ void MainWindow::postWSPRDecode (bool is_new, QStringList parts) void MainWindow::networkError (QString const& e) { - if (QMessageBox::Retry == QMessageBox::warning (this, tr ("Network Error") - , tr ("Error: %1\nUDP server %2:%3") - .arg (e) - .arg (m_config.udp_server_name ()) - .arg (m_config.udp_server_port ()) - , QMessageBox::Cancel | QMessageBox::Retry, QMessageBox::Cancel)) + if (MessageBox::Retry == MessageBox::warning_message (this, tr ("Network Error") + , tr ("Error: %1\nUDP server %2:%3") + .arg (e) + .arg (m_config.udp_server_name ()) + .arg (m_config.udp_server_port ()) + , QString {} + , MessageBox::Cancel | MessageBox::Retry + , MessageBox::Cancel)) { // retry server lookup m_messageClient->set_server (m_config.udp_server_name ()); @@ -5428,7 +5446,9 @@ void MainWindow::WSPR_history(Frequency dialFreq, int ndecodes) out << t1 << endl; f.close(); } else { - msgBox("Cannot open \"" + f.fileName () + "\" for append:" + f.errorString ()); + MessageBox::warning_message (this, tr ("File Error") + , tr ("Cannot open \"%1\" for append: %2") + .arg (f.fileName ()).arg (f.errorString ())); } } diff --git a/mainwindow.h b/mainwindow.h index 2be72c1b8..6ccfebc13 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -34,6 +34,7 @@ #include "decodedtext.h" #include "commons.h" #include "astro.h" +#include "MessageBox.hpp" #define NUM_JT4_SYMBOLS 206 //(72+31)*2, embedded sync #define NUM_JT65_SYMBOLS 126 //63 data + 63 sync @@ -290,7 +291,7 @@ private: Configuration m_config; WSPRBandHopping m_WSPR_band_hopping; bool m_WSPR_tx_next; - QMessageBox m_rigErrorMessageBox; + MessageBox m_rigErrorMessageBox; QScopedPointer m_sampleDownloader; QScopedPointer m_wideGraph; @@ -434,8 +435,6 @@ private: QLabel band_hopping_label; QProgressBar progressBar; - QMessageBox msgBox0; - QFuture m_wav_future; QFutureWatcher m_wav_future_watcher; QFutureWatcher watcher3; @@ -514,7 +513,6 @@ private: void writeSettings(); void createStatusBar(); void updateStatusBar(); - void msgBox(QString const&); void genStdMsgs(QString rpt); void clearDX (); void lookup(); @@ -525,7 +523,7 @@ private: bool gridOK(QString g); bool shortList(QString callsign); void transmit (double snr = 99.); - void rigFailure (QString const& reason, QString const& detail); + void rigFailure (QString const& reason); void pskSetLocal (); void displayDialFrequency (); void transmitDisplay (bool); diff --git a/widegraph.cpp b/widegraph.cpp index 3abf0f1d2..8818554de 100644 --- a/widegraph.cpp +++ b/widegraph.cpp @@ -4,13 +4,13 @@ #include "ui_widegraph.h" #include "commons.h" #include "Configuration.hpp" +#include "MessageBox.hpp" #include "moc_widegraph.cpp" -static float swide[MAX_SCREENSIZE]; - namespace { auto user_defined = QObject::tr ("User Defined"); + float swide[MAX_SCREENSIZE]; } WideGraph::WideGraph(QSettings * settings, QWidget *parent) : @@ -367,9 +367,7 @@ void WideGraph::readPalette () //readPalette } catch (std::exception const& e) { - QMessageBox msgBox0; - msgBox0.setText(e.what()); - msgBox0.exec(); + MessageBox::warning_message (this, tr ("Read Palette"), e.what ()); } } @@ -412,9 +410,7 @@ void WideGraph::on_adjust_palette_push_button_clicked (bool) //Adjust Palette } catch (std::exception const& e) { - QMessageBox msgBox0; - msgBox0.setText(e.what()); - msgBox0.exec(); + MessageBox::warning_message (this, tr ("Read Palette"), e.what ()); } } diff --git a/wsjtx_config.h.in b/wsjtx_config.h.in index 9e6e0368f..4abdbba01 100644 --- a/wsjtx_config.h.in +++ b/wsjtx_config.h.in @@ -33,4 +33,13 @@ #define WSJTX_STRINGIZE1(x) #x #define WSJTX_STRINGIZE(x) WSJTX_STRINGIZE1(x) +/* consistent UNICODE behaviour */ +#ifndef UNICODE +# undef _UNICODE +#else +# ifndef _UNICODE +# define _UNICODE +# endif +#endif + #endif