bar: fix bottom mode, add corner style config

This commit is contained in:
end-4
2025-06-29 23:00:57 +02:00
parent 30c54cb7ce
commit 18ea20f1df
8 changed files with 126 additions and 60 deletions
@@ -288,7 +288,9 @@ Singleton {
}
sizes: QtObject {
property real barHeight: 40
property real baseBarHeight: 40
property real barHeight: ConfigOptions.bar.cornerStyle === 1 ?
(baseBarHeight + Appearance.sizes.hyprlandGapsOut * 2) : baseBarHeight
property real barCenterSideModuleWidth: ConfigOptions?.bar.verbose ? 360 : 140
property real barCenterSideModuleWidthShortened: 280
property real barCenterSideModuleWidthHellaShortened: 190
@@ -47,6 +47,7 @@ Singleton {
property QtObject bar: QtObject {
property bool bottom: false // Instead of top
property int cornerStyle: 0 // 0: Hug | 1: Float | 2: Plain rectangle
property bool borderless: false // true for no grouping of items
property string topLeftIcon: "spark" // Options: distro, spark
property bool showBackground: true
@@ -3,24 +3,21 @@ import QtQuick 2.9
Item {
id: root
enum CornerEnum { TopLeft, TopRight, BottomLeft, BottomRight }
property var corner: RoundCorner.CornerEnum.TopLeft // Default to TopLeft
property int size: 25
property color color: "#000000"
onColorChanged: {
canvas.requestPaint();
}
property QtObject cornerEnum: QtObject {
property int topLeft: 0
property int topRight: 1
property int bottomLeft: 2
property int bottomRight: 3
onCornerChanged: {
canvas.requestPaint();
}
property int corner: cornerEnum.topLeft // Default to TopLeft
width: size
height: size
implicitWidth: size
implicitHeight: size
Canvas {
id: canvas
@@ -31,22 +28,22 @@ Item {
onPaint: {
var ctx = getContext("2d");
var r = root.size;
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.beginPath();
switch (root.corner) {
case cornerEnum.topLeft:
case RoundCorner.CornerEnum.TopLeft:
ctx.arc(r, r, r, Math.PI, 3 * Math.PI / 2);
ctx.lineTo(0, 0);
break;
case cornerEnum.topRight:
case RoundCorner.CornerEnum.TopRight:
ctx.arc(0, r, r, 3 * Math.PI / 2, 2 * Math.PI);
ctx.lineTo(r, 0);
break;
case cornerEnum.bottomLeft:
case RoundCorner.CornerEnum.BottomLeft:
ctx.arc(r, 0, r, Math.PI / 2, Math.PI);
ctx.lineTo(0, r);
break;
case cornerEnum.bottomRight:
case RoundCorner.CornerEnum.BottomRight:
ctx.arc(0, 0, r, 0, Math.PI / 2);
ctx.lineTo(r, r);
break;