From 50d8b54adf116432e244929f823039ea298d5a1e Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Sat, 13 Sep 2025 10:11:57 +0200 Subject: [PATCH] Bar: add floating setting --- Commons/Settings.qml | 8 ++ Modules/Background/ScreenCorners.qml | 2 +- Modules/Bar/Bar.qml | 11 ++ Modules/SettingsPanel/Tabs/BarTab.qml | 196 ++++++++++++++++++++++++++ 4 files changed, 216 insertions(+), 1 deletion(-) diff --git a/Commons/Settings.qml b/Commons/Settings.qml index 567435d..faf0a87 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -267,6 +267,14 @@ Singleton { property real backgroundOpacity: 1.0 property list monitors: [] + // Floating bar settings + property bool floating: false + property real rounding: 12.0 + property real marginTop: 16.0 + property real marginBottom: 16.0 + property real marginLeft: 16.0 + property real marginRight: 16.0 + property bool showActiveWindowIcon: true // TODO: delete property bool alwaysShowBatteryPercentage: false // TODO: delete property bool showNetworkStats: false // TODO: delete diff --git a/Modules/Background/ScreenCorners.qml b/Modules/Background/ScreenCorners.qml index 51aed9c..de720c4 100644 --- a/Modules/Background/ScreenCorners.qml +++ b/Modules/Background/ScreenCorners.qml @@ -7,7 +7,7 @@ import qs.Services import qs.Widgets Loader { - active: Settings.data.general.showScreenCorners + active: Settings.data.general.showScreenCorners && !Settings.data.bar.floating sourceComponent: Variants { model: Quickshell.screens diff --git a/Modules/Bar/Bar.qml b/Modules/Bar/Bar.qml index b2e6850..b4fc4fe 100644 --- a/Modules/Bar/Bar.qml +++ b/Modules/Bar/Bar.qml @@ -44,6 +44,14 @@ Variants { right: true } + // Floating bar margins - only apply when floating is enabled + margins { + top: Settings.data.bar.marginTop + bottom: Settings.data.bar.marginBottom + left: Settings.data.bar.floating ? Settings.data.bar.marginLeft : 0 + right: Settings.data.bar.floating ? Settings.data.bar.marginRight : 0 + } + Item { anchors.fill: parent clip: true @@ -54,6 +62,9 @@ Variants { anchors.fill: parent color: Qt.alpha(Color.mSurface, Settings.data.bar.backgroundOpacity) + + // Floating bar rounded corners + radius: Settings.data.bar.floating ? Settings.data.bar.rounding : 0 } // ------------------------------ diff --git a/Modules/SettingsPanel/Tabs/BarTab.qml b/Modules/SettingsPanel/Tabs/BarTab.qml index 396191a..ae502ce 100644 --- a/Modules/SettingsPanel/Tabs/BarTab.qml +++ b/Modules/SettingsPanel/Tabs/BarTab.qml @@ -86,6 +86,202 @@ ColumnLayout { } } } + + NToggle { + Layout.fillWidth: true + label: "Floating Bar" + description: "Make the bar float with rounded corners and margins. This will hide screen corners." + checked: Settings.data.bar.floating + onToggled: checked => Settings.data.bar.floating = checked + } + + // Floating bar options - only show when floating is enabled + ColumnLayout { + visible: Settings.data.bar.floating + spacing: Style.marginXXS * scaling + Layout.fillWidth: true + + NText { + text: "Rounding" + font.pointSize: Style.fontSizeL * scaling + font.weight: Style.fontWeightBold + color: Color.mOnSurface + } + + NText { + text: "Adjust the corner rounding of the floating bar." + font.pointSize: Style.fontSizeXS * scaling + color: Color.mOnSurfaceVariant + wrapMode: Text.WordWrap + Layout.fillWidth: true + } + + RowLayout { + NSlider { + Layout.fillWidth: true + from: 0 + to: 50 + stepSize: 1 + value: Settings.data.bar.rounding + onMoved: Settings.data.bar.rounding = value + cutoutColor: Color.mSurface + } + + NText { + text: Math.round(Settings.data.bar.rounding) + "px" + Layout.alignment: Qt.AlignVCenter + Layout.leftMargin: Style.marginS * scaling + Layout.preferredWidth: 50 + horizontalAlignment: Text.AlignRight + color: Color.mOnSurface + } + } + + NText { + text: "Margins" + font.pointSize: Style.fontSizeL * scaling + font.weight: Style.fontWeightBold + color: Color.mOnSurface + Layout.topMargin: Style.marginM * scaling + } + + NText { + text: "Adjust the margins around the floating bar." + font.pointSize: Style.fontSizeXS * scaling + color: Color.mOnSurfaceVariant + wrapMode: Text.WordWrap + Layout.fillWidth: true + } + + GridLayout { + columns: 2 + Layout.fillWidth: true + rowSpacing: Style.marginS * scaling + columnSpacing: Style.marginS * scaling + + ColumnLayout { + spacing: Style.marginXXS * scaling + + NText { + text: "Top" + font.pointSize: Style.fontSizeXS * scaling + color: Color.mOnSurfaceVariant + } + + RowLayout { + NSlider { + Layout.fillWidth: true + from: 0 + to: 50 + stepSize: 1 + value: Settings.data.bar.marginTop + onMoved: Settings.data.bar.marginTop = value + cutoutColor: Color.mSurface + } + + NText { + text: Math.round(Settings.data.bar.marginTop) + "px" + Layout.alignment: Qt.AlignVCenter + Layout.leftMargin: Style.marginXS * scaling + color: Color.mOnSurface + } + } + } + + ColumnLayout { + spacing: Style.marginXXS * scaling + + NText { + text: "Bottom" + font.pointSize: Style.fontSizeXS * scaling + color: Color.mOnSurfaceVariant + } + + RowLayout { + NSlider { + Layout.fillWidth: true + from: 0 + to: 50 + stepSize: 1 + value: Settings.data.bar.marginBottom + onMoved: Settings.data.bar.marginBottom = value + cutoutColor: Color.mSurface + } + + NText { + text: Math.round(Settings.data.bar.marginBottom) + "px" + Layout.alignment: Qt.AlignVCenter + Layout.leftMargin: Style.marginXS * scaling + Layout.preferredWidth: 50 + horizontalAlignment: Text.AlignRight + color: Color.mOnSurface + } + } + } + + ColumnLayout { + spacing: Style.marginXXS * scaling + + NText { + text: "Left" + font.pointSize: Style.fontSizeXS * scaling + color: Color.mOnSurfaceVariant + } + + RowLayout { + NSlider { + Layout.fillWidth: true + from: 0 + to: 50 + stepSize: 1 + value: Settings.data.bar.marginLeft + onMoved: Settings.data.bar.marginLeft = value + cutoutColor: Color.mSurface + } + + NText { + text: Math.round(Settings.data.bar.marginLeft) + "px" + Layout.alignment: Qt.AlignVCenter + Layout.leftMargin: Style.marginXS * scaling + Layout.preferredWidth: 50 + horizontalAlignment: Text.AlignRight + color: Color.mOnSurface + } + } + } + + ColumnLayout { + spacing: Style.marginXXS * scaling + + NText { + text: "Right" + font.pointSize: Style.fontSizeXS * scaling + color: Color.mOnSurfaceVariant + } + + RowLayout { + NSlider { + Layout.fillWidth: true + from: 0 + to: 50 + stepSize: 1 + value: Settings.data.bar.marginRight + onMoved: Settings.data.bar.marginRight = value + cutoutColor: Color.mSurface + } + + NText { + text: Math.round(Settings.data.bar.marginRight) + "px" + Layout.alignment: Qt.AlignVCenter + Layout.leftMargin: Style.marginXS * scaling + Layout.preferredWidth: 50 + horizontalAlignment: Text.AlignRight + color: Color.mOnSurface + } + } + } + } + } } NDivider {