Warning, /network/angelfish/lib/contents/ui/ListWebView.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2014-2015 Sebastian Kügler <sebas@kde.org>
0002 //
0003 // SPDX-License-Identifier: GPL-2.0-or-later
0004 
0005 import QtQuick 2.15
0006 import QtQuick.Controls 2.15 as QQC2
0007 import QtQml.Models 2.15
0008 import QtWebEngine 1.10
0009 
0010 import org.kde.kirigami 2.19 as Kirigami
0011 
0012 import org.kde.angelfish 1.0
0013 
0014 Repeater {
0015     id: tabs
0016 
0017     property bool activeTabs: false
0018     property bool privateTabsMode: false
0019 
0020     property alias currentIndex: tabsModel.currentTab
0021     property WebView currentItem
0022 
0023     property alias tabsModel: tabsModel
0024 
0025     property WebEngineProfile profile: AngelfishWebProfile {
0026         httpUserAgent: tabs.currentItem.userAgent.userAgent
0027         offTheRecord: tabs.privateTabsMode
0028         storageName: tabs.privateTabsMode ? "Private" : Settings.profile
0029 
0030         questionLoader: rootPage.questionLoader
0031         urlInterceptor: typeof AdblockUrlInterceptor !== "undefined" && AdblockUrlInterceptor
0032     }
0033 
0034     model: TabsModel {
0035         id: tabsModel
0036         isMobileDefault: Kirigami.Settings.isMobile
0037         privateMode: privateTabsMode
0038     }
0039 
0040     delegate: QQC2.SplitView {
0041         id: tabDelegate
0042 
0043         required property bool isMobile
0044         required property url pageurl
0045         required property bool isDeveloperToolsOpen
0046 
0047         required property int index
0048 
0049         anchors.fill: parent
0050         orientation: width < height ? Qt.Vertical : Qt.Horizontal
0051 
0052         property bool readyForSnapshot: false
0053         property bool showView: index === tabs.currentIndex
0054         property bool isVisible: (showView || readyForSnapshot || pageWebView.loadingActive) && tabs.activeTabs
0055         property alias title: pageWebView.title
0056         property alias icon: pageWebView.icon
0057         property alias readerMode: pageWebView.readerMode
0058         property alias readerTitle: pageWebView.readerTitle
0059 
0060         onShowViewChanged: {
0061             if (showView) {
0062                 tabs.currentItem = pageWebView
0063             }
0064         }
0065         x: showView && tabs.activeTabs ? 0 : -width
0066         z: showView && tabs.activeTabs ? 0 : -1
0067         visible: isVisible
0068 
0069         Item {
0070             QQC2.SplitView.minimumWidth: 25
0071             QQC2.SplitView.minimumHeight: 25
0072             QQC2.SplitView.fillWidth: true
0073             QQC2.SplitView.fillHeight: true
0074 
0075             WebView {
0076                 id: pageWebView
0077                 anchors.fill: parent
0078                 visible: isVisible
0079                 
0080                 privateMode: tabs.privateTabsMode
0081                 userAgent.isMobile: tabDelegate.isMobile
0082                 width: tabs.width
0083 
0084                 profile: tabs.profile
0085 
0086                 Component.onCompleted: {
0087                     url = tabDelegate.pageurl
0088                 }
0089 
0090                 onRequestedUrlChanged: tabsModel.setUrl(index, requestedUrl)
0091 
0092                 Connections {
0093                     target: pageWebView.userAgent
0094                     function onUserAgentChanged() {
0095                         tabsModel.setIsMobile(index, pageWebView.userAgent.isMobile);
0096                     }
0097                 }
0098             }
0099         }
0100 
0101         Item {
0102             QQC2.SplitView.minimumWidth: 75
0103             QQC2.SplitView.minimumHeight: 27 // height of the developer tools menu
0104             QQC2.SplitView.preferredWidth: 500
0105             QQC2.SplitView.preferredHeight: 200
0106             visible: tabDelegate.isDeveloperToolsOpen
0107 
0108             // Prevent other tab content from showing through while loading
0109             Rectangle { anchors.fill: parent; color: Kirigami.Theme.backgroundColor }
0110 
0111             Loader {
0112                 id: developerToolsLoader
0113                 anchors.fill: parent
0114                 active: showView || viewed
0115 
0116                 property bool viewed: false
0117 
0118                 onLoaded: {
0119                     viewed = true
0120                     item.inspectedView = pageWebView;
0121                 }
0122 
0123                 Connections {
0124                     target: developerToolsLoader.item
0125 
0126                     function onWindowCloseRequested() {
0127                         tabsModel.toggleDeveloperTools(tabDelegate.index)
0128                     }
0129                 }
0130 
0131                 Connections {
0132                     target: tabsModel
0133                     function onDataChanged(left, right, roles) {
0134                         if (tabsModel.isDeveloperToolsOpen(tabDelegate.index)) {
0135                             developerToolsLoader.setSource("WebDeveloperTools.qml");
0136                         } else {
0137                             developerToolsLoader.setSource("")
0138                         }
0139                     }
0140                 }
0141             }
0142         }
0143     }
0144 }