From addba9de4465c1d7370cea8b25d6594cb403e11e Mon Sep 17 00:00:00 2001 From: Davide Faconti Date: Thu, 18 Jan 2024 11:37:36 +0100 Subject: [PATCH] refactored changelog --- plotjuggler_app/CMakeLists.txt | 3 +- plotjuggler_app/changelog_dialog.ui | 100 ++++++++++++++++++++++++++++ plotjuggler_app/main.cpp | 47 +++++++++---- 3 files changed, 137 insertions(+), 13 deletions(-) create mode 100644 plotjuggler_app/changelog_dialog.ui diff --git a/plotjuggler_app/CMakeLists.txt b/plotjuggler_app/CMakeLists.txt index b2839740a..5dd0970ee 100644 --- a/plotjuggler_app/CMakeLists.txt +++ b/plotjuggler_app/CMakeLists.txt @@ -15,6 +15,7 @@ QT5_WRAP_UI ( UI_SRC preferences_dialog.ui suggest_dialog.ui new_release_dialog.ui + changelog_dialog.ui multifile_prefix.ui colormap_editor.ui colormap_selector.ui @@ -101,7 +102,7 @@ add_executable(plotjuggler ${PLOtJUGGLER_SRC} ${RES_SRC} ${UI_SRC} - ${BACKWARD_ENABLE} ) + ${BACKWARD_ENABLE}) if (NOT WIN32) add_backward(plotjuggler) diff --git a/plotjuggler_app/changelog_dialog.ui b/plotjuggler_app/changelog_dialog.ui new file mode 100644 index 000000000..03a1c6a7f --- /dev/null +++ b/plotjuggler_app/changelog_dialog.ui @@ -0,0 +1,100 @@ + + + ChangelogDialog + + + + 0 + 0 + 500 + 300 + + + + + 500 + 300 + + + + + 500 + 300 + + + + Dialog + + + + + + <html><head/><body><p align="center"><span style=" font-size:14pt; font-weight:700;">New Version Installed<br/><br/></span><span style=" font-size:12pt;">The latest release of PlotJuggler includes several bug fixed and new features.</span></p></body></html> + + + true + + + + + + + See changelog + + + + + + + Don't show again + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel + + + + + + + + + buttonBox + accepted() + ChangelogDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + ChangelogDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/plotjuggler_app/main.cpp b/plotjuggler_app/main.cpp index 96bcb53dc..bdce31001 100644 --- a/plotjuggler_app/main.cpp +++ b/plotjuggler_app/main.cpp @@ -13,11 +13,14 @@ #include #include #include +#include #include #include #include #include +#include #include +#include #include "PlotJuggler/transform_function.h" #include "transforms/first_derivative.h" @@ -30,6 +33,7 @@ #include "transforms/absolute_transform.h" #include "new_release_dialog.h" +#include "ui_changelog_dialog.h" #ifdef COMPILED_WITH_CATKIN #include @@ -54,6 +58,27 @@ inline int GetVersionNumber(QString str) return major * 10000 + minor * 100 + patch; } +void ShowChangelogDialog() +{ + QDialog* dialog = new QDialog(); + auto ui = new Ui::ChangelogDialog(); + ui->setupUi(dialog); + + QObject::connect(ui->buttonChangelog, &QPushButton::clicked, dialog, [](bool) { + QDesktopServices::openUrl(QUrl("https://bit.ly/plotjuggler-update")); + QSettings settings; + settings.setValue("Changelog/first", false); + }); + + + QObject::connect(ui->checkBox, &QCheckBox::toggled, dialog, [](bool toggle) { + QSettings settings; + settings.setValue("Changelog/dont", toggle); + }); + + dialog->exec(); +} + void OpenNewReleaseDialog(QNetworkReply* reply) { if (reply->error()) @@ -75,19 +100,10 @@ void OpenNewReleaseDialog(QNetworkReply* reply) int dontshow_number = GetVersionNumber(dont_show); int current_number = GetVersionNumber(VERSION_STRING); - bool rr = settings.value("NewRelease/rickrolled", false).toBool(); - if(!rr) { - url = "https://bit.ly/plotjuggler-update"; - } - if (online_number > current_number && online_number > dontshow_number) { NewReleaseDialog* dialog = new NewReleaseDialog(nullptr, tag_name, name, url); dialog->exec(); - if(dialog->link_opened) - { - settings.setValue("NewRelease/rickrolled", true); - } } } @@ -383,8 +399,14 @@ int main(int argc, char* argv[]) * data. Please don't do it. */ - if (!parser.isSet(nosplash_option) && - !(parser.isSet(loadfile_option) || parser.isSet(layout_option))) + bool first_changelog = settings.value("Changelog/first", true).toBool(); + bool dont_changelog = settings.value("Changelog/dont", false).toBool(); + + if(first_changelog && !dont_changelog) { + ShowChangelogDialog(); + } + else if (!parser.isSet(nosplash_option) && + !(parser.isSet(loadfile_option) || parser.isSet(layout_option))) // if(false) // if you uncomment this line, a kitten will die somewhere in the world. { QPixmap main_pixmap; @@ -403,6 +425,7 @@ int main(int argc, char* argv[]) { main_pixmap = getFunnySplashscreen(); } + QSplashScreen splash(main_pixmap, Qt::WindowStaysOnTopHint); QDesktopWidget* desktop = QApplication::desktop(); const int scrn = desktop->screenNumber(); @@ -415,7 +438,7 @@ int main(int argc, char* argv[]) auto deadline = QDateTime::currentDateTime().addMSecs(500); while (QDateTime::currentDateTime() < deadline) { - app.processEvents(); + app.processEvents(); } w = new MainWindow(parser);