mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-06-06 03:55:02 +00:00
Merge pull request #496 from lonerOrz/feat/adapt-bar-density-scaling
feat(bar): Introduce core density scaling mechanism
This commit is contained in:
@@ -102,6 +102,7 @@ Variants {
|
||||
model: Settings.data.bar.widgets.left
|
||||
delegate: BarWidgetLoader {
|
||||
widgetId: (modelData.id !== undefined ? modelData.id : "")
|
||||
barDensity: Settings.data.bar.density
|
||||
widgetProps: {
|
||||
"screen": root.modelData || null,
|
||||
"widgetId": modelData.id,
|
||||
@@ -124,6 +125,7 @@ Variants {
|
||||
model: Settings.data.bar.widgets.center
|
||||
delegate: BarWidgetLoader {
|
||||
widgetId: (modelData.id !== undefined ? modelData.id : "")
|
||||
barDensity: Settings.data.bar.density
|
||||
widgetProps: {
|
||||
"screen": root.modelData || null,
|
||||
"widgetId": modelData.id,
|
||||
@@ -147,6 +149,7 @@ Variants {
|
||||
model: Settings.data.bar.widgets.right
|
||||
delegate: BarWidgetLoader {
|
||||
widgetId: (modelData.id !== undefined ? modelData.id : "")
|
||||
barDensity: Settings.data.bar.density
|
||||
widgetProps: {
|
||||
"screen": root.modelData || null,
|
||||
"widgetId": modelData.id,
|
||||
@@ -180,6 +183,7 @@ Variants {
|
||||
model: Settings.data.bar.widgets.left
|
||||
delegate: BarWidgetLoader {
|
||||
widgetId: (modelData.id !== undefined ? modelData.id : "")
|
||||
barDensity: Settings.data.bar.density
|
||||
widgetProps: {
|
||||
"screen": root.modelData || null,
|
||||
"widgetId": modelData.id,
|
||||
@@ -204,6 +208,7 @@ Variants {
|
||||
model: Settings.data.bar.widgets.center
|
||||
delegate: BarWidgetLoader {
|
||||
widgetId: (modelData.id !== undefined ? modelData.id : "")
|
||||
barDensity: Settings.data.bar.density
|
||||
widgetProps: {
|
||||
"screen": root.modelData || null,
|
||||
"widgetId": modelData.id,
|
||||
@@ -229,6 +234,7 @@ Variants {
|
||||
model: Settings.data.bar.widgets.right
|
||||
delegate: BarWidgetLoader {
|
||||
widgetId: (modelData.id !== undefined ? modelData.id : "")
|
||||
barDensity: Settings.data.bar.density
|
||||
widgetProps: {
|
||||
"screen": root.modelData || null,
|
||||
"widgetId": modelData.id,
|
||||
|
||||
@@ -12,6 +12,9 @@ Item {
|
||||
property string section: widgetProps && widgetProps.section || ""
|
||||
property int sectionIndex: widgetProps && widgetProps.sectionWidgetIndex || 0
|
||||
|
||||
property string barDensity: "default"
|
||||
readonly property real scaling: barDensity === "mini" ? 0.8 : (barDensity === "compact" ? 0.9 : 1.0)
|
||||
|
||||
// Don't reserve space unless the loaded widget is really visible
|
||||
implicitWidth: getImplicitSize(loader.item, "implicitWidth")
|
||||
implicitHeight: getImplicitSize(loader.item, "implicitHeight")
|
||||
@@ -40,6 +43,10 @@ Item {
|
||||
item[prop] = widgetProps[prop]
|
||||
}
|
||||
}
|
||||
// Explicitly set scaling property
|
||||
if (item.hasOwnProperty("scaling")) {
|
||||
item.scaling = Qt.binding(function() { return root.scaling; })
|
||||
}
|
||||
}
|
||||
|
||||
// Register this widget instance with BarService
|
||||
|
||||
@@ -18,6 +18,7 @@ Item {
|
||||
property string section: ""
|
||||
property int sectionWidgetIndex: -1
|
||||
property int sectionWidgetsCount: 0
|
||||
property real scaling: 1.0
|
||||
|
||||
property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId]
|
||||
property var widgetSettings: {
|
||||
@@ -55,8 +56,7 @@ Item {
|
||||
}
|
||||
|
||||
function calculatedVerticalDimension() {
|
||||
const ratio = (Settings.data.bar.density === "mini") ? 0.67 : 0.8
|
||||
return Math.round(Style.baseWidgetSize * ratio)
|
||||
return Math.round((Style.baseWidgetSize - 5) * scaling)
|
||||
}
|
||||
|
||||
function getAppIcon() {
|
||||
@@ -107,7 +107,7 @@ Item {
|
||||
id: fullTitleMetrics
|
||||
visible: false
|
||||
text: windowTitle
|
||||
pointSize: Style.fontSizeS
|
||||
pointSize: Style.fontSizeS * scaling
|
||||
applyUiScale: false
|
||||
font.weight: Style.fontWeightMedium
|
||||
}
|
||||
@@ -125,21 +125,21 @@ Item {
|
||||
Item {
|
||||
id: mainContainer
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: isVerticalBar ? 0 : Style.marginS
|
||||
anchors.rightMargin: isVerticalBar ? 0 : Style.marginS
|
||||
anchors.leftMargin: isVerticalBar ? 0 : Style.marginS * scaling
|
||||
anchors.rightMargin: isVerticalBar ? 0 : Style.marginS * scaling
|
||||
|
||||
// Horizontal layout for top/bottom bars
|
||||
RowLayout {
|
||||
id: rowLayout
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Style.marginS
|
||||
spacing: Style.marginS * scaling
|
||||
visible: !isVerticalBar
|
||||
z: 1
|
||||
|
||||
// Window icon
|
||||
Item {
|
||||
Layout.preferredWidth: 18
|
||||
Layout.preferredHeight: 18
|
||||
Layout.preferredWidth: 18 * scaling
|
||||
Layout.preferredHeight: 18 * scaling
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
visible: showIcon
|
||||
|
||||
@@ -254,7 +254,7 @@ Item {
|
||||
NText {
|
||||
id: titleText
|
||||
text: windowTitle
|
||||
pointSize: Style.fontSizeS
|
||||
pointSize: Style.fontSizeS * scaling
|
||||
applyUiScale: false
|
||||
font.weight: Style.fontWeightMedium
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
@@ -265,7 +265,7 @@ Item {
|
||||
NText {
|
||||
text: windowTitle
|
||||
font: titleText.font
|
||||
pointSize: Style.fontSizeS
|
||||
pointSize: Style.fontSizeS * scaling
|
||||
applyUiScale: false
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
color: Color.mOnSurface
|
||||
@@ -316,7 +316,7 @@ Item {
|
||||
|
||||
// Window icon
|
||||
Item {
|
||||
width: Style.baseWidgetSize * 0.5
|
||||
width: Style.baseWidgetSize * 0.5 * scaling
|
||||
height: width
|
||||
anchors.centerIn: parent
|
||||
visible: windowTitle !== ""
|
||||
|
||||
@@ -15,6 +15,7 @@ Rectangle {
|
||||
property string section: ""
|
||||
property int sectionWidgetIndex: -1
|
||||
property int sectionWidgetsCount: 0
|
||||
property real scaling: 1.0
|
||||
|
||||
property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId]
|
||||
property var widgetSettings: {
|
||||
@@ -66,11 +67,13 @@ Rectangle {
|
||||
visible: text !== ""
|
||||
text: modelData
|
||||
family: useCustomFont && customFont ? customFont : Settings.data.ui.fontDefault
|
||||
pointSize: {
|
||||
if (repeater.model.length == 1) {
|
||||
return Style.fontSizeS
|
||||
} else {
|
||||
return (index == 0) ? Style.fontSizeXS : Style.fontSizeXXS
|
||||
Binding on pointSize {
|
||||
value: {
|
||||
if (repeater.model.length == 1) {
|
||||
return Style.fontSizeS * scaling
|
||||
} else {
|
||||
return (index == 0) ? Style.fontSizeXS * scaling : Style.fontSizeXXS * scaling
|
||||
}
|
||||
}
|
||||
}
|
||||
applyUiScale: false
|
||||
@@ -97,8 +100,11 @@ Rectangle {
|
||||
visible: text !== ""
|
||||
text: modelData
|
||||
family: useCustomFont && customFont ? customFont : Settings.data.ui.fontDefault
|
||||
pointSize: Style.fontSizeS
|
||||
Binding on pointSize {
|
||||
value: Style.fontSizeS * scaling
|
||||
}
|
||||
applyUiScale: false
|
||||
|
||||
font.weight: Style.fontWeightBold
|
||||
color: usePrimaryColor ? Color.mPrimary : Color.mOnSurface
|
||||
wrapMode: Text.WordWrap
|
||||
|
||||
@@ -17,6 +17,7 @@ Item {
|
||||
property string section: ""
|
||||
property int sectionWidgetIndex: -1
|
||||
property int sectionWidgetsCount: 0
|
||||
property real scaling: 1.0
|
||||
|
||||
property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId]
|
||||
property var widgetSettings: {
|
||||
@@ -76,8 +77,7 @@ Item {
|
||||
}
|
||||
|
||||
function calculatedVerticalDimension() {
|
||||
const ratio = (Settings.data.bar.density === "mini") ? 0.67 : 0.8
|
||||
return Math.round(Style.baseWidgetSize * ratio)
|
||||
return Math.round((Style.baseWidgetSize - 5) * scaling)
|
||||
}
|
||||
|
||||
// A hidden text element to safely measure the full title width
|
||||
@@ -87,6 +87,7 @@ Item {
|
||||
text: titleText.text
|
||||
font: titleText.font
|
||||
applyUiScale: false
|
||||
pointSize: Style.fontSizeS * scaling
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
@@ -102,8 +103,8 @@ Item {
|
||||
Item {
|
||||
id: mainContainer
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: isVerticalBar ? 0 : Style.marginS
|
||||
anchors.rightMargin: isVerticalBar ? 0 : Style.marginS
|
||||
anchors.leftMargin: isVerticalBar ? 0 : Style.marginS * scaling
|
||||
anchors.rightMargin: isVerticalBar ? 0 : Style.marginS * scaling
|
||||
|
||||
Loader {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
@@ -155,7 +156,7 @@ Item {
|
||||
id: rowLayout
|
||||
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Style.marginS
|
||||
spacing: Style.marginS * scaling
|
||||
visible: !isVerticalBar
|
||||
z: 1 // Above the visualizer
|
||||
|
||||
@@ -163,7 +164,7 @@ Item {
|
||||
id: windowIcon
|
||||
icon: hasActivePlayer ? (MediaService.isPlaying ? "media-pause" : "media-play") : "disc"
|
||||
color: hasActivePlayer ? Color.mOnSurface : Color.mOnSurfaceVariant
|
||||
pointSize: Style.fontSizeL
|
||||
pointSize: Style.fontSizeL * scaling
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
visible: !hasActivePlayer || (!showAlbumArt && !trackArt.visible)
|
||||
@@ -175,8 +176,8 @@ Item {
|
||||
spacing: 0
|
||||
|
||||
Item {
|
||||
Layout.preferredWidth: Math.round(21 * Style.uiScaleRatio)
|
||||
Layout.preferredHeight: Math.round(21 * Style.uiScaleRatio)
|
||||
Layout.preferredWidth: Math.round(21 * Style.uiScaleRatio * scaling)
|
||||
Layout.preferredHeight: Math.round(21 * Style.uiScaleRatio * scaling)
|
||||
|
||||
NImageCircled {
|
||||
id: trackArt
|
||||
@@ -288,7 +289,7 @@ Item {
|
||||
NText {
|
||||
id: titleText
|
||||
text: hasActivePlayer ? getTitle() : placeholderText
|
||||
pointSize: Style.fontSizeS
|
||||
pointSize: Style.fontSizeS * scaling
|
||||
applyUiScale: false
|
||||
font.weight: Style.fontWeightMedium
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
@@ -300,6 +301,7 @@ Item {
|
||||
text: hasActivePlayer ? getTitle() : placeholderText
|
||||
font: titleText.font
|
||||
applyUiScale: false
|
||||
pointSize: Style.fontSizeS * scaling
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: hasActivePlayer ? Text.AlignLeft : Text.AlignHCenter
|
||||
color: hasActivePlayer ? Color.mOnSurface : Color.mOnSurfaceVariant
|
||||
@@ -359,7 +361,7 @@ Item {
|
||||
anchors.fill: parent
|
||||
icon: hasActivePlayer ? (MediaService.isPlaying ? "media-pause" : "media-play") : "disc"
|
||||
color: hasActivePlayer ? Color.mOnSurface : Color.mOnSurfaceVariant
|
||||
pointSize: Style.fontSizeL
|
||||
pointSize: Style.fontSizeL * scaling
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user