nosignal-shell/components/controls/IconButton.qml
2026-05-02 18:56:56 +10:00

44 lines
1.4 KiB
QML

import QtQuick
import Caelestia.Config
import qs.components
import qs.services
ButtonBase {
id: root
property alias icon: label.text
readonly property alias label: label
padding: type === IconButton.Text ? Tokens.padding.extraSmall / 2 : Tokens.padding.small
activeColour: type === IconButton.Filled ? Colours.palette.m3primary : Colours.palette.m3secondary
inactiveColour: {
if (!isToggle && type === IconButton.Filled)
return Colours.palette.m3primary;
return type === IconButton.Filled ? Colours.tPalette.m3surfaceContainer : Colours.palette.m3secondaryContainer;
}
activeOnColour: type === IconButton.Filled ? Colours.palette.m3onPrimary : type === IconButton.Tonal ? Colours.palette.m3onSecondary : Colours.palette.m3primary
inactiveOnColour: {
if (!isToggle && type === IconButton.Filled)
return Colours.palette.m3onPrimary;
return type === IconButton.Tonal ? Colours.palette.m3onSecondaryContainer : Colours.palette.m3onSurfaceVariant;
}
implicitWidth: implicitHeight
implicitHeight: label.implicitHeight + padding * 2
MaterialIcon {
id: label
anchors.centerIn: parent
color: root.onColour
fontStyle: root.font
fill: !root.isToggle || root.internalChecked ? 1 : 0
Behavior on fill {
Anim {
type: Anim.DefaultEffects
}
}
}
}