Warning, /plasma/drkonqi/src/qml/DuplicatesPage.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: 2022 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.19 as Kirigami
0008 
0009 import org.kde.drkonqi 1.0
0010 
0011 Kirigami.ScrollablePage {
0012     id: page
0013 
0014     title: i18nc("@title", "Look for Possible Duplicate Reports")
0015 
0016     ColumnLayout {
0017         QQC2.Label {
0018             Layout.fillWidth: true
0019             wrapMode: Text.Wrap
0020             text: xi18nc("@info/rich", "See if your bug has already been reported. Double click a report in the list and compare it to yours. You can suggest that your crash is a duplicate of that report or directly attach your information to it.")
0021         }
0022         ListView {
0023             id: listView
0024 
0025             property var possibleDuplicates: []
0026             onPossibleDuplicatesChanged: {
0027                 reportInterface.setPossibleDuplicates(possibleDuplicates)
0028             }
0029 
0030             implicitHeight: contentHeight
0031             Layout.fillWidth: true
0032 
0033             model: duplicateModel
0034 
0035             onMovementEnded: {
0036                 if(atYEnd) {
0037                     console.log("End of list!");
0038                     // FIXME doesnt work with scrollbar
0039                     duplicateModel.searchBugs(reportInterface.relatedBugzillaProducts(), "crash", reportInterface.firstBacktraceFunctions().join(' '))
0040                 }
0041             }
0042 
0043             Kirigami.PromptDialog {
0044                 id: promptDialog
0045                 title: i18nc("@title", "Duplicate?")
0046                 subtitle: i18nc("@label", "Are you quite certain your crash is a duplicate of this bug report?")
0047                 standardButtons: Kirigami.Dialog.Yes | Kirigami.Dialog.No
0048                 property int bugNumber: 0
0049 
0050                 onAccepted: {
0051                     showPassiveNotification("Accepted")
0052                     reportInterface.attachToBugNumber = bugNumber
0053                 }
0054                 onRejected: console.log("Rejected")
0055             }
0056 
0057             delegate: Kirigami.SwipeListItem {
0058                 property bool isDuplicate: reportInterface.attachToBugNumber === ROLE_Number
0059 
0060                 highlighted: isDuplicate
0061 
0062                 Kirigami.BasicListItem {
0063                     icon: reportInterface.attachToBugNumber === ROLE_Number ? "document-duplicate" : undefined
0064                     separatorVisible: false // to parent
0065                     supportsMouseEvents: false // to parent
0066                     text: ROLE_Title
0067                     subtitle: ROLE_Number
0068                     onClicked: Qt.openUrlExternally(Globals.bugzillaUrl + "show_bug.cgi?id=" + ROLE_Number)
0069                 }
0070 
0071                 actions: [
0072                     Kirigami.Action {
0073                         visible: !isDuplicate
0074                         text: i18nc("@action:button", "Crash is a duplicate")
0075                         tooltip: xi18nc("@info:tooltip",
0076                                      `Use this action when you are certain that your crash is a duplicate of this bug report`)
0077                         icon.name: "document-duplicate"
0078                         onTriggered: {
0079                             removeAction.trigger()
0080                             promptDialog.bugNumber = ROLE_Number
0081                             promptDialog.open()
0082                         }
0083                         Accessible.name: text
0084                     },
0085                     Kirigami.Action {
0086                         visible: isDuplicate
0087                         text: i18nc("@action:button", "Crash is not a duplicate")
0088                         icon.name: "edit-clone-unlink"
0089                         onTriggered: reportInterface.attachToBugNumber = 0
0090                     },
0091 
0092                     Kirigami.Action {
0093                         id: addAction
0094                         visible: !listView.possibleDuplicates.includes(ROLE_Number) && !isDuplicate
0095                         text: i18nc("@action:button", "Suggest this crash is related")
0096                         tooltip: xi18nc("@info:tooltip",
0097                                      `Use this button to suggest that
0098                                      the crash you experienced is related to this bug
0099                                      report`)
0100                         icon.name: "list-add"
0101                         onTriggered: {
0102                             listView.possibleDuplicates.unshift(ROLE_Number)
0103                             listView.possibleDuplicatesChanged()
0104                         }
0105                         Accessible.name: text
0106                     },
0107                     Kirigami.Action {
0108                         id: removeAction
0109                         visible: !addAction.visible && !isDuplicate
0110                         text: i18nc("@action:button", "This crash is not related")
0111                         icon.name: "list-remove"
0112                         onTriggered: {
0113                             const index = listView.possibleDuplicates.indexOf(ROLE_Number)
0114                             if (index > -1) {
0115                                 listView.possibleDuplicates.splice(index, 1)
0116                                 listView.possibleDuplicatesChanged()
0117                             }
0118                         }
0119                         Accessible.name: text
0120                     }
0121                 ]
0122             }
0123         }
0124     }
0125 
0126     footer: FooterActionBar {
0127         actions: [
0128             Kirigami.Action {
0129                 iconName: "go-next"
0130                 text: i18nc("@action:button", "Next")
0131                 onTriggered: {
0132                     pageStack.push('qrc:/ui/ReportPage.qml')
0133                 }
0134             }
0135         ]
0136     }
0137 }