Skip to content

Commit

Permalink
Fix download of Sway/Budgie spins and atomic variants (#717)
Browse files Browse the repository at this point in the history
  • Loading branch information
grulja committed Jul 1, 2024
1 parent d81922b commit bd29ed4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
34 changes: 29 additions & 5 deletions src/app/releasemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#include <QJsonDocument>

using namespace Qt::Literals::StringLiterals;

ReleaseManager::ReleaseManager(QObject *parent)
: QSortFilterProxyModel(parent)
, m_sourceModel(new ReleaseListModel(this))
Expand Down Expand Up @@ -176,16 +178,31 @@ ReleaseVariant *ReleaseManager::localFile() const
return nullptr;
}

bool ReleaseManager::updateUrl(const QString &release, int version, const QString &status, const QString &type, const QDateTime &releaseDate, const QString &architecture, const QString &url, const QString &sha256, int64_t size)
bool ReleaseManager::updateUrl(const QString &release,
int version,
const QString &status,
const QString &type,
const QString &category,
const QDateTime &releaseDate,
const QString &architecture,
const QString &url,
const QString &sha256,
int64_t size)
{
if (!ReleaseArchitecture::isKnown(architecture)) {
mWarning() << "Architecture" << architecture << "is not known!";
return false;
}
for (int i = 0; i < m_sourceModel->rowCount(); i++) {
Release *r = get(i);
if (r->name().toLower().contains(release))
if (r->name().toLower().contains(release) || r->subvariant().toLower().contains(release)) {
// Special case for Sway and Budgie
if (release == "sway"_L1 || release == "budgie"_L1) {
if (r->source() == Release::EMERGING && (category != "sericea"_L1 && category != "onyx"_L1))
continue;
}
return r->updateUrl(version, status, type, releaseDate, architecture, url, sha256, size);
}
}
return false;
}
Expand Down Expand Up @@ -296,7 +313,7 @@ void ReleaseManager::onStringDownloaded(const QString &text)
mDebug() << this->metaObject()->className() << "Adding" << release << versionWithStatus << arch;

if (!release.isEmpty() && !url.isEmpty() && !arch.isEmpty())
updateUrl(release, version, status, type, releaseDate, arch, url, sha256, size);
updateUrl(release, version, status, type, category, releaseDate, arch, url, sha256, size);
}

m_beingUpdated = false;
Expand Down Expand Up @@ -388,14 +405,15 @@ ReleaseListModel::ReleaseListModel(ReleaseManager *parent)
if (obj.contains("icon"))
icon = obj["icon"].toString();

m_releases.append(new Release(manager(), m_releases.count(), name, summary, description, source, icon, screenshots));
m_releases.append(new Release(manager(), m_releases.count(), name, summary, description, subvariant, source, icon, screenshots));
}

custom = new Release(manager(),
m_releases.count(),
tr("Custom image"),
QT_TRANSLATE_NOOP("Release", "Pick a file from your drive(s)"),
{QT_TRANSLATE_NOOP("Release", "<p>Here you can choose a OS image from your hard drive to be written to your flash disk</p><p>Currently it is only supported to write raw disk images (.iso or .bin)</p>")},
"Other"_L1,
Release::LOCAL,
"qrc:/logos/folder",
{});
Expand Down Expand Up @@ -440,12 +458,13 @@ int Release::index() const
return m_index;
}

Release::Release(ReleaseManager *parent, int index, const QString &name, const QString &summary, const QStringList &description, Release::Source source, const QString &icon, const QStringList &screenshots)
Release::Release(ReleaseManager *parent, int index, const QString &name, const QString &summary, const QStringList &description, const QString &subvariant, Release::Source source, const QString &icon, const QStringList &screenshots)
: QObject(parent)
, m_index(index)
, m_name(name)
, m_summary(summary)
, m_description(description)
, m_subvariant(subvariant)
, m_source(source)
, m_icon(icon)
, m_screenshots(screenshots)
Expand Down Expand Up @@ -531,6 +550,11 @@ QString Release::description() const
return result;
}

QString Release::subvariant() const
{
return m_subvariant;
}

Release::Source Release::source() const
{
return m_source;
Expand Down
7 changes: 5 additions & 2 deletions src/app/releasemanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class ReleaseManager : public QSortFilterProxyModel, public DownloadReceiver
Q_INVOKABLE void selectLocalFile(const QString &path = QString());
ReleaseVariant *localFile() const;

bool updateUrl(const QString &release, int version, const QString &status, const QString &type, const QDateTime &releaseDate, const QString &architecture, const QString &url, const QString &sha256, int64_t size);
bool
updateUrl(const QString &release, int version, const QString &status, const QString &type, const QString &category, const QDateTime &releaseDate, const QString &architecture, const QString &url, const QString &sha256, int64_t size);

QStringList architectures() const;
int filterArchitecture() const;
Expand Down Expand Up @@ -228,7 +229,7 @@ class Release : public QObject
Q_ENUMS(Source)
Q_INVOKABLE QString sourceString();

Release(ReleaseManager *parent, int index, const QString &name, const QString &summary, const QStringList &description, Release::Source source, const QString &icon, const QStringList &screenshots);
Release(ReleaseManager *parent, int index, const QString &name, const QString &summary, const QStringList &description, const QString &subvariant, Release::Source source, const QString &icon, const QStringList &screenshots);
void setLocalFile(const QString &path);
bool updateUrl(int version, const QString &status, const QString &type, const QDateTime &releaseDate, const QString &architecture, const QString &url, const QString &sha256, int64_t size);
ReleaseManager *manager();
Expand All @@ -237,6 +238,7 @@ class Release : public QObject
QString name() const;
QString summary() const;
QString description() const;
QString subvariant() const;
Release::Source source() const;
bool isLocal() const;
QString icon() const;
Expand All @@ -262,6 +264,7 @@ class Release : public QObject
QString m_name{};
QString m_summary{};
QStringList m_description{};
QString m_subvariant{};
Release::Source m_source{LOCAL};
QString m_icon{};
QStringList m_screenshots{};
Expand Down

0 comments on commit bd29ed4

Please sign in to comment.