bar: add "hella shortened" form for even narrower screens

This commit is contained in:
end-4
2025-05-24 11:44:07 +02:00
parent 0e74fc78e5
commit c8a4da6d8b
4 changed files with 32 additions and 10 deletions
+18 -7
View File
@@ -29,9 +29,12 @@ Scope {
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 property real useShortenedForm: (Appearance.sizes.barHellaShortenScreenWidthThreshold >= screen.width) ? 2 :
readonly property int centerSideModuleWidth: useShortenedForm ? (Appearance.sizes.barShortenScreenWidthThreshold >= screen.width) ? 1 : 0
Appearance.sizes.barCenterSideModuleWidthShortened : Appearance.sizes.barCenterSideModuleWidth readonly property int centerSideModuleWidth:
(useShortenedForm == 2) ? Appearance.sizes.barCenterSideModuleWidthHellaShortened :
(useShortenedForm == 1) ? Appearance.sizes.barCenterSideModuleWidthShortened :
Appearance.sizes.barCenterSideModuleWidth
WlrLayershell.namespace: "quickshell:bar" WlrLayershell.namespace: "quickshell:bar"
implicitHeight: barHeight + Appearance.rounding.screenRounding implicitHeight: barHeight + Appearance.rounding.screenRounding
@@ -162,7 +165,7 @@ Scope {
} }
ActiveWindow { ActiveWindow {
visible: !barRoot.useShortenedForm visible: barRoot.useShortenedForm === 0
Layout.rightMargin: Appearance.rounding.screenRounding Layout.rightMargin: Appearance.rounding.screenRounding
Layout.fillWidth: true Layout.fillWidth: true
bar: barRoot bar: barRoot
@@ -177,21 +180,26 @@ Scope {
spacing: 8 spacing: 8
RowLayout { RowLayout {
id: leftCenterGroup
Layout.preferredWidth: barRoot.centerSideModuleWidth Layout.preferredWidth: barRoot.centerSideModuleWidth
spacing: 4 spacing: 4
Layout.fillHeight: true Layout.fillHeight: true
implicitWidth: 350 implicitWidth: 350
Resources { Resources {
alwaysShowAllResources: barRoot.useShortenedForm === 2
Layout.fillWidth: barRoot.useShortenedForm === 2
} }
Media { Media {
visible: barRoot.useShortenedForm < 2
Layout.fillWidth: true Layout.fillWidth: true
} }
} }
RowLayout { RowLayout {
id: middleCenterGroup
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
@@ -212,21 +220,24 @@ Scope {
} }
RowLayout { RowLayout {
Layout.preferredWidth: barRoot.centerSideModuleWidth id: rightCenterGroup
Layout.preferredWidth: leftCenterGroup.width
Layout.fillHeight: true Layout.fillHeight: true
spacing: 4 spacing: 4
ClockWidget { ClockWidget {
showDate: barRoot.useShortenedForm < 2
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
Layout.fillWidth: true Layout.fillWidth: true
} }
UtilButtons { UtilButtons {
visible: !barRoot.useShortenedForm visible: barRoot.useShortenedForm === 0
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
} }
Battery { Battery {
visible: barRoot.useShortenedForm < 2
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
} }
@@ -397,7 +408,7 @@ Scope {
SysTray { SysTray {
bar: barRoot bar: barRoot
visible: !barRoot.useShortenedForm visible: barRoot.useShortenedForm === 0
Layout.fillWidth: false Layout.fillWidth: false
Layout.fillHeight: true Layout.fillHeight: true
} }
@@ -6,6 +6,7 @@ import QtQuick.Layouts
Rectangle { Rectangle {
property bool borderless: ConfigOptions.bar.borderless property bool borderless: ConfigOptions.bar.borderless
property bool showDate: true
implicitWidth: rowLayout.implicitWidth + rowLayout.spacing * 6 // idk, text seems nicer w/ more padding implicitWidth: rowLayout.implicitWidth + rowLayout.spacing * 6 // idk, text seems nicer w/ more padding
implicitHeight: 32 implicitHeight: 32
color: borderless ? "transparent" : Appearance.colors.colLayer1 color: borderless ? "transparent" : Appearance.colors.colLayer1
@@ -24,12 +25,14 @@ Rectangle {
} }
StyledText { StyledText {
visible: showDate
font.pixelSize: Appearance.font.pixelSize.small font.pixelSize: Appearance.font.pixelSize.small
color: Appearance.colors.colOnLayer1 color: Appearance.colors.colOnLayer1
text: "•" text: "•"
} }
StyledText { StyledText {
visible: showDate
font.pixelSize: Appearance.font.pixelSize.small font.pixelSize: Appearance.font.pixelSize.small
color: Appearance.colors.colOnLayer1 color: Appearance.colors.colOnLayer1
text: DateTime.date text: DateTime.date
+8 -2
View File
@@ -8,7 +8,9 @@ import Quickshell.Io
import Quickshell.Services.Mpris import Quickshell.Services.Mpris
Rectangle { Rectangle {
id: root
property bool borderless: ConfigOptions.bar.borderless property bool borderless: ConfigOptions.bar.borderless
property bool alwaysShowAllResources: false
implicitWidth: rowLayout.implicitWidth + rowLayout.anchors.leftMargin + rowLayout.anchors.rightMargin implicitWidth: rowLayout.implicitWidth + rowLayout.anchors.leftMargin + rowLayout.anchors.rightMargin
implicitHeight: 32 implicitHeight: 32
color: borderless ? "transparent" : Appearance.colors.colLayer1 color: borderless ? "transparent" : Appearance.colors.colLayer1
@@ -30,14 +32,18 @@ Rectangle {
Resource { Resource {
iconName: "swap_horiz" iconName: "swap_horiz"
percentage: ResourceUsage.swapUsedPercentage percentage: ResourceUsage.swapUsedPercentage
shown: (ConfigOptions.bar.resources.alwaysShowSwap && percentage > 0) || (MprisController.activePlayer?.trackTitle == null) shown: (ConfigOptions.bar.resources.alwaysShowSwap && percentage > 0) ||
(MprisController.activePlayer?.trackTitle == null) ||
root.alwaysShowAllResources
Layout.leftMargin: shown ? 4 : 0 Layout.leftMargin: shown ? 4 : 0
} }
Resource { Resource {
iconName: "settings_slow_motion" iconName: "settings_slow_motion"
percentage: ResourceUsage.cpuUsage percentage: ResourceUsage.cpuUsage
shown: ConfigOptions.bar.resources.alwaysShowCpu || !(MprisController.activePlayer?.trackTitle?.length > 0) shown: ConfigOptions.bar.resources.alwaysShowCpu ||
!(MprisController.activePlayer?.trackTitle?.length > 0) ||
root.alwaysShowAllResources
Layout.leftMargin: shown ? 4 : 0 Layout.leftMargin: shown ? 4 : 0
} }
@@ -260,7 +260,9 @@ Singleton {
property real barHeight: 40 property real barHeight: 40
property real barCenterSideModuleWidth: 360 property real barCenterSideModuleWidth: 360
property real barCenterSideModuleWidthShortened: 280 property real barCenterSideModuleWidthShortened: 280
property real barShortenScreenWidth: 1200 // Bar will be shortened if screen width is at most this value property real barCenterSideModuleWidthHellaShortened: 190
property real barShortenScreenWidthThreshold: 1200 // Shorten if screen width is at most this value
property real barHellaShortenScreenWidthThreshold: 1000 // Shorten even more...
property real sidebarWidth: 460 property real sidebarWidth: 460
property real sidebarWidthExtended: 750 property real sidebarWidthExtended: 750
property real osdWidth: 200 property real osdWidth: 200