Qt-Scaling: first cleanup pass

This commit is contained in:
ItsLemmy
2025-10-12 08:23:24 -04:00
parent d5d654e010
commit f4b27380c3
135 changed files with 1562 additions and 1811 deletions
+34 -45
View File
@@ -16,7 +16,6 @@ Variants {
id: root
required property ShellScreen modelData
property real scaling: ScalingService.getScreenScale(modelData)
// Access the notification model from the service
property ListModel notificationModel: NotificationService.activeList
@@ -119,9 +118,6 @@ Variants {
id: panel
screen: modelData
// PanelWindow scaling
property real scaling: ScalingService.getScreenScale(screen)
readonly property string location: (Settings.data.osd && Settings.data.osd.location) ? Settings.data.osd.location : "top_right"
readonly property bool isTop: (location === "top") || (location.length >= 3 && location.substring(0, 3) === "top")
readonly property bool isBottom: (location === "bottom") || (location.length >= 6 && location.substring(0, 6) === "bottom")
@@ -129,28 +125,21 @@ Variants {
readonly property bool isRight: (location.indexOf("_right") >= 0) || (location === "right")
readonly property bool isCentered: (location === "top" || location === "bottom")
readonly property bool verticalMode: (location === "left" || location === "right")
readonly property int hWidth: Math.round(320 * scaling)
readonly property int hHeight: Math.round(64 * scaling)
readonly property int vHeight: Math.round(320 * scaling) // Vertical OSD height (matches horizontal width)
readonly property int hWidth: Math.round(320)
readonly property int hHeight: Math.round(64)
readonly property int vHeight: Math.round(320) // Vertical OSD height (matches horizontal width)
// Ensure an even width to keep the vertical bar perfectly centered
readonly property int barThickness: (function () {
const base = Math.max(8, Math.round(8 * scaling))
const base = Math.max(8, Math.round(8))
return (base % 2 === 0) ? base : base + 1
})()
Component.onCompleted: {
}
Connections {
target: ScalingService
function onScaleChanged(screenName, scale) {
if ((screen !== null) && (screenName === screen.name)) {
scaling = scale
}
}
}
Component.onDestruction: {
}
// Anchor selection based on location (window edges)
@@ -163,10 +152,10 @@ Variants {
margins.top: {
if (!(anchors.top))
return 0
var base = Style.marginM * scaling
var base = Style.marginM
if (Settings.data.bar.position === "top") {
var floatExtraV = Settings.data.bar.floating ? Settings.data.bar.marginVertical * Style.marginXL * scaling : 0
return (Style.barHeight * scaling) + base + floatExtraV
var floatExtraV = Settings.data.bar.floating ? Settings.data.bar.marginVertical * Style.marginXL : 0
return (Style.barHeight) + base + floatExtraV
}
return base
}
@@ -174,10 +163,10 @@ Variants {
margins.bottom: {
if (!(anchors.bottom))
return 0
var base = Style.marginM * scaling
var base = Style.marginM
if (Settings.data.bar.position === "bottom") {
var floatExtraV = Settings.data.bar.floating ? Settings.data.bar.marginVertical * Style.marginXL * scaling : 0
return (Style.barHeight * scaling) + base + floatExtraV
var floatExtraV = Settings.data.bar.floating ? Settings.data.bar.marginVertical * Style.marginXL : 0
return (Style.barHeight) + base + floatExtraV
}
return base
}
@@ -185,10 +174,10 @@ Variants {
margins.left: {
if (!(anchors.left))
return 0
var base = Style.marginM * scaling
var base = Style.marginM
if (Settings.data.bar.position === "left") {
var floatExtraH = Settings.data.bar.floating ? Settings.data.bar.marginHorizontal * Style.marginXL * scaling : 0
return (Style.barHeight * scaling) + base + floatExtraH
var floatExtraH = Settings.data.bar.floating ? Settings.data.bar.marginHorizontal * Style.marginXL : 0
return (Style.barHeight) + base + floatExtraH
}
return base
}
@@ -196,10 +185,10 @@ Variants {
margins.right: {
if (!(anchors.right))
return 0
var base = Style.marginM * scaling
var base = Style.marginM
if (Settings.data.bar.position === "right") {
var floatExtraH = Settings.data.bar.floating ? Settings.data.bar.marginHorizontal * Style.marginXL * scaling : 0
return (Style.barHeight * scaling) + base + floatExtraH
var floatExtraH = Settings.data.bar.floating ? Settings.data.bar.marginHorizontal * Style.marginXL : 0
return (Style.barHeight) + base + floatExtraH
}
return base
}
@@ -217,12 +206,12 @@ Variants {
id: osdItem
width: parent.width
height: panel.verticalMode ? panel.vHeight : Math.round(64 * scaling)
radius: Style.radiusL * scaling
height: panel.verticalMode ? panel.vHeight : Math.round(64)
radius: Style.radiusL
color: Color.mSurface
border.color: Color.mOutline
border.width: (function () {
const bw = Math.max(2, Math.round(Style.borderM * scaling))
const bw = Math.max(2, Math.round(Style.borderM))
return (bw % 2 === 0) ? bw : bw + 1
})()
visible: false
@@ -282,13 +271,13 @@ Variants {
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
anchors.margins: Style.marginM * root.scaling
spacing: Style.marginM * root.scaling
anchors.margins: Style.marginM
spacing: Style.marginM
NIcon {
icon: root.getIcon()
color: root.getIconColor()
pointSize: Style.fontSizeXL * scaling
pointSize: Style.fontSizeXL
Layout.alignment: Qt.AlignVCenter
Behavior on color {
@@ -301,7 +290,7 @@ Variants {
// Progress bar with calculated width
Rectangle {
Layout.preferredWidth: Math.round(220 * root.scaling)
Layout.preferredWidth: Math.round(220)
height: panel.barThickness
radius: Math.round(panel.barThickness / 2)
color: Color.mSurfaceVariant
@@ -334,12 +323,12 @@ Variants {
NText {
text: root.getDisplayPercentage()
color: Color.mOnSurface
pointSize: Style.fontSizeS * scaling
pointSize: Style.fontSizeS
family: Settings.data.ui.fontFixed
Layout.alignment: Qt.AlignVCenter
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
Layout.preferredWidth: Math.round(50 * root.scaling)
Layout.preferredWidth: Math.round(50)
}
}
}
@@ -350,18 +339,18 @@ Variants {
ColumnLayout {
// Ensure inner padding respects the rounded corners; avoid clipping the icon/text
property int vMargin: (function () {
const styleMargin = Math.round(Style.marginL * scaling)
const styleMargin = Math.round(Style.marginL)
const cornerGuard = Math.round(osdItem.radius)
return Math.max(styleMargin, cornerGuard)
})()
property int vMarginTop: Math.max(Math.round(osdItem.radius), Math.round(Style.marginS * scaling))
property int balanceDelta: Math.round(Style.marginS * scaling)
property int vMarginTop: Math.max(Math.round(osdItem.radius), Math.round(Style.marginS))
property int balanceDelta: Math.round(Style.marginS)
anchors.fill: parent
anchors.topMargin: vMargin
anchors.leftMargin: vMargin
anchors.rightMargin: vMargin
anchors.bottomMargin: vMargin
spacing: Math.round(Style.marginS * scaling)
spacing: Math.round(Style.marginS)
// Percentage text at top
Item {
@@ -371,7 +360,7 @@ Variants {
id: percentText
text: root.getDisplayPercentage()
color: Color.mOnSurface
pointSize: Style.fontSizeS * scaling
pointSize: Style.fontSizeS
family: Settings.data.ui.fontFixed
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
@@ -420,7 +409,7 @@ Variants {
NIcon {
icon: root.getIcon()
color: root.getIconColor()
pointSize: Style.fontSizeXL * scaling
pointSize: Style.fontSizeXL
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
Behavior on color {
ColorAnimation {
@@ -548,12 +537,12 @@ Variants {
function onBrightnessChanged(newBrightness) {
root.lastUpdatedBrightness = newBrightness
if (!brightnessInitialized) {
brightnessInitialized = true
return
}
showOSD("brightness")
}