Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-3.6] Fix macOS autoupdater settings #5103

Merged
merged 1 commit into from
Oct 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/gui/generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,20 +267,27 @@ void GeneralSettings::loadMiscSettings()
#if defined(BUILD_UPDATER)
void GeneralSettings::slotUpdateInfo()
{
if (ConfigFile().skipUpdateCheck() || !Updater::instance()) {
const auto updater = Updater::instance();
if (ConfigFile().skipUpdateCheck() || !updater) {
// updater disabled on compile
_ui->updatesGroupBox->setVisible(false);
return;
}

if (updater) {
connect(_ui->updateButton, &QAbstractButton::clicked, this,
&GeneralSettings::slotUpdateCheckNow, Qt::UniqueConnection);
connect(_ui->autoCheckForUpdatesCheckBox, &QAbstractButton::toggled, this,
&GeneralSettings::slotToggleAutoUpdateCheck, Qt::UniqueConnection);
_ui->autoCheckForUpdatesCheckBox->setChecked(ConfigFile().autoUpdateCheck());
}

// Note: the sparkle-updater is not an OCUpdater
auto *ocupdater = qobject_cast<OCUpdater *>(Updater::instance());
auto *ocupdater = qobject_cast<OCUpdater *>(updater);
if (ocupdater) {
connect(ocupdater, &OCUpdater::downloadStateChanged, this, &GeneralSettings::slotUpdateInfo, Qt::UniqueConnection);
connect(_ui->restartButton, &QAbstractButton::clicked, ocupdater, &OCUpdater::slotStartInstaller, Qt::UniqueConnection);
connect(_ui->restartButton, &QAbstractButton::clicked, qApp, &QApplication::quit, Qt::UniqueConnection);
connect(_ui->updateButton, &QAbstractButton::clicked, this, &GeneralSettings::slotUpdateCheckNow, Qt::UniqueConnection);
connect(_ui->autoCheckForUpdatesCheckBox, &QAbstractButton::toggled, this, &GeneralSettings::slotToggleAutoUpdateCheck);

QString status = ocupdater->statusString(OCUpdater::UpdateStatusStringFormat::Html);
Theme::replaceLinkColorStringBackgroundAware(status);
Expand All @@ -296,14 +303,11 @@ void GeneralSettings::slotUpdateInfo()
_ui->updateButton->setEnabled(ocupdater->downloadState() != OCUpdater::CheckingServer &&
ocupdater->downloadState() != OCUpdater::Downloading &&
ocupdater->downloadState() != OCUpdater::DownloadComplete);

_ui->autoCheckForUpdatesCheckBox->setChecked(ConfigFile().autoUpdateCheck());
}
#if defined(Q_OS_MAC) && defined(HAVE_SPARKLE)
else if (auto sparkleUpdater = qobject_cast<SparkleUpdater *>(Updater::instance())) {
else if (auto sparkleUpdater = qobject_cast<SparkleUpdater *>(updater)) {
_ui->updateStateLabel->setText(sparkleUpdater->statusString());
_ui->restartButton->setVisible(false);
connect(_ui->updateButton, &QAbstractButton::clicked, this, &GeneralSettings::slotUpdateCheckNow, Qt::UniqueConnection);
}
#endif

Expand Down