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
+5 -5
View File
@@ -38,9 +38,9 @@ Item {
property bool showPill: false
property bool shouldAnimateHide: false
readonly property int pillHeight: Math.round(Style.capsuleHeight * scaling)
readonly property int pillPaddingHorizontal: Math.round(Style.capsuleHeight * 0.2 * scaling)
readonly property int pillOverlap: Math.round(Style.capsuleHeight * 0.5 * scaling)
readonly property int pillHeight: Math.round(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)
readonly property real iconSize: Math.max(1, compact ? pillHeight * 0.65 : pillHeight * 0.48)
@@ -80,10 +80,10 @@ Item {
x: {
// Better text horizontal centering
var centerX = (parent.width - width) / 2
var offset = rightOpen ? Style.marginXS * scaling : -Style.marginXS * scaling
var offset = rightOpen ? Style.marginXS : -Style.marginXS
if (forceOpen) {
// If its force open, the icon disc background is the same color as the bg pill move text slightly
offset += rightOpen ? -Style.marginXXS * scaling : Style.marginXXS * scaling
offset += rightOpen ? -Style.marginXXS : Style.marginXXS
}
return centerX + offset
}
+3 -3
View File
@@ -45,9 +45,9 @@ Item {
property bool shouldAnimateHide: false
// Sizing logic for vertical bars
readonly property int buttonSize: Math.round(Style.capsuleHeight * scaling)
readonly property int buttonSize: Math.round(Style.capsuleHeight)
readonly property int pillHeight: buttonSize
readonly property int pillPaddingVertical: 3 * 2 * scaling // Very precise adjustment don't replace by Style.margin
readonly property int pillPaddingVertical: 3 * 2 // Very precise adjustment don't replace by Style.margin
readonly property int pillOverlap: buttonSize * 0.5
readonly property int maxPillWidth: buttonSize
readonly property int maxPillHeight: Math.max(1, textItem.implicitHeight + pillPaddingVertical * 4)
@@ -95,7 +95,7 @@ Item {
var offset = openDownward ? pillPaddingVertical * 0.75 : -pillPaddingVertical * 0.75
if (forceOpen) {
// If its force open, the icon disc background is the same color as the bg pill move text slightly
offset += rightOpen ? -Style.marginXXS * scaling : Style.marginXXS * scaling
offset += rightOpen ? -Style.marginXXS : Style.marginXXS
}
return offset
}
-10
View File
@@ -16,16 +16,6 @@ Item {
implicitWidth: getImplicitSize(loader.item, "implicitWidth")
implicitHeight: getImplicitSize(loader.item, "implicitHeight")
Connections {
target: ScalingService
enabled: loader.item && (loader.item.screen !== undefined)
function onScaleChanged(aScreenName, scale) {
if (loader.item && loader.item.screen && aScreenName === screenName) {
loader.item['scaling'] = scale
}
}
}
function getImplicitSize(item, prop) {
return (item && item.visible) ? Math.round(item[prop]) : 0
}
+19 -29
View File
@@ -15,23 +15,13 @@ PopupWindow {
property bool isSubMenu: false
property bool isHovered: rootMouseArea.containsMouse
property ShellScreen screen
property real scaling: ScalingService.getScreenScale(screen)
Connections {
target: ScalingService
function onScaleChanged(screenName, scale) {
if ((screen != null) && (screenName === screen.name)) {
scaling = scale
}
}
}
readonly property int menuWidth: 180
implicitWidth: Math.round(menuWidth * scaling)
implicitWidth: Math.round(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 * scaling))
implicitHeight: Math.min(screen ? screen.height * 0.9 : Screen.height * 0.9, flickable.contentHeight + (Style.marginS * 2))
visible: false
color: Color.transparent
anchor.item: anchorItem
@@ -98,14 +88,14 @@ PopupWindow {
anchors.fill: parent
color: Color.mSurface
border.color: Color.mOutline
border.width: Math.max(1, Style.borderS * scaling)
radius: Style.radiusM * scaling
border.width: Math.max(1, Style.borderS)
radius: Style.radiusM
}
Flickable {
id: flickable
anchors.fill: parent
anchors.margins: Style.marginS * scaling
anchors.margins: Style.marginS
contentHeight: columnLayout.implicitHeight
interactive: true
@@ -125,11 +115,11 @@ PopupWindow {
Layout.preferredWidth: parent.width
Layout.preferredHeight: {
if (modelData?.isSeparator) {
return 8 * scaling
return 8
} else {
// Calculate based on text content
const textHeight = text.contentHeight || (Style.fontSizeS * scaling * 1.2)
return Math.max(28 * scaling, textHeight + (Style.marginS * 2 * scaling))
const textHeight = text.contentHeight || (Style.fontSizeS * 1.2)
return Math.max(28, textHeight + (Style.marginS * 2))
}
}
@@ -138,35 +128,35 @@ PopupWindow {
NDivider {
anchors.centerIn: parent
width: parent.width - (Style.marginM * scaling * 2)
width: parent.width - (Style.marginM * 2)
visible: modelData?.isSeparator ?? false
}
Rectangle {
anchors.fill: parent
color: mouseArea.containsMouse ? Color.mTertiary : Color.transparent
radius: Style.radiusS * scaling
radius: Style.radiusS
visible: !(modelData?.isSeparator ?? false)
RowLayout {
anchors.fill: parent
anchors.leftMargin: Style.marginM * scaling
anchors.rightMargin: Style.marginM * scaling
spacing: Style.marginS * scaling
anchors.leftMargin: Style.marginM
anchors.rightMargin: Style.marginM
spacing: Style.marginS
NText {
id: text
Layout.fillWidth: true
color: (modelData?.enabled ?? true) ? (mouseArea.containsMouse ? Color.mOnTertiary : Color.mOnSurface) : Color.mOnSurfaceVariant
text: modelData?.text !== "" ? modelData?.text.replace(/[\n\r]+/g, ' ') : "..."
pointSize: Style.fontSizeS * scaling
pointSize: Style.fontSizeS
verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
}
Image {
Layout.preferredWidth: Style.marginL * scaling
Layout.preferredHeight: Style.marginL * scaling
Layout.preferredWidth: Style.marginL
Layout.preferredHeight: Style.marginL
source: modelData?.icon ?? ""
visible: (modelData?.icon ?? "") !== ""
fillMode: Image.PreserveAspectFit
@@ -174,7 +164,7 @@ PopupWindow {
NIcon {
icon: modelData?.hasChildren ? "menu" : ""
pointSize: Style.fontSizeS * scaling
pointSize: Style.fontSizeS
verticalAlignment: Text.AlignVCenter
visible: modelData?.hasChildren ?? false
color: (mouseArea.containsMouse ? Color.mOnTertiary : Color.mOnSurface)
@@ -216,8 +206,8 @@ PopupWindow {
}
// Need a slight overlap so that menu don't close when moving the mouse to a submenu
const submenuWidth = menuWidth * scaling // Assuming a similar width as the parent
const overlap = 4 * scaling // A small overlap to bridge the mouse path
const submenuWidth = menuWidth // Assuming a similar width as the parent
const overlap = 4 // A small overlap to bridge the mouse path
// Determine submenu opening direction based on bar position and available space
let openLeft = false