Warning, /plasma/plasma-nano/components/qml/StartupFeedback.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   SPDX-FileCopyrightText: 2015 Marco Martin <notmart@gmail.com>
0003  *
0004  *   SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 import QtQuick 2.12
0008 import QtQuick.Layouts 1.1
0009 import QtQuick.Window 2.2
0010 import org.kde.plasma.core 2.0 as PlasmaCore
0011 import QtGraphicalEffects 1.12
0012 
0013 import org.kde.kirigami 2.13 as Kirigami
0014 
0015 import org.kde.plasma.private.nanoshell 2.0 as NanoShell
0016 
0017 pragma Singleton
0018 
0019 Window {
0020     id: window
0021 
0022     flags: Qt.FramelessWindowHint
0023     property alias backgroundColor: background.color
0024     Kirigami.ImageColors {
0025         id: colorGenerator
0026         source: icon.source
0027     }
0028 
0029     function open(splashIcon, title, x, y, sourceIconSize, color) {
0030         iconParent.scale = sourceIconSize/iconParent.width;
0031         background.scale = 0;
0032         backgroundParent.x = -window.width/2 + x
0033         backgroundParent.y = -window.height/2 + y
0034         window.title = title;
0035         icon.source = splashIcon;
0036 
0037         if (color !== undefined) {
0038             // Break binding to use custom color
0039             background.color = color
0040         } else {
0041             // Recreate binding
0042             background.color = Qt.binding(function() { return colorGenerator.dominant})
0043         }
0044 
0045         background.state = "open";
0046     }
0047 
0048     Connections {
0049         target: NanoShell.StartupNotifier
0050         enabled: NanoShell.StartupNotifier.isValid
0051 
0052         function onActivationStarted(appId, iconName) {
0053             icon.source = iconName
0054             background.state = "open";
0055         }
0056     }
0057 
0058     property alias state: background.state
0059     property alias icon: icon.source
0060 
0061     width: Screen.width
0062     height: Screen.height
0063     color: "transparent"
0064     onVisibleChanged: {
0065         if (!visible) {
0066             background.state = "closed";
0067         }
0068     }
0069     onActiveChanged: {
0070         if (!active) {
0071             background.state = "closed";
0072         }
0073     }
0074 
0075 
0076     Item {
0077         id: backgroundParent
0078         width: window.width
0079         height: window.height
0080 
0081         Item {
0082             id: iconParent
0083             z: 2
0084             anchors.centerIn: background
0085             width: PlasmaCore.Units.iconSizes.enormous
0086             height: width
0087             PlasmaCore.IconItem {
0088                 id: icon
0089                 anchors.fill:parent
0090                 colorGroup: PlasmaCore.Theme.ComplementaryColorGroup
0091             }
0092             DropShadow {
0093                 anchors.fill: icon
0094                 horizontalOffset: 0
0095                 verticalOffset: 0
0096                 radius: 8.0
0097                 samples: 17
0098                 color: "#80000000"
0099                 source: icon
0100             }
0101         }
0102 
0103         Rectangle {
0104             id: background
0105             anchors.fill: parent
0106 
0107             color: colorGenerator.dominant
0108 
0109             state: "closed"
0110 
0111             states: [
0112                 State {
0113                     name: "closed"
0114                     PropertyChanges {
0115                         target: window
0116                         visible: false
0117                     }
0118                 },
0119                 State {
0120                     name: "open"
0121 
0122                     PropertyChanges {
0123                         target: window
0124                         visible: true
0125                     }
0126                 }
0127             ]
0128 
0129             transitions: [
0130                 Transition {
0131                     from: "closed"
0132                     SequentialAnimation {
0133                         ScriptAction {
0134                             script: { 
0135                                 window.showMaximized();
0136                             }
0137                         }
0138                         ParallelAnimation {
0139                             ScaleAnimator {
0140                                 target: background
0141                                 from: background.scale
0142                                 to: 1
0143                                 duration: PlasmaCore.Units.longDuration
0144                                 easing.type: Easing.InOutQuad
0145                             }
0146                             ScaleAnimator {
0147                                 target: iconParent
0148                                 from: iconParent.scale
0149                                 to: 1
0150                                 duration: PlasmaCore.Units.longDuration
0151                                 easing.type: Easing.InOutQuad
0152                             }
0153                             XAnimator {
0154                                 target: backgroundParent
0155                                 from: backgroundParent.x
0156                                 to: 0
0157                                 duration: PlasmaCore.Units.longDuration
0158                                 easing.type: Easing.InOutQuad
0159                             }
0160                             YAnimator {
0161                                 target: backgroundParent
0162                                 from: backgroundParent.y
0163                                 to: 0
0164                                 duration: PlasmaCore.Units.longDuration
0165                                 easing.type: Easing.InOutQuad
0166                             }
0167                         }
0168                     }
0169                 }
0170             ]
0171         }
0172     }
0173 }