feat: improve lock fetch
Also lock fetch is static height, media fills height instead
This commit is contained in:
parent
57123a5c8c
commit
afb52ec506
3 changed files with 107 additions and 109 deletions
|
|
@ -20,18 +20,14 @@ RowLayout {
|
||||||
rootHeight: root.height
|
rootHeight: root.height
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledRect {
|
Fetch {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
rootHeight: root.height
|
||||||
|
|
||||||
radius: Tokens.rounding.medium
|
|
||||||
color: Colours.tPalette.m3surfaceContainer
|
|
||||||
|
|
||||||
Fetch {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Media {
|
Media {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
lock: root.lock
|
lock: root.lock
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,140 +3,146 @@ pragma ComponentBehavior: Bound
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import Quickshell.Services.UPower
|
import Quickshell.Services.UPower
|
||||||
|
import Caelestia
|
||||||
import Caelestia.Config
|
import Caelestia.Config
|
||||||
import qs.components
|
import qs.components
|
||||||
import qs.components.effects
|
import qs.components.effects
|
||||||
import qs.services
|
import qs.services
|
||||||
import qs.utils
|
import qs.utils
|
||||||
|
|
||||||
ColumnLayout {
|
StyledRect {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
anchors.fill: parent
|
required property real rootHeight
|
||||||
anchors.margins: Tokens.padding.extraLargeIncreased
|
readonly property int cBoxSize: Tokens.font.body.medium.pointSize * 2
|
||||||
anchors.topMargin: Tokens.padding.large
|
|
||||||
|
|
||||||
spacing: Tokens.spacing.small
|
implicitHeight: layout.implicitHeight + layout.anchors.topMargin + layout.anchors.margins
|
||||||
|
radius: Tokens.rounding.medium
|
||||||
|
color: Colours.tPalette.m3surfaceContainer
|
||||||
|
|
||||||
RowLayout {
|
ColumnLayout {
|
||||||
Layout.fillWidth: true
|
id: layout
|
||||||
Layout.fillHeight: false
|
|
||||||
spacing: Tokens.spacing.medium
|
|
||||||
|
|
||||||
StyledRect {
|
anchors.fill: parent
|
||||||
implicitWidth: prompt.implicitWidth + Tokens.padding.medium * 2
|
anchors.margins: Tokens.padding.extraLarge
|
||||||
implicitHeight: prompt.implicitHeight + Tokens.padding.medium * 2
|
anchors.topMargin: Tokens.padding.extraLarge
|
||||||
|
anchors.bottomMargin: Tokens.padding.extraLarge
|
||||||
|
|
||||||
color: Colours.palette.m3primary
|
spacing: Tokens.spacing.small
|
||||||
radius: Tokens.rounding.medium
|
|
||||||
|
|
||||||
MonoText {
|
RowLayout {
|
||||||
id: prompt
|
|
||||||
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: ">"
|
|
||||||
font: root.width > 400 ? Tokens.font.mono.large : Tokens.font.mono.medium
|
|
||||||
color: Colours.palette.m3onPrimary
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MonoText {
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: "caelestiafetch.sh"
|
Layout.fillHeight: false
|
||||||
font: root.width > 400 ? Tokens.font.mono.large : Tokens.font.mono.medium
|
|
||||||
elide: Text.ElideRight
|
|
||||||
}
|
|
||||||
|
|
||||||
WrappedLoader {
|
|
||||||
Layout.fillHeight: true
|
|
||||||
active: !iconLoader.active
|
|
||||||
|
|
||||||
sourceComponent: SysInfo.isDefaultLogo ? caelestiaLogo : distroIcon
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.fillHeight: false
|
|
||||||
spacing: height * 0.15
|
|
||||||
|
|
||||||
WrappedLoader {
|
|
||||||
id: iconLoader
|
|
||||||
|
|
||||||
Layout.fillHeight: true
|
|
||||||
active: root.width > 320
|
|
||||||
|
|
||||||
sourceComponent: SysInfo.isDefaultLogo ? caelestiaLogo : distroIcon
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnLayout {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
Layout.topMargin: Tokens.padding.medium
|
|
||||||
Layout.bottomMargin: Tokens.padding.medium
|
|
||||||
Layout.leftMargin: iconLoader.active ? 0 : width * 0.1
|
|
||||||
spacing: Tokens.spacing.medium
|
spacing: Tokens.spacing.medium
|
||||||
|
|
||||||
WrappedLoader {
|
StyledRect {
|
||||||
Layout.fillWidth: true
|
implicitWidth: prompt.implicitWidth + Tokens.padding.medium * 2
|
||||||
active: !batLoader.active && root.height > 200
|
implicitHeight: prompt.implicitHeight + Tokens.padding.small * 2
|
||||||
|
|
||||||
sourceComponent: FetchText {
|
color: Colours.palette.m3primary
|
||||||
text: `OS : ${SysInfo.osPrettyName || SysInfo.osName}`
|
radius: Tokens.rounding.medium
|
||||||
|
|
||||||
|
MonoText {
|
||||||
|
id: prompt
|
||||||
|
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: ">"
|
||||||
|
color: Colours.palette.m3onPrimary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WrappedLoader {
|
MonoText {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
active: root.height > (batLoader.active ? 200 : 110)
|
text: "caelestiafetch.sh"
|
||||||
|
elide: Text.ElideRight
|
||||||
sourceComponent: FetchText {
|
|
||||||
text: `WM : ${SysInfo.wm}`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WrappedLoader {
|
WrappedLoader {
|
||||||
Layout.fillWidth: true
|
Layout.fillHeight: true
|
||||||
active: !batLoader.active || root.height > 110
|
Layout.preferredWidth: height
|
||||||
|
Layout.preferredHeight: 0
|
||||||
|
active: !iconLoader.active
|
||||||
|
|
||||||
sourceComponent: FetchText {
|
sourceComponent: SysInfo.isDefaultLogo ? caelestiaLogo : distroIcon
|
||||||
text: `USER: ${SysInfo.user}`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FetchText {
|
RowLayout {
|
||||||
text: `UP : ${SysInfo.uptime}`
|
Layout.topMargin: -Tokens.spacing.extraSmall
|
||||||
}
|
Layout.bottomMargin: Tokens.spacing.small
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
spacing: Tokens.spacing.extraLarge
|
||||||
|
|
||||||
WrappedLoader {
|
WrappedLoader {
|
||||||
id: batLoader
|
id: iconLoader
|
||||||
|
|
||||||
|
Layout.fillHeight: true
|
||||||
|
active: root.width > 320
|
||||||
|
|
||||||
|
sourceComponent: SysInfo.isDefaultLogo ? caelestiaLogo : distroIcon
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
active: UPower.displayDevice.isLaptopBattery
|
Layout.topMargin: Tokens.padding.medium
|
||||||
|
Layout.bottomMargin: Tokens.padding.medium
|
||||||
|
spacing: Tokens.spacing.medium
|
||||||
|
|
||||||
sourceComponent: FetchText {
|
Repeater {
|
||||||
text: `BATT: ${[UPowerDeviceState.Charging, UPowerDeviceState.FullyCharged, UPowerDeviceState.PendingCharge].includes(UPower.displayDevice.state) ? "(+) " : ""}${Math.round(UPower.displayDevice.percentage * 100)}%`
|
model: {
|
||||||
|
const items = [];
|
||||||
|
const hasBatt = UPower.displayDevice.isLaptopBattery;
|
||||||
|
const rHeight = root.rootHeight;
|
||||||
|
|
||||||
|
if (!hasBatt && rHeight > 200)
|
||||||
|
items.push(`OS : ${SysInfo.osPrettyName || SysInfo.osName}`);
|
||||||
|
|
||||||
|
if (rHeight > (hasBatt ? 200 : 110))
|
||||||
|
items.push(`WM : ${SysInfo.wm}`);
|
||||||
|
|
||||||
|
if (!hasBatt || rHeight > 110)
|
||||||
|
items.push(`USER: ${SysInfo.user}`);
|
||||||
|
|
||||||
|
items.push(`UP : ${SysInfo.uptime}`);
|
||||||
|
|
||||||
|
if (hasBatt)
|
||||||
|
items.push(`BATT: ${[UPowerDeviceState.Charging, UPowerDeviceState.FullyCharged, UPowerDeviceState.PendingCharge].includes(UPower.displayDevice.state) ? "(+) " : ""}${Math.round(UPower.displayDevice.percentage * 100)}%`);
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
MonoText {
|
||||||
|
required property string modelData
|
||||||
|
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: modelData
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
WrappedLoader {
|
WrappedLoader {
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
active: root.height > 180
|
active: root.rootHeight > 180
|
||||||
|
|
||||||
sourceComponent: RowLayout {
|
sourceComponent: RowLayout {
|
||||||
spacing: Tokens.spacing.largeIncreased
|
id: coloursRow
|
||||||
|
|
||||||
Repeater {
|
spacing: Tokens.spacing.largeIncreased
|
||||||
model: Math.max(0, Math.min(8, root.width / (Tokens.font.body.large.pointSize * 2 + Tokens.spacing.large)))
|
|
||||||
|
|
||||||
StyledRect {
|
Repeater {
|
||||||
required property int index
|
model: CUtils.clamp(Math.floor((layout.width + coloursRow.spacing) / (root.cBoxSize + coloursRow.spacing)), 0, 8)
|
||||||
|
|
||||||
implicitWidth: implicitHeight
|
StyledRect {
|
||||||
implicitHeight: Tokens.font.body.large.pointSize * 2
|
required property int index
|
||||||
color: Colours.palette[`term${index}`]
|
|
||||||
radius: Tokens.rounding.medium
|
implicitWidth: implicitHeight
|
||||||
|
implicitHeight: root.cBoxSize
|
||||||
|
color: Colours.palette[`term${index}`]
|
||||||
|
radius: Tokens.rounding.medium
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -166,13 +172,7 @@ ColumnLayout {
|
||||||
visible: active
|
visible: active
|
||||||
}
|
}
|
||||||
|
|
||||||
component FetchText: MonoText {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
font: root.width > 400 ? Tokens.font.mono.large : Tokens.font.mono.medium
|
|
||||||
elide: Text.ElideRight
|
|
||||||
}
|
|
||||||
|
|
||||||
component MonoText: StyledText {
|
component MonoText: StyledText {
|
||||||
font: Tokens.font.mono.small
|
font: root.width > 400 ? Tokens.font.mono.medium : Tokens.font.mono.small
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,9 @@ StyledClippingRect {
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: layout
|
id: layout
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
anchors.margins: Tokens.padding.extraLarge
|
anchors.margins: Tokens.padding.extraLarge
|
||||||
spacing: Tokens.spacing.extraSmall
|
spacing: Tokens.spacing.extraSmall
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue