108 lines
2.9 KiB
QML
108 lines
2.9 KiB
QML
import QtQuick
|
|
import QtQuick.Layouts
|
|
import QtQuick.Effects
|
|
import Quickshell
|
|
import "../core"
|
|
|
|
Item {
|
|
id: root
|
|
|
|
property bool active: true
|
|
property bool clickable: false
|
|
|
|
// Inner content configuration
|
|
property string icon: ""
|
|
property string text: ""
|
|
property Component customContent: null
|
|
|
|
// Popup configuration
|
|
property var popupItem: null
|
|
|
|
// Styling
|
|
property color pillColor: Theme.bgAlt
|
|
|
|
// Standard pill dimensions
|
|
implicitHeight: 28
|
|
|
|
// Monitor tracking for exclusive visibility
|
|
property var monitor: null
|
|
property bool exclusiveToScreen: false
|
|
property bool isFocusedMonitor: monitor ? monitor.focused : true
|
|
property bool effectivelyActive: active && (!exclusiveToScreen || isFocusedMonitor)
|
|
|
|
// Fluid auto-hide transitions
|
|
visible: opacity > 0
|
|
opacity: effectivelyActive ? 1 : 0
|
|
implicitWidth: effectivelyActive ? contentRow.implicitWidth + (Theme.padding * 2) : 0
|
|
clip: false // Turn off clip so shadow isn't cut off
|
|
|
|
Behavior on opacity {
|
|
NumberAnimation { duration: 250; easing.type: Easing.InOutQuad }
|
|
}
|
|
Behavior on implicitWidth {
|
|
NumberAnimation { duration: 250; easing.type: Easing.OutBack }
|
|
}
|
|
|
|
// Shadow Effect
|
|
MultiEffect {
|
|
anchors.fill: bgRect
|
|
source: bgRect
|
|
shadowEnabled: true
|
|
shadowColor: "#000000"
|
|
shadowOpacity: 0.4
|
|
shadowBlur: 0.8
|
|
shadowVerticalOffset: 2
|
|
shadowHorizontalOffset: 0
|
|
}
|
|
|
|
Rectangle {
|
|
id: bgRect
|
|
anchors.fill: parent
|
|
radius: Theme.radius / 2
|
|
color: (clickable || popupItem !== null) && mouseArea.containsMouse ? Qt.darker(root.pillColor, 1.2) : root.pillColor
|
|
|
|
RowLayout {
|
|
id: contentRow
|
|
anchors.centerIn: parent
|
|
spacing: 6
|
|
|
|
Loader {
|
|
active: root.customContent !== null
|
|
sourceComponent: root.customContent
|
|
Layout.alignment: Qt.AlignVCenter
|
|
}
|
|
|
|
Text {
|
|
visible: root.icon !== "" && root.customContent === null
|
|
text: root.icon
|
|
color: Theme.fg
|
|
font: Theme.font
|
|
Layout.alignment: Qt.AlignVCenter
|
|
}
|
|
|
|
Text {
|
|
visible: root.text !== "" && root.customContent === null
|
|
text: root.text
|
|
color: Theme.fg
|
|
font: Theme.fontBold
|
|
Layout.alignment: Qt.AlignVCenter
|
|
}
|
|
}
|
|
}
|
|
|
|
MouseArea {
|
|
id: mouseArea
|
|
anchors.fill: parent
|
|
hoverEnabled: root.clickable || root.popupItem !== null
|
|
cursorShape: (root.clickable || root.popupItem !== null) ? Qt.PointingHandCursor : Qt.ArrowCursor
|
|
onClicked: {
|
|
if (root.popupItem !== null) {
|
|
root.popupItem.visible = !root.popupItem.visible;
|
|
}
|
|
root.clicked();
|
|
}
|
|
}
|
|
|
|
signal clicked()
|
|
}
|