mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2025-03-20 19:19:02 -04:00
Add a new function "Update Hamlib (Windows only)".
This commit is contained in:
parent
b073fa0550
commit
d76790adc3
@ -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 ();
|
||||
|
@ -932,6 +932,52 @@ a few, particularly some Kenwood rigs, require it).</string>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="hamlib_groupBox">
|
||||
<property name="title">
|
||||
<string>Update Hamlib (Windows only)</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_18">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="rbHamlib64">
|
||||
<property name="text">
|
||||
<string>64-bit</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QRadioButton" name="rbHamlib32">
|
||||
<property name="text">
|
||||
<string>32-bit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="hamlib_download_button">
|
||||
<property name="toolTip">
|
||||
<string><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></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Udpate Hamlib</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="revert_update_button">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Revert the last Hamlib update. </p><p>Note: This function is only available on Windows.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Revert Update</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -3421,12 +3467,12 @@ Right click for insert and delete options.</string>
|
||||
</connections>
|
||||
<buttongroups>
|
||||
<buttongroup name="split_mode_button_group"/>
|
||||
<buttongroup name="CAT_data_bits_button_group"/>
|
||||
<buttongroup name="PTT_method_button_group"/>
|
||||
<buttongroup name="CAT_handshake_button_group"/>
|
||||
<buttongroup name="TX_audio_source_button_group"/>
|
||||
<buttongroup name="special_op_activity_button_group"/>
|
||||
<buttongroup name="TX_mode_button_group"/>
|
||||
<buttongroup name="CAT_stop_bits_button_group"/>
|
||||
<buttongroup name="TX_audio_source_button_group"/>
|
||||
<buttongroup name="CAT_data_bits_button_group"/>
|
||||
<buttongroup name="TX_mode_button_group"/>
|
||||
<buttongroup name="CAT_handshake_button_group"/>
|
||||
<buttongroup name="special_op_activity_button_group"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
|
Loading…
Reference in New Issue
Block a user