Qt: Add option to invoke the updater manually

This commit is contained in:
spycrab 2018-05-25 00:19:36 +02:00
parent dfb1dbad47
commit ec322271ee
4 changed files with 46 additions and 1 deletions

View File

@ -49,6 +49,7 @@
#include "DolphinQt2/Host.h" #include "DolphinQt2/Host.h"
#include "DolphinQt2/QtUtils/ActionHelper.h" #include "DolphinQt2/QtUtils/ActionHelper.h"
#include "DolphinQt2/Settings.h" #include "DolphinQt2/Settings.h"
#include "DolphinQt2/Updater.h"
#include "UICommon/GameFile.h" #include "UICommon/GameFile.h"
@ -490,9 +491,31 @@ void MenuBar::AddOptionsMenu()
m_change_font = AddAction(options_menu, tr("&Font..."), this, &MenuBar::ChangeDebugFont); m_change_font = AddAction(options_menu, tr("&Font..."), this, &MenuBar::ChangeDebugFont);
} }
#ifdef _WIN32
void MenuBar::InstallUpdateManually()
{
auto& track = SConfig::GetInstance().m_auto_update_track;
auto previous_value = track;
track = "dev";
auto* updater = new Updater(this);
if (!updater->CheckForUpdate())
{
QMessageBox::information(
this, tr("Update"),
tr("You are running the latest version available on this update track"));
}
track = previous_value;
}
#endif
void MenuBar::AddHelpMenu() void MenuBar::AddHelpMenu()
{ {
QMenu* help_menu = addMenu(tr("&Help")); QMenu* help_menu = addMenu(tr("&Help"));
QAction* website = help_menu->addAction(tr("&Website")); QAction* website = help_menu->addAction(tr("&Website"));
connect(website, &QAction::triggered, this, connect(website, &QAction::triggered, this,
[]() { QDesktopServices::openUrl(QUrl(QStringLiteral("https://dolphin-emu.org/"))); }); []() { QDesktopServices::openUrl(QUrl(QStringLiteral("https://dolphin-emu.org/"))); });
@ -505,6 +528,12 @@ void MenuBar::AddHelpMenu()
QDesktopServices::openUrl(QUrl(QStringLiteral("https://github.com/dolphin-emu/dolphin"))); QDesktopServices::openUrl(QUrl(QStringLiteral("https://github.com/dolphin-emu/dolphin")));
}); });
#ifdef _WIN32
help_menu->addSeparator();
AddAction(help_menu, tr("&Check for Updates..."), this, &MenuBar::InstallUpdateManually);
#endif
help_menu->addSeparator(); help_menu->addSeparator();
AddAction(help_menu, tr("&About"), this, &MenuBar::ShowAboutDialog); AddAction(help_menu, tr("&About"), this, &MenuBar::ShowAboutDialog);
} }

View File

@ -36,6 +36,10 @@ public:
void UpdateStateSlotMenu(); void UpdateStateSlotMenu();
void UpdateToolsMenu(bool emulation_started); void UpdateToolsMenu(bool emulation_started);
#ifdef _WIN32
void InstallUpdateManually();
#endif
signals: signals:
// File // File
void Open(); void Open();

View File

@ -8,6 +8,7 @@
#include <QDialog> #include <QDialog>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QLabel> #include <QLabel>
#include <QMessageBox>
#include <QPushButton> #include <QPushButton>
#include <QTextBrowser> #include <QTextBrowser>
#include <QVBoxLayout> #include <QVBoxLayout>
@ -23,12 +24,21 @@ Updater::Updater(QWidget* parent) : m_parent(parent)
void Updater::run() void Updater::run()
{ {
CheckForUpdate(); AutoUpdateChecker::CheckForUpdate();
}
bool Updater::CheckForUpdate()
{
m_update_available = false;
AutoUpdateChecker::CheckForUpdate();
return m_update_available;
} }
void Updater::OnUpdateAvailable(const NewVersionInformation& info) void Updater::OnUpdateAvailable(const NewVersionInformation& info)
{ {
bool later = false; bool later = false;
m_update_available = true;
std::optional<int> choice = RunOnObject(m_parent, [&] { std::optional<int> choice = RunOnObject(m_parent, [&] {
QDialog* dialog = new QDialog(m_parent); QDialog* dialog = new QDialog(m_parent);

View File

@ -18,7 +18,9 @@ public:
void run() override; void run() override;
void OnUpdateAvailable(const NewVersionInformation& info) override; void OnUpdateAvailable(const NewVersionInformation& info) override;
bool CheckForUpdate();
private: private:
QWidget* m_parent; QWidget* m_parent;
bool m_update_available = false;
}; };