Warning, /plasma/discover/libdiscover/backends/FlatpakBackend/qml/FlatpakOldBeta.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   SPDX-FileCopyrightText: 2022 Aleix Pol Gonzalez <aleixpol@kde.org>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 pragma ComponentBehavior: Bound
0008 
0009 import QtQuick
0010 import QtQuick.Layouts
0011 import org.kde.discover as Discover
0012 import org.kde.discover.app
0013 import org.kde.discover.qml
0014 import org.kde.kirigami as Kirigami
0015 
0016 Kirigami.InlineMessage {
0017     id: root
0018 
0019     required property Discover.AbstractResource resource
0020 
0021     property bool __betaOlderThanStable: false
0022 
0023     Layout.fillWidth: true
0024 
0025     text: __betaOlderThanStable
0026         ? i18ndc("libdiscover", "@label %1 is the name of an application", "This development version of %1 is outdated. Using the stable version is highly recommended.", resource.name)
0027         : i18ndc("libdiscover", "@label %1 is the name of an application", "A more stable version of %1 is available.", resource.name)
0028 
0029     height: visible ? implicitHeight : 0
0030     visible: actions.some(action => action?.visible)
0031     type: __betaOlderThanStable ? Kirigami.MessageType.Warning : Kirigami.MessageType.Information
0032 
0033     onResourceChanged: {
0034         __betaOlderThanStable = false
0035         for (const action of actions) {
0036             action.reset()
0037         }
0038     }
0039 
0040     Instantiator {
0041         id: instantiator
0042         model: Discover.ResourcesProxyModel {
0043             allBackends: true
0044             backendFilter: root.resource.backend
0045             resourcesUrl: root.resource.url
0046         }
0047         active: root.resource.isDesktopApp
0048         delegate: Kirigami.Action {
0049             required property var model
0050 
0051             readonly property int versionCompare: root.resource.versionCompare(model.application)
0052 
0053             visible: instantiator.active && model.application !== root.resource && model.application.branch !== "beta" && model.application.branch !== "master" && versionCompare !== 0
0054             text: i18ndc("libdiscover", "@action: button %1 is the name of a Flatpak repo", "View Stable Version on %1", model.displayOrigin)
0055 
0056             onTriggered: {
0057                 applicationWindow().pageStack.pop();
0058                 Navigation.openApplication(model.application);
0059             }
0060 
0061             Component.onCompleted: reset()
0062 
0063             function reset() {
0064                 root.__betaOlderThanStable |= versionCompare < 0
0065             }
0066         }
0067 
0068         onObjectAdded: (index, object) => {
0069             root.actions.push(object);
0070         }
0071         onObjectRemoved: (index, object) => {
0072             root.actions = root.actions.filter(action => action !== object)
0073         }
0074     }
0075 }