diff --git a/applets/digital-clock/package/contents/ui/main.qml b/applets/digital-clock/package/contents/ui/main.qml index 604a7b9b7..d91cabe04 100644 --- a/applets/digital-clock/package/contents/ui/main.qml +++ b/applets/digital-clock/package/contents/ui/main.qml @@ -1,117 +1,118 @@ /* * Copyright 2013 Heena Mahour * Copyright 2013 Sebastian Kügler * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.0 import QtQuick.Layouts 1.1 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.kquickcontrolsaddons 2.0 import org.kde.plasma.private.digitalclock 1.0 import org.kde.kquickcontrolsaddons 2.0 import org.kde.plasma.calendar 2.0 as PlasmaCalendar Item { id: root 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"]; // get current UTC time var msUTC = now.getTime() + (now.getTimezoneOffset() * 60000); // add the dataengine TZ offset to it return new Date(msUTC + (dataSource.data[plasmoid.configuration.lastSelectedTimezone]["Offset"] * 1000)); } function initTimezones() { var tz = Array() if (plasmoid.configuration.selectedTimeZones.indexOf("Local") === -1) { tz.push("Local"); } root.allTimezones = tz.concat(plasmoid.configuration.selectedTimeZones); } Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation Plasmoid.compactRepresentation: DigitalClock { } Plasmoid.fullRepresentation: CalendarView { } Plasmoid.toolTipItem: Loader { id: tooltipLoader Layout.minimumWidth: item ? item.width : 0 Layout.maximumWidth: item ? item.width : 0 Layout.minimumHeight: item ? item.height : 0 Layout.maximumHeight: item ? item.height : 0 source: "Tooltip.qml" } //We need Local to be *always* present, even if not disaplayed as //it's used for formatting in ToolTip.dateTimeChanged() property var allTimezones Connections { target: plasmoid.configuration onSelectedTimeZonesChanged: root.initTimezones(); } PlasmaCore.DataSource { id: dataSource engine: "time" connectedSources: allTimezones interval: plasmoid.configuration.showSeconds ? 1000 : 60000 intervalAlignment: plasmoid.configuration.showSeconds ? PlasmaCore.Types.NoAlignment : PlasmaCore.Types.AlignToMinute } function setDateFormatString() { // remove "dddd" from the locale format string // /all/ locales in LongFormat have "dddd" either // at the beginning or at the end. so we just // remove it + the delimiter and space var format = Qt.locale().dateFormat(Locale.LongFormat); format = format.replace(/(^dddd.?\s)|(,?\sdddd$)/, ""); return format; } function action_clockkcm() { KCMShell.open("clock"); } function action_formatskcm() { KCMShell.open("formats"); } Component.onCompleted: { plasmoid.setAction("clipboard", i18n("Copy to Clipboard"), "edit-copy"); ClipboardMenu.setupMenu(plasmoid.action("clipboard")); root.initTimezones(); if (KCMShell.authorize("clock.desktop").length > 0) { plasmoid.setAction("clockkcm", i18n("Adjust Date and Time..."), "preferences-system-time"); } if (KCMShell.authorize("formats.desktop").length > 0) { plasmoid.setAction("formatskcm", i18n("Set Time Format...")); } // Set the list of enabled plugins from config // to the manager PlasmaCalendar.EventPluginsManager.enabledPlugins = plasmoid.configuration.enabledCalendarPlugins; } } diff --git a/components/containmentlayoutmanager/qml/BasicAppletContainer.qml b/components/containmentlayoutmanager/qml/BasicAppletContainer.qml index 145c0deb5..a22328c60 100644 --- a/components/containmentlayoutmanager/qml/BasicAppletContainer.qml +++ b/components/containmentlayoutmanager/qml/BasicAppletContainer.qml @@ -1,95 +1,142 @@ /* * Copyright 2019 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ 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 editModeCondition: plasmoid.immutable ? 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; } } Layout.minimumWidth: { if (!applet) { return leftPadding + rightPadding; } if (applet.preferredRepresentation != applet.fullRepresentation && applet.compactRepresentationItem ) { return applet.compactRepresentationItem.Layout.minimumWidth + leftPadding + rightPadding; } else { return applet.Layout.minimumWidth + leftPadding + rightPadding; } } Layout.minimumHeight: { if (!applet) { return topPadding + bottomPadding; } if (applet.preferredRepresentation != applet.fullRepresentation && applet.compactRepresentationItem ) { return applet.compactRepresentationItem.Layout.minimumHeight + topPadding + bottomPadding; } else { return applet.Layout.minimumHeight + topPadding + bottomPadding; } } Layout.preferredWidth: Math.max(applet.Layout.minimumWidth, applet.Layout.preferredWidth) Layout.preferredHeight: Math.max(applet.Layout.minimumHeight, applet.Layout.preferredHeight) Layout.maximumWidth: applet.Layout.maximumWidth Layout.maximumHeight: applet.Layout.maximumHeight leftPadding: background.margins.left topPadding: background.margins.top rightPadding: background.margins.right bottomPadding: background.margins.bottom initialSize.width: applet.switchWidth + leftPadding + rightPadding 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 { anchors.centerIn: parent visible: applet.busy running: visible } configurationRequiredComponent: PlasmaComponents.Button { anchors.centerIn: parent text: i18n("Configure...") visible: applet.configurationRequired onClicked: applet.action("configure").trigger(); } }