Widgets Sizing: reworked our sizing approach to prepare for different bar densities.

This commit is contained in:
LemmyCook 2025-09-15 22:33:09 -04:00
parent 593a0bfc2c
commit 47ef62beb3
31 changed files with 88 additions and 113 deletions

View file

@ -68,23 +68,13 @@ Variants {
radius: Settings.data.bar.floating ? Style.radiusL : 0
}
// For vertical bars, use a single column layout
Loader {
id: verticalBarLayout
anchors.fill: parent
visible: Settings.data.bar.position === "left" || Settings.data.bar.position === "right"
sourceComponent: verticalBarComponent
active: true
sourceComponent: (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? verticalBarComponent : horizontalBarComponent
}
// For horizontal bars, use the original three-section layout
Loader {
id: horizontalBarLayout
anchors.fill: parent
visible: Settings.data.bar.position === "top" || Settings.data.bar.position === "bottom"
sourceComponent: horizontalBarComponent
}
// Main layout components
// For vertical bars
Component {
id: verticalBarComponent
Item {
@ -163,6 +153,7 @@ Variants {
}
}
// For horizontal bars
Component {
id: horizontalBarComponent
Item {

View file

@ -38,7 +38,7 @@ Item {
readonly property string barPosition: Settings.data.bar.position
implicitHeight: (barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight * scaling)
implicitWidth: (barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8 * scaling) : (horizontalLayout.implicitWidth + Style.marginM * 2 * scaling)
implicitWidth: (barPosition === "left" || barPosition === "right") ? Math.round(Style.capsuleHeight * 0.8 * scaling) : (horizontalLayout.implicitWidth + Style.marginM * 2 * scaling)
function getTitle() {
try {
@ -60,7 +60,7 @@ Item {
let total = Style.marginM * 2 * scaling // internal padding
if (showIcon) {
total += Style.baseWidgetSize * 0.5 * scaling + 2 * scaling // icon + spacing
total += Style.capsuleHeight * 0.5 * scaling + 2 * scaling // icon + spacing
}
// Calculate actual text width more accurately
@ -129,11 +129,13 @@ Item {
Rectangle {
id: windowTitleRect
visible: root.visible
anchors.left: parent.left
anchors.left: (barPosition === "top" || barPosition === "bottom") ? parent.left : undefined
anchors.top: (barPosition === "left" || barPosition === "right") ? parent.top : undefined
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
width: (barPosition === "left" || barPosition === "right") ? Math.round(Style.capsuleHeight * scaling) : (horizontalLayout.implicitWidth + Style.marginM * 2 * scaling)
height: (barPosition === "left" || barPosition === "right") ? Math.round(Style.capsuleHeight * scaling) : Math.round(Style.capsuleHeight * scaling)
radius: Math.round(Style.radiusM * scaling)
radius: width / 2
color: Color.mSurfaceVariant
Item {
@ -152,8 +154,8 @@ Item {
// Window icon
Item {
Layout.preferredWidth: Style.baseWidgetSize * 0.5 * scaling
Layout.preferredHeight: Style.baseWidgetSize * 0.5 * scaling
Layout.preferredWidth: Style.capsuleHeight * 0.75 * scaling
Layout.preferredHeight: Style.capsuleHeight * 0.75 * scaling
Layout.alignment: Qt.AlignVCenter
visible: getTitle() !== "" && showIcon
@ -217,11 +219,10 @@ Item {
// Window icon
Item {
width: Style.baseWidgetSize * 0.5 * scaling
height: Style.baseWidgetSize * 0.5 * scaling
width: Style.capsuleHeight * 0.75 * scaling
height: Style.capsuleHeight * 0.75 * scaling
anchors.centerIn: parent
visible: getTitle() !== "" && showIcon
IconImage {
id: windowIconVertical
anchors.fill: parent

View file

@ -13,7 +13,7 @@ NIconButton {
property ShellScreen screen
property real scaling: 1.0
sizeRatio: 0.8
baseSize: Style.capsuleHeight
colorBg: Color.mSurfaceVariant
colorFg: Color.mOnSurface
colorBorder: Color.transparent

View file

@ -39,7 +39,7 @@ Rectangle {
readonly property bool verticalMode: barPosition === "left" || barPosition === "right"
implicitWidth: verticalMode ? Math.round(Style.capsuleHeight * scaling) : Math.round(layout.implicitWidth + Style.marginM * 2 * scaling)
implicitHeight: verticalMode ? Math.round(Style.capsuleHeight * 2.5 * scaling) : Math.round(Style.baseWidgetSize * 0.8 * scaling) // Match NPill
implicitHeight: verticalMode ? Math.round(Style.capsuleHeight * 2.5 * scaling) : Math.round(Style.capsuleHeight * scaling) // Match NPill
radius: Math.round(Style.radiusS * scaling)
color: Color.mSurfaceVariant

View file

@ -10,9 +10,9 @@ NIconButton {
property real scaling: 1.0
icon: "dark-mode"
tooltipText: "Toggle light/dark mode"
sizeRatio: 0.8
tooltipText: "Toggle light/dark mode."
baseSize: Style.capsuleHeight
colorBg: Settings.data.colorSchemes.darkMode ? Color.mSurfaceVariant : Color.mPrimary
colorFg: Settings.data.colorSchemes.darkMode ? Color.mOnSurface : Color.mOnPrimary
colorBorder: Color.transparent

View file

@ -11,14 +11,11 @@ NIconButton {
property ShellScreen screen
property real scaling: 1.0
sizeRatio: 0.8
baseSize: Style.capsuleHeight
icon: IdleInhibitorService.isInhibited ? "keep-awake-on" : "keep-awake-off"
tooltipText: IdleInhibitorService.isInhibited ? "Disable keep awake" : "Enable keep awake"
colorBg: IdleInhibitorService.isInhibited ? Color.mPrimary : Color.mSurfaceVariant
colorFg: IdleInhibitorService.isInhibited ? Color.mOnPrimary : Color.mOnSurface
colorBorder: Color.transparent
onClicked: {
IdleInhibitorService.manualToggle()
}
onClicked: IdleInhibitorService.manualToggle()
}

View file

@ -14,7 +14,7 @@ NIconButton {
property ShellScreen screen
property real scaling: 1.0
sizeRatio: 0.8
baseSize: Style.capsuleHeight
colorBg: Settings.data.nightLight.forced ? Color.mPrimary : Color.mSurfaceVariant
colorFg: Settings.data.nightLight.forced ? Color.mOnPrimary : Color.mOnSurface
colorBorder: Color.transparent

View file

@ -49,7 +49,7 @@ NIconButton {
return count
}
sizeRatio: 0.8
baseSize: Style.capsuleHeight
icon: Settings.data.notifications.doNotDisturb ? "bell-off" : "bell"
tooltipText: Settings.data.notifications.doNotDisturb ? "Notification history.\nRight-click to disable 'Do Not Disturb'." : "Notification history.\nRight-click to enable 'Do Not Disturb'."
colorBg: Color.mSurfaceVariant

View file

@ -13,7 +13,7 @@ NIconButton {
property real scaling: 1.0
readonly property bool hasPP: PowerProfileService.available
sizeRatio: 0.8
baseSize: Style.capsuleHeight
visible: hasPP
function profileIcon() {

View file

@ -11,7 +11,7 @@ NIconButton {
property ShellScreen screen
property real scaling: 1.0
sizeRatio: 0.8
baseSize: Style.capsuleHeight
icon: "power"
tooltipText: "Power Settings"

View file

@ -13,7 +13,7 @@ NIconButton {
visible: ScreenRecorderService.isRecording
icon: "camera-video"
tooltipText: "Screen recording is active\nClick to stop recording"
sizeRatio: 0.8
baseSize: Style.capsuleHeight
colorBg: Color.mPrimary
colorFg: Color.mOnPrimary
onClicked: ScreenRecorderService.toggleRecording()

View file

@ -33,7 +33,7 @@ NIconButton {
icon: useDistroLogo ? "" : "noctalia"
tooltipText: "Open side panel."
sizeRatio: 0.85
baseSize: Style.capsuleHeight
colorBg: Color.mSurfaceVariant
colorFg: Color.mOnSurface

View file

@ -15,7 +15,7 @@ Rectangle {
property ShellScreen screen
property real scaling: 1.0
readonly property real itemSize: Style.baseWidgetSize * 0.8 * scaling
readonly property real itemSize: Style.capsuleHeight * 0.8 * scaling
// Always visible when there are toplevels
implicitWidth: taskbarLayout.implicitWidth + Style.marginM * scaling * 2

View file

@ -13,8 +13,7 @@ NIconButton {
property ShellScreen screen
property real scaling: 1.0
sizeRatio: 0.8
baseSize: Style.capsuleHeight
colorBg: Color.mSurfaceVariant
colorFg: Color.mOnSurface
colorBorder: Color.transparent

View file

@ -53,7 +53,7 @@ NPanel {
enabled: Settings.data.network.bluetoothEnabled
icon: BluetoothService.adapter && BluetoothService.adapter.discovering ? "stop" : "refresh"
tooltipText: "Refresh Devices"
sizeRatio: 0.8
baseSize: Style.baseWidgetSize * 0.8
onClicked: {
if (BluetoothService.adapter) {
BluetoothService.adapter.discovering = !BluetoothService.adapter.discovering
@ -64,7 +64,7 @@ NPanel {
NIconButton {
icon: "close"
tooltipText: "Close."
sizeRatio: 0.8
baseSize: Style.baseWidgetSize * 0.8
onClicked: {
root.close()
}

View file

@ -326,7 +326,7 @@ Variants {
NIconButton {
icon: "close"
tooltipText: "Close."
sizeRatio: 0.6
baseSize: Style.baseWidgetSize * 0.6
anchors.top: parent.top
anchors.topMargin: Style.marginM * scaling
anchors.right: parent.right

View file

@ -48,15 +48,15 @@ NPanel {
NIconButton {
icon: Settings.data.notifications.doNotDisturb ? "bell-off" : "bell"
tooltipText: Settings.data.notifications.doNotDisturb ? "'Do Not Disturb' is enabled." : "'Do Not Disturb' is disabled."
sizeRatio: 0.8
baseSize: Style.baseWidgetSize * 0.8
onClicked: Settings.data.notifications.doNotDisturb = !Settings.data.notifications.doNotDisturb
onRightClicked: Settings.data.notifications.doNotDisturb = !Settings.data.notifications.doNotDisturb
}
NIconButton {
icon: "trash"
tooltipText: "Clear history"
sizeRatio: 0.8
tooltipText: "Clear history."
baseSize: Style.baseWidgetSize * 0.8
onClicked: {
NotificationService.clearHistory()
root.close()
@ -66,7 +66,7 @@ NPanel {
NIconButton {
icon: "close"
tooltipText: "Close."
sizeRatio: 0.8
baseSize: Style.baseWidgetSize * 0.8
onClicked: {
root.close()
}
@ -198,8 +198,8 @@ NPanel {
// Delete button
NIconButton {
icon: "trash"
tooltipText: "Delete notification"
sizeRatio: 0.7
tooltipText: "Delete notification."
baseSize: Style.baseWidgetSize * 0.7
Layout.alignment: Qt.AlignTop
onClicked: {

View file

@ -14,6 +14,9 @@ NBox {
property var widgetModel: []
property var availableWidgets: []
readonly property real miniButtonSize: Style.baseWidgetSize * 0.65
signal addWidget(string widgetId, string section)
signal removeWidget(string section, int index)
signal reorderWidget(string section, int fromIndex, int toIndex)
@ -178,7 +181,7 @@ NBox {
active: BarWidgetRegistry.widgetHasUserSettings(modelData.id)
sourceComponent: NIconButton {
icon: "settings"
sizeRatio: 0.6
baseSize: miniButtonSize
colorBorder: Qt.alpha(Color.mOutline, Style.opacityLight)
colorBg: Color.mOnSurface
colorFg: Color.mOnPrimary
@ -218,7 +221,7 @@ NBox {
NIconButton {
icon: "close"
sizeRatio: 0.6
baseSize: miniButtonSize
colorBorder: Qt.alpha(Color.mOutline, Style.opacityLight)
colorBg: Color.mOnSurface
colorFg: Color.mOnPrimary

View file

@ -298,7 +298,7 @@ ColumnLayout {
NIconButton {
icon: "close"
sizeRatio: 0.8
baseSize: Style.baseWidgetSize * 0.8
Layout.alignment: Qt.AlignVCenter
Layout.rightMargin: Style.marginXS * scaling
onClicked: {

View file

@ -177,8 +177,8 @@ ColumnLayout {
model: Quickshell.screens || []
delegate: NCheckbox {
Layout.fillWidth: true
label: `${modelData.name || "Unknown"}${modelData.model ? `: ${modelData.model}` : ""}`
description: `${modelData.width}x${modelData.height} at (${modelData.x}, ${modelData.y})`
label: modelData.name || "Unknown"
description: `${modelData.model} - ${modelData.width}x${modelData.height} [x:${modelData.x} y:${modelData.y}]`
checked: (Settings.data.bar.monitors || []).indexOf(modelData.name) !== -1
onToggled: checked => {
if (checked) {

View file

@ -87,19 +87,9 @@ ColumnLayout {
anchors.margins: Style.marginL * scaling
spacing: Style.marginXXS * scaling
NText {
text: (`${modelData.name}: ${modelData.model}` || "Unknown")
font.pointSize: Style.fontSizeL * scaling
font.weight: Style.fontWeightBold
color: Color.mPrimary
}
NText {
text: `Resolution: ${modelData.width}x${modelData.height} at (${modelData.x}, ${modelData.y})`
font.pointSize: Style.fontSizeXS * scaling
color: Color.mOnSurfaceVariant
wrapMode: Text.WordWrap
Layout.fillWidth: true
NLabel {
label: modelData.name|| "Unknown"
description: `${modelData.model} - ${modelData.width}x${modelData.height} [x:${modelData.x} y:${modelData.y}]`
}
// Scale
@ -134,8 +124,8 @@ ColumnLayout {
NIconButton {
icon: "refresh"
sizeRatio: 0.8
tooltipText: "Reset scaling"
baseSize: Style.baseWidgetSize * 0.9
tooltipText: "Reset scaling."
onClicked: ScalingService.setScreenScale(modelData, 1.0)
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter

View file

@ -100,8 +100,8 @@ ColumnLayout {
model: Quickshell.screens || []
delegate: NCheckbox {
Layout.fillWidth: true
label: `${modelData.name || "Unknown"}${modelData.model ? `: ${modelData.model}` : ""}`
description: `${modelData.width}x${modelData.height} at (${modelData.x}, ${modelData.y})`
label: modelData.name || "Unknown"
description: `${modelData.model} - ${modelData.width}x${modelData.height} [x:${modelData.x} y:${modelData.y}]`
checked: (Settings.data.dock.monitors || []).indexOf(modelData.name) !== -1
onToggled: checked => {
if (checked) {

View file

@ -60,8 +60,8 @@ ColumnLayout {
model: Quickshell.screens || []
delegate: NCheckbox {
Layout.fillWidth: true
label: `${modelData.name || "Unknown"}${modelData.model ? `: ${modelData.model}` : ""}`
description: `${modelData.width}x${modelData.height} at (${modelData.x}, ${modelData.y})`
label: modelData.name || "Unknown"
description: `${modelData.model} - ${modelData.width}x${modelData.height} [x:${modelData.x} y:${modelData.y}]`
checked: (Settings.data.notifications.monitors || []).indexOf(modelData.name) !== -1
onToggled: checked => {
if (checked) {

View file

@ -136,7 +136,7 @@ Rectangle {
colorBorder: Color.transparent
colorBorderHover: Color.mOutline
sizeRatio: 0.8
baseSize: Style.baseWidgetSize * 0.8
Layout.alignment: Qt.AlignTop
onClicked: root.hide()

View file

@ -57,7 +57,7 @@ NPanel {
NIconButton {
icon: "refresh"
tooltipText: "Refresh"
sizeRatio: 0.8
baseSize: Style.baseWidgetSize * 0.8
enabled: Settings.data.network.wifiEnabled && !NetworkService.scanning
onClicked: NetworkService.scan()
}
@ -65,7 +65,7 @@ NPanel {
NIconButton {
icon: "close"
tooltipText: "Close."
sizeRatio: 0.8
baseSize: Style.baseWidgetSize * 0.8
onClicked: root.close()
}
}
@ -106,7 +106,7 @@ NPanel {
NIconButton {
icon: "close"
sizeRatio: 0.6
baseSize: Style.baseWidgetSize * 0.6
onClicked: NetworkService.lastError = ""
}
}
@ -368,7 +368,7 @@ NPanel {
visible: (modelData.existing || modelData.cached) && !modelData.connected && NetworkService.connectingTo !== modelData.ssid && NetworkService.forgettingNetwork !== modelData.ssid && NetworkService.disconnectingFrom !== modelData.ssid
icon: "trash"
tooltipText: "Forget network"
sizeRatio: 0.7
baseSize: Style.baseWidgetSize * 0.8
onClicked: expandedSsid = expandedSsid === modelData.ssid ? "" : modelData.ssid
}
@ -478,7 +478,7 @@ NPanel {
NIconButton {
icon: "close"
sizeRatio: 0.8
baseSize: Style.baseWidgetSize * 0.8
onClicked: {
passwordSsid = ""
passwordInput = ""
@ -532,7 +532,7 @@ NPanel {
NIconButton {
icon: "close"
sizeRatio: 0.8
baseSize: Style.baseWidgetSize * 0.8
onClicked: expandedSsid = ""
}
}