diff --git a/containments/desktop/package/contents/ui/ActionButton.qml b/containments/desktop/package/contents/ui/ActionButton.qml --- a/containments/desktop/package/contents/ui/ActionButton.qml +++ b/containments/desktop/package/contents/ui/ActionButton.qml @@ -18,131 +18,65 @@ * 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 +import org.kde.plasma.components 3.0 as PlasmaComponents -PlasmaCore.ToolTipArea { +PlasmaComponents.ToolButton { id: button + Layout.fillWidth: true - location: PlasmaCore.Types.LeftEdge - mainText: action !== undefined ? action.text : "" - mainItem: toolTipDelegate + property QtObject qAction - //API property PlasmaCore.Svg svg property alias elementId: icon.elementId - property QtObject action - property bool backgroundVisible: false 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 + property alias toolTip: toolTip.text - opacity: action==undefined||action.enabled?1:0.6 - - Behavior on opacity { - NumberAnimation { - duration: units.longDuration - easing.type: Easing.InOutQuad - } - } + + implicitWidth: Math.min(buttonColumn.implicitWidth, units.gridUnit * 10) + leftPadding + rightPadding - onCheckedChanged: { - if (checked) { - buttonItem.elementId = "pressed" - shadowItem.opacity = 0 - } else { - buttonItem.elementId = "normal" - shadowItem.opacity = 1 + onClicked: { + if (qAction) { + qAction.trigger() } + appletContainer.editMode = false; } - 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 + PlasmaComponents.ToolTip { + id: toolTip + text: button.qAction ? button.qAction.text : "" + delay: 0 + visible: button.hovered + x: button.width + y: button.height/2 - height/2 } - - Row { - id: buttonRow - - 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 - } + contentItem: ColumnLayout { + id: buttonColumn + + PlasmaCore.SvgItem { + id: icon + Layout.preferredWidth: units.iconSizes.small + Layout.preferredHeight: Layout.preferredWidth + Layout.alignment: Qt.AlignHCenter + width: iconSize + height: iconSize + svg: button.svg } - Text { + PlasmaComponents.Label { id: actionText + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter text: button.text - style: Text.Outline + wrapMode: Text.WordWrap + elide: Text.ElideRight + // The handle uses always the main global theme color: theme.textColor - styleColor: Qt.rgba(1,1,1,0.4) - 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; + visible: text.length > 0 } } } diff --git a/containments/desktop/package/contents/ui/ConfigOverlay.qml b/containments/desktop/package/contents/ui/ConfigOverlay.qml --- a/containments/desktop/package/contents/ui/ConfigOverlay.qml +++ b/containments/desktop/package/contents/ui/ConfigOverlay.qml @@ -35,17 +35,6 @@ imagePath: "widgets/configuration-icons" } - PlasmaComponents.Label { - id: toolTipDelegate - - width: contentWidth - height: undefined - - property Item toolTip - - text: (toolTip != null) ? toolTip.mainText : "" - } - SequentialAnimation { id: removeAnim NumberAnimation { @@ -98,10 +87,10 @@ 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 @@ -135,7 +124,6 @@ } onPressed: { - parent.hideToolTip(); mouse.accepted = true startRotation = overlay.itemContainer.rotation; startCenterRelativeAngle = pointAngle(centerRelativePos(mouse.x, mouse.y)); @@ -177,24 +165,50 @@ 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 { 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 { + svg: configIconsSvg + elementId: "showbackground" + //mainText: i18n("Show Background") + toolTip: i18n("Show Background") + iconSize: overlay.iconSize + visible: (applet.backgroundHints & PlasmaCore.Types.ConfigurableBackground) + checked: applet.effectiveBackgroundHints & PlasmaCore.Types.StandardBackground || applet.effectiveBackgroundHints & PlasmaCore.Types.TranslucentBackground + checkable: true + onClicked: { + if (checked) { + if (applet.backgroundHints & PlasmaCore.Types.StandardBackground || applet.backgroundHints & PlasmaCore.Types.TranslucentBackground) { + applet.userBackgroundHints = applet.backgroundHints; + } else { + applet.userBackgroundHints = PlasmaCore.Types.StandardBackground; + } + } else { + if (applet.backgroundHints & PlasmaCore.Types.ShadowBackground || applet.backgroundHints & PlasmaCore.Types.NoBackground) { + applet.userBackgroundHints = applet.backgroundHints; + } else { + applet.userBackgroundHints = PlasmaCore.Types.ShadowBackground; + } } } } @@ -225,7 +239,7 @@ id: closeButton svg: configIconsSvg elementId: "delete" - mainText: i18n("Remove") + toolTip: i18n("Remove") iconSize: overlay.iconSize visible: { if (!applet) {