From 49ef90bcb985ad67cb14d48c384198b0b8a6fa99 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Sat, 24 Mar 2018 18:28:02 +0100 Subject: [PATCH] Don't show the background if Button.flat Summary: Otherwise the flat property is ignored Test Plan: Tested on KDE Connect port to use PlasmaComponents Reviewers: #plasma, mart Reviewed By: #plasma, mart Subscribers: mart, #frameworks Tags: #frameworks Differential Revision: https://phabricator.kde.org/D11652 --- .../plasmacomponents3/Button.qml | 3 +- tests/buttons_pc3.0.qml | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/buttons_pc3.0.qml diff --git a/src/declarativeimports/plasmacomponents3/Button.qml b/src/declarativeimports/plasmacomponents3/Button.qml index 9ffa63e5d..c30648887 100644 --- a/src/declarativeimports/plasmacomponents3/Button.qml +++ b/src/declarativeimports/plasmacomponents3/Button.qml @@ -52,6 +52,7 @@ T.Button { implicitHeight: units.gridUnit * 1.6 Private.ButtonShadow { anchors.fill: parent + visible: (!control.flat || control.hovered) && (!control.pressed || !control.checked) state: { if (control.pressed) { return "hidden" @@ -69,7 +70,7 @@ T.Button { anchors.fill: parent imagePath: "widgets/button" prefix: "normal" - opacity: control.checked || control.pressed ? 0 : 1 + opacity: (!control.flat || control.hovered) && (!control.pressed || !control.checked) ? 1 : 0 Behavior on opacity { OpacityAnimator { duration: units.longDuration diff --git a/tests/buttons_pc3.0.qml b/tests/buttons_pc3.0.qml new file mode 100644 index 000000000..343d2010d --- /dev/null +++ b/tests/buttons_pc3.0.qml @@ -0,0 +1,28 @@ +import QtQuick 2.0 + +import org.kde.plasma.components 3.0 as PlasmaComponents + +Rectangle +{ + width: 500 + height: 300 + color: "white" + + Flow { + anchors.fill: parent + anchors.margins: 20 + spacing: 20 + + PlasmaComponents.Button { + text: "test" + } + PlasmaComponents.Button { + text: "test" + flat: true + } + PlasmaComponents.ToolButton { + text: "test" + } + } +} +