Changeset View
Changeset View
Standalone View
Standalone View
components/containmentlayoutmanager/qml/BasicAppletContainer.qml
Show All 13 Lines | |||||
14 | * You should have received a copy of the GNU Library General Public | 14 | * You should have received a copy of the GNU Library General Public | ||
15 | * License along with this program; if not, write to the | 15 | * License along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | 16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.12 | 20 | import QtQuick 2.12 | ||
21 | import QtQuick.Layouts 1.2 | 21 | import QtQuick.Layouts 1.2 | ||
22 | import QtGraphicalEffects 1.0 | ||||
22 | 23 | | |||
23 | import org.kde.plasma.plasmoid 2.0 | 24 | import org.kde.plasma.plasmoid 2.0 | ||
24 | import org.kde.plasma.core 2.0 as PlasmaCore | 25 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
25 | import org.kde.plasma.components 3.0 as PlasmaComponents | 26 | import org.kde.plasma.components 3.0 as PlasmaComponents | ||
26 | import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager | 27 | import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager | ||
28 | import org.kde.kirigami 2.11 as Kirigami | ||||
27 | 29 | | |||
28 | ContainmentLayoutManager.AppletContainer { | 30 | ContainmentLayoutManager.AppletContainer { | ||
29 | id: appletContainer | 31 | id: appletContainer | ||
30 | editModeCondition: plasmoid.immutable | 32 | editModeCondition: plasmoid.immutable | ||
31 | ? ContainmentLayoutManager.ItemContainer.Manual | 33 | ? ContainmentLayoutManager.ItemContainer.Manual | ||
32 | : ContainmentLayoutManager.ItemContainer.AfterPressAndHold | 34 | : ContainmentLayoutManager.ItemContainer.AfterPressAndHold | ||
33 | 35 | | |||
36 | Kirigami.Theme.inherit: false | ||||
37 | Kirigami.Theme.colorSet: (contentItem.effectiveBackgroundHints & PlasmaCore.Types.ShadowBackground) | ||||
38 | && !(contentItem.effectiveBackgroundHints & PlasmaCore.Types.StandardBackground) | ||||
39 | && !(contentItem.effectiveBackgroundHints & PlasmaCore.Types.TranslucentBackground) | ||||
40 | ? Kirigami.Theme.Complementary | ||||
41 | : Kirigami.Theme.Window | ||||
42 | | ||||
43 | PlasmaCore.ColorScope.inherit: false | ||||
44 | PlasmaCore.ColorScope.colorGroup: Kirigami.Theme.colorSet == Kirigami.Theme.Complementary | ||||
45 | ? PlasmaCore.Theme.ComplementaryColorGroup | ||||
46 | : PlasmaCore.Theme.NormalColorGroup | ||||
47 | | ||||
34 | onFocusChanged: { | 48 | onFocusChanged: { | ||
35 | if (!focus) { | 49 | if (!focus) { | ||
36 | editMode = false; | 50 | editMode = false; | ||
37 | } | 51 | } | ||
38 | } | 52 | } | ||
39 | Layout.minimumWidth: { | 53 | Layout.minimumWidth: { | ||
40 | if (!applet) { | 54 | if (!applet) { | ||
41 | return leftPadding + rightPadding; | 55 | return leftPadding + rightPadding; | ||
Show All 31 Lines | |||||
73 | topPadding: background.margins.top | 87 | topPadding: background.margins.top | ||
74 | rightPadding: background.margins.right | 88 | rightPadding: background.margins.right | ||
75 | bottomPadding: background.margins.bottom | 89 | bottomPadding: background.margins.bottom | ||
76 | 90 | | |||
77 | initialSize.width: applet.switchWidth + leftPadding + rightPadding | 91 | initialSize.width: applet.switchWidth + leftPadding + rightPadding | ||
78 | initialSize.height: applet.switchHeight + topPadding + bottomPadding | 92 | initialSize.height: applet.switchHeight + topPadding + bottomPadding | ||
79 | 93 | | |||
80 | background: PlasmaCore.FrameSvgItem { | 94 | background: PlasmaCore.FrameSvgItem { | ||
81 | imagePath: contentItem && contentItem.backgroundHints == PlasmaCore.Types.StandardBackground ? "widgets/background" : "" | 95 | imagePath: { | ||
96 | if (!contentItem) { | ||||
97 | return ""; | ||||
98 | } | ||||
99 | if (contentItem.effectiveBackgroundHints & PlasmaCore.Types.TranslucentBackground) { | ||||
100 | return "widgets/translucentbackground"; | ||||
101 | } else if (contentItem.effectiveBackgroundHints & PlasmaCore.Types.StandardBackground) { | ||||
102 | return "widgets/background"; | ||||
103 | } else { | ||||
104 | return ""; | ||||
105 | } | ||||
106 | } | ||||
107 | DropShadow { | ||||
108 | anchors { | ||||
109 | fill: parent | ||||
110 | leftMargin: appletContainer.leftPadding | ||||
111 | topMargin: appletContainer.topPadding | ||||
112 | rightMargin: appletContainer.rightPadding | ||||
113 | bottomMargin: appletContainer.bottomPadding | ||||
114 | } | ||||
115 | z: -1 | ||||
116 | horizontalOffset: 0 | ||||
117 | verticalOffset: 1 | ||||
118 | | ||||
119 | radius: 4 | ||||
120 | samples: 9 | ||||
121 | spread: 0.35 | ||||
122 | | ||||
123 | color: Qt.rgba(0, 0, 0, 0.5) | ||||
124 | opacity: 1 | ||||
125 | | ||||
126 | source: contentItem && contentItem.effectiveBackgroundHints & PlasmaCore.Types.ShadowBackground ? contentItem : null | ||||
127 | visible: source != null | ||||
128 | } | ||||
82 | } | 129 | } | ||
83 | 130 | | |||
84 | busyIndicatorComponent: PlasmaComponents.BusyIndicator { | 131 | busyIndicatorComponent: PlasmaComponents.BusyIndicator { | ||
85 | anchors.centerIn: parent | 132 | anchors.centerIn: parent | ||
86 | visible: applet.busy | 133 | visible: applet.busy | ||
87 | running: visible | 134 | running: visible | ||
88 | } | 135 | } | ||
89 | configurationRequiredComponent: PlasmaComponents.Button { | 136 | configurationRequiredComponent: PlasmaComponents.Button { | ||
90 | anchors.centerIn: parent | 137 | anchors.centerIn: parent | ||
91 | text: i18n("Configure...") | 138 | text: i18n("Configure...") | ||
92 | visible: applet.configurationRequired | 139 | visible: applet.configurationRequired | ||
93 | onClicked: applet.action("configure").trigger(); | 140 | onClicked: applet.action("configure").trigger(); | ||
94 | } | 141 | } | ||
95 | } | 142 | } |