Warning, /plasma/plasma-mobile/containments/homescreens/folio/package/contents/ui/delegate/WidgetDelegate.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org> 0002 // SPDX-License-Identifier: LGPL-2.0-or-later 0003 0004 import QtQuick 0005 import QtQuick.Layouts 0006 import QtQuick.Controls as QQC2 0007 import Qt5Compat.GraphicalEffects 0008 0009 import org.kde.kirigami as Kirigami 0010 import org.kde.plasma.core as PlasmaCore 0011 import org.kde.ksvg 1.0 as KSvg 0012 0013 import org.kde.plasma.components 3.0 as PC3 0014 import org.kde.private.mobile.homescreen.folio 1.0 as Folio 0015 0016 import '../private' 0017 0018 Folio.WidgetContainer { 0019 id: root 0020 0021 property Folio.FolioWidget widget 0022 0023 readonly property real widgetWidth: widgetHolder.width 0024 readonly property real widgetHeight: widgetHolder.height 0025 0026 readonly property real topWidgetBackgroundPadding: widgetBackground.margins.top 0027 readonly property real bottomWidgetBackgroundPadding: widgetBackground.margins.bottom 0028 readonly property real leftWidgetBackgroundPadding: widgetBackground.margins.left 0029 readonly property real rightWidgetBackgroundPadding: widgetBackground.margins.right 0030 0031 implicitWidth: (widget ? widget.gridWidth : 0) * Folio.HomeScreenState.pageCellWidth 0032 implicitHeight: (widget ? widget.gridHeight : 0) * Folio.HomeScreenState.pageCellHeight 0033 width: implicitWidth 0034 height: implicitHeight 0035 0036 // prevent widget contents from going outside of the container 0037 clip: true 0038 0039 function updateVisualApplet() { 0040 if (!widget || !widget.visualApplet) { 0041 return; 0042 } 0043 0044 widget.visualApplet.parent = widgetHolder; 0045 widget.visualApplet.anchors.fill = widgetHolder; 0046 if (widget.visualApplet.fullRepresentationItem) { 0047 widget.visualApplet.fullRepresentationItem.parent = widgetHolder; 0048 widget.visualApplet.fullRepresentationItem.anchors.fill = widgetHolder; 0049 } 0050 } 0051 0052 onWidgetChanged: updateVisualApplet() 0053 0054 Component.onCompleted: { 0055 updateVisualApplet(); 0056 } 0057 0058 Connections { 0059 target: widget 0060 0061 function onVisualAppletChanged() { 0062 if (!widget.visualApplet) { 0063 return; 0064 } 0065 0066 root.updateVisualApplet(); 0067 } 0068 } 0069 0070 Item { 0071 id: widgetComponent 0072 anchors.fill: parent 0073 0074 KSvg.FrameSvgItem { 0075 id: widgetBackground 0076 anchors.fill: parent 0077 enabledBorders: KSvg.FrameSvgItem.AllBorders 0078 imagePath: { 0079 if (!root.widget || !root.widget.applet || root.widget.applet.effectiveBackgroundHints === PlasmaCore.Types.NoBackground) { 0080 return ''; 0081 } else if (root.widget.applet.effectiveBackgroundHints & PlasmaCore.Types.StandardBackground) { 0082 return 'widgets/background'; 0083 } else if (root.widget.applet.effectiveBackgroundHints & PlasmaCore.Types.TranslucentBackground) { 0084 return 'widgets/translucentbackground'; 0085 } 0086 return ''; 0087 } 0088 } 0089 0090 Rectangle { 0091 id: temporaryBackground 0092 anchors.fill: parent 0093 visible: root.widget && !root.widget.applet 0094 color: Qt.rgba(255, 255, 255, 0.3) 0095 radius: Kirigami.Units.smallSpacing 0096 } 0097 0098 Item { 0099 id: widgetHolder 0100 anchors.fill: parent 0101 anchors.leftMargin: (root.widget && root.widget.applet && root.widget.applet.constraintHints === PlasmaCore.Types.CanFillArea) ? 0 : widgetBackground.margins.left 0102 anchors.rightMargin: (root.widget && root.widget.applet && root.widget.applet.constraintHints === PlasmaCore.Types.CanFillArea) ? 0 : widgetBackground.margins.right 0103 anchors.topMargin: (root.widget && root.widget.applet && root.widget.applet.constraintHints === PlasmaCore.Types.CanFillArea) ? 0 : widgetBackground.margins.top 0104 anchors.bottomMargin: (root.widget && root.widget.applet && root.widget.applet.constraintHints === PlasmaCore.Types.CanFillArea) ? 0 : widgetBackground.margins.bottom 0105 } 0106 0107 // TODO implement blur behind, see plasma-workspace BasicAppletContainer for how to do this 0108 layer.enabled: root.widget && root.widget.applet && root.widget.applet.effectiveBackgroundHints === PlasmaCore.Types.ShadowBackground 0109 layer.effect: DelegateShadow {} 0110 0111 PC3.Label { 0112 id: noWidget 0113 visible: root.widget && !root.widget.visualApplet 0114 color: 'white' 0115 wrapMode: Text.Wrap 0116 text: i18n('This widget was not found.') 0117 horizontalAlignment: Text.AlignHCenter 0118 0119 anchors.left: parent.left 0120 anchors.right: parent.right 0121 anchors.verticalCenter: parent.verticalCenter 0122 } 0123 0124 PC3.BusyIndicator { 0125 id: loadingIndicator 0126 anchors.centerIn: parent 0127 visible: root.widget && root.widget.applet && root.widget.applet.busy 0128 running: visible 0129 } 0130 0131 PC3.Button { 0132 id: configurationRequiredButton 0133 anchors.centerIn: parent 0134 text: i18n('Configureā¦') 0135 icon.name: 'configure' 0136 visible: root.widget && root.widget.applet && root.widget.applet.configurationRequired 0137 onClicked: root.widget.applet.internalAction('configure').trigger(); 0138 } 0139 } 0140 }