mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
NButton: fix issue when no icon defined
This commit is contained in:
@@ -130,4 +130,4 @@ NBox {
|
||||
NBusyIndicator {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+17
-19
@@ -80,29 +80,27 @@ Rectangle {
|
||||
spacing: Style.marginXS * scaling
|
||||
|
||||
// Icon (optional)
|
||||
Loader {
|
||||
active: root.icon !== ""
|
||||
sourceComponent: NIcon {
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
NIcon {
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
visible: root.icon !== ""
|
||||
|
||||
icon: root.icon
|
||||
font.pointSize: root.iconSize
|
||||
color: {
|
||||
if (!root.enabled)
|
||||
return Color.mOnSurfaceVariant
|
||||
if (root.outlined) {
|
||||
if (root.pressed || root.hovered)
|
||||
return root.backgroundColor
|
||||
icon: root.icon
|
||||
font.pointSize: root.iconSize
|
||||
color: {
|
||||
if (!root.enabled)
|
||||
return Color.mOnSurfaceVariant
|
||||
if (root.outlined) {
|
||||
if (root.pressed || root.hovered)
|
||||
return root.backgroundColor
|
||||
}
|
||||
return root.textColor
|
||||
return root.backgroundColor
|
||||
}
|
||||
return root.textColor
|
||||
}
|
||||
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: Style.animationFast
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: Style.animationFast
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-1
@@ -7,8 +7,12 @@ Text {
|
||||
readonly property string defaultIcon: "balloon"
|
||||
property string icon: defaultIcon
|
||||
|
||||
visible: (icon !== undefined) && (icon !== "")
|
||||
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.callStack()
|
||||
return Bootstrap.icons[defaultIcon]
|
||||
|
||||
Reference in New Issue
Block a user