diff --git a/discover/qml/ApplicationPage.qml b/discover/qml/ApplicationPage.qml --- a/discover/qml/ApplicationPage.qml +++ b/discover/qml/ApplicationPage.qml @@ -45,44 +45,31 @@ } } - Kirigami.OverlaySheet { - id: originsOverlay - bottomPadding: Kirigami.Units.largeSpacing - topPadding: Kirigami.Units.largeSpacing - readonly property alias model: alternativeResourcesView.model - function listBackends() { - var first = true; - var ret = ""; - var m = alternativeResourcesView.model; - for(var i=0, count=m.rowCount(); i" + res.displayOrigin + "" - first = false - } - } - return ret - } - readonly property string sentence: alternativeResourcesView.count <= 1 ? "" : i18n("\nAlso available in %1", listBackends()) - ListView { - id: alternativeResourcesView + contextualActions: [originsMenuAction] + + Kirigami.Action { + id: originsMenuAction + + text: i18n("Sources") + visible: children.length>1 + readonly property var r0: Instantiator { model: ResourcesProxyModel { + id: alternativeResourcesModel allBackends: true resourcesUrl: appInfo.application.url } - delegate: Kirigami.BasicListItem { - label: displayOrigin + delegate: Kirigami.Action { + text: displayOrigin + icon.name: sourceIcon checked: appInfo.application == model.application - onClicked: if(index>=0) { + onTriggered: if(index>=0) { var res = model.application console.assert(res) window.stack.pop() Navigation.openApplication(res) } } + onObjectAdded: originsMenuAction.children.push(object) } } @@ -155,13 +142,7 @@ Layout.topMargin: Kirigami.Units.largeSpacing Layout.fillWidth: true wrapMode: Text.WordWrap - text: appInfo.application.longDescription + originsOverlay.sentence - onLinkActivated: { - var idx = parseInt(link, 10) - var res = originsOverlay.model.resourceAt(idx) - window.stack.pop() - Navigation.openApplication(res) - } + text: appInfo.application.longDescription } Kirigami.Heading { @@ -298,13 +279,11 @@ Layout.alignment: Qt.AlignRight text: i18n("Source:") } - LinkButton { + QQC2.Label { Layout.fillWidth: true horizontalAlignment: Text.AlignLeft - enabled: alternativeResourcesView.count > 1 text: appInfo.application.displayOrigin elide: Text.ElideRight - onClicked: originsOverlay.open() } // License row diff --git a/libdiscover/resources/ResourcesProxyModel.h b/libdiscover/resources/ResourcesProxyModel.h --- a/libdiscover/resources/ResourcesProxyModel.h +++ b/libdiscover/resources/ResourcesProxyModel.h @@ -52,6 +52,7 @@ Q_PROPERTY(bool allBackends READ allBackends WRITE setAllBackends) Q_PROPERTY(QVariantList subcategories READ subcategories NOTIFY subcategoriesChanged) Q_PROPERTY(bool isBusy READ isBusy NOTIFY busyChanged) + Q_PROPERTY(int count READ rowCount NOTIFY countChanged) public: explicit ResourcesProxyModel(QObject* parent = nullptr); enum Roles { @@ -162,6 +163,7 @@ void searchChanged(const QString &search); void subcategoriesChanged(const QVariantList &subcategories); void resourcesUrlChanged(const QUrl &url); + void countChanged(); }; #endif diff --git a/libdiscover/resources/ResourcesProxyModel.cpp b/libdiscover/resources/ResourcesProxyModel.cpp --- a/libdiscover/resources/ResourcesProxyModel.cpp +++ b/libdiscover/resources/ResourcesProxyModel.cpp @@ -70,6 +70,10 @@ connect(ResourcesModel::global(), &ResourcesModel::backendDataChanged, this, &ResourcesProxyModel::refreshBackend); connect(ResourcesModel::global(), &ResourcesModel::resourceDataChanged, this, &ResourcesProxyModel::refreshResource); connect(ResourcesModel::global(), &ResourcesModel::resourceRemoved, this, &ResourcesProxyModel::removeResource); + + connect(this, &QAbstractItemModel::modelReset, this, &ResourcesProxyModel::countChanged); + connect(this, &QAbstractItemModel::rowsInserted, this, &ResourcesProxyModel::countChanged); + connect(this, &QAbstractItemModel::rowsRemoved, this, &ResourcesProxyModel::countChanged); } void ResourcesProxyModel::componentComplete()