Merge pull request #6463 from delroth/auto-update

Initial implementation of the Dolphin auto-updater for Windows
This commit is contained in:
Anthony
2018-03-20 11:28:26 -07:00
committed by GitHub
39 changed files with 7409 additions and 4 deletions

View File

@ -7,6 +7,7 @@
#include <QApplication>
#include <QMessageBox>
#include <QObject>
#include <QWidget>
#include "Common/MsgHandler.h"
#include "Core/Analytics.h"
@ -19,6 +20,7 @@
#include "DolphinQt2/Resources.h"
#include "DolphinQt2/Settings.h"
#include "DolphinQt2/Translation.h"
#include "UICommon/AutoUpdate.h"
#include "UICommon/CommandLineParse.h"
#include "UICommon/UICommon.h"
@ -49,6 +51,35 @@ static bool QtMsgAlertHandler(const char* caption, const char* text, bool yes_no
});
}
// TODO: This should be replaced with something in a background thread, it performs a blocking
// HTTP query. It also needs a proper UI, and many other things. But right now it needs to be
// manually enabled through INI, so all these problems are ignored :)
class QtAutoUpdateChecker : public AutoUpdateChecker
{
public:
explicit QtAutoUpdateChecker(QWidget* parent) : m_parent(parent) {}
protected:
void OnUpdateAvailable(const NewVersionInformation& info) override
{
QMessageBox prompt(m_parent);
prompt.setIcon(QMessageBox::Question);
prompt.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
prompt.setText(QString::fromUtf8("Update Dolphin to version %1?")
.arg(QString::fromStdString(info.new_shortrev)));
const int answer = prompt.exec();
if (answer == QMessageBox::Yes)
{
TriggerUpdate(info);
m_parent->close();
}
}
private:
QWidget* m_parent;
};
// N.B. On Windows, this should be called from WinMain. Link against qtmain and specify
// /SubSystem:Windows
int main(int argc, char* argv[])
@ -146,6 +177,9 @@ int main(int argc, char* argv[])
}
#endif
QtAutoUpdateChecker updater(&win);
updater.CheckForUpdate();
retval = app.exec();
}