diff --git a/containments/desktop/package/contents/ui/ActionButton.qml b/containments/desktop/package/contents/ui/ActionButton.qml index a468bc445..d75faf6a5 100644 --- a/containments/desktop/package/contents/ui/ActionButton.qml +++ b/containments/desktop/package/contents/ui/ActionButton.qml @@ -1,148 +1,148 @@ /* * Copyright 2011 Marco Martin * Copyright 2013 Sebastian Kügler * * 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.0 +import QtQuick 2.12 +import QtQuick.Layouts 1.4 + import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents PlasmaCore.ToolTipArea { id: button location: PlasmaCore.Types.LeftEdge mainText: action !== undefined ? action.text : "" mainItem: toolTipDelegate //API property PlasmaCore.Svg svg property alias elementId: icon.elementId property QtObject action - property bool backgroundVisible: false + property bool backgroundVisible: checked property int iconSize: 32 property int pressedOffset: 1 property bool checked: false property bool toggle: false property string text signal clicked - implicitWidth: buttonRow.implicitWidth - implicitHeight: buttonRow.implicitHeight + implicitWidth: buttonColumn.implicitWidth + implicitHeight: buttonColumn.implicitHeight opacity: action==undefined||action.enabled?1:0.6 Behavior on opacity { NumberAnimation { duration: units.longDuration easing.type: Easing.InOutQuad } } onCheckedChanged: { if (checked) { buttonItem.elementId = "pressed" shadowItem.opacity = 0 } else { buttonItem.elementId = "normal" shadowItem.opacity = 1 } } PlasmaCore.Svg { id: buttonSvg imagePath: "widgets/actionbutton" } PlasmaCore.SvgItem { id: shadowItem svg: buttonSvg elementId: "shadow" width: iconSize+13//button.backgroundVisible?iconSize+8:iconSize height: width visible: button.backgroundVisible } - Row { - id: buttonRow + ColumnLayout { + id: buttonColumn Item { width: buttonItem.visible?buttonItem.width:iconSize height: buttonItem.visible?buttonItem.height:iconSize PlasmaCore.SvgItem { id: buttonItem svg: buttonSvg elementId: "normal" width: shadowItem.width height: shadowItem.height visible: backgroundVisible } PlasmaCore.SvgItem { id: icon width: iconSize height: iconSize svg: button.svg anchors.centerIn: parent } } - Text { + PlasmaComponents.Label { id: actionText text: button.text - style: Text.Outline - color: theme.textColor - styleColor: Qt.rgba(1,1,1,0.4) - anchors.verticalCenter: parent.verticalCenter + wrapMode: Text.WordWrap + //anchors.verticalCenter: parent.verticalCenter } } MouseArea { anchors.fill: parent anchors.leftMargin: -10 anchors.topMargin: -10 anchors.rightMargin: -10 anchors.bottomMargin: -10 preventStealing: true onPressed: { buttonItem.elementId = "pressed" shadowItem.opacity = 0; button.x = button.x + button.pressedOffset; button.y = button.y + button.pressedOffset; } onReleased: { if (button.checked || !button.toggle) { buttonItem.elementId = "normal" shadowItem.opacity = 1 button.checked = false } else { button.checked = true } button.x = button.x - button.pressedOffset; button.y = button.y - button.pressedOffset; } onClicked: { if (action) { action.trigger() } else { button.clicked() } appletContainer.editMode = false; } } } diff --git a/containments/desktop/package/contents/ui/ConfigOverlay.qml b/containments/desktop/package/contents/ui/ConfigOverlay.qml index 0fe1060cb..b725a4980 100644 --- a/containments/desktop/package/contents/ui/ConfigOverlay.qml +++ b/containments/desktop/package/contents/ui/ConfigOverlay.qml @@ -1,269 +1,269 @@ /* * 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.1 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 ContainmentLayoutManager.ConfigOverlayWithHandles { id: overlay readonly property int iconSize: touchInteraction ? units.iconSizes.medium : units.iconSizes.small PlasmaCore.Svg { id: configIconsSvg imagePath: "widgets/configuration-icons" } - PlasmaComponents.Label { - id: toolTipDelegate - - width: contentWidth - height: undefined - - property Item toolTip - - text: (toolTip != null) ? toolTip.mainText : "" - } - SequentialAnimation { id: removeAnim NumberAnimation { target: overlay.itemContainer property: "scale" from: 1 to: 0 duration: units.longDuration easing.type: Easing.InOutQuad } ScriptAction { script: { appletContainer.applet.action("remove").trigger(); appletContainer.editMode = false; } } } PlasmaCore.FrameSvgItem { id: frame anchors.verticalCenter: parent.verticalCenter x: rightAvailableSpace > width + units.gridUnit ? parent.width + units.gridUnit : -width - units.gridUnit transform: Translate { x: open ? 0 : (overlay.rightAvailableSpace > frame.width + units.gridUnit ? -frame.width : frame.width) Behavior on x { NumberAnimation { duration: units.longDuration easing.type: Easing.InOutQuad } } } width: layout.implicitWidth + margins.left + margins.right height: Math.max(layout.implicitHeight + margins.top + margins.bottom, parent.height) imagePath: "widgets/background" ColumnLayout { id: layout anchors { fill: parent topMargin: parent.margins.top leftMargin: parent.margins.left bottomMargin: parent.margins.bottom rightMargin: parent.margins.right } - ActionButton { + ActionButton2 { id: rotateButton svg: configIconsSvg elementId: "rotate" - mainText: i18n("Rotate") + toolTip: i18n("Rotate") iconSize: overlay.iconSize action: (applet) ? applet.action("rotate") : null - active: !rotateHandle.pressed + down: !rotateHandle.pressed Component.onCompleted: { if (action && typeof(action) != "undefined") { action.enabled = true } } MouseArea { id: rotateHandle anchors.fill: parent property int startRotation property real startCenterRelativeAngle; function pointAngle(pos) { var r = Math.sqrt(pos.x * pos.x + pos.y * pos.y); var cosine = pos.x / r; if (pos.y >= 0) { return Math.acos(cosine) * (180/Math.PI); } else { return -Math.acos(cosine) * (180/Math.PI); } } function centerRelativePos(x, y) { var mousePos = overlay.itemContainer.parent.mapFromItem(rotateButton, x, y); var centerPos = overlay.itemContainer.parent.mapFromItem(overlay.itemContainer, overlay.itemContainer.width/2, overlay.itemContainer.height/2); mousePos.x -= centerPos.x; mousePos.y -= centerPos.y; return mousePos; } onPressed: { - parent.hideToolTip(); mouse.accepted = true startRotation = overlay.itemContainer.rotation; startCenterRelativeAngle = pointAngle(centerRelativePos(mouse.x, mouse.y)); } onPositionChanged: { var rot = startRotation%360; var snap = 4; var newRotation = Math.round(pointAngle(centerRelativePos(mouse.x, mouse.y)) - startCenterRelativeAngle + startRotation); if (newRotation < 0) { newRotation = newRotation + 360; } else if (newRotation >= 360) { newRotation = newRotation % 360; } snapIt(0); snapIt(90); snapIt(180); snapIt(270); function snapIt(snapTo) { if (newRotation > (snapTo - snap) && newRotation < (snapTo + snap)) { newRotation = snapTo; } } //print("Start: " + startRotation + " new: " + newRotation); overlay.itemContainer.rotation = newRotation; } onReleased: { // save rotation // print("saving..."); appletsLayout.save(); } } } - ActionButton { + ActionButton2 { svg: configIconsSvg elementId: "configure" iconSize: overlay.iconSize - visible: (action && typeof(action) != "undefined") ? action.enabled : false - action: (applet) ? applet.action("configure") : null + visible: (qAction && typeof(qAction) != "undefined") ? qAction.enabled : false + qAction: (applet) ? applet.action("configure") : null Component.onCompleted: { - if (action && typeof(action) != "undefined") { - action.enabled = true + if (qAction && typeof(qAction) != "undefined") { + qAction.enabled = true } } } - ActionButton { + ActionButton2 { svg: configIconsSvg elementId: "maximize" iconSize: overlay.iconSize - visible: (action && typeof(action) != "undefined") ? action.enabled : false - action: (applet) ? applet.action("run associated application") : null + toolTip: i18n("Open Externally") + visible: (qAction && typeof(qAction) != "undefined") ? qAction.enabled : false + qAction: (applet) ? applet.action("run associated application") : null Component.onCompleted: { - if (action && typeof(action) != "undefined") { - action.enabled = true + if (qAction && typeof(qAction) != "undefined") { + qAction.enabled = true } } } - ActionButton { + ActionButton2 { svg: configIconsSvg - elementId: "help" - mainText: i18n("Remove Background") + elementId: "showbackground" + //mainText: i18n("Show Background") + toolTip: i18n("Show Background") iconSize: overlay.iconSize - visible: true + visible: !(applet.backgroundHints & PlasmaCore.Types.ImmutableBackground) + checked: applet.effectiveBackgroundHints & PlasmaCore.Types.StandardBackground || applet.effectiveBackgroundHints & PlasmaCore.Types.TranslucentBackground + checkable: true onClicked: { - if (applet.effectiveBackgroundHints === applet.backgroundHints) { - applet.effectiveBackgroundHints = PlasmaCore.Types.ShadowBackground; + if (checked) { + if (applet.backgroundHints & PlasmaCore.Types.StandardBackground || applet.backgroundHints & PlasmaCore.Types.TranslucentBackground) { + applet.effectiveBackgroundHints = applet.backgroundHints; + } else { + applet.effectiveBackgroundHints = PlasmaCore.Types.StandardBackground; + } } else { - applet.effectiveBackgroundHints = applet.backgroundHints; + if (applet.backgroundHints & PlasmaCore.Types.ShadowBackground || applet.backgroundHints & PlasmaCore.Types.NoBackground) { + applet.effectiveBackgroundHints = applet.backgroundHints; + } else { + applet.effectiveBackgroundHints = PlasmaCore.Types.ShadowBackground; + } } } } MouseArea { drag.target: overlay.itemContainer Layout.minimumHeight: units.gridUnit * 3 Layout.fillHeight: true Layout.fillWidth: true cursorShape: Qt.DragMoveCursor hoverEnabled: true onPressed: appletsLayout.releaseSpace(overlay.itemContainer); onPositionChanged: { if (!pressed) { return; } appletsLayout.showPlaceHolderForItem(overlay.itemContainer); var dragPos = mapToItem(overlay.itemContainer, mouse.x, mouse.y); overlay.itemContainer.userDrag(Qt.point(overlay.itemContainer.x, overlay.itemContainer.y), dragPos); } onReleased: { appletsLayout.hidePlaceHolder(); appletsLayout.positionItem(overlay.itemContainer); } } - ActionButton { + ActionButton2 { id: closeButton svg: configIconsSvg elementId: "delete" - mainText: i18n("Remove") + toolTip: i18n("Remove") iconSize: overlay.iconSize visible: { if (!applet) { return false; } var a = applet.action("remove"); return (a && typeof(a) != "undefined") ? a.enabled : false; } // we don't set action, since we want to catch the button click, // animate, and then trigger the "remove" action // Triggering the action is handled in the overlay.itemContainer, we just // emit a signal here to avoid the applet-gets-removed-before-we- // can-animate it race condition. onClicked: { removeAnim.restart(); } Component.onCompleted: { var a = applet.action("remove"); if (a && typeof(a) != "undefined") { a.enabled = true } } } } } }