NButton: fix issue when no icon defined
This commit is contained in:
parent
fe139c208a
commit
a6ccc8b0da
3 changed files with 23 additions and 21 deletions
|
|
@ -130,4 +130,4 @@ NBox {
|
||||||
NBusyIndicator {}
|
NBusyIndicator {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,29 +80,27 @@ Rectangle {
|
||||||
spacing: Style.marginXS * scaling
|
spacing: Style.marginXS * scaling
|
||||||
|
|
||||||
// Icon (optional)
|
// Icon (optional)
|
||||||
Loader {
|
NIcon {
|
||||||
active: root.icon !== ""
|
Layout.alignment: Qt.AlignVCenter
|
||||||
sourceComponent: NIcon {
|
visible: root.icon !== ""
|
||||||
Layout.alignment: Qt.AlignVCenter
|
|
||||||
|
|
||||||
icon: root.icon
|
icon: root.icon
|
||||||
font.pointSize: root.iconSize
|
font.pointSize: root.iconSize
|
||||||
color: {
|
color: {
|
||||||
if (!root.enabled)
|
if (!root.enabled)
|
||||||
return Color.mOnSurfaceVariant
|
return Color.mOnSurfaceVariant
|
||||||
if (root.outlined) {
|
if (root.outlined) {
|
||||||
if (root.pressed || root.hovered)
|
if (root.pressed || root.hovered)
|
||||||
return root.backgroundColor
|
|
||||||
return root.backgroundColor
|
return root.backgroundColor
|
||||||
}
|
return root.backgroundColor
|
||||||
return root.textColor
|
|
||||||
}
|
}
|
||||||
|
return root.textColor
|
||||||
|
}
|
||||||
|
|
||||||
Behavior on color {
|
Behavior on color {
|
||||||
ColorAnimation {
|
ColorAnimation {
|
||||||
duration: Style.animationFast
|
duration: Style.animationFast
|
||||||
easing.type: Easing.OutCubic
|
easing.type: Easing.OutCubic
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,12 @@ Text {
|
||||||
readonly property string defaultIcon: "balloon"
|
readonly property string defaultIcon: "balloon"
|
||||||
property string icon: defaultIcon
|
property string icon: defaultIcon
|
||||||
|
|
||||||
|
visible: (icon !== undefined) && (icon !== "")
|
||||||
text: {
|
text: {
|
||||||
if (icon === undefined || Bootstrap.icons[icon] === undefined) {
|
if ((icon === undefined) || (icon === "")) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if (Bootstrap.icons[icon] === undefined) {
|
||||||
Logger.warn("Icon", `"${icon}"`, "doesn't exist in the bootstrap font")
|
Logger.warn("Icon", `"${icon}"`, "doesn't exist in the bootstrap font")
|
||||||
Logger.callStack()
|
Logger.callStack()
|
||||||
return Bootstrap.icons[defaultIcon]
|
return Bootstrap.icons[defaultIcon]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue