diff --git a/Configuration.cpp b/Configuration.cpp
index 90bdb462b..8742be432 100644
--- a/Configuration.cpp
+++ b/Configuration.cpp
@@ -581,6 +581,10 @@ 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();
Q_SLOT void on_cbx2ToneSpacing_clicked(bool);
Q_SLOT void on_cbx4ToneSpacing_clicked(bool);
@@ -2485,6 +2489,83 @@ void Configuration::impl::on_decoded_text_font_push_button_clicked ()
);
}
+void Configuration::impl::on_hamlib_download_button_clicked (bool /*clicked*/)
+{
+#ifdef WIN32
+ 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::rename(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::on_PTT_port_combo_box_activated (int /* index */)
{
set_rig_invariants ();
diff --git a/Configuration.ui b/Configuration.ui
index b3d38dda8..ceb66ad88 100644
--- a/Configuration.ui
+++ b/Configuration.ui
@@ -932,6 +932,52 @@ a few, particularly some Kenwood rigs, require it).
+ -
+
+
+ Update Hamlib (Windows only)
+
+
+
-
+
+
+ 64-bit
+
+
+ true
+
+
+
+ -
+
+
+ 32-bit
+
+
+
+ -
+
+
+ <html><head/><body><p>Download the latest libhamlib-4.dll file from https://n0nb.users.sourceforge.net/. </p><p>Note: This function is only available on Windows.</p></body></html>
+
+
+ Udpate Hamlib
+
+
+
+ -
+
+
+ <html><head/><body><p>Revert the last Hamlib update. </p><p>Note: This function is only available on Windows.</p></body></html>
+
+
+ Revert Update
+
+
+
+
+
+
@@ -3421,12 +3467,12 @@ Right click for insert and delete options.
-
-
-
-
-
+
+
+
+
+