Warning, /plasma/xdg-desktop-portal-kde/src/ScreenChooserDialog.qml is written in an unsupported language. File is not indexed.
0001 /* This file is part of the KDE project 0002 SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.15 0008 import QtQuick.Layouts 1.15 0009 import QtQuick.Controls 2.15 as QQC2 0010 import org.kde.kirigami 2.14 as Kirigami 0011 import org.kde.plasma.workspace.dialogs 1.0 as PWD 0012 import org.kde.taskmanager 0.1 as TaskManager 0013 0014 PWD.SystemDialog 0015 { 0016 id: root 0017 property alias outputsModel: outputsView.model 0018 property alias windowsModel: windowsView.model 0019 property bool multiple: false 0020 property alias allowRestore: allowRestoreItem.checked 0021 iconName: "video-display" 0022 acceptable: (outputsModel && outputsModel.hasSelection) || (windowsModel && windowsModel.hasSelection) 0023 0024 signal clearSelection() 0025 0026 ColumnLayout { 0027 spacing: 0 0028 0029 QQC2.TabBar { 0030 id: tabView 0031 Layout.fillWidth: true 0032 visible: root.outputsModel && root.windowsModel 0033 currentIndex: outputsView.count > 0 ? 0 : 1 0034 0035 QQC2.TabButton { 0036 text: i18n("Screens") 0037 } 0038 QQC2.TabButton { 0039 text: i18n("Windows") 0040 } 0041 } 0042 0043 QQC2.Frame { 0044 Layout.fillWidth: true 0045 Layout.fillHeight: true 0046 Layout.preferredHeight: Kirigami.Units.gridUnit * 20 0047 Layout.preferredWidth: Kirigami.Units.gridUnit * 30 0048 Kirigami.Theme.inherit: false 0049 Kirigami.Theme.colorSet: Kirigami.Theme.View 0050 background: Rectangle { 0051 color: Kirigami.Theme.backgroundColor 0052 property color borderColor: Kirigami.Theme.textColor 0053 border.color: Qt.rgba(borderColor.r, borderColor.g, borderColor.b, 0.3) 0054 } 0055 0056 StackLayout { 0057 anchors.fill: parent 0058 currentIndex: tabView.currentIndex 0059 0060 QQC2.ScrollView { 0061 Kirigami.CardsGridView { 0062 id: outputsView 0063 model: null 0064 cellHeight: Kirigami.Units.gridUnit * 15 0065 delegate: PipeWireDelegate { 0066 height: outputsView.cellHeight - Kirigami.Units.largeSpacing 0067 0068 banner { 0069 title: model.display 0070 titleIcon: model.decoration 0071 titleLevel: 3 0072 } 0073 checkable: true 0074 checked: model.checked === Qt.Checked 0075 nodeId: waylandItem.nodeId 0076 TaskManager.ScreencastingRequest { 0077 id: waylandItem 0078 outputName: model.name 0079 } 0080 0081 onToggled: { 0082 var to = model.checked !== Qt.Checked ? Qt.Checked : Qt.Unchecked; 0083 if (!root.multiple && to === Qt.Checked) { 0084 root.clearSelection() 0085 } 0086 outputsView.model.setData(outputsView.model.index(model.row, 0), to, Qt.CheckStateRole) 0087 } 0088 } 0089 } 0090 } 0091 QQC2.ScrollView { 0092 Kirigami.CardsGridView { 0093 id: windowsView 0094 model: null 0095 clip: true 0096 cellHeight: Kirigami.Units.gridUnit * 15 0097 0098 delegate: PipeWireDelegate { 0099 height: windowsView.cellHeight - Kirigami.Units.smallSpacing 0100 banner { 0101 title: model.DisplayRole || "" 0102 titleIcon: model.DecorationRole || "" 0103 titleLevel: 3 0104 } 0105 checkable: true 0106 checked: model.checked === Qt.Checked 0107 nodeId: waylandItem.nodeId 0108 TaskManager.ScreencastingRequest { 0109 id: waylandItem 0110 uuid: model.Uuid 0111 } 0112 0113 onToggled: { 0114 var to = model.checked !== Qt.Checked ? Qt.Checked : Qt.Unchecked; 0115 if (!root.multiple && to === Qt.Checked) { 0116 root.clearSelection() 0117 } 0118 windowsView.model.setData(windowsView.model.index(model.row, 0), to, Qt.CheckStateRole) 0119 } 0120 } 0121 } 0122 } 0123 } 0124 } 0125 0126 QQC2.CheckBox { 0127 id: allowRestoreItem 0128 checked: true 0129 text: i18n("Allow restoring on future sessions") 0130 } 0131 } 0132 0133 standardButtons: QQC2.DialogButtonBox.Ok | QQC2.DialogButtonBox.Cancel 0134 Component.onCompleted: { 0135 dialogButtonBox.standardButton(QQC2.DialogButtonBox.Ok).text = i18n("Share") 0136 0137 // If there's only one thing in the list, pre-select it to save the user a click 0138 if (outputsView.count == 1 && windowsView.count == 0) { 0139 outputsView.model.setData(outputsView.model.index(0, 0), Qt.Checked, Qt.CheckStateRole); 0140 } else if (windowsView.count == 1 && outputsView.count == 0) { 0141 windowsView.model.setData(outputsView.model.index(0, 0), Qt.Checked, Qt.CheckStateRole); 0142 } 0143 } 0144 }