Warning, /system/drkonqi-pk-debug-installer/src/qml/MainPage.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0002 // SPDX-FileCopyrightText: 2020 Harald Sitter <sitter@kde.org>
0003 
0004 import QtQuick 2.15
0005 import QtQuick.Layouts 1.15
0006 import QtQuick.Controls 2.15 as QQC2
0007 import org.kde.kirigami 2.4 as Kirigami
0008 import org.kde.drkonqi.debug.installer.pk 1.0
0009 
0010 Kirigami.ScrollablePage {
0011     title: i18nc("@title", "Debug Symbols Helper")
0012 
0013     Component.onCompleted: Installer.resolve() // start resolivng data
0014 
0015     footer: QQC2.DialogButtonBox {
0016         QQC2.Button {
0017             id: installButton
0018             enabled: Installer.ready && !Installer.installing
0019             action: Kirigami.Action {
0020                 text: i18nc("@action:button all = debug symbols for which packages are available",
0021                             "Install All")
0022                 iconName: "run-install"
0023                 onTriggered: {
0024                     Installer.install()
0025                     installButton.visible = false
0026                 }
0027             }
0028             QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole
0029         }
0030         QQC2.Button {
0031             action: Kirigami.Action {
0032                 enabled: !Installer.installing
0033                 text: Installer.installed ?
0034                         i18nc("@action:button", "Close") :
0035                         i18nc("@action:button", "Cancel")
0036                 onTriggered: Qt.quit()
0037             }
0038             QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.RejectRole
0039         }
0040     }
0041 
0042     ListView {
0043         id: view
0044         model: Installer.files
0045         currentIndex: -1 // don't select anything by default
0046         delegate: Kirigami.AbstractListItem {
0047             id: listItem
0048             // TODO do we need this?
0049             // width: parent ? parent.width : implicitWidth
0050 
0051             contentItem: RowLayout {
0052                 QQC2.Label {
0053                     Layout.fillWidth: true
0054                     text: modelData.path
0055                     elide: Text.ElideMiddle
0056                 }
0057                 // Indicates either resolution in progress or install in progress.
0058                 QQC2.BusyIndicator {
0059                     id: busy
0060                     visible: running
0061                     running: !modelData.resolved || Installer.installing
0062                 }
0063 
0064                 // FIXME: icon diagnostic state ought to be on the file page somehow
0065 
0066                 // don't make the line jump; keep consistent size with indicator
0067                 // and place the icon within at an implict width equal to
0068                 // the busy indicator's effective width. This effectively centers
0069                 // the icon while keeping the same spatial requirements.
0070                 Item {
0071                     visible: !busy.running
0072                     width: busy.width
0073                     height: busy.height
0074 
0075                     Kirigami.Icon {
0076                         implicitWidth: busy.width
0077                         anchors.centerIn: parent
0078                         source: {
0079                             if (modelData.packageID === "" || modelData.debugPackageID === "") {
0080                                 return "package-broken"
0081                             }
0082                             if (modelData.debugPackageInstalled) {
0083                                 return "installed"
0084                             }
0085                             return "package-install"
0086                         }
0087                     }
0088                 }
0089             }
0090 
0091             action: Kirigami.Action {
0092                 onTriggered: {
0093                     if (pageStack.depth > 1) {
0094                         if (pageStack.lastItem.file == modelData) {
0095                             // Clicked this entry twice, treat this as deselecting again.
0096                             view.currentIndex = -1
0097                             pageStack.pop()
0098                             return
0099                         }
0100 
0101                         pageStack.pop()
0102                     }
0103                     pageStack.push("qrc:/FilePage.qml", {"file": modelData});
0104                 }
0105             }
0106         }
0107     }
0108 }