From 99d0066f1e999c49983ec181398bae8d4ff356c7 Mon Sep 17 00:00:00 2001 From: Kiara Navarro Date: Sun, 27 Jun 2021 13:04:27 -0300 Subject: [PATCH 1/2] gui: implement about dialog and unify app version/hash --- Software/PC_Application/LibreVNA-GUI.pro | 4 + Software/PC_Application/Util/app_common.h | 8 + Software/PC_Application/about.cpp | 33 ++++ Software/PC_Application/about.h | 34 ++++ Software/PC_Application/aboutdialog.ui | 179 ++++++++++++++++++++++ Software/PC_Application/appwindow.cpp | 36 +++-- Software/PC_Application/appwindow.h | 6 + Software/PC_Application/main.cpp | 11 ++ 8 files changed, 300 insertions(+), 11 deletions(-) create mode 100644 Software/PC_Application/Util/app_common.h create mode 100644 Software/PC_Application/about.cpp create mode 100644 Software/PC_Application/about.h create mode 100644 Software/PC_Application/aboutdialog.ui diff --git a/Software/PC_Application/LibreVNA-GUI.pro b/Software/PC_Application/LibreVNA-GUI.pro index 58cb655..1d5c4eb 100644 --- a/Software/PC_Application/LibreVNA-GUI.pro +++ b/Software/PC_Application/LibreVNA-GUI.pro @@ -102,6 +102,7 @@ HEADERS += \ Traces/xyplotaxisdialog.h \ Util/qpointervariant.h \ Util/util.h \ + Util/app_common.h \ VNA/Deembedding/deembedding.h \ VNA/Deembedding/deembeddingdialog.h \ VNA/Deembedding/deembeddingoption.h \ @@ -111,6 +112,7 @@ HEADERS += \ VNA/Deembedding/twothru.h \ VNA/tracewidgetvna.h \ VNA/vna.h \ + about.h \ appwindow.h \ averaging.h \ csv.h \ @@ -223,6 +225,7 @@ SOURCES += \ VNA/Deembedding/twothru.cpp \ VNA/tracewidgetvna.cpp \ VNA/vna.cpp \ + about.cpp \ appwindow.cpp \ averaging.cpp \ csv.cpp \ @@ -285,6 +288,7 @@ FORMS += \ VNA/Deembedding/portextensioneditdialog.ui \ VNA/Deembedding/twothrudialog.ui \ VNA/s2pImportOptions.ui \ + aboutdialog.ui \ main.ui \ preferencesdialog.ui diff --git a/Software/PC_Application/Util/app_common.h b/Software/PC_Application/Util/app_common.h new file mode 100644 index 0000000..6b7b844 --- /dev/null +++ b/Software/PC_Application/Util/app_common.h @@ -0,0 +1,8 @@ +#ifndef APP_COMMON_H +#define APP_COMMON_H + +#include + +#define qlibrevnaApp (QCoreApplication::instance()) + +#endif // APP_COMMON_H diff --git a/Software/PC_Application/about.cpp b/Software/PC_Application/about.cpp new file mode 100644 index 0000000..e6aae1f --- /dev/null +++ b/Software/PC_Application/about.cpp @@ -0,0 +1,33 @@ +#include "Util/app_common.h" +#include "about.h" +#include "ui_aboutdialog.h" + +About About::instance; + +AboutDialog::AboutDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::AboutDialog) +{ + ui->setupUi(this); + setWindowTitle("About " + qlibrevnaApp->applicationName()); + ui->appName->setText(qlibrevnaApp->applicationName()); + ui->appVersion->setText(QString("Version: %1") + .arg(qlibrevnaApp->applicationVersion())); + ui->sourceCodeDescription->setText(QString("%1") + .arg("https://github.com/jankae/LibreVNA")); + ui->sourceCodeDescription->setOpenExternalLinks(true); + ui->contributeDescription->setOpenExternalLinks(true); + ui->headerDescription->setOpenExternalLinks(true); +} + + +AboutDialog::~AboutDialog() +{ + delete ui; +} + +void About::about() +{ + auto dialog = new AboutDialog(); + dialog->exec(); +} diff --git a/Software/PC_Application/about.h b/Software/PC_Application/about.h new file mode 100644 index 0000000..79c2a3e --- /dev/null +++ b/Software/PC_Application/about.h @@ -0,0 +1,34 @@ +#ifndef ABOUT_H +#define ABOUT_H + +#include + +class About +{ +public: + static About& getInstance() { + return instance; + } + void about(); +private: + About() {}; + static About instance; +}; + +namespace Ui +{ + class AboutDialog; +} + +class AboutDialog : public QDialog +{ + Q_OBJECT +public: + explicit AboutDialog(QWidget *parent = nullptr); + ~AboutDialog(); + +private: + Ui::AboutDialog *ui; +}; + +#endif // ABOUT_H diff --git a/Software/PC_Application/aboutdialog.ui b/Software/PC_Application/aboutdialog.ui new file mode 100644 index 0000000..62ef8a8 --- /dev/null +++ b/Software/PC_Application/aboutdialog.ui @@ -0,0 +1,179 @@ + + + AboutDialog + + + + 0 + 0 + 381 + 344 + + + + Dialog + + + Qt::LeftToRight + + + + + + + + PLACEHOLDER_APP_NAME + + + Qt::AutoText + + + Qt::AlignCenter + + + + + + + PLACEHOLDER_MAIN + + + Qt::AlignCenter + + + + + + + + + + + 0 + + + + Information + + + + + + 6 + + + + + + 0 + 0 + + + + false + + + LibreVNA it's a Vector Network Analyzer instrument that comes with a set of tools aside of hardware as LibreVNA-GUI application and the firmware that runs over theboard itself. + + + true + + + + + + + <html><head/><body><p><span style=" font-weight:600;">LibreVNA Community</span></p></body></html> + + + Qt::AutoText + + + + + + + For general questions or discussions, the <a href="https://groups.io/g/LibreVNA">LibreVNA group</a> is probably the best place. + + + true + + + + + + + <html><head/><body><p><span style=" font-weight:600;">LibreVNA Source Code</span></p></body></html> + + + + + + + PLACEHOLDER_SOURCE_CODE_DESC + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + Contribute + + + + + + + + Qt::LeftToRight + + + <html><head/><body><p>Pull request are always welcome and this project is always in on-going development. If you have any proposal or feature just go to: <a href="https://github.com/jankae/LibreVNA/issues"><span style=" text-decoration: underline;">LibreVNA issues</span></a></p></body></html> + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + + diff --git a/Software/PC_Application/appwindow.cpp b/Software/PC_Application/appwindow.cpp index 8c81c4b..c86f267 100644 --- a/Software/PC_Application/appwindow.cpp +++ b/Software/PC_Application/appwindow.cpp @@ -50,28 +50,31 @@ #include #include "CustomWidgets/jsonpickerdialog.h" #include +#include "Util/app_common.h" +#include "about.h" using namespace std; + +static const QString APP_VERSION = QString::number(FW_MAJOR) + "." + + QString::number(FW_MINOR) + "." + + QString::number(FW_PATCH); +static const QString APP_GIT_HASH = QString(GITHASH); + AppWindow::AppWindow(QWidget *parent) : QMainWindow(parent) , deviceActionGroup(new QActionGroup(this)) , ui(new Ui::MainWindow) , server(nullptr) + , appVersion(APP_VERSION) + , appGitHash(APP_GIT_HASH) { - QCoreApplication::setOrganizationName("LibreVNA"); - QCoreApplication::setApplicationName("LibreVNA-GUI"); - auto commit = QString(GITHASH); - commit.truncate(7); - QCoreApplication::setApplicationVersion(QString::number(FW_MAJOR) + "." + QString::number(FW_MINOR) - + "." + QString::number(FW_PATCH) + FW_SUFFIX + " ("+ commit+")"); - qSetMessagePattern("%{time process}: [%{type}] %{message}"); // qDebug().setVerbosity(0); qDebug() << "Application start"; - parser.setApplicationDescription("LibreVNA-GUI"); + parser.setApplicationDescription(qlibrevnaApp->applicationName()); parser.addHelpOption(); parser.addVersionOption(); parser.addOption(QCommandLineOption({"p","port"}, "Specify port to listen for SCPI commands", "port")); @@ -202,12 +205,13 @@ AppWindow::AppWindow(QWidget *parent) // settings might have changed, update necessary stuff // TraceXYPlot::updateGraphColors(); }); + connect(ui->actionAbout, &QAction::triggered, [=](){ - QMessageBox::about(this, "About", "More information: github.com/jankae/LibreVNA\n" - "\nVersion: " + QCoreApplication::applicationVersion()); + auto &a = About::getInstance(); + a.about(); }); - setWindowTitle("LibreVNA-GUI"); + setWindowTitle(qlibrevnaApp->applicationName() + " v" + getAppVersion()); setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); @@ -696,3 +700,13 @@ Ui::MainWindow *AppWindow::getUi() const { return ui; } + +const QString& AppWindow::getAppVersion() const +{ + return appVersion; +} + +const QString& AppWindow::getAppGitHash() const +{ + return appGitHash; +} diff --git a/Software/PC_Application/appwindow.h b/Software/PC_Application/appwindow.h index 85c58c0..59343d5 100644 --- a/Software/PC_Application/appwindow.h +++ b/Software/PC_Application/appwindow.h @@ -41,6 +41,9 @@ public: QStackedWidget *getCentral() const; Device *getDevice() const; + const QString& getAppVersion() const; + const QString& getAppGitHash() const; + protected: void closeEvent(QCloseEvent *event) override; private slots: @@ -95,6 +98,9 @@ private: SCPI scpi; TCPServer *server; + + QString appVersion; + QString appGitHash; }; #endif // VNA_H diff --git a/Software/PC_Application/main.cpp b/Software/PC_Application/main.cpp index 680c030..b8a8a04 100644 --- a/Software/PC_Application/main.cpp +++ b/Software/PC_Application/main.cpp @@ -11,6 +11,8 @@ #include +static void setApplicationData(); + static QApplication *app; static AppWindow *window; @@ -35,7 +37,16 @@ int main(int argc, char *argv[]) { } app = new QApplication(argc, argv_ext); window = new AppWindow; + setApplicationData(); signal(SIGINT, sig_handler); app->exec(); return 0; } + +static void setApplicationData() +{ + QCoreApplication::setOrganizationName("LibreVNA"); + QCoreApplication::setApplicationName("LibreVNA-GUI"); + QCoreApplication::setApplicationVersion(window->getAppVersion() + "-" + + window->getAppGitHash().left(9)); +} From 4d1dedd46a762545b751aabe7e62b2ff075ee9af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20K=C3=A4berich?= Date: Mon, 28 Jun 2021 21:21:12 +0200 Subject: [PATCH 2/2] Set application name/organization before loading preferences, minor adjustments to about text --- Software/PC_Application/aboutdialog.ui | 4 ++-- Software/PC_Application/main.cpp | 15 ++++----------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/Software/PC_Application/aboutdialog.ui b/Software/PC_Application/aboutdialog.ui index 62ef8a8..6039c2c 100644 --- a/Software/PC_Application/aboutdialog.ui +++ b/Software/PC_Application/aboutdialog.ui @@ -73,7 +73,7 @@ false - LibreVNA it's a Vector Network Analyzer instrument that comes with a set of tools aside of hardware as LibreVNA-GUI application and the firmware that runs over theboard itself. + <html><head/><body><p>LibreVNA is a Vector Network Analyzer that consists of the hardware, the LibreVNA-GUI (this application) and the firmware/FPGA configuration on the board. </p></body></html> true @@ -144,7 +144,7 @@ Qt::LeftToRight - <html><head/><body><p>Pull request are always welcome and this project is always in on-going development. If you have any proposal or feature just go to: <a href="https://github.com/jankae/LibreVNA/issues"><span style=" text-decoration: underline;">LibreVNA issues</span></a></p></body></html> + <html><head/><body><p>Pull request are always welcome as this project is still in on-going development. If you have any proposal or feature, please create an issue or a pull request: <a href="https://github.com/jankae/LibreVNA/issues"><span style=" text-decoration: underline; color:#0000ff;">LibreVNA issues</span></a></p></body></html> true diff --git a/Software/PC_Application/main.cpp b/Software/PC_Application/main.cpp index b8a8a04..831cd38 100644 --- a/Software/PC_Application/main.cpp +++ b/Software/PC_Application/main.cpp @@ -11,8 +11,6 @@ #include -static void setApplicationData(); - static QApplication *app; static AppWindow *window; @@ -36,17 +34,12 @@ int main(int argc, char *argv[]) { } } app = new QApplication(argc, argv_ext); + QCoreApplication::setOrganizationName("LibreVNA"); + QCoreApplication::setApplicationName("LibreVNA-GUI"); window = new AppWindow; - setApplicationData(); + QCoreApplication::setApplicationVersion(window->getAppVersion() + "-" + + window->getAppGitHash().left(9)); signal(SIGINT, sig_handler); app->exec(); return 0; } - -static void setApplicationData() -{ - QCoreApplication::setOrganizationName("LibreVNA"); - QCoreApplication::setApplicationName("LibreVNA-GUI"); - QCoreApplication::setApplicationVersion(window->getAppVersion() + "-" + - window->getAppGitHash().left(9)); -}