From 4ccdb42107670ede987bb02a53fde43a6505a02c Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Tue, 9 Jun 2015 17:39:59 +0000 Subject: [PATCH] User-configurable directory for file azel.dat. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5566 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- Configuration.cpp | 27 +++++++++++++-- Configuration.hpp | 1 + Configuration.ui | 83 ++++++++++++++++++++++++++++++++++++----------- astro.cpp | 3 +- astro.h | 2 ++ mainwindow.cpp | 2 ++ 6 files changed, 95 insertions(+), 23 deletions(-) diff --git a/Configuration.cpp b/Configuration.cpp index aa3ab16af..d01a91cee 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -409,6 +409,7 @@ private: Q_SLOT void delete_macro (); void delete_selected_macros (QModelIndexList); Q_SLOT void on_save_path_select_push_button_clicked (bool); + Q_SLOT void on_azel_path_select_push_button_clicked (bool); Q_SLOT void delete_frequencies (); Q_SLOT void on_reset_frequencies_push_button_clicked (bool); Q_SLOT void insert_frequency (); @@ -446,6 +447,8 @@ private: QDir temp_dir_; QDir default_save_directory_; QDir save_directory_; + QDir default_azel_directory_; + QDir azel_directory_; QFont font_; QFont next_font_; @@ -631,6 +634,7 @@ FrequencyList const * Configuration::frequencies () const {return &m_->frequenci QStringListModel * Configuration::macros () {return &m_->macros_;} QStringListModel const * Configuration::macros () const {return &m_->macros_;} QDir Configuration::save_directory () const {return m_->save_directory_;} +QDir Configuration::azel_directory () const {return m_->azel_directory_;} QString Configuration::rig_name () const {return m_->rig_params_.rig_name;} bool Configuration::transceiver_online (bool open_if_closed) @@ -797,9 +801,11 @@ Configuration::impl::impl (Configuration * self, QSettings * settings, QWidget * // Make sure the default save directory exists QString save_dir {"save"}; default_save_directory_ = data_dir; + 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) + "\"."); + QMessageBox::critical (this, "WSJT-X", tr ("Create Directory", "Cannot create directory \"") + + default_save_directory_.absoluteFilePath (save_dir) + "\"."); throw std::runtime_error {"Failed to create save directory"}; } @@ -809,7 +815,8 @@ Configuration::impl::impl (Configuration * self, QSettings * settings, QWidget * 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) + "\"."); + 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"}; } @@ -1011,6 +1018,7 @@ void Configuration::impl::initialize_models () ui_->CW_id_interval_spin_box->setValue (id_interval_); ui_->PTT_method_button_group->button (rig_params_.ptt_type)->setChecked (true); ui_->save_path_display_label->setText (save_directory_.absolutePath ()); + ui_->azel_path_display_label->setText (azel_directory_.absolutePath ()); ui_->CW_id_after_73_check_box->setChecked (id_after_73_); ui_->tx_QSY_check_box->setChecked (tx_QSY_allowed_); ui_->psk_reporter_check_box->setChecked (spot_to_psk_reporter_); @@ -1122,6 +1130,7 @@ void Configuration::impl::read_settings () id_interval_ = settings_->value ("IDint", 0).toInt (); save_directory_ = settings_->value ("SaveDir", default_save_directory_.absolutePath ()).toString (); + azel_directory_ = settings_->value ("AzElDir", default_azel_directory_.absolutePath ()).toString (); { // @@ -1256,6 +1265,7 @@ void Configuration::impl::write_settings () settings_->setValue ("PTTMethod", QVariant::fromValue (rig_params_.ptt_type)); settings_->setValue ("PTTport", rig_params_.ptt_port); settings_->setValue ("SaveDir", save_directory_.absolutePath ()); + settings_->setValue ("AzElDir", azel_directory_.absolutePath ()); if (default_audio_input_device_selected_) { @@ -1671,6 +1681,7 @@ void Configuration::impl::accept () TX_messages_ = ui_->TX_messages_check_box->isChecked (); data_mode_ = static_cast (ui_->TX_mode_button_group->checkedId ()); save_directory_ = ui_->save_path_display_label->text (); + azel_directory_ = ui_->azel_path_display_label->text (); enable_VHF_features_ = ui_->enable_VHF_features_check_box->isChecked (); decode_at_52s_ = ui_->decode_at_52s_check_box->isChecked (); frequency_calibration_intercept_ = ui_->calibration_intercept_spin_box->value (); @@ -2056,6 +2067,18 @@ void Configuration::impl::on_save_path_select_push_button_clicked (bool /* check } } +void Configuration::impl::on_azel_path_select_push_button_clicked (bool /* checked */) +{ + QFileDialog fd {this, tr ("AzEl Directory"), ui_->azel_path_display_label->text ()}; + fd.setFileMode (QFileDialog::Directory); + fd.setOption (QFileDialog::ShowDirsOnly); + if (fd.exec ()) { + if (fd.selectedFiles ().size ()) { + ui_->azel_path_display_label->setText(fd.selectedFiles().at(0)); + } + } +} + bool Configuration::impl::have_rig (bool open_if_closed) { if (open_if_closed && !open_rig ()) diff --git a/Configuration.hpp b/Configuration.hpp index 001d1947b..f6983665b 100644 --- a/Configuration.hpp +++ b/Configuration.hpp @@ -125,6 +125,7 @@ public: QStringListModel * macros (); QStringListModel const * macros () const; QDir save_directory () const; + QDir azel_directory () const; QString rig_name () const; unsigned jt9w_bw_mult () const; float jt9w_min_dt () const; diff --git a/Configuration.ui b/Configuration.ui index f2647f624..535fce4bf 100644 --- a/Configuration.ui +++ b/Configuration.ui @@ -44,7 +44,7 @@ Select tab to change configuration parameters. - 0 + 2 @@ -1161,6 +1161,26 @@ radio interface behave as expected. Audio interface settings + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + @@ -1328,7 +1348,7 @@ both here. - + JT9W Settings @@ -1482,24 +1502,49 @@ both here. - - - - Qt::Vertical - - + + + - 20 - 40 + 0 + 56 - - - - - - Qt::Horizontal + + AzEl Directory + + + + + Location: + + + + + + + + 1 + 0 + + + + background-color: rgb(255, 255, 255); + + + TextLabel + + + + + + + Select + + + + @@ -2376,12 +2421,12 @@ soundcard changes - - + - + + diff --git a/astro.cpp b/astro.cpp index d59fc9679..c4af0c4a7 100644 --- a/astro.cpp +++ b/astro.cpp @@ -100,8 +100,7 @@ void Astro::astroUpdate(QDateTime t, QString mygrid, QString hisgrid, qint64 fre int nfreq=freqMoon/1000000; double freq8=(double)freqMoon; - QDir writable = QStandardPaths::writableLocation (QStandardPaths::DataLocation); - QString AzElFileName = QDir::toNativeSeparators(writable.absoluteFilePath ("azel.dat")); + QString AzElFileName = QDir::toNativeSeparators(m_azelDir.absoluteFilePath ("azel.dat")); astrosub_(&nyear, &month, &nday, &uth, &freq8, mygrid.toLatin1().constData(), hisgrid.toLatin1().constData(), &azsun, &elsun, &azmoon, &elmoon, diff --git a/astro.h b/astro.h index e5062be87..240aae7f5 100644 --- a/astro.h +++ b/astro.h @@ -34,6 +34,8 @@ public: qint32 m_Hz; qint32 m_stepHz; + QDir m_azelDir; + protected: void closeEvent (QCloseEvent *) override; diff --git a/mainwindow.cpp b/mainwindow.cpp index 43226af28..31cad75eb 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -958,6 +958,7 @@ void MainWindow::on_actionSettings_triggered() //Setup Dialog { Q_EMIT m_config.transceiver_frequency (m_dialFreq); } + if(m_astroWidget) m_astroWidget->m_azelDir=m_config.azel_directory(); } void MainWindow::on_monitorButton_clicked (bool checked) @@ -1358,6 +1359,7 @@ void MainWindow::on_actionAstronomical_data_triggered() connect (this, &MainWindow::finished, m_astroWidget.data (), &Astro::close); } m_astroWidget->showNormal(); + m_astroWidget->m_azelDir=m_config.azel_directory(); } void MainWindow::on_actionMessage_averaging_triggered()