Warning, /plasma/print-manager/src/kcm/ui/Drivers.qml is written in an unsupported language. File is not indexed.
0001 /**
0002 SPDX-FileCopyrightText: 2023 Mike Noe <noeerover@gmail.com>
0003 SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005
0006 import QtQuick
0007 import QtQuick.Layouts
0008 import QtQuick.Controls as QQC2
0009 import org.kde.plasma.components as PComp
0010 import org.kde.kirigami as Kirigami
0011 import org.kde.plasma.extras as PlasmaExtras
0012
0013 ColumnLayout {
0014 id: root
0015 spacing: Kirigami.Units.largeSpacing
0016
0017 Layout.fillWidth: true
0018 Layout.fillHeight: true
0019
0020 readonly property alias busy: kcmConn.loading
0021
0022 signal selected(var driver)
0023
0024 function load(devid, makeModel, uri) {
0025 kcmConn.loading = true
0026 kcm.clearRecommendedDrivers()
0027 kcm.getRecommendedDrivers(devid, makeModel, uri)
0028 }
0029
0030 Component.onDestruction: kcm.clearRecommendedDrivers()
0031
0032 Connections {
0033 id: kcmConn
0034 target: kcm
0035
0036 property bool loading: false
0037
0038 function onRecommendedDriversLoaded() {
0039 kcmConn.loading = false
0040 let found = kcm.recommendedDrivers.findIndex(d => {return d.match === "exact"})
0041 if (found >= 0) {
0042 recmlist.itemAtIndex(found).clicked()
0043 }
0044 }
0045 }
0046
0047 QQC2.Button {
0048 id: recmAction
0049 Layout.alignment: Qt.AlignHCenter
0050 enabled: recmlist.count > 0
0051 icon.name: "dialog-ok-symbolic"
0052 text: i18nc("@action:button", "Select Recommended Driver")
0053 onClicked: {
0054 root.selected(kcm.recommendedDrivers[recmlist.currentIndex])
0055 }
0056
0057 QQC2.ToolTip {
0058 text: i18nc("@info:tooltip", "Recommended drivers are based on printer make/model and connection type")
0059 }
0060 }
0061
0062 QQC2.ScrollView {
0063 Layout.alignment: Qt.AlignHCenter
0064 Layout.fillWidth: true
0065 Layout.fillHeight: true
0066
0067 contentItem: ListView {
0068 id: recmlist
0069 highlight: PlasmaExtras.Highlight {}
0070 highlightMoveDuration: 0
0071 highlightResizeDuration: 0
0072
0073 PComp.BusyIndicator {
0074 running: kcmConn.loading
0075 anchors.centerIn: parent
0076 implicitWidth: Kirigami.Units.gridUnit * 6
0077 implicitHeight: Kirigami.Units.gridUnit * 6
0078 }
0079
0080 activeFocusOnTab: true
0081 keyNavigationWraps: true
0082
0083 KeyNavigation.backtab: root.parent
0084 Keys.onUpPressed: event => {
0085 if (currentIndex === 0) {
0086 currentIndex = -1;
0087 }
0088 event.accepted = false;
0089 }
0090
0091 model: kcm.recommendedDrivers
0092
0093 delegate: Kirigami.SubtitleDelegate {
0094 width: ListView.view.width
0095 text: modelData["ppd-name"]
0096 subtitle: modelData.match
0097 icon.name: modelData.match.startsWith("exact")
0098 ? "favorites-symbolic"
0099 : "dialog-question-symbolic"
0100
0101 onClicked: {
0102 ListView.view.currentIndex = index
0103 }
0104 }
0105 }
0106 }
0107
0108 }