Feature: Shorter bar labels on narrow screens
Bar.qml switches ActiveWindow and MediaPlayer to tighter truncation limits when the bar is narrower than compactBarWidth (1600px), so on the laptop's eDP-1 they don't crowd the centre clock/weather group. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -36,6 +36,13 @@ QtObject {
|
||||
// with "…" (ActiveWindow.qml and MediaPlayer.qml).
|
||||
readonly property int activeWindowMaxChars: 50
|
||||
readonly property int mediaMaxChars: 40
|
||||
// Tighter limits for narrow screens (the laptop's eDP-1 is 1440 logical
|
||||
// px wide), where the full-length labels nearly run into the centre
|
||||
// clock/weather group. Bar.qml switches when it's narrower than
|
||||
// compactBarWidth.
|
||||
readonly property int compactBarWidth: 1600
|
||||
readonly property int activeWindowMaxCharsCompact: 32
|
||||
readonly property int mediaMaxCharsCompact: 28
|
||||
|
||||
// Counts code points rather than UTF-16 units so emoji / some CJK
|
||||
// aren't split in half at the cut.
|
||||
|
||||
@@ -4,8 +4,9 @@ import Quickshell.Hyprland
|
||||
import "../../config"
|
||||
|
||||
Text {
|
||||
property bool compact: false
|
||||
font.family: Appearance.fontFamily
|
||||
font.pixelSize: Appearance.fontSizeSmall
|
||||
color: Colors.muted
|
||||
text: Hyprland.activeToplevel ? Appearance.truncate(Hyprland.activeToplevel.title, Appearance.activeWindowMaxChars) : ""
|
||||
text: Hyprland.activeToplevel ? Appearance.truncate(Hyprland.activeToplevel.title, compact ? Appearance.activeWindowMaxCharsCompact : Appearance.activeWindowMaxChars) : ""
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@ PanelWindow {
|
||||
exclusiveZone: implicitHeight
|
||||
color: "transparent"
|
||||
|
||||
// Narrow screen (laptop): shorten the left-side free-text labels so they
|
||||
// don't crowd the centre group.
|
||||
readonly property bool compact: width < Appearance.compactBarWidth
|
||||
|
||||
WlrLayershell.layer: WlrLayer.Top
|
||||
WlrLayershell.namespace: "quickshell:bar"
|
||||
|
||||
@@ -32,8 +36,8 @@ PanelWindow {
|
||||
}
|
||||
spacing: Appearance.spacing
|
||||
Workspaces { screen: bar.screen }
|
||||
MediaPlayer { barWindow: bar }
|
||||
ActiveWindow {}
|
||||
MediaPlayer { barWindow: bar; compact: bar.compact }
|
||||
ActiveWindow { compact: bar.compact }
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
|
||||
@@ -20,6 +20,8 @@ Item {
|
||||
// to the bar so it sits flush under it rather than under this label's
|
||||
// (shorter) text box.
|
||||
required property var barWindow
|
||||
// Set by Bar.qml on narrow screens — shortens the label.
|
||||
property bool compact: false
|
||||
|
||||
// Last player seen playing. Becomes null by itself if that player's
|
||||
// process exits and Quickshell destroys the object.
|
||||
@@ -121,7 +123,7 @@ Item {
|
||||
return ""
|
||||
const title = root.player.trackTitle || root.player.identity
|
||||
const artist = root.player.trackArtist
|
||||
return Appearance.truncate(artist ? artist + " — " + title : title, Appearance.mediaMaxChars)
|
||||
return Appearance.truncate(artist ? artist + " — " + title : title, root.compact ? Appearance.mediaMaxCharsCompact : Appearance.mediaMaxChars)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user