Changeset View
Changeset View
Standalone View
Standalone View
applet/contents/ui/SwitchButton.qml
Show All 26 Lines | 25 | Item { | |||
---|---|---|---|---|---|
27 | 27 | | |||
28 | property alias icon: switchButtonIcon.source | 28 | property alias icon: switchButtonIcon.source | ||
29 | property alias checked: switchButtonCheckbox.checked | 29 | property alias checked: switchButtonCheckbox.checked | ||
30 | property alias enabled: switchButtonCheckbox.enabled | 30 | property alias enabled: switchButtonCheckbox.enabled | ||
31 | property alias tooltip: switchButtonCheckbox.tooltip | 31 | property alias tooltip: switchButtonCheckbox.tooltip | ||
32 | 32 | | |||
33 | signal clicked | 33 | signal clicked | ||
34 | 34 | | |||
35 | height: switchButtonIcon.height + units.gridUnit / 2 | 35 | height: Math.max(switchButtonCheckbox.height, switchButtonIcon.height) | ||
36 | width: switchButtonCheckbox.width + switchButtonIcon.width + units.gridUnit | 36 | width: switchButtonCheckbox.width + switchButtonIcon.width + units.gridUnit | ||
37 | 37 | | |||
38 | PlasmaComponents.CheckBox { | 38 | PlasmaComponents.CheckBox { | ||
39 | id: switchButtonCheckbox | 39 | id: switchButtonCheckbox | ||
40 | anchors { | 40 | anchors { | ||
41 | bottomMargin: Math.round(units.gridUnit / 3) | | |||
42 | left: parent.left | 41 | left: parent.left | ||
43 | leftMargin: units.gridUnit / 2 | 42 | leftMargin: units.smallSpacing | ||
44 | topMargin: Math.round(units.gridUnit / 3) | | |||
45 | verticalCenter: parent.verticalCenter | | |||
46 | } | 43 | } | ||
47 | 44 | | |||
48 | onClicked: { | 45 | onClicked: { | ||
49 | switchButton.clicked() | 46 | switchButton.clicked() | ||
50 | } | 47 | } | ||
51 | } | 48 | } | ||
52 | 49 | | |||
53 | PlasmaCore.IconItem { | 50 | PlasmaCore.IconItem { | ||
54 | id: switchButtonIcon | 51 | id: switchButtonIcon | ||
55 | anchors { | 52 | anchors { | ||
56 | left: switchButtonCheckbox.right | 53 | left: switchButtonCheckbox.right | ||
57 | leftMargin: units.gridUnit / 2 | 54 | // Checkbox bug adds internally a smallSpacing on the right. Doubling the effective spacing here. | ||
58 | top: switchButtonCheckbox.top | 55 | leftMargin: units.smallSpacing | ||
59 | bottom: switchButtonCheckbox.bottom | 56 | verticalCenter: parent.verticalCenter | ||
broulik: Can this bug be fixed? Or is that because we use a `CheckBox` without a label and so it is icon… | |||||
I made some tests. I even comment out in checkbox style, label and background but always added spacing. gvgeo: I made some tests. I even comment out in checkbox style, label and background but always added… | |||||
60 | } | 57 | } | ||
61 | width: height | 58 | width: units.iconSizes.smallMedium | ||
59 | height: units.iconSizes.smallMedium | ||||
62 | } | 60 | } | ||
63 | } | 61 | } |
Can this bug be fixed? Or is that because we use a CheckBox without a label and so it is icon width + spacing + no label?