Skip to content

Commit

Permalink
fix new release dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Jan 16, 2024
1 parent c40a291 commit 231dd6a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 66 deletions.
17 changes: 10 additions & 7 deletions plotjuggler_app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ void OpenNewReleaseDialog(QNetworkReply* reply)
{
if (reply->error())
{
qDebug() << "reply error";
return;
}

QString answer = reply->readAll();
QJsonDocument document = QJsonDocument::fromJson(answer.toUtf8());
QJsonObject data = document.object();
Expand All @@ -74,14 +76,18 @@ void OpenNewReleaseDialog(QNetworkReply* reply)
int current_number = GetVersionNumber(VERSION_STRING);

bool rr = settings.value("NewRelease/rickrolled", false).toBool();
if(rr) {
url = "https://plotjuggler-update.carrd.co/";
if(!rr) {
url = "https://bit.ly/plotjuggler-update";
}

if (online_number > current_number && online_number > dontshow_number)
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 @@ -358,11 +364,8 @@ int main(int argc, char* argv[])
QObject::connect(&manager, &QNetworkAccessManager::finished, OpenNewReleaseDialog);

QNetworkRequest request;
request.setUrl(QUrl("https://api.github.com/repos/facontidavide/PlotJuggler/releases/latest"));

QString uuid = settings.value("UUID", QUuid::createUuid().toString()).toString();
settings.setValue("UUID", uuid);

request.setUrl(QUrl(QString("https://l4g9l4.deta.dev/check_updates/%1").arg(uuid)));
manager.get(request);

MainWindow* w = nullptr;
Expand Down
4 changes: 1 addition & 3 deletions plotjuggler_app/new_release_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ NewReleaseDialog::NewReleaseDialog(QWidget* parent, QString release, QString tit

connect(ui->pushButtonWeb, &QPushButton::clicked, this, [=] {
QDesktopServices::openUrl(QUrl(url));
QSettings settings;
settings.setValue("NewRelease/rickrolled", true);
link_opened = true;
});

connect(ui->buttonBox, &QDialogButtonBox::rejected, this, [=] {
Expand All @@ -32,7 +31,6 @@ NewReleaseDialog::NewReleaseDialog(QWidget* parent, QString release, QString tit
}
});

ui->labelRelease->setText(release);
ui->labelTitle->setText(title);
}

Expand Down
1 change: 1 addition & 0 deletions plotjuggler_app/new_release_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class NewReleaseDialog : public QDialog
NewReleaseDialog(QWidget* parent, QString release, QString title, QString url);
~NewReleaseDialog();

bool link_opened = false;
private:
Ui::NewReleaseDialog* ui;
};
Expand Down
77 changes: 21 additions & 56 deletions plotjuggler_app/new_release_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>725</width>
<width>825</width>
<height>400</height>
</rect>
</property>
Expand All @@ -18,13 +18,13 @@
</property>
<property name="minimumSize">
<size>
<width>725</width>
<width>825</width>
<height>400</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>729</width>
<width>841</width>
<height>400</height>
</size>
</property>
Expand Down Expand Up @@ -74,7 +74,7 @@
<widget class="QWidget" name="widget" native="true">
<property name="minimumSize">
<size>
<width>350</width>
<width>450</width>
<height>0</height>
</size>
</property>
Expand All @@ -99,61 +99,26 @@
</spacer>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="horizontalSpacing">
<number>12</number>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="verticalSpacing">
<number>12</number>
<property name="text">
<string>New release: </string>
</property>
<property name="leftMargin">
<number>5</number>
</widget>
</item>
<item>
<widget class="QLabel" name="labelTitle">
<property name="text">
<string>title</string>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Release: </string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="labelRelease">
<property name="text">
<string>TextLabel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Title:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="labelTitle">
<property name="text">
<string>TextLabel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
Expand Down

0 comments on commit 231dd6a

Please sign in to comment.