diff --git a/declarativeimports/plasmacomponents/platformcomponents/touch/ToolButton.qml b/declarativeimports/plasmacomponents/platformcomponents/touch/ToolButton.qml index 2401505a0..f8c1f4262 100644 --- a/declarativeimports/plasmacomponents/platformcomponents/touch/ToolButton.qml +++ b/declarativeimports/plasmacomponents/platformcomponents/touch/ToolButton.qml @@ -26,8 +26,8 @@ Item { // Commmon API property bool flat: true - property bool checked: false - property bool checkable: false + property bool checked: defaultAction ? defaultAction.checked : false + property bool checkable: defaultAction ? defaultAction.checkable : false property alias pressed: mouse.pressed property alias text: label.text property alias iconSource: icon.source @@ -35,11 +35,16 @@ Item { signal clicked() + // Plasma extensiuons + property QtObject defaultAction onFlatChanged: { - delegate.opacity = 1 + if (!flat) { + delegate.opacity = 1 + } } + enabled: defaultAction==undefined||defaultAction.enabled implicitWidth: { if (label.paintedWidth == 0) { @@ -88,12 +93,18 @@ Item { return } - if (button.checkable) { + if (defaultAction && defaultAction.checkable) { + defaultAction.checked = !defaultAction.checked + } else if (button.checkable) { button.checked = !button.checked } button.clicked() button.forceActiveFocus() + + if (defaultAction) { + defaultAction.trigger() + } } } @@ -142,10 +153,10 @@ Item { Item { anchors.fill: parent property QtObject margins: QtObject { - property int left: 16 - property int top: 16 - property int right: 16 - property int bottom: 16 + property int left: 8 + property int top: 8 + property int right: 8 + property int bottom: 8 } RoundShadow { anchors.fill: parent @@ -175,6 +186,10 @@ Item { rightMargin: delegate.margins.right bottomMargin: delegate.margins.bottom } + scale: internal.userPressed ? 0.9 : 1 + Behavior on scale { + PropertyAnimation { duration: 100 } + } IconLoader { id: icon @@ -184,6 +199,8 @@ Item { left: label.text ? parent.left : undefined horizontalCenter: label.text ? undefined : parent.horizontalCenter } + width: label.text ? implicitWidth : roundToStandardSize(parent.width) + height: width } Text { diff --git a/declarativeimports/plasmacomponents/qml/Button.qml b/declarativeimports/plasmacomponents/qml/Button.qml index 9ad82314a..6912658eb 100644 --- a/declarativeimports/plasmacomponents/qml/Button.qml +++ b/declarativeimports/plasmacomponents/qml/Button.qml @@ -127,6 +127,10 @@ Item { Item { id: buttonContent state: (internal.userPressed || checked) ? "pressed" : "normal" + scale: state == "pressed" ? 0.9 : 1 + Behavior on scale { + PropertyAnimation { duration: 100 } + } states: [ State { name: "normal" }, diff --git a/declarativeimports/plasmacomponents/qml/IconLoader.qml b/declarativeimports/plasmacomponents/qml/IconLoader.qml index 8e9862a03..a8a27e725 100644 --- a/declarativeimports/plasmacomponents/qml/IconLoader.qml +++ b/declarativeimports/plasmacomponents/qml/IconLoader.qml @@ -56,6 +56,23 @@ Item { id: svgIcon } + function roundToStandardSize(size) + { + if (size >= theme.enormousIconSize) { + return theme.enormousIconSize + } else if (size >= theme.hugeIconSize) { + return theme.hugeIconSize + } else if (size >= theme.largeIconSize) { + return theme.largeIconSize + } else if (size >= theme.mediumIconSize) { + return theme.mediumIconSize + } else if (size >= theme.smallMediumIconSize) { + return theme.smallMediumIconSize + } else { + return theme.smallIconSize + } + } + Loader { id: imageLoader anchors.fill: parent diff --git a/declarativeimports/plasmacomponents/qml/ToolButton.qml b/declarativeimports/plasmacomponents/qml/ToolButton.qml index 14a65e878..accb809c4 100644 --- a/declarativeimports/plasmacomponents/qml/ToolButton.qml +++ b/declarativeimports/plasmacomponents/qml/ToolButton.qml @@ -26,8 +26,8 @@ Item { // Commmon API property bool flat: true - property bool checked: false - property bool checkable: false + property bool checked: defaultAction ? defaultAction.checked : false + property bool checkable: defaultAction ? defaultAction.checkable : false property alias pressed: mouse.pressed property alias text: label.text property alias iconSource: icon.source @@ -35,6 +35,11 @@ Item { signal clicked() + // Plasma extensiuons + property QtObject defaultAction + + + enabled: defaultAction==undefined||defaultAction.enabled onFlatChanged: { surface.opacity = 1 @@ -88,12 +93,18 @@ Item { return } - if (button.checkable) { + if (defaultAction && defaultAction.checkable) { + defaultAction.checked = !defaultAction.checked + } else if (button.checkable) { button.checked = !button.checked } button.clicked() button.forceActiveFocus() + + if (defaultAction) { + defaultAction.trigger() + } } } @@ -112,7 +123,7 @@ Item { //internal: if there is no hover status, don't paint on mouse over in touchscreens opacity: (internal.userPressed || checked || !flat || (shadow.hasOverState && mouse.containsMouse)) ? 1 : 0 Behavior on opacity { - PropertyAnimation { duration: 250 } + PropertyAnimation { duration: 100 } } } @@ -124,6 +135,10 @@ Item { rightMargin: surface.margins.right bottomMargin: surface.margins.bottom } + scale: internal.userPressed ? 0.9 : 1 + Behavior on scale { + PropertyAnimation { duration: 250 } + } IconLoader { id: icon