diff options
Diffstat (limited to 'quickshell/modules/bar/Bar.qml')
| -rw-r--r-- | quickshell/modules/bar/Bar.qml | 171 |
1 files changed, 171 insertions, 0 deletions
diff --git a/quickshell/modules/bar/Bar.qml b/quickshell/modules/bar/Bar.qml new file mode 100644 index 0000000..e983faf --- /dev/null +++ b/quickshell/modules/bar/Bar.qml @@ -0,0 +1,171 @@ +import QtQuick +import QtQuick.Layouts +import Quickshell +import "../../config.js" as Config + +PanelWindow { + id: bar + + required property var modelData + screen: modelData + + readonly property bool atBottom: Config.barPosition === "bottom" + readonly property real hiddenY: atBottom ? Config.barHeight : -Config.barHeight + + anchors { + top: !bar.atBottom + bottom: bar.atBottom + left: true + right: true + } + + implicitHeight: Config.barHeight + color: "transparent" + + Rectangle { + id: content + + anchors.fill: parent + color: Config.barBackground + opacity: 0 + y: bar.hiddenY + + RowLayout { + anchors { + left: parent.left + leftMargin: Config.barMargin + verticalCenter: parent.verticalCenter + } + + spacing: Config.workspaceSpacing + + Loader { + active: true + sourceComponent: Workspaces {} + } + } + + Rectangle { + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + + height: Config.blockHeight + width: windowTitle.contentWidth + Config.blockPadding + radius: Config.blockRadius + color: "transparent" + + Text { + id: windowTitle + + anchors.centerIn: parent + + text: (niri.focusedWindow?.appId === "firefox" || + niri.focusedWindow?.appId === "firefox-bin") + ? "Mozilla Firefox" + : (niri.focusedWindow?.appId === "vesktop" || + niri.focusedWindow?.appId === "vesktop-bin") + ? "Vesktop" + : (niri.focusedWindow?.appId === "equibop" || + niri.focusedWindow?.appId === "equibop-bin") + ? "Equibop" + : (niri.focusedWindow?.title ?? "") + + + color: Config.textWindow + + font.family: Config.fontFamily + font.pixelSize: Config.fontSize + font.bold: true + + elide: Text.ElideRight + } + } + + RowLayout { + id: rightLayout + + anchors { + right: parent.right + rightMargin: Config.barMargin + verticalCenter: parent.verticalCenter + } + + spacing: Config.workspaceSpacing + + Loader { + active: true + sourceComponent: Music {} + } + + Loader { + active: true + sourceComponent: Time {} + } + + Loader { + active: true + sourceComponent: QuickControl {} + } + } + } + + ParallelAnimation { + id: showAnimation + + NumberAnimation { + target: content + property: "y" + from: bar.hiddenY + to: 0 + duration: Config.barAnimationDuration + easing.type: Easing.OutCubic + } + + NumberAnimation { + target: content + property: "opacity" + from: 0 + to: 1 + duration: Config.barAnimationDuration + easing.type: Easing.OutCubic + } + } + + ParallelAnimation { + id: hideAnimation + + NumberAnimation { + target: content + property: "y" + from: 0 + to: bar.hiddenY + duration: Config.barAnimationDuration + easing.type: Easing.InCubic + } + + NumberAnimation { + target: content + property: "opacity" + from: 1 + to: 0 + duration: Config.barAnimationDuration + easing.type: Easing.InCubic + } + + onFinished: { + showAnimation.start() + } + } + + Component.onCompleted: { + showAnimation.start() + } + + function restart() { + showAnimation.stop() + hideAnimation.stop() + hideAnimation.start() + } +} |
