Commit 8477234b authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Nate Graham
Browse files

flatpak: Improve detecting beta/nightly builds

parent 7b7a9a17
......@@ -43,7 +43,9 @@ static QString iconCachePath(const AppStream::Icon &icon)
return QStringLiteral("%1/icons/%2").arg(QStandardPaths::writableLocation(QStandardPaths::CacheLocation), icon.url().fileName());
}
const QStringList FlatpakResource::s_objects({QStringLiteral("qrc:/qml/FlatpakAttention.qml"), QStringLiteral("qrc:/qml/FlatpakRemoveData.qml")});
const QStringList FlatpakResource::s_objects({QStringLiteral("qrc:/qml/FlatpakAttention.qml"),
QStringLiteral("qrc:/qml/FlatpakRemoveData.qml"),
QStringLiteral("qrc:/qml/FlatpakOldBeta.qml")});
const QStringList FlatpakResource::s_bottomObjects({QStringLiteral("qrc:/qml/PermissionsList.qml")});
FlatpakResource::FlatpakResource(const AppStream::Component &component, FlatpakInstallation *installation, FlatpakBackend *parent)
......
......@@ -29,6 +29,7 @@ class FlatpakResource : public AbstractResource
Q_PROPERTY(QStringList objects MEMBER s_bottomObjects CONSTANT)
Q_PROPERTY(QString attentionText READ attentionText CONSTANT)
Q_PROPERTY(QString dataLocation READ dataLocation CONSTANT)
Q_PROPERTY(QString branch READ branch CONSTANT)
Q_PROPERTY(bool hasDataButUninstalled READ hasDataButUninstalled NOTIFY hasDataButUninstalledChanged)
public:
explicit FlatpakResource(const AppStream::Component &component, FlatpakInstallation *installation, FlatpakBackend *parent);
......
/*
* SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez <aleixpol@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
import QtQuick 2.15
import QtQuick.Layouts 1.1
import org.kde.kirigami 2.10 as Kirigami
import org.kde.discover 2.0
import org.kde.discover.app 1.0
import "navigation.js" as Navigation
Kirigami.InlineMessage
{
id: oldBetaItem
// resource is set by the creator of the element in ApplicationPage.
//required property AbstractResource resource
Layout.fillWidth: true
text: i18n("There is a stable version of %1", resource.name)
height: visible ? implicitHeight : 0
visible: actionsArray.filter(action => action.visible).length > 0
Instantiator {
id: inst
model: ResourcesProxyModel {
allBackends: true
backendFilter: resource.backend
resourcesUrl: resource.url
}
delegate: Kirigami.Action {
visible: model.application !== resource && model.application.branch !== "beta" && model.application.branch !== "master"
text: i18nc("@action: button %1 is the name of a Flatpak repo", "View Stable Version on %1", displayOrigin)
onTriggered: {
applicationWindow().pageStack.pop();
Navigation.openApplication(model.application)
}
}
onObjectAdded: {
oldBetaItem.actionsArray.splice(index, 0, object)
oldBetaItem.actions = oldBetaItem.actionsArray = oldBetaItem.actionsArray
}
onObjectRemoved: {
oldBetaItem.actionsArray.splice(index, 1)
oldBetaItem.actions = oldBetaItem.actionsArray = oldBetaItem.actionsArray
}
}
property var actionsArray: []
actions: actionsArray
}
......@@ -3,6 +3,7 @@
<qresource prefix="/">
<file>qml/FlatpakAttention.qml</file>
<file>qml/FlatpakRemoveData.qml</file>
<file>qml/FlatpakOldBeta.qml</file>
<file>qml/PermissionsList.qml</file>
</qresource>
</RCC>
......@@ -117,6 +117,7 @@ public:
QString origin;
bool allBackends = false;
bool filterMinimumState = true;
AbstractResourcesBackend *backend = nullptr;
bool isEmpty() const
{
......
......@@ -316,7 +316,7 @@ void ResourcesProxyModel::invalidateFilter()
delete m_currentStream;
}
m_currentStream = ResourcesModel::global()->search(m_filters);
m_currentStream = m_filters.backend ? m_filters.backend->search(m_filters) : ResourcesModel::global()->search(m_filters);
Q_EMIT busyChanged(true);
if (!m_displayedResources.isEmpty()) {
......@@ -325,8 +325,8 @@ void ResourcesProxyModel::invalidateFilter()
endResetModel();
}
connect(m_currentStream, &AggregatedResultsStream::resourcesFound, this, &ResourcesProxyModel::addResources);
connect(m_currentStream, &AggregatedResultsStream::finished, this, [this]() {
connect(m_currentStream, &ResultsStream::resourcesFound, this, &ResourcesProxyModel::addResources);
connect(m_currentStream, &ResultsStream::destroyed, this, [this]() {
m_currentStream = nullptr;
Q_EMIT busyChanged(false);
});
......@@ -453,6 +453,16 @@ void ResourcesProxyModel::setAllBackends(bool allBackends)
m_filters.allBackends = allBackends;
}
AbstractResourcesBackend *ResourcesProxyModel::backendFilter() const
{
return m_filters.backend;
}
void ResourcesProxyModel::setBackendFilter(AbstractResourcesBackend *filtered)
{
m_filters.backend = filtered;
}
QVariant ResourcesProxyModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid()) {
......
......@@ -32,6 +32,7 @@ class DISCOVERCOMMON_EXPORT ResourcesProxyModel : public QAbstractListModel, pub
Q_PROPERTY(AbstractResource::State stateFilter READ stateFilter WRITE setStateFilter NOTIFY stateFilterChanged)
Q_PROPERTY(bool filterMinimumState READ filterMinimumState WRITE setFilterMinimumState NOTIFY filterMinimumStateChanged)
Q_PROPERTY(QString mimeTypeFilter READ mimeTypeFilter WRITE setMimeTypeFilter)
Q_PROPERTY(AbstractResourcesBackend *backendFilter READ backendFilter WRITE setBackendFilter)
Q_PROPERTY(QString search READ lastSearch WRITE setSearch NOTIFY searchChanged)
Q_PROPERTY(QUrl resourcesUrl READ resourcesUrl WRITE setResourcesUrl NOTIFY resourcesUrlChanged)
Q_PROPERTY(QString extending READ extends WRITE setExtends)
......@@ -105,6 +106,9 @@ public:
bool allBackends() const;
void setAllBackends(bool allBackends);
AbstractResourcesBackend *backendFilter() const;
void setBackendFilter(AbstractResourcesBackend *filtered);
QVariantList subcategories() const;
QVariant data(const QModelIndex &index, int role) const override;
......@@ -159,7 +163,7 @@ private:
QVector<AbstractResource *> m_displayedResources;
const QHash<int, QByteArray> m_roles;
AggregatedResultsStream *m_currentStream;
ResultsStream *m_currentStream;
Q_SIGNALS:
void roughCountChanged();
......
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