Always relayout when changing icon/text/font
Previously we would only relayout when creating/deleting the icon/text, but not when changing it.
E.g. the layout would not change size when text changed.
Probably fixes #13 (haven't actually tested KTrip or NeoChat)
There is one pre-existing bug caused when removing the icon, where the button actually gets a tiny amount larger. I have tracked this down to geometryChange
being called with the wrong geometry (still seems to account for icon size) after emitting hasIconChanged
, so the button uses a geometry larger than it should be using.
Tested with the following code:
ColumnLayout {
QQC2.Button {
id: button
property bool shortMode: true
property bool showIcon: false
property bool useCourierFont: false
property bool smallFontSize: true
text: shortMode ? "Short text" : "Long text button"
icon.name: showIcon ? "go-next" : ""
font.family: useCourierFont ? "Courier" : "Helvetica"
font.pointSize: smallFontSize ? 10 : 15
Layout.alignment: Qt.AlignHCenter
}
QQC2.Button {
text: "Toggle button text length"
onClicked: button.shortMode = !button.shortMode
Layout.alignment: Qt.AlignHCenter
}
QQC2.Button {
text: "Toggle button icon"
onClicked: button.showIcon = !button.showIcon
Layout.alignment: Qt.AlignHCenter
}
QQC2.Button {
text: "Toggle button font family"
onClicked: button.useCourierFont = !button.useCourierFont
Layout.alignment: Qt.AlignHCenter
}
QQC2.Button {
text: "Toggle button font size"
onClicked: button.smallFontSize = !button.smallFontSize
Layout.alignment: Qt.AlignHCenter
}
}
Edited by Noah Davis