ScalingService: 1st pass of the refactoring via signals instead of nested bindings for better efficienty and compatibility with old versions of Qt

This commit is contained in:
LemmyCook 2025-09-01 13:52:12 -04:00
parent 934c8c61b3
commit 210bbac583
31 changed files with 186 additions and 56 deletions

View file

@ -16,7 +16,16 @@ Variants {
id: root
required property ShellScreen modelData
readonly property real scaling: modelData ? ScalingService.scale(modelData) : 1.0
property real scaling: ScalingService.getScreenScale(modelData)
Connections {
target: ScalingService
function onScaleChanged(screenName, scale) {
if ((modelData !== null) && (screenName === modelData.name)) {
scaling = scale
}
}
}
active: Settings.isLoaded && modelData && modelData.name ? (Settings.data.bar.monitors.includes(modelData.name)
|| (Settings.data.bar.monitors.length === 0)) : false
@ -67,6 +76,7 @@ Variants {
widgetName: modelData
widgetProps: {
"screen": root.modelData || null,
"scaling": ScalingService.getScreenScale(screen),
"barSection": parent.objectName,
"sectionWidgetIndex": index,
"sectionWidgetsCount": Settings.data.bar.widgets.left.length
@ -90,9 +100,11 @@ Variants {
Repeater {
model: Settings.data.bar.widgets.center
delegate: NWidgetLoader {
widgetName: modelData
widgetProps: {
"screen": root.modelData || null,
"scaling": ScalingService.getScreenScale(screen),
"barSection": parent.objectName,
"sectionWidgetIndex": index,
"sectionWidgetsCount": Settings.data.bar.widgets.center.length
@ -120,6 +132,7 @@ Variants {
widgetName: modelData
widgetProps: {
"screen": root.modelData || null,
"scaling": ScalingService.getScreenScale(screen),
"barSection": parent.objectName,
"sectionWidgetIndex": index,
"sectionWidgetsCount": Settings.data.bar.widgets.right.length

View file

@ -15,7 +15,7 @@ PopupWindow {
property bool isSubMenu: false
property bool isHovered: rootMouseArea.containsMouse
property ShellScreen screen
property real scaling: screen ? ScalingService.scale(screen) : 1.0
property real scaling: ScalingService.getScreenScale(screen)
readonly property int menuWidth: 180

View file

@ -11,7 +11,7 @@ Row {
id: root
property ShellScreen screen
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
readonly property real minWidth: 160
readonly property real maxWidth: 400

View file

@ -10,7 +10,7 @@ NIconButton {
id: root
property ShellScreen screen
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
sizeRatio: 0.8
colorBg: Color.mSurfaceVariant

View file

@ -10,7 +10,7 @@ Item {
id: root
property ShellScreen screen
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
property string barSection: ""
property int sectionWidgetIndex: 0
property int sectionWidgetsCount: 0

View file

@ -11,7 +11,7 @@ NIconButton {
id: root
property ShellScreen screen
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
visible: Settings.data.network.bluetoothEnabled
sizeRatio: 0.8

View file

@ -9,7 +9,7 @@ Item {
id: root
property ShellScreen screen
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
property string barSection: ""
property int sectionWidgetIndex: 0
property int sectionWidgetsCount: 0

View file

@ -8,7 +8,7 @@ Rectangle {
id: root
property ShellScreen screen
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
implicitWidth: clock.width + Style.marginM * 2 * scaling
implicitHeight: Math.round(Style.capsuleHeight * scaling)

View file

@ -10,7 +10,7 @@ Row {
id: root
property ShellScreen screen
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
property string barSection: ""
property int sectionWidgetIndex: 0
property int sectionWidgetsCount: 0

View file

@ -11,7 +11,7 @@ Row {
id: root
property ShellScreen screen
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
readonly property real minWidth: 160
readonly property real maxWidth: 400

View file

@ -11,7 +11,7 @@ Item {
id: root
property ShellScreen screen
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
property string barSection: ""
property int sectionWidgetIndex: 0
property int sectionWidgetsCount: 0

View file

@ -11,7 +11,7 @@ NIconButton {
id: root
property ShellScreen screen
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
sizeRatio: 0.8

View file

@ -11,7 +11,7 @@ NIconButton {
id: root
property ShellScreen screen
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
sizeRatio: 0.8
icon: "notifications"

View file

@ -10,7 +10,7 @@ NIconButton {
id: root
property ShellScreen screen
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
property var powerProfiles: PowerProfiles
readonly property bool hasPP: powerProfiles.hasPerformanceProfile

View file

@ -8,7 +8,7 @@ NIconButton {
id: root
property ShellScreen screen
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
visible: ScreenRecorderService.isRecording
icon: "videocam"

View file

@ -7,7 +7,7 @@ NIconButton {
id: root
property ShellScreen screen
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
icon: "widgets"
tooltipText: "Open side panel"

View file

@ -8,7 +8,7 @@ Row {
id: root
property ShellScreen screen
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
anchors.verticalCenter: parent.verticalCenter
spacing: Style.marginS * scaling

View file

@ -12,7 +12,7 @@ import qs.Widgets
Rectangle {
id: root
property ShellScreen screen
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
readonly property real itemSize: Style.baseWidgetSize * 0.8 * scaling

View file

@ -14,7 +14,7 @@ Rectangle {
id: root
property ShellScreen screen
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
readonly property real itemSize: 24 * scaling
visible: SystemTray.items.values.length > 0

View file

@ -11,7 +11,7 @@ Item {
id: root
property ShellScreen screen
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
property string barSection: ""
property int sectionWidgetIndex: 0
property int sectionWidgetsCount: 0

View file

@ -11,7 +11,7 @@ NIconButton {
id: root
property ShellScreen screen
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
visible: Settings.data.network.wifiEnabled

View file

@ -12,7 +12,7 @@ Item {
id: root
property ShellScreen screen: null
property real scaling: ScalingService.scale(screen)
property real scaling: 1.0
property bool isDestroying: false
property bool hovered: false