osd: loader content
This commit is contained in:
parent
2fa949139a
commit
d06d8b870f
3 changed files with 19 additions and 9 deletions
|
|
@ -10,6 +10,7 @@ Slider {
|
||||||
|
|
||||||
required property string icon
|
required property string icon
|
||||||
property real oldValue
|
property real oldValue
|
||||||
|
property bool initialized
|
||||||
|
|
||||||
orientation: Qt.Vertical
|
orientation: Qt.Vertical
|
||||||
|
|
||||||
|
|
@ -32,7 +33,7 @@ Slider {
|
||||||
handle: Item {
|
handle: Item {
|
||||||
id: handle
|
id: handle
|
||||||
|
|
||||||
property bool moving
|
property alias moving: icon.moving
|
||||||
|
|
||||||
y: root.visualPosition * (root.availableHeight - height)
|
y: root.visualPosition * (root.availableHeight - height)
|
||||||
implicitWidth: root.width
|
implicitWidth: root.width
|
||||||
|
|
@ -64,7 +65,7 @@ Slider {
|
||||||
MaterialIcon {
|
MaterialIcon {
|
||||||
id: icon
|
id: icon
|
||||||
|
|
||||||
property bool moving: handle.moving
|
property bool moving
|
||||||
|
|
||||||
function update(): void {
|
function update(): void {
|
||||||
animate = !moving;
|
animate = !moving;
|
||||||
|
|
@ -73,7 +74,6 @@ Slider {
|
||||||
font.family = moving ? Appearance.font.family.sans : Appearance.font.family.material;
|
font.family = moving ? Appearance.font.family.sans : Appearance.font.family.material;
|
||||||
}
|
}
|
||||||
|
|
||||||
animate: true
|
|
||||||
text: root.icon
|
text: root.icon
|
||||||
color: Colours.palette.m3inverseOnSurface
|
color: Colours.palette.m3inverseOnSurface
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
|
@ -108,6 +108,10 @@ Slider {
|
||||||
onPressedChanged: handle.moving = pressed
|
onPressedChanged: handle.moving = pressed
|
||||||
|
|
||||||
onValueChanged: {
|
onValueChanged: {
|
||||||
|
if (!initialized) {
|
||||||
|
initialized = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (Math.abs(value - oldValue) < 0.01)
|
if (Math.abs(value - oldValue) < 0.01)
|
||||||
return;
|
return;
|
||||||
oldValue = value;
|
oldValue = value;
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,6 @@ Item {
|
||||||
required property Brightness.Monitor monitor
|
required property Brightness.Monitor monitor
|
||||||
required property var visibilities
|
required property var visibilities
|
||||||
|
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
|
||||||
anchors.left: parent.left
|
|
||||||
|
|
||||||
implicitWidth: layout.implicitWidth + Appearance.padding.large * 2
|
implicitWidth: layout.implicitWidth + Appearance.padding.large * 2
|
||||||
implicitHeight: layout.implicitHeight + Appearance.padding.large * 2
|
implicitHeight: layout.implicitHeight + Appearance.padding.large * 2
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import qs.components
|
import qs.components
|
||||||
import qs.services
|
import qs.services
|
||||||
import qs.config
|
import qs.config
|
||||||
|
|
@ -46,10 +48,17 @@ Item {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
Content {
|
Loader {
|
||||||
id: content
|
id: content
|
||||||
|
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
anchors.left: parent.left
|
||||||
|
|
||||||
|
Component.onCompleted: active = Qt.binding(() => (root.visibilities.osd && Config.osd.enabled) || root.visible)
|
||||||
|
|
||||||
|
sourceComponent: Content {
|
||||||
monitor: Brightness.getMonitorForScreen(root.screen)
|
monitor: Brightness.getMonitorForScreen(root.screen)
|
||||||
visibilities: root.visibilities
|
visibilities: root.visibilities
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue