Skip to content

Commit

Permalink
refactored changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Jan 18, 2024
1 parent 49d0a37 commit addba9d
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 13 deletions.
3 changes: 2 additions & 1 deletion plotjuggler_app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -101,7 +102,7 @@ add_executable(plotjuggler
${PLOtJUGGLER_SRC}
${RES_SRC}
${UI_SRC}
${BACKWARD_ENABLE} )
${BACKWARD_ENABLE})

if (NOT WIN32)
add_backward(plotjuggler)
Expand Down
100 changes: 100 additions & 0 deletions plotjuggler_app/changelog_dialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ChangelogDialog</class>
<widget class="QDialog" name="ChangelogDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>300</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>500</width>
<height>300</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>500</width>
<height>300</height>
</size>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:14pt; font-weight:700;&quot;&gt;New Version Installed&lt;br/&gt;&lt;br/&gt;&lt;/span&gt;&lt;span style=&quot; font-size:12pt;&quot;&gt;The latest release of PlotJuggler includes several bug fixed and new features.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonChangelog">
<property name="text">
<string>See changelog</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Don't show again</string>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ChangelogDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ChangelogDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
47 changes: 35 additions & 12 deletions plotjuggler_app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
#include <QDesktopWidget>
#include <QFontDatabase>
#include <QSettings>
#include <QPushButton>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QJsonDocument>
#include <QDir>
#include <QDialog>
#include <QUuid>
#include <QDesktopServices>

#include "PlotJuggler/transform_function.h"
#include "transforms/first_derivative.h"
Expand All @@ -30,6 +33,7 @@
#include "transforms/absolute_transform.h"

#include "new_release_dialog.h"
#include "ui_changelog_dialog.h"

#ifdef COMPILED_WITH_CATKIN
#include <ros/ros.h>
Expand All @@ -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())
Expand All @@ -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);
}
}
}

Expand Down Expand Up @@ -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;
Expand All @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit addba9d

Please sign in to comment.