bar: add shortened form for narrow screens

This commit is contained in:
end-4
2025-05-24 11:15:47 +02:00
parent ddb434662b
commit 0e74fc78e5
2 changed files with 11 additions and 5 deletions
+9 -4
View File
@@ -17,7 +17,6 @@ Scope {
id: bar id: bar
readonly property int barHeight: Appearance.sizes.barHeight readonly property int barHeight: Appearance.sizes.barHeight
readonly property int barCenterSideModuleWidth: Appearance.sizes.barCenterSideModuleWidth
readonly property int osdHideMouseMoveThreshold: 20 readonly property int osdHideMouseMoveThreshold: 20
property bool showBarBackground: ConfigOptions.bar.showBackground property bool showBarBackground: ConfigOptions.bar.showBackground
@@ -26,11 +25,14 @@ Scope {
PanelWindow { // Bar window PanelWindow { // Bar window
id: barRoot id: barRoot
screen: modelData
property ShellScreen modelData property ShellScreen modelData
property var brightnessMonitor: Brightness.getMonitorForScreen(modelData) property var brightnessMonitor: Brightness.getMonitorForScreen(modelData)
property bool useShortenedForm: Appearance.sizes.barShortenScreenWidth >= screen.width
readonly property int centerSideModuleWidth: useShortenedForm ?
Appearance.sizes.barCenterSideModuleWidthShortened : Appearance.sizes.barCenterSideModuleWidth
screen: modelData
WlrLayershell.namespace: "quickshell:bar" WlrLayershell.namespace: "quickshell:bar"
implicitHeight: barHeight + Appearance.rounding.screenRounding implicitHeight: barHeight + Appearance.rounding.screenRounding
exclusiveZone: showBarBackground ? barHeight : (barHeight - 4) exclusiveZone: showBarBackground ? barHeight : (barHeight - 4)
@@ -160,6 +162,7 @@ Scope {
} }
ActiveWindow { ActiveWindow {
visible: !barRoot.useShortenedForm
Layout.rightMargin: Appearance.rounding.screenRounding Layout.rightMargin: Appearance.rounding.screenRounding
Layout.fillWidth: true Layout.fillWidth: true
bar: barRoot bar: barRoot
@@ -174,7 +177,7 @@ Scope {
spacing: 8 spacing: 8
RowLayout { RowLayout {
Layout.preferredWidth: barCenterSideModuleWidth Layout.preferredWidth: barRoot.centerSideModuleWidth
spacing: 4 spacing: 4
Layout.fillHeight: true Layout.fillHeight: true
implicitWidth: 350 implicitWidth: 350
@@ -209,7 +212,7 @@ Scope {
} }
RowLayout { RowLayout {
Layout.preferredWidth: barCenterSideModuleWidth Layout.preferredWidth: barRoot.centerSideModuleWidth
Layout.fillHeight: true Layout.fillHeight: true
spacing: 4 spacing: 4
@@ -219,6 +222,7 @@ Scope {
} }
UtilButtons { UtilButtons {
visible: !barRoot.useShortenedForm
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
} }
@@ -393,6 +397,7 @@ Scope {
SysTray { SysTray {
bar: barRoot bar: barRoot
visible: !barRoot.useShortenedForm
Layout.fillWidth: false Layout.fillWidth: false
Layout.fillHeight: true Layout.fillHeight: true
} }
@@ -259,7 +259,8 @@ Singleton {
sizes: QtObject { sizes: QtObject {
property real barHeight: 40 property real barHeight: 40
property real barCenterSideModuleWidth: 360 property real barCenterSideModuleWidth: 360
property real barPreferredSideSectionWidth: 400 property real barCenterSideModuleWidthShortened: 280
property real barShortenScreenWidth: 1200 // Bar will be shortened if screen width is at most this value
property real sidebarWidth: 460 property real sidebarWidth: 460
property real sidebarWidthExtended: 750 property real sidebarWidthExtended: 750
property real osdWidth: 200 property real osdWidth: 200