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.9] Improve macOS Sparkle updater #5914

Merged
merged 15 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/gui/generalsettings.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/generalsettings.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/generalsettings.cpp

File src/gui/generalsettings.cpp (lines 309): Code does not conform to Custom style guidelines.
* Copyright (C) by Daniel Molkentin <danimo@owncloud.com>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -300,9 +300,15 @@
ocupdater->downloadState() != OCUpdater::DownloadComplete);
}
#if defined(Q_OS_MAC) && defined(HAVE_SPARKLE)
else if (auto sparkleUpdater = qobject_cast<SparkleUpdater *>(updater)) {
else if (const auto sparkleUpdater = qobject_cast<SparkleUpdater *>(updater)) {
connect(sparkleUpdater, &SparkleUpdater::statusChanged, this, &GeneralSettings::slotUpdateInfo, Qt::UniqueConnection);
_ui->updateStateLabel->setText(sparkleUpdater->statusString());
_ui->restartButton->setVisible(false);

const auto updaterState = sparkleUpdater->state();
const auto enableUpdateButton = updaterState == SparkleUpdater::State::Idle ||
updaterState == SparkleUpdater::State::Unknown;
_ui->updateButton->setEnabled(enableUpdateButton);
}
#endif

Expand Down
32 changes: 25 additions & 7 deletions src/gui/updater/sparkleupdater.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/updater/sparkleupdater.h

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/updater/sparkleupdater.h

File src/gui/updater/sparkleupdater.h (lines 32, 33, 34, 35, 36, 44): Code does not conform to Custom style guidelines.
* Copyright (C) by Daniel Molkentin <danimo@owncloud.com>
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -24,22 +24,40 @@
class SparkleUpdater : public Updater
{
Q_OBJECT
Q_PROPERTY(QString statusString READ statusString NOTIFY statusChanged)
Q_PROPERTY(State state READ state NOTIFY statusChanged)

public:
SparkleUpdater(const QUrl &appCastUrl);
class SparkleInterface;
enum class State {
Unknown = 0,
Idle,
Working,
AwaitingUserInput
};

explicit SparkleUpdater(const QUrl &appCastUrl);
~SparkleUpdater() override;

void setUpdateUrl(const QUrl &url);
[[nodiscard]] static bool autoUpdaterAllowed();

// unused in this updater
[[nodiscard]] bool handleStartup() override { return false; }
[[nodiscard]] QString statusString() const;
[[nodiscard]] State state() const;

public slots:
void setUpdateUrl(const QUrl &url);
void checkForUpdate() override;
void backgroundCheckForUpdate() override;
bool handleStartup() override { return false; }

QString statusString();
signals:
void statusChanged();

private:
class Private;
Private *d;
std::unique_ptr<SparkleInterface> _interface;
QString _statusString;
State _state = State::Unknown;
friend class SparkleInterface;
};

} // namespace OCC
Expand Down