Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #6489 from spycrab/qt_updater
Qt: Improve and better integrate updater
- Loading branch information
Showing
11 changed files
with
240 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -117,6 +117,7 @@ set(SRCS | ||
| TAS/Shared.cpp | ||
| TAS/StickWidget.cpp | ||
| TAS/IRWidget.cpp | ||
| Updater.cpp | ||
| ) | ||
|
|
||
| list(APPEND LIBS core uicommon) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| // Copyright 2018 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| #include "DolphinQt2/Updater.h" | ||
|
|
||
| #include <QCheckBox> | ||
| #include <QDialog> | ||
| #include <QDialogButtonBox> | ||
| #include <QLabel> | ||
| #include <QPushButton> | ||
| #include <QTextBrowser> | ||
| #include <QVBoxLayout> | ||
|
|
||
| #include "Common/Version.h" | ||
| #include "DolphinQt2/QtUtils/RunOnObject.h" | ||
| #include "DolphinQt2/Settings.h" | ||
|
|
||
| Updater::Updater(QWidget* parent) : m_parent(parent) | ||
| { | ||
| connect(this, &QThread::finished, this, &QObject::deleteLater); | ||
| } | ||
|
|
||
| void Updater::run() | ||
| { | ||
| CheckForUpdate(); | ||
| } | ||
|
|
||
| void Updater::OnUpdateAvailable(const NewVersionInformation& info) | ||
| { | ||
| bool later = false; | ||
|
|
||
| int choice = RunOnObject(m_parent, [&] { | ||
| QDialog* dialog = new QDialog(m_parent); | ||
| dialog->setWindowTitle(tr("Update available")); | ||
|
|
||
| auto* label = new QLabel( | ||
| tr("<h2>A new version of Dolphin is available!</h2>Dolphin %1 is available for " | ||
| "download. " | ||
| "You are running %2.<br> Would you like to update?<br><h4>Release Notes:</h4>") | ||
| .arg(QString::fromStdString(info.new_shortrev)) | ||
| .arg(QString::fromStdString(Common::scm_desc_str))); | ||
| label->setTextFormat(Qt::RichText); | ||
|
|
||
| auto* changelog = new QTextBrowser; | ||
|
|
||
| changelog->setHtml(QString::fromStdString(info.changelog_html)); | ||
| changelog->setOpenExternalLinks(true); | ||
| changelog->setMinimumWidth(400); | ||
|
|
||
| auto* update_later_check = new QCheckBox(tr("Update after closing Dolphin")); | ||
|
|
||
| connect(update_later_check, &QCheckBox::toggled, [&](bool checked) { later = checked; }); | ||
|
|
||
| auto* buttons = new QDialogButtonBox; | ||
|
|
||
| auto* never_btn = | ||
| buttons->addButton(tr("Never Auto-Update"), QDialogButtonBox::DestructiveRole); | ||
| buttons->addButton(tr("Remind Me Later"), QDialogButtonBox::RejectRole); | ||
| buttons->addButton(tr("Install Update"), QDialogButtonBox::AcceptRole); | ||
|
|
||
| auto* layout = new QVBoxLayout; | ||
| dialog->setLayout(layout); | ||
|
|
||
| layout->addWidget(label); | ||
| layout->addWidget(changelog); | ||
| layout->addWidget(update_later_check); | ||
| layout->addWidget(buttons); | ||
|
|
||
| connect(never_btn, &QPushButton::pressed, [dialog] { | ||
| Settings::Instance().SetAutoUpdateTrack(QStringLiteral("")); | ||
| dialog->reject(); | ||
| }); | ||
|
|
||
| connect(buttons, &QDialogButtonBox::accepted, dialog, &QDialog::accept); | ||
| connect(buttons, &QDialogButtonBox::rejected, dialog, &QDialog::reject); | ||
|
|
||
| return dialog->exec(); | ||
| }); | ||
|
|
||
| if (choice == QDialog::Accepted) | ||
| { | ||
| TriggerUpdate(info); | ||
|
|
||
| if (!later) | ||
| m_parent->close(); | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // Copyright 2018 Dolphin Emulator Project | ||
| // Licensed under GPLv2+ | ||
| // Refer to the license.txt file included. | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <QThread> | ||
|
|
||
| #include "UICommon/AutoUpdate.h" | ||
|
|
||
| class QWidget; | ||
|
|
||
| class Updater : public QThread, public AutoUpdateChecker | ||
| { | ||
| Q_OBJECT | ||
| public: | ||
| explicit Updater(QWidget* parent); | ||
|
|
||
| void run() override; | ||
| void OnUpdateAvailable(const NewVersionInformation& info) override; | ||
|
|
||
| private: | ||
| QWidget* m_parent; | ||
| }; |
Oops, something went wrong.