Commit 8d9b51f3 authored by David Redondo's avatar David Redondo 🏎
Browse files

flatpak resource: set displayOrigin to the remote title

This way the sources drop down menu displays the user intended
title instead of the name.
parent 1acbdbf4
Pipeline #209266 passed with stage
in 2 minutes and 36 seconds
......@@ -110,6 +110,11 @@ public:
return m_remote ? QString::fromUtf8(flatpak_remote_get_name(m_remote)) : QString();
}
QString title() const
{
return m_remote ? QString::fromUtf8(flatpak_remote_get_title(m_remote)) : QString();
}
FlatpakInstallation *installation() const
{
return m_installation;
......@@ -491,6 +496,7 @@ FlatpakResource *FlatpakBackend::getAppForInstalledRef(FlatpakInstallation *inst
FlatpakResource *resource = new FlatpakResource(cid, source->installation(), const_cast<FlatpakBackend *>(this));
resource->setOrigin(source->name());
resource->setDisplayOrigin(source->title());
resource->setIconPath(pathExports);
resource->updateFromRef(FLATPAK_REF(ref));
resource->setState(AbstractResource::Installed);
......@@ -801,6 +807,7 @@ void FlatpakBackend::addAppFromFlatpakRef(const QUrl &url, ResultsStream *stream
resource->setResourceFile(url);
resource->setResourceLocation(QUrl(refurl));
resource->setOrigin(remoteName);
resource->setDisplayOrigin(remote ? QString::fromUtf8(flatpak_remote_get_title(remote)) : QString());
resource->setFlatpakName(name);
resource->setArch(flatpak_get_default_arch());
resource->setBranch(settings.value(QStringLiteral("Flatpak Ref/Branch")).toString());
......@@ -1600,6 +1607,7 @@ FlatpakResource *FlatpakBackend::resourceForComponent(const AppStream::Component
FlatpakResource *res = new FlatpakResource(component, source->installation(), const_cast<FlatpakBackend *>(this));
res->setOrigin(source->name());
res->setDisplayOrigin(source->title());
res->setIconPath(source->appstreamIconsDir());
res->updateFromAppStream();
source->addResource(res);
......
......@@ -356,6 +356,11 @@ QString FlatpakResource::origin() const
return m_origin;
}
QString FlatpakResource::displayOrigin() const
{
return !m_displayOrigin.isEmpty() ? m_displayOrigin : m_origin;
}
QString FlatpakResource::packageName() const
{
return flatpakName() + QLatin1Char('/') + arch() + QLatin1Char('/') + branch();
......@@ -534,6 +539,11 @@ void FlatpakResource::setOrigin(const QString &origin)
m_origin = origin;
}
void FlatpakResource::setDisplayOrigin(const QString &displayOrigin)
{
m_displayOrigin = displayOrigin;
}
void FlatpakResource::setPropertyState(FlatpakResource::PropertyKind kind, FlatpakResource::PropertyState newState)
{
auto &state = m_propertyStates[kind];
......
......@@ -117,6 +117,7 @@ public:
QString longDescription() override;
QString name() const override;
QString origin() const override;
QString displayOrigin() const override;
QString packageName() const override;
PropertyState propertyState(PropertyKind kind) const;
QUrl resourceFile() const;
......@@ -153,6 +154,7 @@ public:
void setFlatpakFileType(FlatpakFileType fileType);
void setFlatpakName(const QString &name);
void setOrigin(const QString &origin);
void setDisplayOrigin(const QString &displayOrigin);
void setPropertyState(PropertyKind kind, PropertyState state);
void setResourceFile(const QUrl &url);
void setRuntime(const QString &runtime);
......@@ -214,6 +216,7 @@ private:
AbstractResource::State m_state;
FlatpakInstallation *const m_installation;
QString m_origin;
QString m_displayOrigin;
QString m_availableVersion;
FlatpakResource::ResourceType m_type = DesktopApp;
QSharedPointer<FlatpakSource> m_temp;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment