diff --git a/src/declarativeimports/plasmacomponents3/CheckBox.qml b/src/declarativeimports/plasmacomponents3/CheckBox.qml index 04e90ae50..be71e6104 100644 --- a/src/declarativeimports/plasmacomponents3/CheckBox.qml +++ b/src/declarativeimports/plasmacomponents3/CheckBox.qml @@ -18,6 +18,7 @@ */ import QtQuick 2.6 +import QtQuick.Layouts 1.3 import QtQuick.Templates @QQC2_VERSION@ as T import QtQuick.Controls @QQC2_VERSION@ import org.kde.plasma.core 2.0 as PlasmaCore @@ -32,8 +33,9 @@ T.CheckBox { indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding) baselineOffset: contentItem.y + contentItem.baselineOffset - padding: 1 - spacing: Math.round(units.gridUnit / 8) + leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0 + rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0 + spacing: units.smallSpacing hoverEnabled: true @@ -47,16 +49,26 @@ T.CheckBox { control: control } - contentItem: Label { - leftPadding: control.indicator && !control.mirrored ? control.indicator.width + control.spacing : 0 - rightPadding: control.indicator && control.mirrored ? control.indicator.width + control.spacing : 0 + contentItem: RowLayout { opacity: control.enabled ? 1 : 0.6 - text: control.text - font: control.font - color: PlasmaCore.ColorScope.textColor - elide: Text.ElideRight - visible: control.text - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter + spacing: units.smallSpacing + + PlasmaCore.IconItem { + source: control.icon.name || control.icon.source + visible: source.length > 0 + + implicitWidth: units.iconSizes.smallMedium + implicitHeight: units.iconSizes.smallMedium + } + + Label { + text: control.text + font: control.font + color: PlasmaCore.ColorScope.textColor + elide: Text.ElideRight + visible: control.text + horizontalAlignment: Text.AlignLeft + verticalAlignment: Text.AlignVCenter + } } } diff --git a/tests/components/checkbox3.qml b/tests/components/checkbox3.qml index e71c438cc..0e13e0110 100644 --- a/tests/components/checkbox3.qml +++ b/tests/components/checkbox3.qml @@ -17,6 +17,21 @@ ComponentBase { text: "Some awesome checkbox" } + PlasmaComponents.Label { + text: "icon" + } + PlasmaComponents.CheckBox { + icon.name: "start-here-kde-plasma" + } + + PlasmaComponents.Label { + text: "text plus icon" + } + PlasmaComponents.CheckBox { + text: "text" + icon.name: "start-here-kde-plasma" + } + PlasmaComponents.Label { text: "focus" }