import QtQuick import QtQuick.Layouts import "../config/" // Mostly from here: https://github.com/ChrisTitusTech/quickshell/blob/main/bar/BarBlock.qml Rectangle { id: root radius: Appearance.rounding.barItems Layout.preferredWidth: contentContainer.implicitWidth + 20 Layout.preferredHeight: 30 property Item content: Text { text: "No content" } property bool hoverEnabled: false property Item mouseArea: mouseArea property bool dim: false property var onClicked: function () {} property int leftPadding property int rightPadding // Background color color: { if (mouseArea.containsMouse) return Appearance.colors.m3primary; return Appearance.colors.m3background; } states: [ State { when: mouseArea.containsMouse PropertyChanges { target: root } } ] Behavior on color { ColorAnimation { duration: 200 } } Item { // Contents of the bar block id: contentContainer implicitWidth: content.implicitWidth implicitHeight: content.implicitHeight anchors.centerIn: parent children: content } MouseArea { enabled: root.hoverEnabled id: mouseArea anchors.fill: root hoverEnabled: true acceptedButtons: Qt.LeftButton onClicked: root.onClicked() } }