summaryrefslogtreecommitdiff
path: root/Configuration.cpp
diff options
context:
space:
mode:
authortony mancill <tmancill@debian.org>2024-01-01 11:39:50 -0800
committertony mancill <tmancill@debian.org>2024-01-01 11:39:50 -0800
commitffea9660ba79a513401639a2f5d90e2fdc190fb8 (patch)
tree4e1abd6eca581d5baec48b86e213ae31138bcf5e /Configuration.cpp
parent393a486ee1d7e308a49f8e0b8c3a4b2f43223248 (diff)
New upstream version 2.7.0~rc3+repackupstream/2.7.0_rc3+repack
Diffstat (limited to 'Configuration.cpp')
-rwxr-xr-xConfiguration.cpp134
1 files changed, 130 insertions, 4 deletions
diff --git a/Configuration.cpp b/Configuration.cpp
index 7c333b45..ac7e8739 100755
--- a/Configuration.cpp
+++ b/Configuration.cpp
@@ -173,7 +173,6 @@
#include <QJsonDocument>
#include <QJsonArray>
-
#include "pimpl_impl.hpp"
#include "Logger.hpp"
#include "qt_helpers.hpp"
@@ -245,6 +244,7 @@ namespace
|X85|X86|X87|X88|X89|X90|X91
|X92|X93|X94|X95|X96|X97|X98
|X99
+ |[0-9][0-9][0-9][0-9] # 4-digit numbers
)
)", QRegularExpression::CaseInsensitiveOption | QRegularExpression::ExtendedPatternSyntaxOption};
@@ -330,9 +330,9 @@ public:
connect (button_box, &QDialogButtonBox::accepted, this, &FrequencyDialog::accept);
connect (button_box, &QDialogButtonBox::rejected, this, &FrequencyDialog::reject);
- connect(start_date_time_edit_, &QDateTimeEdit::dateTimeChanged, this, &FrequencyDialog::checkSaneDates);
- connect(end_date_time_edit_, &QDateTimeEdit::dateTimeChanged, this, &FrequencyDialog::checkSaneDates);
- connect(enable_dates_checkbox_, &QCheckBox::stateChanged, this, &FrequencyDialog::toggleValidity);
+ connect (start_date_time_edit_, &QDateTimeEdit::dateTimeChanged, this, &FrequencyDialog::checkSaneDates);
+ connect (end_date_time_edit_, &QDateTimeEdit::dateTimeChanged, this, &FrequencyDialog::checkSaneDates);
+ connect (enable_dates_checkbox_, &QCheckBox::stateChanged, this, &FrequencyDialog::toggleValidity);
toggleValidity();
}
@@ -580,6 +580,11 @@ private:
Q_SLOT void on_rescan_log_push_button_clicked (bool);
Q_SLOT void on_CTY_download_button_clicked (bool);
Q_SLOT void on_LotW_CSV_fetch_push_button_clicked (bool);
+ Q_SLOT void on_hamlib_download_button_clicked (bool);
+ Q_SLOT void on_revert_update_button_clicked (bool);
+ void error_during_hamlib_download (QString const& reason);
+ void after_hamlib_downloaded();
+ void display_file_information();
Q_SLOT void on_cbx2ToneSpacing_clicked(bool);
Q_SLOT void on_cbx4ToneSpacing_clicked(bool);
@@ -684,6 +689,7 @@ private:
QString FD_exchange_;
QString RTTY_exchange_;
QString Contest_Name_;
+ QString hamlib_backed_up_;
qint32 id_interval_;
qint32 ntrials_;
@@ -1570,6 +1576,7 @@ void Configuration::impl::read_settings ()
ui_->Field_Day_Exchange->setText(FD_exchange_);
ui_->RTTY_Exchange->setText(RTTY_exchange_);
ui_->Contest_Name->setText(Contest_Name_);
+ hamlib_backed_up_ = settings_->value ("HamlibBackedUp",QString {}).toString ();
if (next_font_.fromString (settings_->value ("Font", QGuiApplication::font ().toString ()).toString ())
&& next_font_ != font_)
@@ -1746,6 +1753,18 @@ void Configuration::impl::read_settings ()
pwrBandTuneMemory_ = settings_->value("pwrBandTuneMemory",false).toBool ();
highlight_DXcall_ = settings_->value("highlight_DXcall",false).toBool ();
highlight_DXgrid_ = settings_->value("highlight_DXgrid",false).toBool ();
+#ifdef WIN32
+ QTimer::singleShot (2500, [=] {display_file_information ();});
+#else
+ ui_->hamlib_groupBox->setTitle("Hamlib Version");
+ ui_->rbHamlib64->setVisible(false);
+ ui_->rbHamlib32->setVisible(false);
+ ui_->hamlib_download_button->setVisible(false);
+ ui_->revert_update_button->setVisible(false);
+ ui_->backed_up_text->setVisible(false);
+ ui_->backed_up->setVisible(false);
+ QTimer::singleShot (2500, [=] {display_file_information ();});
+#endif
}
void Configuration::impl::find_audio_devices ()
@@ -2484,6 +2503,113 @@ void Configuration::impl::on_decoded_text_font_push_button_clicked ()
);
}
+void Configuration::impl::on_hamlib_download_button_clicked (bool /*clicked*/)
+{
+#ifdef WIN32
+ extern char* hamlib_version2;
+ QString hamlib = QString(QLatin1String(hamlib_version2));
+ SettingsGroup g {settings_, "Configuration"};
+ settings_->setValue ("HamlibBackedUp", hamlib);
+ settings_->sync ();
+ QDir dataPath = QCoreApplication::applicationDirPath();
+ QFile f1 {dataPath.absolutePath() + "/" + "libhamlib-4_old.dll"};
+ QFile f2 {dataPath.absolutePath() + "/" + "libhamlib-4_new.dll"};
+ if (f1.exists()) f1.remove();
+ if (f2.exists()) f2.remove();
+ ui_->hamlib_download_button->setEnabled (false);
+ ui_->revert_update_button->setEnabled (false);
+ if (ui_->rbHamlib32->isChecked()) {
+ cty_download.configure(network_manager_,
+ "https://n0nb.users.sourceforge.net/dll32/libhamlib-4.dll",
+ dataPath.absoluteFilePath("libhamlib-4_new.dll"),
+ "Downloading latest libhamlib-4.dll");
+ } else {
+ cty_download.configure(network_manager_,
+ "https://n0nb.users.sourceforge.net/dll64/libhamlib-4.dll",
+ dataPath.absoluteFilePath("libhamlib-4_new.dll"),
+ "Downloading latest libhamlib-4.dll");
+ }
+ connect (&cty_download, &FileDownload::complete, this, &Configuration::impl::after_hamlib_downloaded, Qt::UniqueConnection);
+ connect (&cty_download, &FileDownload::error, this, &Configuration::impl::error_during_hamlib_download, Qt::UniqueConnection);
+ cty_download.start_download();
+#else
+ MessageBox::warning_message (this, tr ("Hamlib update only available on Windows."));
+#endif
+}
+
+void Configuration::impl::error_during_hamlib_download (QString const& reason)
+{
+ QDir dataPath = QCoreApplication::applicationDirPath();
+ MessageBox::warning_message (this, tr ("Error Loading libhamlib-4.dll"), reason);
+ ui_->hamlib_download_button->setEnabled (true);
+ ui_->revert_update_button->setEnabled (true);
+}
+
+void Configuration::impl::after_hamlib_downloaded ()
+{
+ QDir dataPath = QCoreApplication::applicationDirPath();
+ QFile::rename(dataPath.absolutePath() + "/" + "libhamlib-4.dll", dataPath.absolutePath() + "/" + "libhamlib-4_old.dll");
+ QTimer::singleShot (1000, [=] {
+ QFile::rename(dataPath.absolutePath() + "/" + "libhamlib-4_new.dll", dataPath.absolutePath() + "/" + "libhamlib-4.dll");
+ });
+ QTimer::singleShot (2000, [=] {
+ MessageBox::information_message (this, tr ("Hamlib Update successful \n\nNew Hamlib will be used after restart"));
+ ui_->revert_update_button->setEnabled (true);
+ ui_->hamlib_download_button->setEnabled (true);
+ });
+}
+
+void Configuration::impl::on_revert_update_button_clicked (bool /*clicked*/)
+{
+#ifdef WIN32
+ QDir dataPath = QCoreApplication::applicationDirPath();
+ QFile f {dataPath.absolutePath() + "/" + "libhamlib-4_old.dll"};
+ if (f.exists()) {
+ ui_->revert_update_button->setEnabled (false);
+ ui_->hamlib_download_button->setEnabled (false);
+ QFile::rename(dataPath.absolutePath() + "/" + "libhamlib-4.dll", dataPath.absolutePath() + "/" + "libhamlib-4_new.dll");
+ QTimer::singleShot (1000, [=] {
+ QFile::copy(dataPath.absolutePath() + "/" + "libhamlib-4_old.dll", dataPath.absolutePath() + "/" + "libhamlib-4.dll");
+ });
+ QTimer::singleShot (2000, [=] {
+ MessageBox::information_message (this, tr ("Hamlib successfully reverted \n\nReverted Hamlib will be used after restart"));
+ ui_->revert_update_button->setEnabled (true);
+ ui_->hamlib_download_button->setEnabled (true);
+ });
+ } else {
+ MessageBox::warning_message (this, tr ("No Hamlib update found that could be reverted"));
+ }
+#else
+ MessageBox::warning_message (this, tr ("Hamlib update only available on Windows."));
+#endif
+}
+
+void Configuration::impl::display_file_information ()
+{
+#ifdef WIN32
+ QDir dataPath = QCoreApplication::applicationDirPath();
+ extern char* hamlib_version2;
+ QString hamlib = QString(QLatin1String(hamlib_version2));
+ ui_->in_use->setText(hamlib);
+ QFileInfo fi2(dataPath.absolutePath() + "/" + "libhamlib-4_old.dll");
+ QString birthTime2 = fi2.birthTime().toString("yyyy-MM-dd hh:mm");
+ QFile f {dataPath.absolutePath() + "/" + "libhamlib-4_old.dll"};
+ if (f.exists()) {
+ if (hamlib_backed_up_=="") {
+ ui_->backed_up->setText(QString{"no hamlib data available, file saved %1"}.arg(birthTime2));
+ } else {
+ ui_->backed_up->setText(hamlib_backed_up_);
+ }
+ } else {
+ ui_->backed_up->setText("");
+ }
+#else
+ extern char* hamlib_version2;
+ QString hamlib = QString(QLatin1String(hamlib_version2));
+ ui_->in_use->setText(hamlib);
+#endif
+}
+
void Configuration::impl::on_PTT_port_combo_box_activated (int /* index */)
{
set_rig_invariants ();