More cleanup

This commit is contained in:
ItsLemmy
2025-10-12 09:33:04 -04:00
parent 6a6a8b3f10
commit 292ecd493b
15 changed files with 46 additions and 187 deletions
-1
View File
@@ -173,7 +173,6 @@
"fontFixed": "DejaVu Sans Mono",
"fontDefaultScale": 1,
"fontFixedScale": 1,
"monitorsScaling": [],
"idleInhibitorEnabled": false,
"tooltipsEnabled": true
},
+4 -4
View File
@@ -38,10 +38,10 @@ Loader {
margins {
// When bar is floating, corners should be at screen edges (no margins)
// When bar is not floating, respect bar margins as before
top: !Settings.data.bar.floating && BarService.isVisible && ((modelData && Settings.data.bar.monitors.includes(modelData.name)) || (Settings.data.bar.monitors.length === 0)) && Settings.data.bar.position === "top" && Settings.data.bar.backgroundOpacity > 0 ? Math.round(Style.barHeight) : 0
bottom: !Settings.data.bar.floating && BarService.isVisible && ((modelData && Settings.data.bar.monitors.includes(modelData.name)) || (Settings.data.bar.monitors.length === 0)) && Settings.data.bar.position === "bottom" && Settings.data.bar.backgroundOpacity > 0 ? Math.round(Style.barHeight) : 0
left: !Settings.data.bar.floating && BarService.isVisible && ((modelData && Settings.data.bar.monitors.includes(modelData.name)) || (Settings.data.bar.monitors.length === 0)) && Settings.data.bar.position === "left" && Settings.data.bar.backgroundOpacity > 0 ? Math.round(Style.barHeight) : 0
right: !Settings.data.bar.floating && BarService.isVisible && ((modelData && Settings.data.bar.monitors.includes(modelData.name)) || (Settings.data.bar.monitors.length === 0)) && Settings.data.bar.position === "right" && Settings.data.bar.backgroundOpacity > 0 ? Math.round(Style.barHeight) : 0
top: !Settings.data.bar.floating && BarService.isVisible && ((modelData && Settings.data.bar.monitors.includes(modelData.name)) || (Settings.data.bar.monitors.length === 0)) && Settings.data.bar.position === "top" && Settings.data.bar.backgroundOpacity > 0 ? Style.barHeight : 0
bottom: !Settings.data.bar.floating && BarService.isVisible && ((modelData && Settings.data.bar.monitors.includes(modelData.name)) || (Settings.data.bar.monitors.length === 0)) && Settings.data.bar.position === "bottom" && Settings.data.bar.backgroundOpacity > 0 ? Style.barHeight : 0
left: !Settings.data.bar.floating && BarService.isVisible && ((modelData && Settings.data.bar.monitors.includes(modelData.name)) || (Settings.data.bar.monitors.length === 0)) && Settings.data.bar.position === "left" && Settings.data.bar.backgroundOpacity > 0 ? Style.barHeight : 0
right: !Settings.data.bar.floating && BarService.isVisible && ((modelData && Settings.data.bar.monitors.includes(modelData.name)) || (Settings.data.bar.monitors.length === 0)) && Settings.data.bar.position === "right" && Settings.data.bar.backgroundOpacity > 0 ? Style.barHeight : 0
}
mask: Region {}
+2 -2
View File
@@ -25,8 +25,8 @@ Variants {
WlrLayershell.namespace: "noctalia-bar"
implicitHeight: (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? screen.height : Math.round(Style.barHeight)
implicitWidth: (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? Math.round(Style.barHeight) : screen.width
implicitHeight: (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? screen.height : Style.barHeight
implicitWidth: (Settings.data.bar.position === "left" || Settings.data.bar.position === "right") ? Style.barHeight : screen.width
color: Color.transparent
anchors {
+1 -1
View File
@@ -38,7 +38,7 @@ Item {
property bool showPill: false
property bool shouldAnimateHide: false
readonly property int pillHeight: Math.round(Style.capsuleHeight)
readonly property int pillHeight: Style.capsuleHeight
readonly property int pillPaddingHorizontal: Math.round(Style.capsuleHeight * 0.2)
readonly property int pillOverlap: Math.round(Style.capsuleHeight * 0.5)
readonly property int pillMaxWidth: Math.max(1, textItem.implicitWidth + pillPaddingHorizontal * 2 + pillOverlap)
+1 -1
View File
@@ -45,7 +45,7 @@ Item {
property bool shouldAnimateHide: false
// Sizing logic for vertical bars
readonly property int buttonSize: Math.round(Style.capsuleHeight)
readonly property int buttonSize: Style.capsuleHeight
readonly property int pillHeight: buttonSize
readonly property int pillPaddingVertical: 3 * 2 // Very precise adjustment don't replace by Style.margin
readonly property int pillOverlap: buttonSize * 0.5
+1 -1
View File
@@ -18,7 +18,7 @@ PopupWindow {
readonly property int menuWidth: 180
implicitWidth: Math.round(menuWidth)
implicitWidth: menuWidth
// Use the content height of the Flickable for implicit height
implicitHeight: Math.min(screen ? screen.height * 0.9 : Screen.height * 0.9, flickable.contentHeight + (Style.marginS * 2))
+5 -5
View File
@@ -43,7 +43,7 @@ Item {
readonly property string scrollingMode: (widgetSettings.scrollingMode !== undefined) ? widgetSettings.scrollingMode : (widgetMetadata.scrollingMode !== undefined ? widgetMetadata.scrollingMode : "hover")
readonly property int widgetWidth: (widgetSettings.width !== undefined) ? widgetSettings.width : Math.max(widgetMetadata.width, screen.width * 0.06)
implicitHeight: visible ? ((barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight)) : 0
implicitHeight: visible ? ((barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Style.barHeight) : 0
implicitWidth: visible ? ((barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8) : (widgetWidth)) : 0
opacity: !autoHide || hasActiveWindow ? 1.0 : 0
@@ -116,8 +116,8 @@ Item {
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
width: (barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8) : (widgetWidth)
height: (barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8) : Math.round(Style.capsuleHeight)
radius: (barPosition === "left" || barPosition === "right") ? width / 2 : Math.round(Style.radiusM)
height: (barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8) : Style.capsuleHeight
radius: (barPosition === "left" || barPosition === "right") ? width / 2 : Style.radiusM
color: Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent
Item {
@@ -136,8 +136,8 @@ Item {
// Window icon
Item {
Layout.preferredWidth: Math.round(18)
Layout.preferredHeight: Math.round(18)
Layout.preferredWidth: 18
Layout.preferredHeight: 18
Layout.alignment: Qt.AlignVCenter
visible: showIcon
+3 -3
View File
@@ -40,11 +40,11 @@ Rectangle {
readonly property string formatHorizontal: widgetSettings.formatHorizontal !== undefined ? widgetSettings.formatHorizontal : widgetMetadata.formatHorizontal
readonly property string formatVertical: widgetSettings.formatVertical !== undefined ? widgetSettings.formatVertical : widgetMetadata.formatVertical
implicitWidth: isBarVertical ? Math.round(Style.capsuleHeight) : Math.round((isBarVertical ? verticalLoader.implicitWidth : horizontalLoader.implicitWidth) + Style.marginM * 2)
implicitWidth: isBarVertical ? Style.capsuleHeight : Math.round((isBarVertical ? verticalLoader.implicitWidth : horizontalLoader.implicitWidth) + Style.marginM * 2)
implicitHeight: isBarVertical ? Math.round(verticalLoader.implicitHeight + Style.marginS * 2) : Math.round(Style.capsuleHeight)
implicitHeight: isBarVertical ? Math.round(verticalLoader.implicitHeight + Style.marginS * 2) : Style.capsuleHeight
radius: Math.round(Style.radiusS)
radius: Style.radiusS
color: Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent
Item {
+5 -5
View File
@@ -59,7 +59,7 @@ Item {
return title
}
implicitHeight: visible ? ((barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Math.round(Style.barHeight)) : 0
implicitHeight: visible ? ((barPosition === "left" || barPosition === "right") ? calculatedVerticalHeight() : Style.barHeight) : 0
implicitWidth: visible ? ((barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8) : (widgetWidth)) : 0
opacity: !autoHide || hasActivePlayer || (!hasActivePlayer && !autoHide) ? 1.0 : 0
@@ -92,8 +92,8 @@ Item {
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
width: (barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8) : (widgetWidth)
height: (barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8) : Math.round(Style.capsuleHeight)
radius: (barPosition === "left" || barPosition === "right") ? width / 2 : Math.round(Style.radiusM)
height: (barPosition === "left" || barPosition === "right") ? Math.round(Style.baseWidgetSize * 0.8) : Style.capsuleHeight
radius: (barPosition === "left" || barPosition === "right") ? width / 2 : Style.radiusM
color: Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent
Item {
@@ -172,8 +172,8 @@ Item {
spacing: 0
Item {
Layout.preferredWidth: Math.round(21)
Layout.preferredHeight: Math.round(21)
Layout.preferredWidth: 21
Layout.preferredHeight: 21
NImageCircled {
id: trackArt
+9 -9
View File
@@ -73,9 +73,9 @@ Rectangle {
}
anchors.centerIn: parent
implicitWidth: isVertical ? Math.round(Style.capsuleHeight) : Math.round(mainGrid.implicitWidth + Style.marginM * 2)
implicitHeight: isVertical ? Math.round(mainGrid.implicitHeight + Style.marginM * 2) : Math.round(Style.capsuleHeight)
radius: Math.round(Style.radiusM)
implicitWidth: isVertical ? Style.capsuleHeight : Math.round(mainGrid.implicitWidth + Style.marginM * 2)
implicitHeight: isVertical ? Math.round(mainGrid.implicitHeight + Style.marginM * 2) : Style.capsuleHeight
radius: Style.radiusM
color: Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent
GridLayout {
@@ -90,7 +90,7 @@ Rectangle {
// CPU Usage Component
Item {
Layout.preferredWidth: isVertical ? root.width : iconSize + percentTextWidth + (Style.marginXXS)
Layout.preferredHeight: Math.round(Style.capsuleHeight)
Layout.preferredHeight: Style.capsuleHeight
Layout.alignment: isVertical ? Qt.AlignHCenter : Qt.AlignVCenter
visible: showCpuUsage
@@ -131,7 +131,7 @@ Rectangle {
// CPU Temperature Component
Item {
Layout.preferredWidth: isVertical ? root.width : (iconSize + tempTextWidth) + (Style.marginXXS)
Layout.preferredHeight: Math.round(Style.capsuleHeight)
Layout.preferredHeight: Style.capsuleHeight
Layout.alignment: isVertical ? Qt.AlignHCenter : Qt.AlignVCenter
visible: showCpuTemp
@@ -172,7 +172,7 @@ Rectangle {
// Memory Usage Component
Item {
Layout.preferredWidth: isVertical ? root.width : iconSize + (showMemoryAsPercent ? percentTextWidth : memTextWidth) + (Style.marginXXS)
Layout.preferredHeight: Math.round(Style.capsuleHeight)
Layout.preferredHeight: Style.capsuleHeight
Layout.alignment: isVertical ? Qt.AlignHCenter : Qt.AlignVCenter
visible: showMemoryUsage
@@ -213,7 +213,7 @@ Rectangle {
// Network Download Speed Component
Item {
Layout.preferredWidth: isVertical ? root.width : iconSize + memTextWidth + (Style.marginXXS)
Layout.preferredHeight: Math.round(Style.capsuleHeight)
Layout.preferredHeight: Style.capsuleHeight
Layout.alignment: isVertical ? Qt.AlignHCenter : Qt.AlignVCenter
visible: showNetworkStats
@@ -254,7 +254,7 @@ Rectangle {
// Network Upload Speed Component
Item {
Layout.preferredWidth: isVertical ? root.width : iconSize + memTextWidth + (Style.marginXXS)
Layout.preferredHeight: Math.round(Style.capsuleHeight)
Layout.preferredHeight: Style.capsuleHeight
Layout.alignment: isVertical ? Qt.AlignHCenter : Qt.AlignVCenter
visible: showNetworkStats
@@ -295,7 +295,7 @@ Rectangle {
// Disk Usage Component (primary drive)
Item {
Layout.preferredWidth: isVertical ? root.width : iconSize + percentTextWidth + (Style.marginXXS)
Layout.preferredHeight: Math.round(Style.capsuleHeight)
Layout.preferredHeight: Style.capsuleHeight
Layout.alignment: isVertical ? Qt.AlignHCenter : Qt.AlignVCenter
visible: showDiskUsage
+3 -3
View File
@@ -35,9 +35,9 @@ Rectangle {
}
// Always visible when there are toplevels
implicitWidth: isVerticalBar ? Math.round(Style.capsuleHeight) : Math.round(taskbarLayout.implicitWidth + Style.marginM * 2)
implicitHeight: isVerticalBar ? Math.round(taskbarLayout.implicitHeight + Style.marginM * 2) : Math.round(Style.capsuleHeight)
radius: Math.round(Style.radiusM)
implicitWidth: isVerticalBar ? Style.capsuleHeight : Math.round(taskbarLayout.implicitWidth + Style.marginM * 2)
implicitHeight: isVerticalBar ? Math.round(taskbarLayout.implicitHeight + Style.marginM * 2) : Style.capsuleHeight
radius: Style.radiusM
color: Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent
GridLayout {
+4 -4
View File
@@ -144,9 +144,9 @@ Rectangle {
}
visible: filteredItems.length > 0
implicitWidth: isVertical ? Math.round(Style.capsuleHeight) : Math.round(trayFlow.implicitWidth + Style.marginM * 2)
implicitHeight: isVertical ? Math.round(trayFlow.implicitHeight + Style.marginM * 2) : Math.round(Style.capsuleHeight)
radius: Math.round(Style.radiusM)
implicitWidth: isVertical ? Style.capsuleHeight : Math.round(trayFlow.implicitWidth + Style.marginM * 2)
implicitHeight: isVertical ? Math.round(trayFlow.implicitHeight + Style.marginM * 2) : Style.capsuleHeight
radius: Style.radiusM
color: Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent
Layout.alignment: Qt.AlignVCenter
@@ -239,7 +239,7 @@ Rectangle {
} else {
// For horizontal bars: center horizontally and position below
menuX = (width / 2) - (trayMenu.item.width / 2)
menuY = Math.round(Style.barHeight)
menuY = Style.barHeight
}
trayMenu.item.menu = modelData.menu
trayMenu.item.showAt(parent, menuX, menuY)
+5 -5
View File
@@ -62,8 +62,8 @@ Item {
signal workspaceChanged(int workspaceId, color accentColor)
implicitWidth: isVertical ? Math.round(Style.barHeight) : computeWidth()
implicitHeight: isVertical ? computeHeight() : Math.round(Style.barHeight)
implicitWidth: isVertical ? Style.barHeight : computeWidth()
implicitHeight: isVertical ? computeHeight() : Style.barHeight
function getWorkspaceWidth(ws) {
const d = Style.capsuleHeight * root.baseDimensionRatio
@@ -202,9 +202,9 @@ Item {
Rectangle {
id: workspaceBackground
width: isVertical ? Math.round(Style.capsuleHeight) : parent.width
height: isVertical ? parent.height : Math.round(Style.capsuleHeight)
radius: Math.round(Style.radiusM)
width: isVertical ? Style.capsuleHeight : parent.width
height: isVertical ? parent.height : Style.capsuleHeight
radius: Style.radiusM
color: Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent
anchors.horizontalCenter: parent.horizontalCenter
-131
View File
@@ -1,131 +0,0 @@
pragma Singleton
import QtQuick
import Quickshell
import qs.Commons
Singleton {
id: root
// Cache for current scales - updated via signals
property var currentScales: ({})
// Signal emitted when scale changes
signal scaleChanged(string screenName, real scale)
Component.onCompleted: {
Logger.log("Scaling", "Service started")
// Initialize cache from Settings once they are loaded on startup
var monitors = Settings.data.ui.monitorsScaling || []
for (var i = 0; i < monitors.length; i++) {
if (monitors[i].name && monitors[i].scale !== undefined) {
currentScales[monitors[i].name] = monitors[i].scale
root.scaleChanged(monitors[i].name, monitors[i].scale)
Logger.log("Scaling", "Caching scaling for", monitors[i].name, ":", monitors[i].scale)
}
}
}
// -------------------------------------------
// Manual scaling via Settings
function getScreenScale(aScreen) {
try {
if (aScreen !== undefined && aScreen.name !== undefined) {
return getScreenScaleByName(aScreen.name)
}
} catch (e) {
//Logger.warn(e)
}
return 1.0
}
// -------------------------------------------
// Get scale from cache for better performance
function getScreenScaleByName(aScreenName) {
try {
var scale = currentScales[aScreenName]
if ((scale !== undefined) && (scale != null)) {
return scale
}
} catch (e) {
//Logger.warn(e)
}
return 1.0
}
// -------------------------------------------
function setScreenScale(aScreen, scale) {
try {
if (aScreen !== undefined && aScreen.name !== undefined) {
return setScreenScaleByName(aScreen.name, scale)
}
} catch (e) {
//Logger.warn(e)
}
}
// -------------------------------------------
function setScreenScaleByName(aScreenName, scale) {
try {
// Check if scale actually changed
var oldScale = currentScales[aScreenName] || 1.0
if (oldScale === scale) {
return
// No change needed
}
// Update cache directly
currentScales[aScreenName] = scale
// Update Settings with immutable update for proper persistence
var monitors = Settings.data.ui.monitorsScaling || []
var found = false
var newMonitors = monitors.map(function (monitor) {
if (monitor.name === aScreenName) {
found = true
return {
"name": aScreenName,
"scale": scale
}
}
return monitor
})
if (!found) {
newMonitors.push({
"name": aScreenName,
"scale": scale
})
}
// Use slice() to ensure Settings detects the change
Settings.data.ui.monitorsScaling = newMonitors.slice()
// Emit signal for components to react
root.scaleChanged(aScreenName, scale)
Logger.log("Scaling", "Scale changed for", aScreenName, "to", scale)
} catch (e) {
Logger.warn("Scaling", "Error setting scale:", e)
}
}
// -------------------------------------------
// Dynamic scaling based on resolution
// Design reference resolution (for scale = 1.0)
readonly property int designScreenWidth: 2560
readonly property int designScreenHeight: 1440
function dynamicScale(aScreen) {
return 1.0
// if (aScreen != null) {
// var ratioW = aScreen.width / designScreenWidth
// var ratioH = aScreen.height / designScreenHeight
// return Math.min(ratioW, ratioH)
// }
// return 1.0
}
}
+3 -12
View File
@@ -26,8 +26,6 @@ Loader {
property bool panelAnchorLeft: false
property bool panelAnchorRight: false
property bool isMasked: false
// Properties to support positioning relative to the opener (button)
property bool useButtonPosition: false
property point buttonPosition: Qt.point(0, 0)
@@ -38,10 +36,8 @@ Loader {
property bool backgroundClickEnabled: true
// Animation properties
readonly property real originalScale: 0.5
readonly property real originalOpacity: 0.0
readonly property real originalScale: 0.0
property real scaleValue: originalScale
property real opacityValue: originalOpacity
property real dimmingOpacity: 0
signal opened
@@ -99,7 +95,6 @@ Loader {
function close() {
dimmingOpacity = 0
scaleValue = originalScale
opacityValue = originalOpacity
root.closed()
active = false
useButtonPosition = false
@@ -137,7 +132,7 @@ Loader {
readonly property string barPosition: Settings.data.bar.position
readonly property bool isVertical: barPosition === "left" || barPosition === "right"
readonly property bool barIsVisible: (screen !== null) && (Settings.data.bar.monitors.includes(screen.name) || (Settings.data.bar.monitors.length === 0))
readonly property real verticalBarWidth: Math.round(Style.barHeight)
readonly property real verticalBarWidth: Style.barHeight
Component.onCompleted: {
Logger.log("NPanel", "Opened", root.objectName, "on", screen.name)
@@ -158,14 +153,12 @@ Loader {
}
visible: true
color: Settings.data.general.dimDesktop && !root.isMasked ? Qt.alpha(Color.mShadow, dimmingOpacity) : Color.transparent
color: Settings.data.general.dimDesktop ? Qt.alpha(Color.mShadow, dimmingOpacity) : Color.transparent
WlrLayershell.exclusionMode: ExclusionMode.Ignore
WlrLayershell.namespace: "noctalia-panel"
WlrLayershell.keyboardFocus: root.panelKeyboardFocus ? WlrKeyboardFocus.OnDemand : WlrKeyboardFocus.None
mask: root.isMasked ? maskRegion : null
Region {
id: maskRegion
}
@@ -231,7 +224,6 @@ Loader {
}
scale: root.scaleValue
opacity: root.isMasked ? 0 : root.opacityValue
x: isDragged ? manualX : calculatedX
y: isDragged ? manualY : calculatedY
@@ -371,7 +363,6 @@ Loader {
// Animate in when component is completed
Component.onCompleted: {
root.scaleValue = 1.0
root.opacityValue = 1.0
}
// Reset drag position when panel closes