mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 02:16:51 +02:00
Merge pull request #15977 from MiladNazeri/permissionsUIFix
[DEV-190] + [DEV-191] :: Permissions UI
This commit is contained in:
commit
e6e771df7b
6 changed files with 189 additions and 5 deletions
|
@ -14,7 +14,6 @@ Item {
|
||||||
HifiStyles.HifiConstants { id: hifistyles }
|
HifiStyles.HifiConstants { id: hifistyles }
|
||||||
|
|
||||||
height: 600
|
height: 600
|
||||||
property variant permissionsBar: {'securityOrigin':'none','feature':'none'}
|
|
||||||
property alias url: webview.url
|
property alias url: webview.url
|
||||||
|
|
||||||
property bool canGoBack: webview.canGoBack
|
property bool canGoBack: webview.canGoBack
|
||||||
|
@ -30,6 +29,10 @@ Item {
|
||||||
webview.profile = profile;
|
webview.profile = profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onUrlChanged: {
|
||||||
|
permissionPopupBackground.visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
WebEngineView {
|
WebEngineView {
|
||||||
id: webview
|
id: webview
|
||||||
objectName: "webEngineView"
|
objectName: "webEngineView"
|
||||||
|
@ -84,7 +87,14 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
onFeaturePermissionRequested: {
|
onFeaturePermissionRequested: {
|
||||||
grantFeaturePermission(securityOrigin, feature, false);
|
if (permissionPopupBackground.visible === true) {
|
||||||
|
console.log("Browser engine requested a new permission, but user is already being presented with a different permission request. Aborting request for new permission...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
permissionPopupBackground.securityOrigin = securityOrigin;
|
||||||
|
permissionPopupBackground.feature = feature;
|
||||||
|
|
||||||
|
permissionPopupBackground.visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoadingChanged: {
|
onLoadingChanged: {
|
||||||
|
@ -122,4 +132,11 @@ Item {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HifiControls.PermissionPopupBackground {
|
||||||
|
id: permissionPopupBackground
|
||||||
|
onSendPermission: {
|
||||||
|
webview.grantFeaturePermission(securityOrigin, feature, shouldGivePermission);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import QtWebChannel 1.0
|
||||||
import QtQuick.Controls 2.2
|
import QtQuick.Controls 2.2
|
||||||
|
|
||||||
import stylesUit 1.0 as StylesUIt
|
import stylesUit 1.0 as StylesUIt
|
||||||
|
import controlsUit 1.0 as ControlsUit
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: flick
|
id: flick
|
||||||
|
@ -28,6 +29,10 @@ Item {
|
||||||
|
|
||||||
property bool blurOnCtrlShift: true
|
property bool blurOnCtrlShift: true
|
||||||
|
|
||||||
|
onUrlChanged: {
|
||||||
|
permissionPopupBackground.visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
StylesUIt.HifiConstants {
|
StylesUIt.HifiConstants {
|
||||||
id: hifi
|
id: hifi
|
||||||
}
|
}
|
||||||
|
@ -141,7 +146,15 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
onFeaturePermissionRequested: {
|
onFeaturePermissionRequested: {
|
||||||
grantFeaturePermission(securityOrigin, feature, false);
|
if (permissionPopupBackground.visible === true) {
|
||||||
|
console.log("Browser engine requested a new permission, but user is already being presented with a different permission request. Aborting request for new permission...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
permissionPopupBackground.securityOrigin = securityOrigin;
|
||||||
|
permissionPopupBackground.feature = feature;
|
||||||
|
|
||||||
|
permissionPopupBackground.visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//disable popup
|
//disable popup
|
||||||
|
@ -186,4 +199,12 @@ Item {
|
||||||
webViewCore.focus = false;
|
webViewCore.focus = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ControlsUit.PermissionPopupBackground {
|
||||||
|
id: permissionPopupBackground
|
||||||
|
onSendPermission: {
|
||||||
|
webViewCore.grantFeaturePermission(securityOrigin, feature, shouldGivePermission);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
|
|
||||||
import QtQuick 2.7
|
import QtQuick 2.7
|
||||||
import QtWebEngine 1.5
|
import QtWebEngine 1.5
|
||||||
|
import controlsUit 1.0 as ControlsUit
|
||||||
|
|
||||||
WebEngineView {
|
WebEngineView {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
console.log("Connecting JS messaging to Hifi Logging")
|
console.log("Connecting JS messaging to Hifi Logging")
|
||||||
// Ensure the JS from the web-engine makes it to our logging
|
// Ensure the JS from the web-engine makes it to our logging
|
||||||
|
@ -22,6 +22,10 @@ WebEngineView {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onUrlChanged: {
|
||||||
|
permissionPopupBackground.visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
onLoadingChanged: {
|
onLoadingChanged: {
|
||||||
// Required to support clicking on "hifi://" links
|
// Required to support clicking on "hifi://" links
|
||||||
if (WebEngineView.LoadStartedStatus == loadRequest.status) {
|
if (WebEngineView.LoadStartedStatus == loadRequest.status) {
|
||||||
|
@ -37,6 +41,21 @@ WebEngineView {
|
||||||
WebSpinner { }
|
WebSpinner { }
|
||||||
|
|
||||||
onFeaturePermissionRequested: {
|
onFeaturePermissionRequested: {
|
||||||
grantFeaturePermission(securityOrigin, feature, false);
|
if (permissionPopupBackground.visible === true) {
|
||||||
|
console.log("Browser engine requested a new permission, but user is already being presented with a different permission request. Aborting request for new permission...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
permissionPopupBackground.securityOrigin = securityOrigin;
|
||||||
|
permissionPopupBackground.feature = feature;
|
||||||
|
|
||||||
|
permissionPopupBackground.visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ControlsUit.PermissionPopupBackground {
|
||||||
|
id: permissionPopupBackground
|
||||||
|
z: 100
|
||||||
|
onSendPermission: {
|
||||||
|
root.grantFeaturePermission(securityOrigin, feature, shouldGivePermission);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
90
interface/resources/qml/controlsUit/PermissionPopup.qml
Normal file
90
interface/resources/qml/controlsUit/PermissionPopup.qml
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
import QtQuick 2.5
|
||||||
|
import QtWebEngine 1.5
|
||||||
|
import QtQuick.Layouts 1.3
|
||||||
|
import controlsUit 1.0 as HifiControls
|
||||||
|
import stylesUit 1.0 as HifiStyles
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: root
|
||||||
|
width: 750
|
||||||
|
height: 210
|
||||||
|
color: hifi.colors.white
|
||||||
|
|
||||||
|
anchors.centerIn: parent
|
||||||
|
readonly property var permissionLanguage: ({
|
||||||
|
[WebEngineView.MediaAudioCapture]: "access an audio input device",
|
||||||
|
[WebEngineView.MediaVideoCapture]: "access a video device, like your webcam",
|
||||||
|
[WebEngineView.MediaAudioVideoCapture]: "access an audio input device and video device",
|
||||||
|
[WebEngineView.Geolocation]: "access your location",
|
||||||
|
[WebEngineView.DesktopVideoCapture]: "capture video from your desktop",
|
||||||
|
[WebEngineView.DesktopAudioVideoCapture]: "capture audio and video from your desktop",
|
||||||
|
"none": "Undefined permission being requested"
|
||||||
|
})
|
||||||
|
property string currentRequestedPermission
|
||||||
|
signal permissionButtonPressed(int buttonNumber)
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
anchors.fill: parent
|
||||||
|
Rectangle {
|
||||||
|
Layout.preferredHeight: 75
|
||||||
|
Layout.preferredWidth: parent.width
|
||||||
|
|
||||||
|
HifiStyles.RalewayBold {
|
||||||
|
text: "REQUEST FOR DEVICE ACCESS"
|
||||||
|
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
color: hifi.colors.black
|
||||||
|
size: 30
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
Layout.preferredHeight: 35
|
||||||
|
Layout.preferredWidth: parent.width
|
||||||
|
|
||||||
|
HifiStyles.RalewayLight {
|
||||||
|
text: "This website is attempting to " + root.permissionLanguage[root.currentRequestedPermission] + "."
|
||||||
|
|
||||||
|
anchors.centerIn: parent
|
||||||
|
wrapMode: Text.Wrap
|
||||||
|
size: 20
|
||||||
|
color: hifi.colors.black
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
Layout.preferredHeight: 100
|
||||||
|
Layout.preferredWidth: parent.width
|
||||||
|
Layout.topMargin: 35
|
||||||
|
property int space: 8
|
||||||
|
|
||||||
|
HifiControls.Button {
|
||||||
|
text: "Don't Allow"
|
||||||
|
|
||||||
|
anchors.right: parent.horizontalCenter
|
||||||
|
anchors.rightMargin: parent.space
|
||||||
|
width: 125
|
||||||
|
color: hifi.buttons.red
|
||||||
|
height: 38
|
||||||
|
onClicked: {
|
||||||
|
root.permissionButtonPressed(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HifiControls.Button {
|
||||||
|
text: "Yes allow access"
|
||||||
|
|
||||||
|
anchors.left: parent.horizontalCenter
|
||||||
|
anchors.leftMargin: parent.space
|
||||||
|
color: hifi.buttons.blue
|
||||||
|
width: 155
|
||||||
|
height: 38
|
||||||
|
onClicked: {
|
||||||
|
root.permissionButtonPressed(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
import QtQuick 2.5
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: root
|
||||||
|
anchors.fill: parent
|
||||||
|
color: Qt.rgba(0, 0, 0, 0.5);
|
||||||
|
visible: false
|
||||||
|
property string securityOrigin: 'none'
|
||||||
|
property string feature: 'none'
|
||||||
|
signal sendPermission(string securityOrigin, string feature, bool shouldGivePermission)
|
||||||
|
|
||||||
|
onFeatureChanged: {
|
||||||
|
permissionPopupItem.currentRequestedPermission = feature;
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
propagateComposedEvents: false
|
||||||
|
}
|
||||||
|
|
||||||
|
PermissionPopup {
|
||||||
|
id: permissionPopupItem
|
||||||
|
onPermissionButtonPressed: {
|
||||||
|
if (buttonNumber === 0) {
|
||||||
|
root.sendPermission(securityOrigin, feature, false);
|
||||||
|
} else {
|
||||||
|
root.sendPermission(securityOrigin, feature, true);
|
||||||
|
}
|
||||||
|
root.visible = false;
|
||||||
|
securityOrigin = 'none';
|
||||||
|
feature = 'none';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,6 +15,8 @@ Key 1.0 Key.qml
|
||||||
Keyboard 1.0 Keyboard.qml
|
Keyboard 1.0 Keyboard.qml
|
||||||
Label 1.0 Label.qml
|
Label 1.0 Label.qml
|
||||||
QueuedButton 1.0 QueuedButton.qml
|
QueuedButton 1.0 QueuedButton.qml
|
||||||
|
PermissionPopup 1.0 PermissionPopup.qml
|
||||||
|
PermissionPopupBackground 1.0 PermissionPopupBackground.qml
|
||||||
RadioButton 1.0 RadioButton.qml
|
RadioButton 1.0 RadioButton.qml
|
||||||
ScrollBar 1.0 ScrollBar.qml
|
ScrollBar 1.0 ScrollBar.qml
|
||||||
Separator 1.0 Separator.qml
|
Separator 1.0 Separator.qml
|
||||||
|
|
Loading…
Reference in a new issue