Nano Browser Example

A web browser implemented using the WebEngineView QML type.

Nano Browser Screenshot

Download this example

from __future__ import annotations

"""PySide6 WebEngine QtQuick 2 Example"""

import sys
from argparse import ArgumentParser, RawTextHelpFormatter
from pathlib import Path

from PySide6.QtCore import (QCoreApplication, QFileInfo, QLoggingCategory,
                            QObject, QUrl, Slot)
from PySide6.QtQml import QQmlApplicationEngine, QmlElement, QmlSingleton
from PySide6.QtGui import QGuiApplication
from PySide6.QtWebEngineQuick import QtWebEngineQuick

import rc_resources  # noqa: F401


# To be used on the @QmlElement decorator
# (QML_IMPORT_MINOR_VERSION is optional)
QML_IMPORT_NAME = "BrowserUtils"
QML_IMPORT_MAJOR_VERSION = 1


DEFAULT_URL = "chrome://qt?example=Quick Nano Browser"


def url_from_user_input(user_input):
    file_info = QFileInfo(user_input)
    if file_info.exists():
        return QUrl.fromLocalFile(file_info.absoluteFilePath())
    return QUrl.fromUserInput(user_input)


@QmlElement
@QmlSingleton
class Utils(QObject):

    @Slot(str, result=QUrl)
    def fromUserInput(self, user_input):
        return url_from_user_input(user_input)


if __name__ == '__main__':
    QCoreApplication.setApplicationName("Quick Nano Browser")
    QCoreApplication.setOrganizationName("QtProject")

    QLoggingCategory.setFilterRules("qt.webenginecontext.debug=true")

    QtWebEngineQuick.initialize()

    argument_parser = ArgumentParser(description="Quick Nano Browser",
                                     formatter_class=RawTextHelpFormatter)
    argument_parser.add_argument("--single-process", "-s", action="store_true",
                                 help="Run in single process mode (trouble shooting)")
    argument_parser.add_argument("url", help="The URL to open",
                                 nargs='?', type=str)
    options = argument_parser.parse_args()

    url = url_from_user_input(options.url) if options.url else QUrl(DEFAULT_URL)

    app_args = sys.argv
    if options.single_process:
        app_args.extend(["--webEngineArgs", "--single-process"])
    app = QGuiApplication(app_args)
    engine = QQmlApplicationEngine()
    engine.setInitialProperties({"startupUrl": url})
    engine.addImportPath(Path(__file__).parent)
    engine.loadFromModule("BrowserUtils", "ApplicationRoot")
    if not engine.rootObjects():
        sys.exit(-1)

    exit_code = app.exec()
    del engine
    sys.exit(exit_code)
pragma ComponentBehavior: Bound

import QtQuick
import QtQuick.Controls.Material
import QtWebEngine

Item {
    id: root
    required property ApplicationWindow browserWindow
    required property WebEngineView webView
    required property DownloadView downloads
    required property WebToolBar toolBar
    required property FindBar searchBar
    required property FullScreenNotification fullScreenNotifications

    signal newTabRequested(WebEngineProfile profile)

    Action {
        shortcut: "Ctrl+D"
        onTriggered: {
            root.downloads.visible = !root.downloads.visible;
        }
    }
    Action {
        shortcut: "Ctrl+L"
        onTriggered: {
            if (root.toolBar != null) {
                root.toolBar.addressBar.forceActiveFocus();
                root.toolBar.addressBar.selectAll();
            }
        }
    }
    Action {
        shortcut: StandardKey.Refresh
        onTriggered: {
            if (root.webView)
                root.webView.reload();
        }
    }
    Action {
        shortcut: StandardKey.AddTab
        onTriggered: {
            root.newTabRequested();
            if (root.toolBar != null) {
                root.toolBar.addressBar.forceActiveFocus();
                root.toolBar.addressBar.selectAll();
            }
        }
    }
    Action {
        shortcut: StandardKey.Close
        onTriggered: {
            root.webView.triggerWebAction(WebEngineView.RequestClose);
        }
    }
    Action {
        shortcut: StandardKey.Quit
        onTriggered: root.browserWindow.close()
    }
    Action {
        shortcut: "Escape"
        onTriggered: {
            if (root.webView.state === "FullScreen") {
                root.fullScreenNotifications.hide();
                root.webView.triggerWebAction(WebEngineView.ExitFullScreen);
            }

            if (root.searchBar.visible)
                root.searchBar.visible = false;
        }
    }
    Action {
        shortcut: "Ctrl+0"
        onTriggered: root.webView.zoomFactor = 1.0
    }
    Action {
        shortcut: StandardKey.ZoomOut
        onTriggered: root.webView.zoomFactor -= 0.1
    }
    Action {
        shortcut: StandardKey.ZoomIn
        onTriggered: root.webView.zoomFactor += 0.1
    }

    Action {
        shortcut: StandardKey.Copy
        onTriggered: root.webView.triggerWebAction(WebEngineView.Copy)
    }
    Action {
        shortcut: StandardKey.Cut
        onTriggered: root.webView.triggerWebAction(WebEngineView.Cut)
    }
    Action {
        shortcut: StandardKey.Paste
        onTriggered: root.webView.triggerWebAction(WebEngineView.Paste)
    }
    Action {
        shortcut: "Shift+" + StandardKey.Paste
        onTriggered: root.webView.triggerWebAction(WebEngineView.PasteAndMatchStyle)
    }
    Action {
        shortcut: StandardKey.SelectAll
        onTriggered: root.webView.triggerWebAction(WebEngineView.SelectAll)
    }
    Action {
        shortcut: StandardKey.Undo
        onTriggered: root.webView.triggerWebAction(WebEngineView.Undo)
    }
    Action {
        shortcut: StandardKey.Redo
        onTriggered: root.webView.triggerWebAction(WebEngineView.Redo)
    }
    Action {
        shortcut: StandardKey.Back
        onTriggered: root.webView.triggerWebAction(WebEngineView.Back)
    }
    Action {
        shortcut: StandardKey.Forward
        onTriggered: root.webView.triggerWebAction(WebEngineView.Forward)
    }
    Action {
        shortcut: StandardKey.Find
        onTriggered: {
            if (!root.searchBar.visible)
                root.searchBar.visible = true;
        }
    }
    Action {
        shortcut: StandardKey.FindNext
        onTriggered: root.searchBar.findNext()
    }
    Action {
        shortcut: StandardKey.FindPrevious
        onTriggered: root.searchBar.findPrevious()
    }
}
pragma ComponentBehavior: Bound

import QtQuick
import BrowserUtils

QtObject {
    id: root
    required property string startupUrl
    Component.onCompleted: BrowserManager.load(startupUrl)
}
import QtQuick
import QtQuick.Window
import QtWebEngine

Window {
    id: window
    property alias currentWebView: webView
    flags: Qt.Dialog
    width: 800
    height: 600
    visible: true
    onClosing: destroy()
    WebEngineView {
        id: webView
        anchors.fill: parent

        onGeometryChangeRequested: function(geometry) {
            window.x = geometry.x
            window.y = geometry.y
            window.width = geometry.width
            window.height = geometry.height
        }
    }
}
pragma Singleton

import QtQuick
import QtWebEngine

QtObject {
    id: manager

    property WebEngineProfilePrototype defaultProfilePrototype : WebEngineProfilePrototype {
        storageName: "Profile"
    }

    property WebEngineProfilePrototype otrPrototype : WebEngineProfilePrototype {}

    function createWindow(profile) {
        let browserWindowComponent = Qt.createComponent("BrowserUtils", "BrowserWindow");
        let newWindow = browserWindowComponent.createObject(manager) as BrowserWindow;
        newWindow.currentWebView.profile = profile;
        profile.downloadRequested.connect(newWindow.onDownloadRequested);
        return newWindow;
    }
    function createDialog(profile) {
        let browserDialogComponent = Qt.createComponent("BrowserUtils", "BrowserDialog");
        let newDialog = browserDialogComponent.createObject(manager) as BrowserDialog;
        newDialog.closing.connect(function(){destroy()})
        newDialog.currentWebView.profile = profile;
        return newDialog;
    }
    function load(url) {
        let browserWindow = createWindow(manager.defaultProfilePrototype.instance());
        browserWindow.currentWebView.url = url;
    }

    Component.onCompleted: {
        let fullVersionList = manager.defaultProfilePrototype.instance().clientHints.fullVersionList;
        fullVersionList["QuickNanoBrowser"] = "1.0";
        manager.defaultProfilePrototype.instance().clientHints.fullVersionList = fullVersionList;
    }
}
pragma ComponentBehavior: Bound

import QtQuick
import QtQuick.Layouts
import QtWebEngine

StackLayout {
    id: root
    required property BrowserTabBar tabs
    required property FindBar searchBar
    required property SslDialog certificateDialog
    required property PermissionDialog permissionPrompt
    required property WebAuthDialog webAuthenticationDialog
    // appSettings from BrowserWindow, which declares the custom properties.
    required property var browserSettings
    readonly property BrowserTab currentTab: root.currentIndex < root.count ? root.children[root.currentIndex] as BrowserTab : null
    readonly property url newTabUrl: "chrome://qt?example=Quick Nano Browser"

    signal linkHovered(url hoveredUrl)
    signal fullScreenToggled(bool toggleOn)
    signal lastTabClosed()

    currentIndex: root.tabs.currentIndex

    Component.onCompleted: createTab(BrowserManager.defaultProfilePrototype.instance())

    function createTab(profile, focusOnNewTab = true, url = undefined) {
        var tab = tabFactory.createObject(root, {profile: profile}) as BrowserTab;
        var webview = tab.webView;
        root.tabs.addTabButton(tab);
        if (focusOnNewTab) {
            root.tabs.setCurrentIndex(root.tabs.count - 1);
        }
        if (url !== undefined) {
            webview.url = url;
        }
        return webview;
    }

    function tryCloseTab(index) {
        (root.children[index] as BrowserTab).tryCloseTab();
    }

    function closeTab(index) {
        if (root.tabs.count > 1) {
            root.tabs.removeTabButton(index);
            root.children[index].destroy();
        } else {
            root.lastTabClosed();
        }
    }

    Component {
        id: tabFactory
        BrowserTab {
            id: tab
            searchBar: root.searchBar
            certificateDialog: root.certificateDialog
            permissionPrompt: root.permissionPrompt
            webAuthenticationDialog: root.webAuthenticationDialog
            imageAnimationPolicy: root.browserSettings.imageAnimationPolicy
            toolBar.loadImagesChecked: root.browserSettings.autoLoadImages
            toolBar.javaScriptEnabledChecked: root.browserSettings.javaScriptEnabled
            toolBar.errorPageEnabledChecked: root.browserSettings.errorPageEnabled
            toolBar.pluginsEnabledChecked: root.browserSettings.pluginsEnabled
            toolBar.fullScreenSupportEnabledChecked: root.browserSettings.fullScreenSupportEnabled
            toolBar.autoLoadIconsForPageChecked: root.browserSettings.autoLoadIconsForPage
            toolBar.touchIconsEnabledChecked: root.browserSettings.touchIconsEnabled
            toolBar.webRTCPublicInterfacesOnlyChecked: root.browserSettings.webRTCPublicInterfacesOnly
            toolBar.devToolsEnabledChecked: root.browserSettings.devToolsEnabled
            toolBar.pdfViewerEnabledChecked: root.browserSettings.pdfViewerEnabled
            toolBar.javascriptCanAccessClipboardChecked: root.browserSettings.javascriptCanAccessClipboard
            toolBar.javascriptCanPasteChecked: root.browserSettings.javascriptCanPaste
            toolBar.disableImageAnimationChecked: root.browserSettings.imageAnimationPolicy === WebEngineSettings.ImageAnimationPolicy.Disallow
            toolBar.allowImageAnimationChecked: root.browserSettings.imageAnimationPolicy === WebEngineSettings.ImageAnimationPolicy.Allow
            toolBar.animateImageOnceChecked: root.browserSettings.imageAnimationPolicy === WebEngineSettings.ImageAnimationPolicy.AnimateOnce

            onSettingToggled: function(name, value) {
                root.browserSettings[name] = value;
            }

            onLinkHovered: hoveredUrl => root.linkHovered(hoveredUrl)

            onTabViewCloseRequested: function() {
                root.closeTab(tab.index);
            }

            onNewWindowRequested: function(request) {
                if (!request.userInitiated)
                    console.warn("Blocked a popup window.");
                else if (request.destination === WebEngineNewWindowRequest.InNewTab) {
                    let newTab = root.createTab(root.currentTab.webView.profile, true, request.requestedUrl);
                    newTab.acceptAsNewWindow(request);
                } else if (request.destination === WebEngineNewWindowRequest.InNewBackgroundTab) {
                    let backgroundTab = root.createTab(root.currentTab.webView.profile, false);
                    backgroundTab.acceptAsNewWindow(request);
                } else if (request.destination === WebEngineNewWindowRequest.InNewDialog) {
                    let dialog = BrowserManager.createDialog(root.currentTab.webView.profile);
                    dialog.currentWebView.acceptAsNewWindow(request);
                } else {
                    let window = BrowserManager.createWindow(root.currentTab.webView.profile);
                    window.currentWebView.acceptAsNewWindow(request);
                }
            }

            onDevToolsNewWindowRequested: function(request) {
                let newTab = root.createTab(root.currentTab.webView.profile);
                request.openIn(newTab);
            }

            onFullScreenToggled: toggleOn => root.fullScreenToggled(toggleOn)
        }
    }
}
pragma ComponentBehavior: Bound

import QtQuick
import QtQuick.Layouts
import QtWebEngine

ColumnLayout {
    id: root
    required property FindBar searchBar
    required property SslDialog certificateDialog
    required property PermissionDialog permissionPrompt
    required property WebAuthDialog webAuthenticationDialog
    property alias profile: tabWebView.profile
    readonly property alias toolBar: tabToolBar
    readonly property alias webView: tabWebView
    required property int imageAnimationPolicy
    property int index: 0

    signal fullScreenToggled(bool toggleOn)
    signal linkHovered(url hoveredUrl)
    signal tabViewCloseRequested()
    signal newWindowRequested(WebEngineNewWindowRequest request)
    signal devToolsNewWindowRequested(WebEngineNewWindowRequest request)
    signal settingToggled(string name, var value)

    spacing: 0

    function tryCloseTab() {
        tabWebView.triggerWebAction(WebEngineView.RequestClose);
    }

    WebToolBar {
        id: tabToolBar
        Layout.fillWidth: true
        currentWebView: tabWebView
        onSettingToggled: (name, value) => root.settingToggled(name, value)
    }

    WebEngineView {
        id: tabWebView
        Layout.fillWidth: true
        Layout.fillHeight: true
        focus: true

        settings.localContentCanAccessRemoteUrls: true
        settings.localContentCanAccessFileUrls: false
        settings.autoLoadImages: tabToolBar.loadImagesChecked
        settings.javascriptEnabled: tabToolBar.javaScriptEnabledChecked
        settings.errorPageEnabled: tabToolBar.errorPageEnabledChecked
        settings.pluginsEnabled: tabToolBar.pluginsEnabledChecked
        settings.fullScreenSupportEnabled: tabToolBar.fullScreenSupportEnabledChecked
        settings.autoLoadIconsForPage: tabToolBar.autoLoadIconsForPageChecked
        settings.touchIconsEnabled: tabToolBar.touchIconsEnabledChecked
        settings.webRTCPublicInterfacesOnly: tabToolBar.webRTCPublicInterfacesOnlyChecked
        settings.pdfViewerEnabled: tabToolBar.pdfViewerEnabledChecked
        settings.imageAnimationPolicy: root.imageAnimationPolicy
        settings.screenCaptureEnabled: true
        settings.javascriptCanAccessClipboard: tabToolBar.javascriptCanAccessClipboardChecked
        settings.javascriptCanPaste: tabToolBar.javascriptCanPasteChecked

        onCertificateError: function(error) {
            if (!error.isMainFrame) {
                error.rejectCertificate();
                return;
            }

            error.defer();
            root.certificateDialog.enqueue(error);
        }

        onFullScreenRequested: function(request) {
            tabToolBar.visible = request.toggleOn;
            root.fullScreenToggled(request.toggleOn);
            request.accept();
        }

        onRegisterProtocolHandlerRequested: function(request) {
            console.log("accepting registerProtocolHandler request for "
                        + request.scheme + " from " + request.origin);
            request.accept();
        }

        onDesktopMediaRequested: function(request) {
            // select the primary screen
            request.selectScreen(request.screensModel.index(0, 0));
        }

        onRenderProcessTerminated: function(terminationStatus, exitCode) {
            var status = "";
            switch (terminationStatus) {
            case WebEngineView.NormalTerminationStatus:
                status = "(normal exit)";
                break;
            case WebEngineView.AbnormalTerminationStatus:
                status = "(abnormal exit)";
                break;
            case WebEngineView.CrashedTerminationStatus:
                status = "(crashed)";
                break;
            case WebEngineView.KilledTerminationStatus:
                status = "(killed)";
                break;
            }

            print("Render process exited with code " + exitCode + " " + status);
            Qt.callLater(function() { tabWebView.reload() })
        }

        onSelectClientCertificate: function(selection) {
            selection.certificates[0].select();
        }

        onFindTextFinished: function(result) {
            if (!root.searchBar.visible)
                root.searchBar.visible = true;

            root.searchBar.numberOfMatches = result.numberOfMatches;
            root.searchBar.activeMatch = result.activeMatch;
        }

        onLoadingChanged: function(loadRequest) {
            if (loadRequest.status === WebEngineView.LoadStartedStatus)
                root.searchBar.reset();
        }

        onPermissionRequested: function(permission) {
            root.permissionPrompt.permission = permission;
            root.permissionPrompt.visible = true;
        }
        onWebAuthUxRequested: function(request) {
            root.webAuthenticationDialog.init(request);
        }

        onLinkHovered: hoveredUrl => root.linkHovered(hoveredUrl)
        onWindowCloseRequested: root.tabViewCloseRequested()
        onNewWindowRequested: request => root.newWindowRequested(request)
    }

    WebEngineView {
        id: devToolsWebEngineView
        visible: tabToolBar.devToolsEnabledChecked
        Layout.fillWidth: true
        Layout.preferredHeight: 400
        inspectedView: visible ? tabWebView : null
        onNewWindowRequested: request => root.devToolsNewWindowRequested(request)

        onWindowCloseRequested: function() {
            // Delay hiding for keep the inspectedView set to receive the ACK message of close.
            Qt.callLater(function() { root.settingToggled("devToolsEnabled", false) })
        }
    }
}
pragma ComponentBehavior: Bound

import QtQuick
import QtQuick.Controls.Material
import QtQuick.Layouts

Pane {
    id: root
    property alias currentIndex: tabBar.currentIndex
    readonly property alias count: tabBar.count
    padding: 0

    signal newTabRequested()
    signal tabCloseRequested(int index)

    function addTabButton(tab) {
        var newTabButton = tabButtonFactory.createObject(tabBar, {tabTitle: Qt.binding(function () { return tab.webView.title; })});
        tab.index = Qt.binding(function () { return newTabButton.TabBar.index; })
        tabBar.addItem(newTabButton);
        return newTabButton;
    }

    function removeTabButton(index) {
        tabBar.removeItem(tabBar.itemAt(index));
    }

    function setCurrentIndex(index) {
        tabBar.setCurrentIndex(index);
    }

    RowLayout {
        spacing: 0
        anchors.fill: parent

        ToolButton {
            Layout.bottomMargin: 2
            font.pointSize: 12
            font.bold: true
            implicitWidth: 32
            implicitHeight: 32
            text: "+"
            onClicked: root.newTabRequested()
        }

        TabBar {
            id: tabBar
            Layout.fillWidth: true
            Layout.fillHeight: true
        }

    }

    Component {
        id: tabButtonFactory

        TabButton {
            id: tabButton
            property string tabTitle: "New Tab"

            contentItem: RowLayout {
                Label {
                    id: tabText
                    Layout.fillWidth: true
                    Layout.leftMargin: 4
                    Layout.rightMargin: 4
                    text: tabButton.tabTitle
                    elide: Text.ElideRight
                }
                ToolButton {
                    id: button
                    font.pointSize: 12
                    font.bold: true
                    implicitWidth: 32
                    implicitHeight: 32
                    text: "x"
                    onClicked: tabButton.closeTab()
                }
            }

            function closeTab() {
                root.tabCloseRequested(TabBar.index);
            }
        }
    }
}
pragma ComponentBehavior: Bound

import QtCore
import QtQml
import QtQuick
import QtQuick.Controls.Material
import QtQuick.Dialogs
import QtQuick.Window
import QtWebEngine
import BrowserUtils

ApplicationWindow {
    id: win
    property BrowserTab currentTab: tabLayout.currentTab
    property WebEngineView currentWebView: currentTab?.webView ?? null
    property int previousVisibility: Window.Windowed
    property bool lastTabClosing: false

    width: 900
    height: 600
    visible: true
    title: win.currentWebView?.title ?? ""


    header: BrowserTabBar {
        id: tabBar
        onTabCloseRequested: index => tabLayout.tryCloseTab(index)
        onNewTabRequested: {
            tabLayout.createTab(win.currentWebView?.profile
                                ?? BrowserManager.defaultProfilePrototype.instance(),
                                true, tabLayout.newTabUrl);
            win.currentTab.toolBar.addressBar.forceActiveFocus();
            win.currentTab.toolBar.addressBar.selectAll();
        }
    }

    // Make sure the Qt.WindowFullscreenButtonHint is set on OS X.
    Component.onCompleted: flags = flags | Qt.WindowFullscreenButtonHint

    onCurrentWebViewChanged: {
        findBar.reset();
    }

    Settings {
        id: appSettings
        property bool autoLoadImages: WebEngine.settings.autoLoadImages
        property bool javaScriptEnabled: WebEngine.settings.javascriptEnabled
        property bool errorPageEnabled: WebEngine.settings.errorPageEnabled
        property bool pluginsEnabled: true
        property bool fullScreenSupportEnabled: WebEngine.settings.fullScreenSupportEnabled
        property bool autoLoadIconsForPage: WebEngine.settings.autoLoadIconsForPage
        property bool touchIconsEnabled: WebEngine.settings.touchIconsEnabled
        property bool webRTCPublicInterfacesOnly: WebEngine.settings.webRTCPublicInterfacesOnly
        property bool devToolsEnabled: false
        property bool pdfViewerEnabled: WebEngine.settings.pdfViewerEnabled
        property bool javascriptCanAccessClipboard: WebEngine.settings.javascriptCanAccessClipboard
        property bool javascriptCanPaste: WebEngine.settings.javascriptCanPaste
        property int imageAnimationPolicy: WebEngine.settings.imageAnimationPolicy
    }

    ActionManager {
        browserWindow: win
        webView: win.currentWebView
        downloads: downloadView
        toolBar: win.currentTab?.toolBar ?? null
        searchBar: findBar
        fullScreenNotifications: fullScreenNotification
        onNewTabRequested: tabLayout.createTab(BrowserManager.defaultProfilePrototype.instance(), true, tabLayout.newTabUrl)
    }

    BrowserStackLayout {
        id: tabLayout
        anchors.fill: parent
        tabs: tabBar
        searchBar: findBar
        certificateDialog: sslDialog
        permissionPrompt: permissionDialog
        webAuthenticationDialog: webAuthDialog
        browserSettings: appSettings

        onLinkHovered: function(hoveredUrl) {
            if (hoveredUrl === "")
                hideStatusText.start();
            else {
                statusText.text = hoveredUrl;
                statusBubble.visible = true;
                hideStatusText.stop();
            }
        }

        onFullScreenToggled: function(toggleOn) {
            if (toggleOn) {
                tabs.visible =  false;
                win.previousVisibility = win.visibility;
                win.showFullScreen();
                fullScreenNotification.show();
            } else {
                tabs.visible =  true;
                win.visibility = win.previousVisibility;
                fullScreenNotification.hide();
            }
        }

        onLastTabClosed: {
            win.lastTabClosing = true;
            win.close();
        }
    }

    SslDialog {
        id: sslDialog
        anchors.centerIn: parent
    }
    PermissionDialog {
        id: permissionDialog
        anchors.centerIn: parent
        width: Math.min(win.width, win.height) / 3 * 2
    }

    FullScreenNotification {
        id: fullScreenNotification
    }

    DownloadView {
        id: downloadView
        visible: false
        anchors.fill: parent
    }

    WebAuthDialog {
        id: webAuthDialog
        visible: false
        width: Math.min(win.width, win.height) / 3 * 2
    }

    MessageDialog {
        id: downloadAcceptDialog
        property var downloadRequest: downloadView.pendingDownloadRequest
        title: "Download requested"
        text: downloadRequest ? downloadRequest.suggestedFileName : ""
        buttons: Dialog.No | Dialog.Yes
        onAccepted: {
            downloadView.visible = true;
            downloadView.append(downloadRequest);
            downloadRequest.accept();
        }
        onRejected: {
            downloadRequest.cancel();
        }
        onButtonClicked: {
            visible = false;
        }
        visible: false
    }

    function onDownloadRequested(download) {
        downloadView.pendingDownloadRequest = download;
        downloadAcceptDialog.visible = true;
    }

    FindBar {
        id: findBar
        visible: false
        anchors.right: parent.right
        anchors.rightMargin: 10
        anchors.top: parent.top

        onFindNext: {
            if (text)
                win.currentWebView?.findText(text);
            else if (!visible)
                visible = true;
        }
        onFindPrevious: {
            if (text)
                win.currentWebView?.findText(text, WebEngineView.FindBackward);
            else if (!visible)
                visible = true;
        }
    }


    Rectangle {
        id: statusBubble
        color: "oldlace"
        property int padding: 8
        visible: false

        anchors.left: parent.left
        anchors.bottom: parent.bottom
        width: statusText.paintedWidth + padding
        height: statusText.paintedHeight + padding

        Text {
            id: statusText
            anchors.centerIn: statusBubble
            elide: Qt.ElideMiddle

            Timer {
                id: hideStatusText
                interval: 750
                onTriggered: {
                    statusText.text = "";
                    statusBubble.visible = false;
                }
            }
        }
    }

    onClosing: function(closeEvent) {
       if (lastTabClosing) {
           return;
       }
       closeEvent.accepted = false
       for (let i = 0; i < tabBar.count; i++)  {
           tabLayout.tryCloseTab(i);
       }
    }
}
pragma ComponentBehavior: Bound

import QtQuick
import QtQuick.Controls.Material

Rectangle {
    id: downloadView
    color: "lightgray"
    property var pendingDownloadRequest: null

    ListModel {
        id: downloadModel
        property var downloads: []
    }

    function append(download) {
        downloadModel.append(download);
        downloadModel.downloads.push(download);
    }

    Component {
        id: downloadItemDelegate

        Rectangle {
            id: downloadItem
            width: listView.width
            height: childrenRect.height
            anchors.margins: 10
            radius: 3
            color: "transparent"
            border.color: "black"

            required property int index

            Rectangle {
                id: progressBar

                property real progress: {
                    let d = downloadModel.downloads[downloadItem.index]
                    return d ? d.receivedBytes / d.totalBytes : 0
                }

                radius: 3
                color: width === listView.width ? "green" : "#2b74c7"
                width: listView.width * progress
                height: cancelButton.height

                Behavior on width {
                    SmoothedAnimation { duration: 100 }
                }
            }
            Rectangle {
                anchors {
                    left: parent.left
                    right: parent.right
                    leftMargin: 20
                }
                Label {
                    id: label
                    text: {
                        let d = downloadModel.downloads[downloadItem.index]
                        return d ? d.downloadDirectory + "/" + d.downloadFileName : qsTr("")
                    }
                    anchors {
                        verticalCenter: cancelButton.verticalCenter
                        left: parent.left
                        right: cancelButton.left
                    }
                }
                Button {
                    id: cancelButton
                    anchors.right: parent.right
                    icon.source: "qrc:///icons/3rdparty/process-stop.png"
                    onClicked: {
                        var download = downloadModel.downloads[downloadItem.index];

                        download.cancel();

                        downloadModel.downloads = downloadModel.downloads.filter(function (el) {
                            return el.id !== download.id;
                        });
                        downloadModel.remove(downloadItem.index);
                    }
                }
            }
        }

    }
    ListView {
        id: listView
        anchors {
            topMargin: 10
            top: parent.top
            bottom: parent.bottom
            horizontalCenter: parent.horizontalCenter
        }
        width: parent.width - 20
        spacing: 5

        model: downloadModel
        delegate: downloadItemDelegate

        Text {
            visible: !listView.count
            horizontalAlignment: Text.AlignHCenter
            height: 30
            anchors {
                top: parent.top
                left: parent.left
                right: parent.right
            }
            font.pixelSize: 20
            text: "No active downloads."
        }

        Rectangle {
            color: "gray"
            anchors {
                bottom: parent.bottom
                left: parent.left
                right: parent.right
            }
            height: 30
            Button {
                id: okButton
                text: "OK"
                anchors.centerIn: parent
                onClicked: {
                    downloadView.visible = false;
                }
            }
        }
    }
}
import QtQuick
import QtQuick.Controls.Material
import QtQuick.Layouts

Rectangle {
    id: root

    property int numberOfMatches: 0
    property int activeMatch: 0
    property alias text: findTextField.text

    function reset() {
        numberOfMatches = 0;
        activeMatch = 0;
        visible = false;
    }

    signal findNext()
    signal findPrevious()

    width: 250
    height: 35
    radius: 2

    border.width: 1
    border.color: "black"
    color: "white"

    onVisibleChanged: {
        if (visible)
            findTextField.forceActiveFocus();
    }


    RowLayout {
        anchors.fill: parent
        anchors.topMargin: 5
        anchors.bottomMargin: 5
        anchors.leftMargin: 10
        anchors.rightMargin: 10

        spacing: 5

        Rectangle {
            Layout.fillWidth: true
            Layout.fillHeight: true

            TextField {
                id: findTextField
                anchors.fill: parent
                color: "black"
                background: Rectangle {
                    color: "transparent"
                }

                onAccepted: root.findNext()
                onTextChanged: root.findNext()
                onActiveFocusChanged: activeFocus ? selectAll() : deselect()
            }
        }

        Label {
            text: root.activeMatch + "/" + root.numberOfMatches
            visible: findTextField.text !== ""
            color: "black"
        }

        Rectangle {
            border.width: 1
            border.color: "#dddddd"
            Layout.preferredWidth: 2
            Layout.preferredHeight: parent.height
        }

        ToolButton {
            id: findBtnLeft
            text: "<"
            enabled: root.numberOfMatches > 0
            onClicked: root.findPrevious()
            contentItem: Text {
                color: "black"
                text: findBtnLeft.text
            }
        }

        ToolButton {
            id: findBtnRight
            text: ">"
            enabled: root.numberOfMatches > 0
            onClicked: root.findNext()
            contentItem: Text {
                color: "black"
                text: findBtnRight.text
            }
        }

        ToolButton {
            id: findBtnClose
            text: "x"
            onClicked: root.visible = false
            contentItem: Text {
                color: "black"
                text: findBtnClose.text
            }
        }
    }
}
import QtQuick

Rectangle {
    id: fullScreenNotification
    width: 500
    height: 40
    color: "white"
    radius: 7

    visible: false
    opacity: 0

    function show() {
        visible = true;
        opacity = 1;
        reset.start();
    }

    function hide() {
        reset.stop();
        opacity = 0;
    }

    Behavior on opacity {
        NumberAnimation {
            duration: 750
            onStopped: {
                if (fullScreenNotification.opacity === 0)
                    fullScreenNotification.visible = false;
            }
        }
    }

    Timer {
        id: reset
        interval: 5000
        onTriggered: fullScreenNotification.hide()
    }

    anchors.horizontalCenter: parent.horizontalCenter
    y: 125

    Text {
        id: message
        width: parent.width

        anchors.horizontalCenter: parent.horizontalCenter
        anchors.verticalCenter: parent.verticalCenter

        horizontalAlignment: Text.AlignHCenter
        verticalAlignment: Text.AlignVCenter

        wrapMode: Text.WordWrap
        elide: Text.ElideNone
        clip: true

        text: qsTr("You are now in fullscreen mode. Press ESC to quit!")
    }
}
pragma ComponentBehavior: Bound

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtWebEngine

Dialog {
    id: webAuthDialog
    anchors.centerIn: parent
    contentWidth: verticalLayout.width +10;
    contentHeight: verticalLayout.height +10;
    standardButtons: Dialog.Cancel | Dialog.Apply
    title: "WebAuth Request"

    property var selectAccount;
    property var authrequest: null;

    Connections {
        id: webauthConnection
        ignoreUnknownSignals: true
        function onStateChanged(state) {
            webAuthDialog.setupUI(state);
        }
    }

    onApplied: {
        switch (webAuthDialog.authrequest.state) {
            case WebEngineWebAuthUxRequest.WebAuthUxState.CollectPin:
                webAuthDialog.authrequest.setPin(pinEdit.text);
                break;
            case WebEngineWebAuthUxRequest.WebAuthUxState.SelectAccount:
                webAuthDialog.authrequest.setSelectedAccount(webAuthDialog.selectAccount);
                break;
             default:
                 break;
        }
    }

    onRejected: {
        webAuthDialog.authrequest.cancel();
    }

    function init(request) {
        pinLabel.visible = false;
        pinEdit.visible = false;
        confirmPinLabel.visible = false;
        confirmPinEdit.visible = false;
        selectAccountModel.clear();
        webAuthDialog.authrequest = request;
        webauthConnection.target = request;
        setupUI(webAuthDialog.authrequest.state)
        webAuthDialog.visible = true;
        pinEntryError.visible = false;
    }

    function setupUI(state) {
        switch (state) {
        case WebEngineWebAuthUxRequest.WebAuthUxState.SelectAccount:
            setupSelectAccountUI();
            break;
        case WebEngineWebAuthUxRequest.WebAuthUxState.CollectPin:
            setupCollectPin();
            break;
        case WebEngineWebAuthUxRequest.WebAuthUxState.FinishTokenCollection:
            setupFinishCollectToken();
            break;
        case WebEngineWebAuthUxRequest.WebAuthUxState.RequestFailed:
            setupErrorUI();
            break;
        case WebEngineWebAuthUxRequest.WebAuthUxState.Completed:
            webAuthDialog.close();
            break;
        }
    }

    ButtonGroup {
        id : selectAccountButtonGroup;
        exclusive: true;
    }

    ListModel {
        id: selectAccountModel

    }
    contentItem: Item {
        ColumnLayout  {
            id : verticalLayout
            spacing : 10

            Label {
                id: heading
                text: "";
            }

            Label {
                id: description
                text: "";
            }

            Row {
                spacing : 10
                Label {
                    id: pinLabel
                    text: "PIN";
                }
                TextInput {
                    id: pinEdit
                    text: "EnterPin"
                    enabled: true
                    focus: true
                    color: "white"
                    layer.sourceRect: Qt.rect(0, 0, 20, 20)
                }
            }

            Row {
                spacing : 10
                Label {
                    id: confirmPinLabel
                    text: "Confirm PIN";
                }
                TextEdit {
                    id: confirmPinEdit
                    text: ""
                }
            }

            Label {
                id: pinEntryError
                text: "";
            }

            Repeater {
                id : selectAccountRepeater
                model: selectAccountModel
                Column {
                    id: selectAccountRepeaterColumn
                    required property string modelData
                    spacing : 5
                    RadioButton {
                        text: selectAccountRepeaterColumn.modelData
                        ButtonGroup.group : selectAccountButtonGroup;
                        onClicked: function(){
                            webAuthDialog.selectAccount = text;
                        }
                    }
                }
            }
        }
    }

    function setupSelectAccountUI() {
        webAuthDialog.selectAccount = "";
        heading.text = "Choose a passkey";
        description.text = "Which passkey do you want to use for " + webAuthDialog.authrequest.relyingPartyId;

        selectAccountModel.clear();
        var userNames = webAuthDialog.authrequest.userNames;
        for (let i = 0; i < userNames.length; i++) {
            selectAccountModel.append( {"name" : userNames[i]});
        }
        pinLabel.visible = false;
        pinEdit.visible = false;
        confirmPinLabel.visible = false;
        confirmPinEdit.visible = false;
        pinEntryError.visible = false;
        standardButton(Dialog.Apply).visible = true;
        standardButton(Dialog.Cancel).visible = true;
        standardButton(Dialog.Cancel).text ="Cancel"
    }

    function setupCollectPin() {
        var requestInfo = webAuthDialog.authrequest.pinRequest;

        pinEdit.clear();

        if (requestInfo.reason === WebEngineWebAuthUxRequest.PinEntryReason.Challenge) {
            heading.text = "PIN required";
            description.text = "Enter the PIN for your security key";
            pinLabel.visible = true;
            pinEdit.visible = true;
            confirmPinLabel.visible = false;
            confirmPinEdit.visible = false;
        } else if (requestInfo.reason === WebEngineWebAuthUxRequest.PinEntryReason.Set) {
            heading.text = "Set PIN ";
            description.text = "Set new PIN for your security key";
            pinLabel.visible = true;
            pinEdit.visible = true;
            confirmPinLabel.visible = true;
            confirmPinEdit.visible = true;
        }
        pinEntryError.text = getPINErrorDetails() + " " + requestInfo.remainingAttempts + " attempts reamining";
        pinEntryError.visible = true;
        selectAccountModel.clear();
        standardButton(Dialog.Cancel).visible = true;
        standardButton(Dialog.Cancel).text ="Cancel"
        standardButton(Dialog.Apply).visible = true;
    }

    function getPINErrorDetails() {
        var requestInfo = webAuthDialog.authrequest.pinRequest;
        switch (requestInfo.error) {
        case WebEngineWebAuthUxRequest.PinEntryError.NoError:
            return "";
        case WebEngineWebAuthUxRequest.PinEntryError.TooShort:
            return "Too short";
        case WebEngineWebAuthUxRequest.PinEntryError.InternalUvLocked:
            return "Internal Uv locked";
        case WebEngineWebAuthUxRequest.PinEntryError.WrongPin:
            return "Wrong PIN";
        case WebEngineWebAuthUxRequest.PinEntryError.InvalidCharacters:
            return "Invalid characters";
        case WebEngineWebAuthUxRequest.PinEntryError.SameAsCurrentPin:
            return "Same as current PIN";
        }
    }

    function getRequestFailureResaon() {
        var requestFailureReason = webAuthDialog.authrequest.requestFailureReason;
        switch (requestFailureReason) {
        case WebEngineWebAuthUxRequest.RequestFailureReason.Timeout:
            return " Request Timeout";
        case WebEngineWebAuthUxRequest.RequestFailureReason.KeyNotRegistered:
            return "Key not registered";
        case WebEngineWebAuthUxRequest.RequestFailureReason.KeyAlreadyRegistered:
            return "You already registered this device. You don't have to register it again\n"
                     + "Try again with different key or device.";
        case WebEngineWebAuthUxRequest.RequestFailureReason.SoftPinBlock:
            return "The security key is locked because the wrong PIN was entered too many times.\n"
                    + "To unlock it, remove and reinsert it.";
        case WebEngineWebAuthUxRequest.RequestFailureReason.HardPinBlock:
            return "The security key is locked because the wrong PIN was entered too many times.\n"
                    + "You'll need to reset the security key.";
        case WebEngineWebAuthUxRequest.RequestFailureReason.AuthenticatorRemovedDuringPinEntry:
            return "Authenticator removed during verification. Please reinsert and try again";
        case WebEngineWebAuthUxRequest.RequestFailureReason.AuthenticatorMissingResidentKeys:
            return "Authenticator doesn't have resident key support";
        case WebEngineWebAuthUxRequest.RequestFailureReason.AuthenticatorMissingUserVerification:
            return "Authenticator missing user verification";
        case WebEngineWebAuthUxRequest.RequestFailureReason.AuthenticatorMissingLargeBlob:
            return "Authenticator missing Large Blob support";
        case WebEngineWebAuthUxRequest.RequestFailureReason.NoCommonAlgorithms:
            return "No common Algorithms";
        case WebEngineWebAuthUxRequest.RequestFailureReason.StorageFull:
            return "Storage full";
        case WebEngineWebAuthUxRequest.RequestFailureReason.UserConsentDenied:
            return "User consent denied";
        case WebEngineWebAuthUxRequest.RequestFailureReason.WinUserCancelled:
            return "User cancelled request";
        }
    }

    function setupFinishCollectToken() {
        heading.text = "Use your security key with " + webAuthDialog.authrequest.relyingPartyId;
        description.text = "Touch your security key again to complete the request.";
        pinLabel.visible = false;
        pinEdit.visible = false;
        confirmPinLabel.visible = false;
        confirmPinEdit.visible = false;
        selectAccountModel.clear();
        pinEntryError.visible = false;
        standardButton(Dialog.Apply).visible = false;
        standardButton(Dialog.Cancel).visible = true;
        standardButton(Dialog.Cancel).text ="Cancel"
    }

    function setupErrorUI() {
        heading.text = "Something went wrong";
        description.text = getRequestFailureResaon();
        pinLabel.visible = false;
        pinEdit.visible = false;
        confirmPinLabel.visible = false;
        confirmPinEdit.visible = false;
        selectAccountModel.clear();
        pinEntryError.visible = false;
        standardButton(Dialog.Apply).visible = false;
        standardButton(Dialog.Cancel).visible = true;
        standardButton(Dialog.Cancel).text ="Close"
    }
}
pragma ComponentBehavior: Bound

import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Material
import QtQuick.Layouts
import QtWebEngine

ToolBar {
    id: root
    required property WebEngineView currentWebView

    // When using style "mac", ToolButtons are not supposed to accept focus.
    property bool platformIsMac: Qt.platform.os === "osx"

    property alias loadImagesChecked: loadImages.checked
    property alias javaScriptEnabledChecked: javaScriptEnabledMenuItem.checked
    property alias errorPageEnabledChecked: errorPageEnabledMenuItem.checked
    property alias pluginsEnabledChecked: pluginsEnabledMenuItem.checked
    property alias fullScreenSupportEnabledChecked: fullScreenSupportEnabledMenuItem.checked
    property alias autoLoadIconsForPageChecked: autoLoadIconsForPageMenuItem.checked
    property alias touchIconsEnabledChecked: touchIconsEnabledMenuItem.checked
    property alias webRTCPublicInterfacesOnlyChecked: webRTCPublicInterfacesOnlyMenuItem.checked
    property alias devToolsEnabledChecked: devToolsEnabledMenuItem.checked
    property alias pdfViewerEnabledChecked: pdfViewerEnabledMenuItem.checked
    property alias javascriptCanAccessClipboardChecked: javascriptCanAccessClipboardMenuItem.checked
    property alias javascriptCanPasteChecked: javascriptCanPasteMenuItem.checked
    property alias disableImageAnimationChecked: disableImageAnimation.checked
    property alias allowImageAnimationChecked: allowImageAnimation.checked
    property alias animateImageOnceChecked: animateImageOnce.checked
    property alias addressBar: addressBar

    signal settingToggled(string name, var value)

    RowLayout {
        anchors.fill: parent
        ToolButton {
            enabled: root.currentWebView?.canGoBack || root.currentWebView?.canGoForward
            onClicked: historyMenu.open()
            text: qsTr("▼")
            Menu {
                id: historyMenu
                Instantiator {
                    model: root.currentWebView?.history?.items
                    MenuItem {
                        required property var model
                        text: model.title
                        onTriggered: root.currentWebView.goBackOrForward(model.offset)
                        checkable: !enabled
                        checked: !enabled
                        enabled: model.offset
                    }

                    onObjectAdded: function (index, object) {
                        historyMenu.insertItem(index, object);
                    }
                    onObjectRemoved: function (index, object) {
                        historyMenu.removeItem(object);
                    }
                }
            }
        }

        ToolButton {
            id: backButton
            icon.source: "qrc:///icons/3rdparty/go-previous.png"
            onClicked: root.currentWebView.goBack()
            enabled: root.currentWebView?.canGoBack ?? false
            activeFocusOnTab: !root.platformIsMac
        }
        ToolButton {
            id: forwardButton
            icon.source: "qrc:///icons/3rdparty/go-next.png"
            onClicked: root.currentWebView.goForward()
            enabled: root.currentWebView?.canGoForward ?? false
            activeFocusOnTab: !root.platformIsMac
        }
        ToolButton {
            id: reloadButton
            icon.source: root.currentWebView?.loading ? "qrc:///icons/3rdparty/process-stop.png" : "qrc:///icons/3rdparty/view-refresh.png"
            onClicked: root.currentWebView?.loading ? root.currentWebView.stop() : root.currentWebView.reload()
            activeFocusOnTab: !root.platformIsMac
        }
        TextField {
            id: addressBar
            Image {
                id: faviconImage
                anchors.verticalCenter: addressBar.verticalCenter
                x: 5
                z: 2
                width: 16
                height: 16
                sourceSize: Qt.size(width, height)
                source: root.currentWebView?.icon ? root.currentWebView.icon : ''
            }
            MouseArea {
                id: textFieldMouseArea
                acceptedButtons: Qt.RightButton
                anchors.fill: parent
                onClicked: {
                    var textSelectionStartPos = addressBar.selectionStart;
                    var textSelectionEndPos = addressBar.selectionEnd;
                    textFieldContextMenu.open();
                    addressBar.select(textSelectionStartPos, textSelectionEndPos);
                }
                Menu {
                    id: textFieldContextMenu
                    x: textFieldMouseArea.mouseX
                    y: textFieldMouseArea.mouseY
                    MenuItem {
                        text: qsTr("Cut")
                        onTriggered: addressBar.cut()
                        enabled: addressBar.selectedText.length > 0
                    }
                    MenuItem {
                        text: qsTr("Copy")
                        onTriggered: addressBar.copy()
                        enabled: addressBar.selectedText.length > 0
                    }
                    MenuItem {
                        text: qsTr("Paste")
                        onTriggered: addressBar.paste()
                        enabled: addressBar.canPaste
                    }
                    MenuItem {
                        text: qsTr("Delete")
                        onTriggered: addressBar.text = qsTr("")
                        enabled: addressBar.selectedText.length > 0
                    }
                    MenuSeparator {}
                    MenuItem {
                        text: qsTr("Select All")
                        onTriggered: addressBar.selectAll()
                        enabled: addressBar.text.length > 0
                    }
                }
            }
            leftPadding: 26
            focus: true
            Layout.fillWidth: true
            Binding on text {
                when: root.currentWebView
                value: root.currentWebView.url
            }
            onAccepted: root.currentWebView.url = Utils.fromUserInput(text)
            selectByMouse: true
        }
        ToolButton {
            id: settingsMenuButton
            text: qsTr("⋮")
            onClicked: settingsMenu.open()
            Menu {
                id: settingsMenu
                y: settingsMenuButton.height
                MenuItem {
                    id: loadImages
                    text: "Autoload images"
                    checkable: true
                    checked: WebEngine.settings.autoLoadImages
                    onToggled: root.settingToggled("autoLoadImages", checked)
                }
                MenuItem {
                    id: javaScriptEnabledMenuItem
                    text: "JavaScript On"
                    checkable: true
                    checked: WebEngine.settings.javascriptEnabled
                    onToggled: root.settingToggled("javaScriptEnabled", checked)
                }
                MenuItem {
                    id: errorPageEnabledMenuItem
                    text: "ErrorPage On"
                    checkable: true
                    checked: WebEngine.settings.errorPageEnabled
                    onToggled: root.settingToggled("errorPageEnabled", checked)
                }
                MenuItem {
                    id: pluginsEnabledMenuItem
                    text: "Plugins On"
                    checkable: true
                    checked: true
                    onToggled: root.settingToggled("pluginsEnabled", checked)
                }
                MenuItem {
                    id: fullScreenSupportEnabledMenuItem
                    text: "FullScreen On"
                    checkable: true
                    checked: WebEngine.settings.fullScreenSupportEnabled
                    onToggled: root.settingToggled("fullScreenSupportEnabled", checked)
                }
                MenuItem {
                    id: offTheRecordEnabled
                    text: "Off The Record"
                    checkable: true
                    checked: root.currentWebView?.profile === BrowserManager.otrPrototype.instance()
                    onToggled: function () {
                        if (root.currentWebView) {
                            root.currentWebView.profile = offTheRecordEnabled.checked ? BrowserManager.otrPrototype.instance() : BrowserManager.defaultProfilePrototype.instance();
                        }
                    }
                }
                MenuItem {
                    id: httpDiskCacheEnabled
                    text: "HTTP Disk Cache"
                    checkable: !root.currentWebView?.profile?.offTheRecord ?? false
                    checked: root.currentWebView?.profile.httpCacheType === WebEngineProfile.DiskHttpCache
                    onToggled: function () {
                        if (root.currentWebView) {
                            root.currentWebView.profile.httpCacheType = httpDiskCacheEnabled.checked ? WebEngineProfile.DiskHttpCache : WebEngineProfile.MemoryHttpCache;
                        }
                    }
                }
                MenuItem {
                    id: autoLoadIconsForPageMenuItem
                    text: "Icons On"
                    checkable: true
                    checked: WebEngine.settings.autoLoadIconsForPage
                    onToggled: root.settingToggled("autoLoadIconsForPage", checked)
                }
                MenuItem {
                    id: touchIconsEnabledMenuItem
                    text: "Touch Icons On"
                    checkable: true
                    checked: WebEngine.settings.touchIconsEnabled
                    onToggled: root.settingToggled("touchIconsEnabled", checked)
                    enabled: autoLoadIconsForPageMenuItem.checked
                }
                MenuItem {
                    id: webRTCPublicInterfacesOnlyMenuItem
                    text: "WebRTC Public Interfaces Only"
                    checkable: true
                    checked: WebEngine.settings.webRTCPublicInterfacesOnly
                    onToggled: root.settingToggled("webRTCPublicInterfacesOnly", checked)
                }
                MenuItem {
                    id: devToolsEnabledMenuItem
                    text: "Open DevTools"
                    checkable: true
                    checked: false
                    onToggled: root.settingToggled("devToolsEnabled", checked)
                }
                MenuItem {
                    id: pdfViewerEnabledMenuItem
                    text: "PDF Viewer Enabled"
                    checkable: true
                    checked: WebEngine.settings.pdfViewerEnabled
                    onToggled: root.settingToggled("pdfViewerEnabled", checked)
                }
                Menu {
                    id: imageAnimationPolicyMenu
                    title: "Image Animation Policy"

                    MenuItem {
                        id: disableImageAnimation
                        text: "Disable All Image Animation"
                        checkable: true
                        autoExclusive: true
                        checked: WebEngine.settings.imageAnimationPolicy === WebEngineSettings.ImageAnimationPolicy.Disallow
                        onToggled: if (checked) root.settingToggled("imageAnimationPolicy", WebEngineSettings.ImageAnimationPolicy.Disallow)
                    }

                    MenuItem {
                        id: allowImageAnimation
                        text: "Allow All Animated Images"
                        checkable: true
                        autoExclusive: true
                        checked: WebEngine.settings.imageAnimationPolicy === WebEngineSettings.ImageAnimationPolicy.Allow
                        onToggled: if (checked) root.settingToggled("imageAnimationPolicy", WebEngineSettings.ImageAnimationPolicy.Allow)
                    }

                    MenuItem {
                        id: animateImageOnce
                        text: "Animate Image Once"
                        checkable: true
                        autoExclusive: true
                        checked: WebEngine.settings.imageAnimationPolicy === WebEngineSettings.ImageAnimationPolicy.AnimateOnce
                        onToggled: if (checked) root.settingToggled("imageAnimationPolicy", WebEngineSettings.ImageAnimationPolicy.AnimateOnce)
                    }
                }

                MenuItem {
                    id: javascriptCanAccessClipboardMenuItem
                    text: "JavaScript can access clipboard"
                    checkable: true
                    checked: WebEngine.settings.javascriptCanAccessClipboard
                    onToggled: root.settingToggled("javascriptCanAccessClipboard", checked)
                }
                MenuItem {
                    id: javascriptCanPasteMenuItem
                    text: "JavaScript can paste"
                    checkable: true
                    checked: WebEngine.settings.javascriptCanPaste
                    onToggled: root.settingToggled("javascriptCanPaste", checked)
                }
            }
        }
    }
    ProgressBar {
        id: progressBar
        height: 3
        anchors {
            left: parent.left
            top: parent.bottom
            right: parent.right
            leftMargin: parent.anchors.leftMargin
            rightMargin: parent.anchors.rightMargin
        }
        background: Item {}
        z: -2
        from: 0
        to: 100
        value: (root.currentWebView?.loadProgress < 100) ? root.currentWebView.loadProgress : 0
    }
}
module BrowserUtils
ActionManager 254.0 ActionManager.qml
ApplicationRoot 254.0 ApplicationRoot.qml
BrowserDialog 254.0 BrowserDialog.qml
singleton BrowserManager 254.0 BrowserManager.qml
BrowserStackLayout 254.0 BrowserStackLayout.qml
BrowserTab 254.0 BrowserTab.qml
BrowserTabBar 254.0 BrowserTabBar.qml
BrowserWindow 254.0 BrowserWindow.qml
DownloadView 254.0 DownloadView.qml
FindBar 254.0 FindBar.qml
FullScreenNotification 254.0 FullScreenNotification.qml
PermissionDialog 254.0 PermissionDialog.qml
SslDialog 254.0 SslDialog.qml
WebAuthDialog 254.0 WebAuthDialog.qml
WebToolBar 254.0 WebToolBar.qml
depends QtQuick
typeinfo main.qmltypes
<RCC>
    <qresource>
        <file>icons/3rdparty/go-next.png</file>
        <file>icons/3rdparty/go-previous.png</file>
        <file>icons/3rdparty/process-stop.png</file>
        <file>icons/3rdparty/view-refresh.png</file>
    </qresource>
     <qresource prefix="/">
        <file>qtquickcontrols2.conf</file>
    </qresource>
</RCC>