From 34adcec6165662d6245a55ee0a75c36753061df2 Mon Sep 17 00:00:00 2001 From: Kenneth Chew Date: Fri, 22 Apr 2022 22:29:00 -0400 Subject: Add functionality to (Sparkle) updater settings on macOS Also remove a debug line I accidentally left in --- launcher/ui/pages/global/LauncherPage.cpp | 8 ++++++++ launcher/ui/pages/global/LauncherPage.ui | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'launcher/ui/pages') diff --git a/launcher/ui/pages/global/LauncherPage.cpp b/launcher/ui/pages/global/LauncherPage.cpp index af2e2cd1..51284a8e 100644 --- a/launcher/ui/pages/global/LauncherPage.cpp +++ b/launcher/ui/pages/global/LauncherPage.cpp @@ -261,7 +261,11 @@ void LauncherPage::applySettings() auto s = APPLICATION->settings(); // Updates +#ifdef Q_OS_MAC + APPLICATION->updateChecker()->getSparkleUpdater()->setAutomaticallyChecksForUpdates(ui->autoUpdateCheckBox->isChecked()); +#else s->set("AutoUpdate", ui->autoUpdateCheckBox->isChecked()); +#endif s->set("UpdateChannel", m_currentUpdateChannel); auto original = s->get("IconTheme").toString(); //FIXME: make generic @@ -343,7 +347,11 @@ void LauncherPage::loadSettings() { auto s = APPLICATION->settings(); // Updates +#ifdef Q_OS_MAC + ui->autoUpdateCheckBox->setChecked(APPLICATION->updateChecker()->getSparkleUpdater()->getAutomaticallyChecksForUpdates()); +#else ui->autoUpdateCheckBox->setChecked(s->get("AutoUpdate").toBool()); +#endif m_currentUpdateChannel = s->get("UpdateChannel").toString(); //FIXME: make generic auto theme = s->get("IconTheme").toString(); diff --git a/launcher/ui/pages/global/LauncherPage.ui b/launcher/ui/pages/global/LauncherPage.ui index ae7eb73f..a306a91b 100644 --- a/launcher/ui/pages/global/LauncherPage.ui +++ b/launcher/ui/pages/global/LauncherPage.ui @@ -54,7 +54,7 @@ - Check for updates on start? + Check for updates automatically -- cgit From 05cd30ac06b67ebc594773fc7e7ccf110fc336a3 Mon Sep 17 00:00:00 2001 From: Kenneth Chew Date: Mon, 25 Apr 2022 19:33:17 -0400 Subject: Refactor code, create abstract class `ExternalUpdater` (Hopefully) this makes implementing updaters using external libraries easier on other platforms. To implement an updater on a new platform, create a new class that implements the pure virtual methods from `ExternalUpdater` and add code in the `UpdateChecker` initializer to initialize the new class. --- launcher/ui/pages/global/LauncherPage.cpp | 37 ++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'launcher/ui/pages') diff --git a/launcher/ui/pages/global/LauncherPage.cpp b/launcher/ui/pages/global/LauncherPage.cpp index 51284a8e..b244b039 100644 --- a/launcher/ui/pages/global/LauncherPage.cpp +++ b/launcher/ui/pages/global/LauncherPage.cpp @@ -90,6 +90,13 @@ LauncherPage::LauncherPage(QWidget *parent) : QWidget(parent), ui(new Ui::Launch { APPLICATION->updateChecker()->updateChanList(false); } + + if (APPLICATION->updateChecker()->getExternalUpdater()) + { + ui->updateChannelComboBox->setVisible(false); + ui->updateChannelDescLabel->setVisible(false); + ui->updateChannelLabel->setVisible(false); + } } else { @@ -261,11 +268,16 @@ void LauncherPage::applySettings() auto s = APPLICATION->settings(); // Updates -#ifdef Q_OS_MAC - APPLICATION->updateChecker()->getSparkleUpdater()->setAutomaticallyChecksForUpdates(ui->autoUpdateCheckBox->isChecked()); -#else - s->set("AutoUpdate", ui->autoUpdateCheckBox->isChecked()); -#endif + if (BuildConfig.UPDATER_ENABLED && APPLICATION->updateChecker()->getExternalUpdater()) + { + APPLICATION->updateChecker()->getExternalUpdater()->setAutomaticallyChecksForUpdates( + ui->autoUpdateCheckBox->isChecked()); + } + else + { + s->set("AutoUpdate", ui->autoUpdateCheckBox->isChecked()); + } + s->set("UpdateChannel", m_currentUpdateChannel); auto original = s->get("IconTheme").toString(); //FIXME: make generic @@ -347,11 +359,16 @@ void LauncherPage::loadSettings() { auto s = APPLICATION->settings(); // Updates -#ifdef Q_OS_MAC - ui->autoUpdateCheckBox->setChecked(APPLICATION->updateChecker()->getSparkleUpdater()->getAutomaticallyChecksForUpdates()); -#else - ui->autoUpdateCheckBox->setChecked(s->get("AutoUpdate").toBool()); -#endif + if (BuildConfig.UPDATER_ENABLED && APPLICATION->updateChecker()->getExternalUpdater()) + { + ui->autoUpdateCheckBox->setChecked( + APPLICATION->updateChecker()->getExternalUpdater()->getAutomaticallyChecksForUpdates()); + } + else + { + ui->autoUpdateCheckBox->setChecked(s->get("AutoUpdate").toBool()); + } + m_currentUpdateChannel = s->get("UpdateChannel").toString(); //FIXME: make generic auto theme = s->get("IconTheme").toString(); -- cgit