GUI: added simple update checker
This commit is contained in:
parent
031dadc319
commit
1638b30f46
|
|
@ -141,6 +141,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||
connect(ui->actionLabels,SIGNAL(triggered()),this,SLOT(displayLabels()));
|
||||
connect(ui->actionBookmarks,SIGNAL(triggered()),this,SLOT(displayBookmarks()));
|
||||
connect(ui->actionFunctions,SIGNAL(triggered()),this,SLOT(displayFunctions()));
|
||||
connect(ui->actionCheckUpdates,SIGNAL(triggered()),this,SLOT(checkUpdates()));
|
||||
|
||||
connect(Bridge::getBridge(), SIGNAL(updateWindowTitle(QString)), this, SLOT(updateWindowTitleSlot(QString)));
|
||||
connect(Bridge::getBridge(), SIGNAL(addRecentFile(QString)), this, SLOT(addRecentFile(QString)));
|
||||
|
|
@ -159,6 +160,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||
lastException=0;
|
||||
defaultSettings.SaveSettings();
|
||||
|
||||
//Create updatechecker
|
||||
mUpdateChecker = new UpdateChecker(this);
|
||||
|
||||
//setup menu api
|
||||
initMenuApi();
|
||||
|
||||
|
|
@ -797,3 +801,8 @@ void MainWindow::displayFunctions()
|
|||
DbgCmdExec("functionlist");
|
||||
displayReferencesWidget();
|
||||
}
|
||||
|
||||
void MainWindow::checkUpdates()
|
||||
{
|
||||
mUpdateChecker->checkForUpdates();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include "AppearanceDialog.h"
|
||||
#include "CloseDialog.h"
|
||||
#include "PatchDialog.h"
|
||||
#include "UpdateChecker.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
|
|
@ -84,6 +85,7 @@ public slots:
|
|||
void displayLabels();
|
||||
void displayBookmarks();
|
||||
void displayFunctions();
|
||||
void checkUpdates();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
|
@ -106,6 +108,8 @@ private:
|
|||
|
||||
Configuration* mConfiguration;
|
||||
|
||||
UpdateChecker* mUpdateChecker;
|
||||
|
||||
const char* mWindowMainTitle;
|
||||
|
||||
std::vector<QString> mMRUList;
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@
|
|||
<string>&Help</string>
|
||||
</property>
|
||||
<addaction name="actionAbout"/>
|
||||
<addaction name="actionCheckUpdates"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuPlugins">
|
||||
<property name="title">
|
||||
|
|
@ -594,6 +595,15 @@
|
|||
<string>Alt+F</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCheckUpdates">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resource.qrc">
|
||||
<normaloff>:/icons/images/update.png</normaloff>:/icons/images/update.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Check for &Updates</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
#include "UpdateChecker.h"
|
||||
#include <QMessageBox>
|
||||
#include "Bridge.h"
|
||||
|
||||
UpdateChecker::UpdateChecker(QWidget* parent)
|
||||
{
|
||||
mParent=parent;
|
||||
connect(this, SIGNAL(finished(QNetworkReply*)), this, SLOT(finishedSlot(QNetworkReply*)));
|
||||
}
|
||||
|
||||
void UpdateChecker::checkForUpdates()
|
||||
{
|
||||
get(QNetworkRequest(QUrl("http://x64dbg.com/version.txt")));
|
||||
}
|
||||
|
||||
void UpdateChecker::finishedSlot(QNetworkReply* reply)
|
||||
{
|
||||
if(reply->error() != QNetworkReply::NoError) //error
|
||||
{
|
||||
QMessageBox msg(QMessageBox::Critical, "Network Error!", reply->errorString());
|
||||
msg.setParent(mParent, Qt::Dialog);
|
||||
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
|
||||
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
return;
|
||||
}
|
||||
bool ok = false;
|
||||
int version = QString(reply->readAll()).toInt(&ok);
|
||||
reply->close();
|
||||
if(!ok)
|
||||
{
|
||||
QMessageBox msg(QMessageBox::Critical, "Error!", "File on server could not be parsed...");
|
||||
msg.setParent(mParent);
|
||||
msg.setWindowIcon(QIcon(":/icons/images/compile-error.png"));
|
||||
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
return;
|
||||
}
|
||||
QString info;
|
||||
int dbgVersion = BridgeGetDbgVersion();
|
||||
if(version > dbgVersion)
|
||||
info = QString().sprintf("New version v%d available!\nDownload at http://x64dbg.com\n\nYou are now on version v%d", version, dbgVersion);
|
||||
else if(version < dbgVersion)
|
||||
info = QString().sprintf("You have a development version (v%d) of x64_dbg!", dbgVersion);
|
||||
else
|
||||
info = QString().sprintf("You have the latest version (%d) of x64_dbg!", version);
|
||||
QMessageBox msg(QMessageBox::Information, "Information", info);
|
||||
msg.setWindowIcon(QIcon(":/icons/images/information.png"));
|
||||
msg.setParent(mParent, Qt::Dialog);
|
||||
msg.setWindowFlags(msg.windowFlags()&(~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef UPDATECHECKER_H
|
||||
#define UPDATECHECKER_H
|
||||
|
||||
#include <QtNetwork>
|
||||
#include <QtGui>
|
||||
|
||||
class UpdateChecker : public QNetworkAccessManager
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
UpdateChecker(QWidget* parent);
|
||||
void checkForUpdates();
|
||||
|
||||
private slots:
|
||||
void finishedSlot(QNetworkReply* reply);
|
||||
|
||||
private:
|
||||
QWidget* mParent;
|
||||
|
||||
};
|
||||
|
||||
#endif // UPDATECHECKER_H
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 917 B |
|
|
@ -38,5 +38,6 @@
|
|||
<file>images/functions.png</file>
|
||||
<file>images/labels.png</file>
|
||||
<file>images/comments.png</file>
|
||||
<file>images/update.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
QT += core gui network
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
|
|
@ -77,7 +77,8 @@ SOURCES += \
|
|||
Src/QHexEdit/QHexEditPrivate.cpp \
|
||||
Src/QHexEdit/XByteArray.cpp \
|
||||
Src/Gui/PatchDialog.cpp \
|
||||
Src/Gui/PatchDialogGroupSelector.cpp
|
||||
Src/Gui/PatchDialogGroupSelector.cpp \
|
||||
Src/Utils/UpdateChecker.cpp
|
||||
|
||||
|
||||
HEADERS += \
|
||||
|
|
@ -133,7 +134,8 @@ HEADERS += \
|
|||
Src/QHexEdit/QHexEditPrivate.h \
|
||||
Src/QHexEdit/XByteArray.h \
|
||||
Src/Gui/PatchDialog.h \
|
||||
Src/Gui/PatchDialogGroupSelector.h
|
||||
Src/Gui/PatchDialogGroupSelector.h \
|
||||
Src/Utils/UpdateChecker.h
|
||||
|
||||
|
||||
INCLUDEPATH += \
|
||||
|
|
|
|||
Loading…
Reference in New Issue