Warning, /plasma/plasma-welcome/src/qml/pages/Network.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *  SPDX-FileCopyrightText: 2022 Nate Graham <nate@kde.org>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 import QtQuick
0008 import QtQuick.Layouts
0009 import Qt5Compat.GraphicalEffects
0010 import org.kde.kirigami as Kirigami
0011 import org.kde.kirigamiaddons.components as KirigamiAddons
0012 
0013 import org.kde.plasma.welcome
0014 import org.kde.plasma.components as PC3
0015 import org.kde.ksvg as KSvg
0016 //NOTE: necessary for KSvg to load the Plasma theme
0017 import org.kde.plasma.core as PlasmaCore
0018 import org.kde.plasma.plasma5support as P5Support
0019 
0020 GenericPage {
0021     id: root
0022 
0023     heading: i18nc("@info:window", "Access the Internet")
0024     description: xi18nc("@info:usagetip", "You can connect to the internet and manage your network connections with the <interface>Networks applet</interface>. To access it, click on the <interface>Networks</interface> icon in your <interface>System Tray</interface>, which lives in the bottom-right corner of the screen.")
0025 
0026     // To get the current date and time
0027     P5Support.DataSource {
0028         id: timeSource
0029         engine: "time"
0030         connectedSources: ["Local"]
0031         interval: 1000
0032     }
0033 
0034     Loader {
0035         id: nmLoader
0036         source: "PlasmaNM.qml"
0037 
0038         // Defaults for when PlasmaNM is not available
0039         property bool statusConnected: false
0040         property bool iconConnecting: false
0041         property string icon: "network-wireless-available"
0042 
0043         onStatusChanged: {
0044             if (status === Loader.Ready) {
0045                 statusConnected = Qt.binding(() => nmLoader.item.networkStatus.connectivity === 4) // 4, Full connectivity
0046                 iconConnecting = Qt.binding(() => nmLoader.item.connectionIcon.connecting)
0047                 icon = Qt.binding(() => nmLoader.item.connectionIcon.connectionIcon)
0048             } else if (status === Loader.Error) {
0049                 console.warn("PlasmaNM integration failed to load (is plasma-nm available?)");
0050             }
0051         }
0052 
0053         // Continue to the next page automatically when connected
0054         onStatusConnectedChanged: {
0055             if (statusConnected && pageStack.currentItem == root) {
0056                 pageStack.currentIndex += 1
0057             }
0058         }
0059     }
0060 
0061     Kirigami.AbstractCard {
0062         anchors.centerIn: parent
0063 
0064         width: Kirigami.Units.gridUnit * 20
0065         height: Kirigami.Units.gridUnit * 10
0066 
0067         // Container for everything else so we don't have the apply margins
0068         // multiple times
0069         Item {
0070             anchors.fill: parent
0071             anchors.margins: Kirigami.Units.smallSpacing
0072 
0073             // Wallpaper background image
0074             Image {
0075                 anchors.fill: parent
0076                 fillMode: Image.PreserveAspectCrop
0077                 source: "file:" + Controller.installPrefix() + "/share/wallpapers/Next/contents/images/1024x768.png"
0078                 // anchor the image to the bottom-right corner of the "screen"
0079                 sourceClipRect: Qt.rect(1024-parent.width,
0080                                         768-parent.height,
0081                                         parent.width,
0082                                         parent.height)
0083             }
0084 
0085             // Wallpaper background image blur source behind panel
0086             Image {
0087                 anchors.fill: panelContainer
0088                 fillMode: Image.PreserveAspectCrop
0089                 source: "file:" + Controller.installPrefix() + "/share/wallpapers/Next/contents/images/1024x768.png"
0090                 sourceClipRect: Qt.rect(1024-panelContainer.width,
0091                                         768-panelContainer.height,
0092                                         panelContainer.width,
0093                                         panelContainer.height)
0094 
0095                 layer.enabled: true
0096                 layer.effect: GaussianBlur {
0097                     radius: 32
0098                     samples: 16
0099                     cached: true
0100                 }
0101             }
0102 
0103             // Panel item container, so opacity won't propagate down
0104             Item {
0105                 id: panelContainer
0106 
0107                 readonly property int margins: Kirigami.Units.smallSpacing
0108                 width: parent.width
0109                 height: 36 // default panel height
0110                 anchors.right: parent.right
0111                 anchors.bottom: parent.bottom
0112 
0113                 // Panel background
0114                 KSvg.FrameSvgItem {
0115                     anchors.fill: parent
0116                     imagePath: "solid/widgets/panel-background"
0117                     enabledBorders: "TopBorder"
0118                     opacity: 0.75
0119                 }
0120 
0121                 // Fake System Tray items go in here
0122                 RowLayout {
0123                     id: appletContainer
0124 
0125                     readonly property int iconSize: Kirigami.Units.iconSizes.roundedIconSize(height - (panelContainer.margins * 2))
0126 
0127                     anchors {
0128                         right: parent.right
0129                         rightMargin: Kirigami.Units.smallSpacing
0130                         top: parent.top
0131                         bottom: parent.bottom
0132                     }
0133                     spacing: Kirigami.Units.smallSpacing * 2
0134 
0135                     Item {
0136                         Layout.fillWidth: true
0137                     }
0138 
0139                     KSvg.SvgItem {
0140                         implicitWidth: appletContainer.iconSize
0141                         implicitHeight: appletContainer.iconSize
0142                         imagePath: "icons/klipper"
0143                         elementId: "klipper"
0144                     }
0145                     KSvg.SvgItem {
0146                         implicitWidth: appletContainer.iconSize
0147                         implicitHeight: appletContainer.iconSize
0148                         imagePath: "icons/audio"
0149                         elementId: "audio-volume-high"
0150                     }
0151                     KSvg.SvgItem {
0152                         implicitWidth: appletContainer.iconSize
0153                         implicitHeight: appletContainer.iconSize
0154                         imagePath: "icons/network"
0155                         elementId: nmLoader.icon
0156                         PC3.BusyIndicator {
0157                             id: connectingIndicator
0158 
0159                             anchors.centerIn: parent
0160                             height: Math.min(parent.width, parent.height)
0161                             width: height
0162                             running: nmLoader.iconConnecting
0163                             visible: running
0164                         }
0165                     }
0166                     KSvg.SvgItem {
0167                         implicitWidth: appletContainer.iconSize
0168                         implicitHeight: appletContainer.iconSize
0169                         imagePath: "widgets/arrows"
0170                         elementId: "up-arrow"
0171                     }
0172                     ColumnLayout {
0173                         spacing: 0
0174                         PC3.Label {
0175                             color: PlasmaCore.Theme.textColor
0176                             text: Qt.formatTime(timeSource.data["Local"]["DateTime"])
0177                             fontSizeMode: Text.Fit
0178                             Layout.fillHeight: true
0179                             Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
0180                             Layout.topMargin: Kirigami.Units.smallSpacing
0181                         }
0182                         PC3.Label {
0183                             color: PlasmaCore.Theme.textColor
0184                             text: Qt.formatDate(timeSource.data["Local"]["DateTime"], Qt.DefaultLocaleShortDate)
0185                             fontSizeMode: Text.Fit
0186                             Layout.fillHeight: true
0187                             Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
0188                             Layout.bottomMargin: Kirigami.Units.smallSpacing
0189                         }
0190                     }
0191                     KSvg.SvgItem {
0192                         implicitWidth: appletContainer.iconSize
0193                         implicitHeight: appletContainer.iconSize
0194                         imagePath: "icons/user"
0195                         elementId: "user-desktop"
0196                     }
0197                 }
0198             }
0199 
0200             // Arrow container
0201             Kirigami.Icon {
0202                 id: indicatorArrow
0203                 readonly property int originalY: parent.height - panelContainer.height - height
0204                 readonly property int translatedY: originalY - Kirigami.Units.gridUnit
0205                 width : Kirigami.Units.iconSizes.large
0206                 height: Kirigami.Units.iconSizes.large
0207                 y: parent.height - panelContainer.height - height
0208                 anchors {
0209                     right: panelContainer.right
0210                     rightMargin: appletContainer.width + appletContainer.anchors.rightMargin   // Align with the left of the appletContainer
0211                                   - ((appletContainer.iconSize + appletContainer.spacing) * 3) // Align with the right of the third icon
0212                                   + (appletContainer.iconSize / 2)                             // Align with the center of the icon
0213                                   - (width / 2)                                                // Center the arrow on the icon
0214                 }
0215                 source: "arrow-down"
0216 
0217                 layer.enabled: true
0218                 layer.effect: Glow {
0219                     radius: 6
0220                     samples: 17
0221                     spread: 0.5
0222                     color: "white"
0223                 }
0224 
0225                 SequentialAnimation on y {
0226                     running: pageStack.currentItem == root && !nmLoader.statusConnected
0227                     loops:  Animation.Infinite
0228                     alwaysRunToEnd: true
0229                     NumberAnimation {
0230                         from: indicatorArrow.originalY
0231                         to: indicatorArrow.translatedY
0232                         duration: 1000
0233                         easing.type: Easing.InOutQuad
0234                     }
0235                     NumberAnimation {
0236                         from: indicatorArrow.translatedY
0237                         to: indicatorArrow.originalY
0238                         duration: 1000
0239                         easing.type: Easing.InOutQuad
0240                     }
0241                 }
0242             }
0243         }
0244     }
0245 
0246     footer: KirigamiAddons.Banner {
0247         visible: Controller.patchVersion === 80
0248         text: i18nc("@info", "This page is being shown regardless of network connectivity because you are using a development version.")
0249     }
0250 }