Commit b5496a99 authored by Nathaniel Graham's avatar Nathaniel Graham
Browse files

Expose more URLs relevant to the app

Summary:
Make the help, bug tracker, and donation URLs available to the backends, and display them on the App page.

Currently working on a better design to make the metadata section not look so intimidating for apps that behave well and expose all these URLs--but that can go in later, since this has to land on master.

Test Plan:
Tested in KDE Neon with apps available from multiple backends. Here's an example of how it looks with Gedit, which defines all the URLs:

{F5676433}

Reviewers: apol, #discover_software_store

Reviewed By: apol, #discover_software_store

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10131
parent 22154310
......@@ -254,14 +254,14 @@ DiscoverPage {
// Version row
QQC2.Label {
readonly property string version: appInfo.application.isInstalled ? appInfo.application.installedVersion : appInfo.application.availableVersion
visible: version.length > 0
visible: versionLabel.visible
Layout.alignment: Qt.AlignRight
text: i18n("Version:")
}
QQC2.Label {
readonly property string version: appInfo.application.isInstalled ? appInfo.application.installedVersion : appInfo.application.availableVersion
visible: version.length > 0
id: versionLabel
visible: text.length > 0
Layout.fillWidth: true
elide: Text.ElideRight
text: version ? version : ""
......@@ -310,20 +310,67 @@ DiscoverPage {
// Homepage row
QQC2.Label {
readonly property string homepage: application.homepage
visible: homepage.length > 0
visible: homepageLink.visible
Layout.alignment: Qt.AlignRight
text: i18n("Homepage:")
}
LinkButton {
readonly property string homepage: application.homepage
visible: homepage.length > 0
text: homepage
id: homepageLink
visible: text.length > 0
text: application.homepage
onClicked: Qt.openUrlExternally(application.homepage)
elide: Text.ElideRight
Layout.fillWidth: true
horizontalAlignment: Text.AlignLeft
}
// "User Guide" row
QQC2.Label {
visible: docsLink.visible
Layout.alignment: Qt.AlignRight
text: i18n("User Guide:")
}
LinkButton {
id: docsLink
visible: text.length > 0
text: application.helpURL
onClicked: Qt.openUrlExternally(helpURL)
elide: Text.ElideRight
Layout.fillWidth: true
horizontalAlignment: Text.AlignLeft
}
// Donate row
QQC2.Label {
visible: donationLink.visible
Layout.alignment: Qt.AlignRight
text: i18n("Donate:")
}
LinkButton {
id: donationLink
visible: text.length > 0
text: application.donationURL
onClicked: Qt.openUrlExternally(donationURL)
elide: Text.ElideRight
Layout.fillWidth: true
horizontalAlignment: Text.AlignLeft
}
// "Report a Droblem" row
QQC2.Label {
visible: bugLink.visible
Layout.alignment: Qt.AlignRight
text: i18n("Report a Problem:")
}
LinkButton {
id: bugLink
visible: text.length > 0
text: application.bugURL
onClicked: Qt.openUrlExternally(bugURL)
elide: Text.ElideRight
Layout.fillWidth: true
horizontalAlignment: Text.AlignLeft
}
}
}
......
......@@ -76,6 +76,21 @@ QUrl DummyResource::homepage()
return QUrl(QStringLiteral("http://kde.org"));
}
QUrl DummyResource::helpURL()
{
return QUrl(QStringLiteral("http://very-very-excellent-docs.lol"));
}
QUrl DummyResource::bugURL()
{
return QUrl(QStringLiteral("file:///dev/null"));
}
QUrl DummyResource::donationURL()
{
return QUrl(QStringLiteral("https://youtu.be/0o8XMlL8rqY"));
}
QVariant DummyResource::icon() const
{
return isTechnical() ? QStringLiteral("kalarm") : m_iconName;
......
......@@ -39,6 +39,9 @@ public:
QString license() override;
int size() override;
QUrl homepage() override;
QUrl helpURL() override;
QUrl bugURL() override;
QUrl donationURL() override;
QStringList categories() override;
AbstractResource::State state() override;
QVariant icon() const override;
......
......@@ -243,6 +243,21 @@ QUrl FlatpakResource::homepage()
return m_appdata.url(AppStream::Component::UrlKindHomepage);
}
QUrl FlatpakResource::helpURL()
{
return m_appdata.url(AppStream::Component::UrlKindHelp);
}
QUrl FlatpakResource::bugURL()
{
return m_appdata.url(AppStream::Component::UrlKindBugtracker);
}
QUrl FlatpakResource::donationURL()
{
return m_appdata.url(AppStream::Component::UrlKindDonation);
}
QString FlatpakResource::flatpakFileType() const
{
return m_flatpakFileType;
......
......@@ -84,6 +84,9 @@ public:
int installedSize() const;
bool isTechnical() const override;
QUrl homepage() override;
QUrl helpURL() override;
QUrl bugURL() override;
QUrl donationURL() override;
QString flatpakFileType() const;
QString flatpakName() const;
QString license() override;
......
......@@ -124,6 +124,21 @@ QUrl AppPackageKitResource::homepage()
return m_appdata.url(AppStream::Component::UrlKindHomepage);
}
QUrl AppPackageKitResource::helpURL()
{
return m_appdata.url(AppStream::Component::UrlKindHelp);
}
QUrl AppPackageKitResource::bugURL()
{
return m_appdata.url(AppStream::Component::UrlKindBugtracker);
}
QUrl AppPackageKitResource::donationURL()
{
return m_appdata.url(AppStream::Component::UrlKindDonation);
}
bool AppPackageKitResource::isTechnical() const
{
static QString desktop = QString::fromUtf8(qgetenv("XDG_CURRENT_DESKTOP"));
......
......@@ -39,6 +39,9 @@ class AppPackageKitResource : public PackageKitResource
QStringList categories() override;
QString longDescription() override;
QUrl homepage() override;
QUrl helpURL() override;
QUrl bugURL() override;
QUrl donationURL() override;
QString comment() override;
QString license() override;
QStringList allPackageNames() const override;
......
......@@ -54,11 +54,6 @@ int SnapResource::size()
return m_snap->downloadSize();
}
QUrl SnapResource::homepage()
{
return {};
}
QVariant SnapResource::icon() const
{
if (m_icon.isNull()) {
......
......@@ -42,7 +42,6 @@ public:
QString installedVersion() const override;
QString license() override;
int size() override;
QUrl homepage() override;
QStringList categories() override;
AbstractResource::State state() override;
QVariant icon() const override;
......
......@@ -38,6 +38,26 @@ AbstractResource::AbstractResource(AbstractResourcesBackend* parent)
AbstractResource::~AbstractResource() = default;
QUrl AbstractResource::homepage()
{
return QUrl();
}
QUrl AbstractResource::helpURL()
{
return QUrl();
}
QUrl AbstractResource::bugURL()
{
return QUrl();
}
QUrl AbstractResource::donationURL()
{
return QUrl();
}
bool AbstractResource::isTechnical() const
{
return false;
......
......@@ -56,6 +56,9 @@ class DISCOVERCOMMON_EXPORT AbstractResource : public QObject
Q_PROPERTY(QStringList category READ categories CONSTANT)
Q_PROPERTY(bool isTechnical READ isTechnical CONSTANT)
Q_PROPERTY(QUrl homepage READ homepage CONSTANT)
Q_PROPERTY(QUrl helpURL READ helpURL CONSTANT)
Q_PROPERTY(QUrl bugURL READ bugURL CONSTANT)
Q_PROPERTY(QUrl donationURL READ donationURL CONSTANT)
Q_PROPERTY(bool canUpgrade READ canUpgrade NOTIFY stateChanged)
Q_PROPERTY(bool isInstalled READ isInstalled NOTIFY stateChanged)
Q_PROPERTY(QString license READ license CONSTANT)
......@@ -125,8 +128,14 @@ class DISCOVERCOMMON_EXPORT AbstractResource : public QObject
virtual State state() = 0;
virtual QStringList categories() = 0;
///@returns a URL that points to the content
virtual QUrl homepage() = 0;
///@returns a URL that points to the app's website
virtual QUrl homepage();
///@returns a URL that points to the app's online documentation
virtual QUrl helpURL();
///@returns a URL that points to the place where you can file a bug
virtual QUrl bugURL();
///@returns a URL that points to the place where you can donate money to the app developer
virtual QUrl donationURL();
virtual bool isTechnical() const;
......
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