diff --git a/src/declarativeimports/plasmacomponents3/Button.qml b/src/declarativeimports/plasmacomponents3/Button.qml index 68383138c..428101f88 100644 --- a/src/declarativeimports/plasmacomponents3/Button.qml +++ b/src/declarativeimports/plasmacomponents3/Button.qml @@ -1,92 +1,93 @@ /* * Copyright 2016 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.6 import QtQuick.Templates 2.0 as T import org.kde.plasma.core 2.0 as PlasmaCore import "private" as Private T.Button { id: control - implicitWidth: Math.max(background ? background.implicitWidth : 0, + implicitWidth: Math.max(background.implicitWidth, contentItem.implicitWidth + leftPadding + rightPadding) - implicitHeight: Math.max(units.gridUnit * 1.6, contentItem.implicitHeight + topPadding + bottomPadding) + implicitHeight: Math.max(background.implicitHeight, contentItem.implicitHeight + topPadding + bottomPadding) leftPadding: surfaceNormal.margins.left topPadding: surfaceNormal.margins.top rightPadding: surfaceNormal.margins.right bottomPadding: surfaceNormal.margins.bottom hoverEnabled: true //Qt.styleHints.useHoverEffects TODO: how to make this work in 5.7? contentItem: Label { text: control.text font: control.font opacity: enabled || control.highlighted || control.checked ? 1 : 0.4 color: theme.buttonTextColor horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter elide: Text.ElideRight } background: Item { //retrocompatibility with old controls implicitWidth: units.gridUnit * 6 + implicitHeight: units.gridUnit * 1.6 Private.ButtonShadow { anchors.fill: parent state: { if (control.pressed) { return "hidden" } else if (control.hovered) { return "hover" } else if (control.activeFocus) { return "focus" } else { return "shadow" } } } PlasmaCore.FrameSvgItem { id: surfaceNormal anchors.fill: parent imagePath: "widgets/button" prefix: "normal" opacity: control.checked || control.pressed ? 0 : 1 Behavior on opacity { OpacityAnimator { duration: units.longDuration easing.type: Easing.InOutQuad } } } PlasmaCore.FrameSvgItem { anchors.fill: parent imagePath: "widgets/button" prefix: "pressed" opacity: control.checked || control.pressed ? 1 : 0 Behavior on opacity { OpacityAnimator { duration: units.longDuration easing.type: Easing.InOutQuad } } } } } diff --git a/src/declarativeimports/plasmacomponents3/CheckIndicator.qml b/src/declarativeimports/plasmacomponents3/CheckIndicator.qml index 98ba3e249..a7c74ca74 100644 --- a/src/declarativeimports/plasmacomponents3/CheckIndicator.qml +++ b/src/declarativeimports/plasmacomponents3/CheckIndicator.qml @@ -1,65 +1,64 @@ /* * Copyright 2016 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.6 import org.kde.plasma.core 2.0 as PlasmaCore import "private" as Private PlasmaCore.FrameSvgItem { id: root property Item control imagePath: "widgets/button" prefix: "normal" implicitWidth: units.gridUnit implicitHeight: units.gridUnit opacity: control.enabled ? 1 : 0.6 - property int checkState: control.checkState PlasmaCore.SvgItem { svg: PlasmaCore.Svg { id: checkmarkSvg imagePath: "widgets/checkmarks" } elementId: "checkbox" opacity: { - switch (root.checkState) { + switch (control.checkState) { case Qt.Checked: return 1; case Qt.PartiallyChecked: return 0.5; default: return 0; } } anchors { fill: parent } Behavior on opacity { NumberAnimation { duration: units.longDuration easing.type: Easing.InOutQuad } } } Private.ButtonShadow { z: -1 anchors.fill: parent state: control.activeFocus ? "focus" : (control.hovered ? "hover" : "shadow") } } diff --git a/src/declarativeimports/plasmacomponents3/ToolButton.qml b/src/declarativeimports/plasmacomponents3/ToolButton.qml index 6390abbf4..61d5cfd13 100644 --- a/src/declarativeimports/plasmacomponents3/ToolButton.qml +++ b/src/declarativeimports/plasmacomponents3/ToolButton.qml @@ -1,94 +1,96 @@ /* * Copyright 2016 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.6 import QtQuick.Templates 2.0 as T import org.kde.plasma.core 2.0 as PlasmaCore import "private" as Private T.ToolButton { id: control - implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding - implicitHeight: Math.max(units.gridUnit * 1.6, contentItem.implicitHeight + topPadding + bottomPadding) + implicitWidth: Math.max(background.implicitWidth, + contentItem.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(background.implicitHeight, contentItem.implicitHeight + topPadding + bottomPadding) leftPadding: surfaceNormal.margins.left topPadding: surfaceNormal.margins.top rightPadding: surfaceNormal.margins.right bottomPadding: surfaceNormal.margins.bottom hoverEnabled: true //Qt.styleHints.useHoverEffects TODO: how to make this work in 5.7? flat: true contentItem: Label { text: control.text font: control.font opacity: enabled || control.highlighted || control.checked ? 1 : 0.4 color: theme.buttonTextColor horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter elide: Text.ElideRight } background: Item { //retrocompatibility with old controls implicitWidth: units.gridUnit * 6 + 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" } else if (control.hovered) { return "hover" } else if (control.activeFocus) { return "focus" } else { return "shadow" } } } PlasmaCore.FrameSvgItem { id: surfaceNormal anchors.fill: parent imagePath: "widgets/button" prefix: "normal" opacity: (!control.flat || control.hovered) && (!control.pressed || !control.checked) ? 1 : 0 Behavior on opacity { OpacityAnimator { duration: units.longDuration easing.type: Easing.InOutQuad } } } PlasmaCore.FrameSvgItem { anchors.fill: parent imagePath: "widgets/button" prefix: "pressed" opacity: control.checked || control.pressed ? 1 : 0 Behavior on opacity { OpacityAnimator { duration: units.longDuration easing.type: Easing.InOutQuad } } } } } diff --git a/src/declarativeimports/plasmacomponents3/qmldir b/src/declarativeimports/plasmacomponents3/qmldir index 2c6b3fb5f..a5ab8dbc6 100644 --- a/src/declarativeimports/plasmacomponents3/qmldir +++ b/src/declarativeimports/plasmacomponents3/qmldir @@ -1,39 +1,36 @@ module org.kde.plasma.components BusyIndicator 3.0 BusyIndicator.qml Button 3.0 Button.qml CheckBox 3.0 CheckBox.qml CheckDelegate 3.0 CheckDelegate.qml -CheckIndicator 3.0 CheckIndicator.qml ComboBox 3.0 ComboBox.qml Container 3.0 Container.qml Control 3.0 Control.qml DialogButtonBox 3.0 DialogButtonBox.qml Dialog 3.0 Dialog.qml Dial 3.0 Dial.qml Drawer 3.0 Drawer.qml Frame 3.0 Frame.qml GroupBox 3.0 GroupBox.qml ItemDelegate 3.0 ItemDelegate.qml Label 3.0 Label.qml MenuItem 3.0 MenuItem.qml Menu 3.0 Menu.qml Popup 3.0 Popup.qml ProgressBar 3.0 ProgressBar.qml RadioButton 3.0 RadioButton.qml RadioDelegate 3.0 RadioDelegate.qml -RadioIndicator 3.0 RadioIndicator.qml RangeSlider 3.0 RangeSlider.qml ScrollBar 3.0 ScrollBar.qml Slider 3.0 Slider.qml SpinBox 3.0 SpinBox.qml SwitchDelegate 3.0 SwitchDelegate.qml -SwitchIndicator 3.0 SwitchIndicator.qml Switch 3.0 Switch.qml TabBar 3.0 TabBar.qml TabButton 3.0 TabButton.qml TextArea 3.0 TextArea.qml TextField 3.0 TextField.qml ToolBar 3.0 ToolBar.qml ToolButton 3.0 ToolButton.qml ToolTip 3.0 ToolTip.qml