diff --git a/ChangeLog.txt b/ChangeLog.txt index cbcd389..cb687db 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -2,6 +2,9 @@ CatRadio (+ New, * Updated, - Removed) +1.4.1 - 2024-xx-xx + + Check hamlib version on startup + 1.4.0 - 2024-03-17 + Auto Connect option + Auto Power-on option diff --git a/mainwindow.cpp b/mainwindow.cpp index 219b0b2..7df3d87 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include //Hamlib @@ -193,7 +194,19 @@ MainWindow::MainWindow(QWidget *parent) ui->lineEdit_vfoMain->setValue(0); ui->lineEdit_vfoSub->setValue(0); - if (rigCom.autoConnect) ui->pushButton_Connect->toggle(); //Auto connect + //Check Hamlib version + if (!checkHamlibVersion(4, 6, 0)) + { + QMessageBox msgBox; + msgBox.setWindowTitle("Hamlib"); + msgBox.setText("Please, update Hamlib libraries to version 4.6 or higher."); + msgBox.setIcon(QMessageBox::Warning); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.exec(); + } + + //Auto connect + if (rigCom.autoConnect) ui->pushButton_Connect->toggle(); } MainWindow::~MainWindow() @@ -802,6 +815,32 @@ void MainWindow::setSubMeter() } +bool MainWindow::checkHamlibVersion(int major, int minor, int revision) +{ + QString hamlibVer = rig_version(); + QRegularExpression hamlibVerExp("(?P\\d)\\.(?P\\d)\\.?(?P\\d)?"); + + QRegularExpressionMatch hamlibVerMatch = hamlibVerExp.match(hamlibVer); + + if (hamlibVerMatch.hasMatch()) + { + int majorVer = hamlibVerMatch.captured("major").toInt(); + int minorVer = hamlibVerMatch.captured("minor").toInt(); + int revisionVer = hamlibVerMatch.captured("revision").toInt(); + + //qDebug()< major) return true; + else if (majorVer < major) return false; + else if (minorVer > minor) return true; //& majorVer=major + else if (minorVer < minor) return false; //& majorVer=major + else if (revisionVer < revision) return false; //& majorVer=major, minorVer=minor + else return true; //revisionVer>=revision & majorVer=major, minorVer=minor + } + else return false; +} + + //***** PushButton ***** void MainWindow::on_pushButton_Connect_toggled(bool checked) diff --git a/mainwindow.h b/mainwindow.h index 2111747..6a618b9 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -220,6 +220,8 @@ private: void guiInit(); void setSubMeter(); + + bool checkHamlibVersion(int major, int minor, int revision); }; #endif // MAINWINDOW_H