Advertisement
Guest User

Untitled

a guest
Sep 20th, 2023
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. import QtQuick 2.0
  2. import Sailfish.WebView 1.0
  3. import Sailfish.WebEngine 1.0
  4. import Sailfish.Silica 1.0
  5.  
  6. WebViewPage {
  7. allowedOrientations: Orientation.Landscape | Orientation.Portrait
  8.  
  9. property alias url: webview.url
  10. property string redirectionUri
  11.  
  12. signal accepted
  13.  
  14. // work around Silica bug: don't let webview enable forward navigation
  15. onForwardNavigationChanged: {
  16. if (forwardNavigation)
  17. forwardNavigation = false;
  18. }
  19.  
  20. WebView {
  21. id: webview
  22.  
  23. anchors.fill: parent
  24. opacity: 0
  25.  
  26. //experimental.userAgent: "Mozilla/5.0 (Maemo; Linux; Jolla; Sailfish; Mobile) AppleWebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13"
  27.  
  28. onLoadingChanged: {
  29. if (loaded){
  30. console.log("loaded")
  31. alreadyloaded = true
  32. WebEngineSettings.setPreference("security.csp.enable", false, WebEngineSettings.BoolPref)
  33. }
  34. opacity = 1
  35. /* switch (loadRequest.status)
  36. {
  37. case WebView.LoadSucceededStatus:
  38. opacity = 1
  39. break
  40. case WebView.LoadFailedStatus:
  41. opacity = 0
  42. break
  43. default:
  44. opacity = 0
  45. break
  46. }*/
  47. }
  48.  
  49. onUrlChanged: {
  50. console.log("URL: " + url);
  51. console.log("Redirection URI: " + redirectionUri);
  52. if (redirectionUri !== "" &&
  53. ("" + url).indexOf(redirectionUri) === 0)
  54. {
  55. accepted();
  56. pageStack.pop();
  57. }
  58. }
  59. }
  60.  
  61. BusyIndicator {
  62. running: webview.loading
  63. anchors.centerIn: parent
  64. size: BusyIndicatorSize.Large
  65. }
  66.  
  67. }
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement