mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 11:26:11 +00:00
parent
6f85616538
commit
a40c1ce4bf
@ -17,7 +17,7 @@ ICON = img/cutter.icns
|
|||||||
# Icon/resources for Windows
|
# Icon/resources for Windows
|
||||||
win32: RC_ICONS = img/cutter.ico
|
win32: RC_ICONS = img/cutter.ico
|
||||||
|
|
||||||
QT += core gui widgets svg
|
QT += core gui widgets svg network
|
||||||
QT_CONFIG -= no-pkg-config
|
QT_CONFIG -= no-pkg-config
|
||||||
CONFIG += c++11
|
CONFIG += c++11
|
||||||
|
|
||||||
|
@ -5,6 +5,14 @@
|
|||||||
#include "r_version.h"
|
#include "r_version.h"
|
||||||
#include "utils/Configuration.h"
|
#include "utils/Configuration.h"
|
||||||
|
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QProgressBar>
|
||||||
|
#include <QProgressDialog>
|
||||||
|
#include <QtNetwork/QNetworkRequest>
|
||||||
|
#include <QtNetwork/QNetworkAccessManager>
|
||||||
|
|
||||||
#include "CutterConfig.h"
|
#include "CutterConfig.h"
|
||||||
|
|
||||||
AboutDialog::AboutDialog(QWidget *parent) :
|
AboutDialog::AboutDialog(QWidget *parent) :
|
||||||
@ -51,7 +59,7 @@ void AboutDialog::on_buttonBox_rejected()
|
|||||||
void AboutDialog::on_showVersionButton_clicked()
|
void AboutDialog::on_showVersionButton_clicked()
|
||||||
{
|
{
|
||||||
QMessageBox popup(this);
|
QMessageBox popup(this);
|
||||||
popup.setWindowTitle("radare2 version information");
|
popup.setWindowTitle(tr("radare2 version information"));
|
||||||
auto versionInformation = Core()->getVersionInformation();
|
auto versionInformation = Core()->getVersionInformation();
|
||||||
popup.setText(versionInformation);
|
popup.setText(versionInformation);
|
||||||
popup.exec();
|
popup.exec();
|
||||||
@ -62,3 +70,69 @@ void AboutDialog::on_showPluginsButton_clicked()
|
|||||||
R2PluginsDialog dialog(this);
|
R2PluginsDialog dialog(this);
|
||||||
dialog.exec();
|
dialog.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AboutDialog::on_checkForUpdatesButton_clicked()
|
||||||
|
{
|
||||||
|
QUrl url("https://api.github.com/repos/radareorg/cutter/releases/latest");
|
||||||
|
QNetworkRequest request;
|
||||||
|
request.setUrl(url);
|
||||||
|
|
||||||
|
QProgressDialog waitDialog;
|
||||||
|
QProgressBar *bar = new QProgressBar(&waitDialog);
|
||||||
|
bar->setMaximum(0);
|
||||||
|
|
||||||
|
waitDialog.setBar(bar);
|
||||||
|
waitDialog.setLabel(new QLabel(tr("Checking for updates..."), &waitDialog));
|
||||||
|
|
||||||
|
QNetworkAccessManager nm;
|
||||||
|
|
||||||
|
QTimer timeoutTimer;
|
||||||
|
timeoutTimer.setSingleShot(true);
|
||||||
|
timeoutTimer.setInterval(7000);
|
||||||
|
|
||||||
|
connect(&nm, &QNetworkAccessManager::finished, &timeoutTimer, &QTimer::stop);
|
||||||
|
connect(&nm, &QNetworkAccessManager::finished, &waitDialog, &QProgressDialog::cancel);
|
||||||
|
connect(&nm, &QNetworkAccessManager::finished, this, &AboutDialog::serveVersionCheckReply);
|
||||||
|
|
||||||
|
QNetworkReply *reply = nm.get(request);
|
||||||
|
timeoutTimer.start();
|
||||||
|
|
||||||
|
connect(&timeoutTimer, &QTimer::timeout, []() {
|
||||||
|
QMessageBox mb;
|
||||||
|
mb.setIcon(QMessageBox::Critical);
|
||||||
|
mb.setStandardButtons(QMessageBox::Ok);
|
||||||
|
mb.setWindowTitle(tr("Timeout error!"));
|
||||||
|
mb.setText(tr("Please check your internet connection and try again."));
|
||||||
|
mb.exec();
|
||||||
|
});
|
||||||
|
|
||||||
|
waitDialog.exec();
|
||||||
|
delete reply;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AboutDialog::serveVersionCheckReply(QNetworkReply *reply)
|
||||||
|
{
|
||||||
|
QString currVersion = "";
|
||||||
|
QMessageBox mb;
|
||||||
|
mb.setStandardButtons(QMessageBox::Ok);
|
||||||
|
if (reply->error()) {
|
||||||
|
mb.setIcon(QMessageBox::Critical);
|
||||||
|
mb.setWindowTitle(tr("Error!"));
|
||||||
|
mb.setText(reply->errorString());
|
||||||
|
} else {
|
||||||
|
currVersion = QJsonDocument::fromJson(reply->readAll()).object().value("tag_name").toString();
|
||||||
|
currVersion.remove('v');
|
||||||
|
|
||||||
|
mb.setWindowTitle(tr("Version control"));
|
||||||
|
mb.setIcon(QMessageBox::Information);
|
||||||
|
if (currVersion == CUTTER_VERSION_FULL) {
|
||||||
|
mb.setText(tr("You have latest version and no need to update!"));
|
||||||
|
} else {
|
||||||
|
mb.setText(tr("<b>Current version</b>: " CUTTER_VERSION_FULL "<br/>"
|
||||||
|
"<b>Latest version</b>: %1<br/><br/>"
|
||||||
|
"For update, please check the link: <a href=\"%2\">%2</a>")
|
||||||
|
.arg(currVersion, "https://github.com/radareorg/cutter/releases"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mb.exec();
|
||||||
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <QtNetwork/QNetworkReply>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class AboutDialog;
|
class AboutDialog;
|
||||||
@ -20,6 +21,8 @@ private slots:
|
|||||||
void on_buttonBox_rejected();
|
void on_buttonBox_rejected();
|
||||||
void on_showVersionButton_clicked();
|
void on_showVersionButton_clicked();
|
||||||
void on_showPluginsButton_clicked();
|
void on_showPluginsButton_clicked();
|
||||||
|
void on_checkForUpdatesButton_clicked();
|
||||||
|
void serveVersionCheckReply(QNetworkReply *reply);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Ui::AboutDialog> ui;
|
std::unique_ptr<Ui::AboutDialog> ui;
|
||||||
|
@ -63,6 +63,19 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="checkForUpdatesButton">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Check for updates</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
Loading…
Reference in New Issue
Block a user