Warning, /plasma/aura-browser/app/qml/TopBar.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 QtQuick.Window 2.12
0010 import QtWebEngine 1.7
0011 import QtQuick.Layouts 1.12
0012 import QtQuick.LocalStorage 2.12
0013 import Aura 1.0 as Aura
0014 import "code/RecentStorage.js" as RecentStorage
0015 import "code/Utils.js" as Utils
0016 import Qt5Compat.GraphicalEffects
0017 import org.kde.kirigami as Kirigami
0018 
0019 Rectangle {
0020     property bool viewFullscreenMode: false
0021     width: parent.width
0022     height: viewFullscreenMode ? 0 : Kirigami.Units.iconSizes.large + Kirigami.Units.largeSpacing
0023     color: Qt.lighter(Kirigami.Theme.backgroundColor, 1.2)
0024     layer.enabled: true
0025     z: 1000
0026     layer.effect: DropShadow {
0027         horizontalOffset: 0
0028         verticalOffset: 1
0029         radius: 8.0
0030         samples: 17
0031         color: Qt.rgba(0,0,0,0.6)
0032     }
0033 
0034     Item {
0035         id: tbarLayout
0036         width: parent.width
0037         visible: viewFullscreenMode ? 0 : 1
0038         enabled: viewFullscreenMode ? 0 : 1
0039         height: Kirigami.Units.iconSizes.large
0040         anchors.centerIn: parent
0041 
0042         Item {
0043             id: backButtonTopBar
0044             width: Kirigami.Units.iconSizes.large
0045             height: Kirigami.Units.iconSizes.large
0046             anchors.left: parent.left
0047 
0048             Kirigami.Icon {
0049                 width: Kirigami.Units.iconSizes.medium
0050                 height: Kirigami.Units.iconSizes.medium
0051                 anchors.centerIn: parent
0052                 source: "arrow-left"
0053             }
0054 
0055             MouseArea {
0056                 anchors.fill: parent
0057                 onClicked: (mouse)=> {
0058                     Aura.NavigationSoundEffects.playClickedSound()
0059                     webView.goBack()
0060                 }
0061             }
0062         }
0063 
0064         Item {
0065             id: forwardButtonTopBar
0066             width: Kirigami.Units.iconSizes.large
0067             height: Kirigami.Units.iconSizes.large
0068             anchors.left: backButtonTopBar.right
0069 
0070             Kirigami.Icon {
0071                 width: Kirigami.Units.iconSizes.medium
0072                 height: Kirigami.Units.iconSizes.medium
0073                 anchors.centerIn: parent
0074                 source: "arrow-right"
0075             }
0076 
0077             MouseArea {
0078                 anchors.fill: parent
0079                 onClicked: (mouse)=> {
0080                     Aura.NavigationSoundEffects.playClickedSound()
0081                     webView.goForward()
0082                 }
0083             }
0084         }
0085 
0086         Rectangle {
0087             id: homeButtonTopBar
0088             width: Kirigami.Units.iconSizes.large
0089             height: Kirigami.Units.iconSizes.large
0090             anchors.left: forwardButtonTopBar.right
0091             color: Qt.lighter(Kirigami.Theme.backgroundColor, 1.2)
0092 
0093             Kirigami.Icon {
0094                 width: Kirigami.Units.iconSizes.medium
0095                 height: Kirigami.Units.iconSizes.medium
0096                 anchors.centerIn: parent
0097                 source: "go-home"
0098             }
0099 
0100             MouseArea {
0101                 anchors.fill: parent
0102 
0103                 onClicked: (mouse)=> {
0104                     Aura.NavigationSoundEffects.playClickedSound()
0105                     auraStack.currentIndex = 0
0106                     auraStack.itemAt(0).focus = true
0107                     auraStack.itemAt(0).forceActiveFocus();
0108                 }
0109             }
0110         }
0111 
0112         Rectangle {
0113             id: urlBox
0114             anchors.left: homeButtonTopBar.right
0115             anchors.right: bookmarkButtonTopBar.left
0116             anchors.leftMargin: Kirigami.Units.largeSpacing
0117             anchors.rightMargin: Kirigami.Units.largeSpacing
0118             anchors.verticalCenter: parent.verticalCenter
0119             height: Kirigami.Units.iconSizes.medium
0120             radius: 20
0121             color: Qt.lighter(Kirigami.Theme.backgroundColor, 1.5)
0122             border.color: Kirigami.Theme.disabledTextColor
0123             border.width: 0.5
0124 
0125             Image {
0126                 id: websiteImgIcon
0127                 width: Kirigami.Units.iconSizes.small
0128                 height: Kirigami.Units.iconSizes.small
0129                 anchors.left: parent.left
0130                 anchors.verticalCenter: parent.verticalCenter
0131                 anchors.leftMargin: Kirigami.Units.largeSpacing
0132                 source: webView.icon
0133             }
0134 
0135             Kirigami.Separator {
0136                 id: urlboxsept
0137                 width: 1
0138                 anchors.top: parent.top
0139                 anchors.bottom: parent.bottom
0140                 anchors.left: websiteImgIcon.right
0141                 anchors.margins: Kirigami.Units.smallSpacing
0142             }
0143 
0144             Item {
0145                 anchors.left: urlboxsept.right
0146                 anchors.leftMargin: Kirigami.Units.largeSpacing
0147                 height: parent.height
0148                 width: urlBox.width - (websiteImgIcon.width + refreshbtn.width + Kirigami.Units.largeSpacing * 4)
0149 
0150                 RowLayout {
0151                     anchors.fill: parent
0152                     anchors.verticalCenter: parent.verticalCenter
0153 
0154                     Label {
0155                         maximumLineCount: 1
0156                         Layout.maximumWidth: parent.width
0157                         Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
0158                         wrapMode: Text.WrapAnywhere
0159                         color: Kirigami.Theme.textColor
0160                         text: webView.url
0161                     }
0162                 }
0163             }
0164 
0165             MouseArea {
0166                 anchors.fill: parent
0167                 onClicked: (mouse)=> {
0168                     Aura.NavigationSoundEffects.playClickedSound()
0169                     localUrlEntryDrawer.open()
0170                 }
0171             }
0172 
0173             Item {
0174                 id: refreshbtn
0175                 anchors.right: parent.right
0176                 width: Kirigami.Units.iconSizes.medium
0177                 height: parent.height
0178                 anchors.verticalCenter: parent.verticalCenter
0179 
0180                 Kirigami.Icon {
0181                     source: "refactor"
0182                     width: Kirigami.Units.iconSizes.small
0183                     height: Kirigami.Units.iconSizes.small
0184                     anchors.centerIn: parent
0185                 }
0186 
0187                 MouseArea {
0188                     anchors.fill: parent
0189                     onClicked: (mouse)=> {
0190                         Aura.NavigationSoundEffects.playClickedSound()
0191                         webView.reload()
0192                     }
0193                 }
0194             }
0195         }
0196 
0197 
0198         Item {
0199             id: bookmarkButtonTopBar
0200             width: Kirigami.Units.iconSizes.large
0201             height: Kirigami.Units.iconSizes.large
0202             anchors.right: adblockButtonTopBar.left
0203 
0204             Kirigami.Icon {
0205                 width: Kirigami.Units.iconSizes.medium
0206                 height: Kirigami.Units.iconSizes.medium
0207                 anchors.centerIn: parent
0208                 source: "bookmark-new"
0209             }
0210 
0211             MouseArea {
0212                 anchors.fill: parent
0213                 onClicked: (mouse)=> {
0214                     Aura.NavigationSoundEffects.playClickedSound()
0215                     bookmarkTabManager.bookmarkStack = 1
0216                     bookmarkTabManager.preBookmarkName = webView.title
0217                     bookmarkTabManager.preBookmarkUrl = webView.url
0218                     bookmarkTabManager.open()
0219                 }
0220             }
0221         }
0222 
0223         Item {
0224             id: adblockButtonTopBar
0225             width: Kirigami.Units.iconSizes.large
0226             height: Kirigami.Units.iconSizes.large
0227             anchors.right: tabButtonTopBar.left
0228 
0229             Kirigami.Icon {
0230                 width: Kirigami.Units.iconSizes.medium
0231                 height: Kirigami.Units.iconSizes.medium
0232                 anchors.centerIn: parent
0233                 source: "draw-polygon"
0234                 color: Aura.GlobalSettings.adblockEnabled ? "green" : "red"
0235 
0236                 Label {
0237                     color: Kirigami.Theme.textColor
0238                     width: parent.width
0239                     height: parent.height
0240                     horizontalAlignment: Text.AlignHCenter
0241                     verticalAlignment: Text.AlignVCenter
0242                     fontSizeMode: Text.Fit
0243                     minimumPixelSize: 2
0244                     font.bold: true
0245                     font.pixelSize: parent.height * 0.5
0246                     font.strikeout: !Aura.GlobalSettings.adblockEnabled
0247                     text: i18n("A")
0248                 }
0249             }
0250 
0251             MouseArea {
0252                 anchors.fill: parent
0253                 onClicked: (mouse)=> {
0254                     Aura.NavigationSoundEffects.playClickedSound()
0255                     if(Aura.GlobalSettings.adblockEnabled){
0256                         Aura.GlobalSettings.setAdblockEnabled(false);
0257                     } else {
0258                         Aura.GlobalSettings.setAdblockEnabled(true);
0259                     }
0260                 }
0261             }
0262         }
0263 
0264         Item {
0265             id: tabButtonTopBar
0266             width: Kirigami.Units.iconSizes.large
0267             height: Kirigami.Units.iconSizes.large
0268             anchors.right: parent.right
0269 
0270             Kirigami.Icon {
0271                 width: Kirigami.Units.iconSizes.medium
0272                 height: Kirigami.Units.iconSizes.medium
0273                 anchors.centerIn: parent
0274                 source: "layer-duplicate"
0275             }
0276 
0277             MouseArea {
0278                 anchors.fill: parent
0279                 onClicked: (mouse)=> {
0280                     Aura.NavigationSoundEffects.playClickedSound()
0281                     tabBarView.open()
0282                 }
0283             }
0284         }
0285     }
0286 }