58 lines
1.9 KiB
QML
58 lines
1.9 KiB
QML
import QtQuick
|
|
import "../config" as Cfg
|
|
|
|
Rectangle {
|
|
id: chip
|
|
|
|
property real panelRadius: Cfg.Config.radius / 2
|
|
property int borderWidth: Cfg.Config.panelBorderWidth
|
|
property bool isTop: true
|
|
property var targetScreen: null
|
|
property int barHeight: Cfg.Config.barHeight
|
|
property int barMargin: Cfg.Config.margin
|
|
property int barEdgePad: Cfg.Config.frameVariant === "bar" ? (Cfg.Config.barPosition === "top" ? Cfg.Config.frameBarPadTop : Cfg.Config.frameBarPadBottom) : 0
|
|
readonly property var t: Cfg.Config.theme
|
|
|
|
property bool moduleEnabled: true
|
|
|
|
property bool hovered: false
|
|
property bool popupOpen: false
|
|
|
|
property color chipColor: "transparent"
|
|
property color chipColorHovered: "transparent"
|
|
property color chipBorderColor: "transparent"
|
|
property color chipBorderColorHovered: "transparent"
|
|
property bool chipHoverEnabled: false
|
|
property var chipTapAction: null
|
|
|
|
property int chipAnimDuration: 150
|
|
property bool chipAnimWidth: false
|
|
property bool chipAnimImplicitWidth: false
|
|
|
|
radius: panelRadius
|
|
color: hovered ? chipColorHovered : chipColor
|
|
border.color: (hovered || popupOpen) ? chipBorderColorHovered : chipBorderColor
|
|
border.width: borderWidth
|
|
|
|
Behavior on color { ColorAnimation { duration: chip.chipAnimDuration } }
|
|
Behavior on border.color { ColorAnimation { duration: chip.chipAnimDuration } }
|
|
Behavior on width {
|
|
NumberAnimation { duration: 250; easing.type: Easing.OutCubic }
|
|
enabled: chipAnimWidth
|
|
}
|
|
Behavior on implicitWidth {
|
|
NumberAnimation { duration: 250; easing.type: Easing.OutCubic }
|
|
enabled: chipAnimImplicitWidth
|
|
}
|
|
|
|
HoverHandler {
|
|
id: hoverHandler
|
|
cursorShape: chipHoverEnabled ? Qt.PointingHandCursor : Qt.ArrowCursor
|
|
onHoveredChanged: chip.hovered = hovered
|
|
}
|
|
|
|
TapHandler {
|
|
onTapped: if (chip.chipTapAction) chip.chipTapAction()
|
|
}
|
|
}
|