Warning, /plasma/aura-browser/app/qml/FeatureRequest.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 SPDX-FileCopyrightText: 2022 Aditya Mehra <aix.m@outlook.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.12 0008 import QtQuick.Controls 2.12 0009 import QtWebEngine 1.7 0010 import QtWebChannel 1.0 0011 import QtQuick.Layouts 1.12 0012 import org.kde.kirigami as Kirigami 0013 0014 Item { 0015 property var requestedFeature; 0016 property url securityOrigin; 0017 0018 width: parent.width 0019 height: parent.height 0020 0021 onRequestedFeatureChanged: { 0022 message.text = securityOrigin + " has requested access to your " 0023 + message.textForFeature(requestedFeature); 0024 } 0025 0026 RowLayout { 0027 anchors.fill: parent 0028 0029 Label { 0030 id: message 0031 Layout.fillWidth: true 0032 Layout.leftMargin: Kirigami.Units.largeSpacing 0033 color: Kirigami.Theme.textColor 0034 0035 function textForFeature(feature) { 0036 if (feature === WebEngineView.MediaAudioCapture) 0037 return "microphone" 0038 if (feature === WebEngineView.MediaVideoCapture) 0039 return "camera" 0040 if (feature === WebEngineView.MediaAudioVideoCapture) 0041 return "camera and microphone" 0042 if (feature === WebEngineView.Geolocation) 0043 return "location" 0044 } 0045 } 0046 0047 Button { 0048 id: acceptButton 0049 text: i18n("Accept") 0050 palette.buttonText: Kirigami.Theme.textColor 0051 Layout.alignment: Qt.AlignRight 0052 Layout.preferredWidth: Kirigami.Units.iconSizes.large 0053 0054 background: Rectangle { 0055 color: acceptButton.activeFocus ? Kirigami.Theme.highlightColor : Qt.lighter(Kirigami.Theme.backgroundColor, 1.2) 0056 border.color: Kirigami.Theme.disabledTextColor 0057 radius: 20 0058 } 0059 0060 onClicked: (mouse)=> { 0061 webView.grantFeaturePermission(securityOrigin, 0062 requestedFeature, true); 0063 interactionBar.isRequested = false; 0064 } 0065 } 0066 0067 Button { 0068 id: denyButton 0069 text: i18n("Deny") 0070 Layout.alignment: Qt.AlignRight 0071 Layout.preferredWidth: Kirigami.Units.iconSizes.large 0072 palette.buttonText: Kirigami.Theme.textColor 0073 0074 background: Rectangle { 0075 color: denyButton.activeFocus ? Kirigami.Theme.highlightColor : Qt.lighter(Kirigami.Theme.backgroundColor, 1.2) 0076 border.color: Kirigami.Theme.disabledTextColor 0077 radius: 20 0078 } 0079 0080 onClicked: (mouse)=> { 0081 webView.grantFeaturePermission(securityOrigin, 0082 requestedFeature, false); 0083 interactionBar.isRequested = false 0084 } 0085 } 0086 0087 Button { 0088 id: closeButton 0089 Layout.alignment: Qt.AlignRight 0090 Layout.preferredWidth: Kirigami.Units.iconSizes.large - (Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing) 0091 Layout.preferredHeight: Kirigami.Units.iconSizes.large - (Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing) 0092 Layout.leftMargin: Kirigami.Units.largeSpacing 0093 palette.buttonText: Kirigami.Theme.textColor 0094 0095 background: Rectangle { 0096 color: denyButton.activeFocus ? Kirigami.Theme.highlightColor : Qt.lighter(Kirigami.Theme.backgroundColor, 1.2) 0097 border.color: Kirigami.Theme.disabledTextColor 0098 radius: 200 0099 } 0100 0101 Kirigami.Icon { 0102 anchors.centerIn: parent 0103 width: Kirigami.Units.iconSizes.medium 0104 height: Kirigami.Units.iconSizes.medium 0105 source: "window-close" 0106 } 0107 0108 onClicked: (mouse)=> { 0109 interactionBar.isRequested = false 0110 } 0111 } 0112 } 0113 }