From 42581598e146e7d064b4392fec251be74f4f44b5 Mon Sep 17 00:00:00 2001 From: fourtf Date: Mon, 2 Sep 2019 10:52:01 +0200 Subject: [PATCH] added "beta update" settings --- src/Application.cpp | 4 ++++ src/singletons/Settings.hpp | 1 + src/singletons/Updates.cpp | 11 +++++++++-- src/widgets/settingspages/GeneralPage.cpp | 5 +++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Application.cpp b/src/Application.cpp index 0a374fbc..42b9bd0b 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -24,6 +24,7 @@ #include "singletons/Settings.hpp" #include "singletons/Theme.hpp" #include "singletons/Toasts.hpp" +#include "singletons/Updates.hpp" #include "singletons/WindowManager.hpp" #include "util/IsBigEndian.hpp" #include "util/PostToThread.hpp" @@ -99,6 +100,9 @@ int Application::run(QApplication &qtApp) this->windows->getMainWindow().show(); + getSettings()->betaUpdates.connect( + [] { Updates::getInstance().checkForUpdates(); }, false); + return qtApp.exec(); } diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 295ad7e5..2ab20d06 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -198,6 +198,7 @@ public: QStringSetting streamlinkOpts = {"/external/streamlink/options", ""}; /// Misc + BoolSetting betaUpdates = {"/misc/beta", false}; IntSetting startUpNotification = {"/misc/startUpNotification", 0}; QStringSetting currentVersion = {"/misc/currentVersion", ""}; BoolSetting loadTwitchMessageHistoryOnConnect = { diff --git a/src/singletons/Updates.cpp b/src/singletons/Updates.cpp index 5930c59c..8a5c813d 100644 --- a/src/singletons/Updates.cpp +++ b/src/singletons/Updates.cpp @@ -1,5 +1,6 @@ #include "Updates.hpp" +#include "Settings.hpp" #include "common/NetworkRequest.hpp" #include "common/Outcome.hpp" #include "common/Version.hpp" @@ -13,6 +14,12 @@ #include namespace chatterino { +namespace { + QString currentBranch() + { + return getSettings()->betaUpdates ? "beta" : "stable"; + } +} // namespace Updates::Updates() : currentVersion_(CHATTERINO_VERSION) @@ -195,8 +202,8 @@ void Updates::installUpdates() void Updates::checkForUpdates() { QString url = - "https://notitia.chatterino.com/version/chatterino/" CHATTERINO_OS - "/stable"; + "https://notitia.chatterino.com/version/chatterino/" CHATTERINO_OS "/" + + currentBranch(); NetworkRequest(url) .timeout(60000) diff --git a/src/widgets/settingspages/GeneralPage.cpp b/src/widgets/settingspages/GeneralPage.cpp index 6ee10777..41312b47 100644 --- a/src/widgets/settingspages/GeneralPage.cpp +++ b/src/widgets/settingspages/GeneralPage.cpp @@ -290,6 +290,11 @@ void GeneralPage::initLayout(SettingsLayout &layout) layout.addCheckbox("Category", s.headerGame); layout.addCheckbox("Title", s.headerStreamTitle); + layout.addTitle("Beta"); + layout.addDescription("You can receive updates earlier by ticking the box " + "below. Updates are checked on startup."); + layout.addCheckbox("Receive beta updates", s.betaUpdates); + layout.addTitle("Miscellaneous"); //layout.addWidget(makeOpenSettingDirButton());