Commit 84247e84 authored by Marco Martin's avatar Marco Martin
Browse files

support for the shadow and effectiveBackgroundhints

Summary:
support the automatic shadow hint

When the hint is shadowedBackground, do an automatic shadow with a shader, and
change applet's color to complementary

Test Plan:
Tested the functionality on various applets. To test, the digital clock is enabling explicitly background configurability
{F7788553}

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D25591
parent cacc7dd3
......@@ -32,6 +32,7 @@ Item {
width: units.gridUnit * 10
height: units.gridUnit * 4
property string dateFormatString: setDateFormatString()
Plasmoid.backgroundHints: PlasmaCore.Types.ShadowBackground | PlasmaCore.Types.ConfigurableBackground
property date tzDate: {
// get the time for the given timezone from the dataengine
var now = dataSource.data[plasmoid.configuration.lastSelectedTimezone]["DateTime"];
......
......@@ -19,11 +19,13 @@
import QtQuick 2.12
import QtQuick.Layouts 1.2
import QtGraphicalEffects 1.0
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager
import org.kde.kirigami 2.11 as Kirigami
ContainmentLayoutManager.AppletContainer {
id: appletContainer
......@@ -31,6 +33,18 @@ ContainmentLayoutManager.AppletContainer {
? ContainmentLayoutManager.ItemContainer.Manual
: ContainmentLayoutManager.ItemContainer.AfterPressAndHold
Kirigami.Theme.inherit: false
Kirigami.Theme.colorSet: (contentItem.effectiveBackgroundHints & PlasmaCore.Types.ShadowBackground)
&& !(contentItem.effectiveBackgroundHints & PlasmaCore.Types.StandardBackground)
&& !(contentItem.effectiveBackgroundHints & PlasmaCore.Types.TranslucentBackground)
? Kirigami.Theme.Complementary
: Kirigami.Theme.Window
PlasmaCore.ColorScope.inherit: false
PlasmaCore.ColorScope.colorGroup: Kirigami.Theme.colorSet == Kirigami.Theme.Complementary
? PlasmaCore.Theme.ComplementaryColorGroup
: PlasmaCore.Theme.NormalColorGroup
onFocusChanged: {
if (!focus) {
editMode = false;
......@@ -78,7 +92,40 @@ ContainmentLayoutManager.AppletContainer {
initialSize.height: applet.switchHeight + topPadding + bottomPadding
background: PlasmaCore.FrameSvgItem {
imagePath: contentItem && contentItem.backgroundHints == PlasmaCore.Types.StandardBackground ? "widgets/background" : ""
imagePath: {
if (!contentItem) {
return "";
}
if (contentItem.effectiveBackgroundHints & PlasmaCore.Types.TranslucentBackground) {
return "widgets/translucentbackground";
} else if (contentItem.effectiveBackgroundHints & PlasmaCore.Types.StandardBackground) {
return "widgets/background";
} else {
return "";
}
}
DropShadow {
anchors {
fill: parent
leftMargin: appletContainer.leftPadding
topMargin: appletContainer.topPadding
rightMargin: appletContainer.rightPadding
bottomMargin: appletContainer.bottomPadding
}
z: -1
horizontalOffset: 0
verticalOffset: 1
radius: 4
samples: 9
spread: 0.35
color: Qt.rgba(0, 0, 0, 0.5)
opacity: 1
source: contentItem && contentItem.effectiveBackgroundHints & PlasmaCore.Types.ShadowBackground ? contentItem : null
visible: source != null
}
}
busyIndicatorComponent: PlasmaComponents.BusyIndicator {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment