161 lines
4.6 KiB
QML
161 lines
4.6 KiB
QML
pragma ComponentBehavior: Bound
|
|
|
|
import qs.config
|
|
import qs.custom
|
|
import qs.services
|
|
import qs.util
|
|
import Quickshell
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
|
|
ColumnLayout {
|
|
id: root
|
|
|
|
spacing: 7
|
|
width: 340
|
|
|
|
function nixosVersionShort(version: string): string {
|
|
const parts = version.split('.');
|
|
return `${parts[0]}.${parts[1]}`;
|
|
}
|
|
|
|
Row {
|
|
spacing: 12
|
|
|
|
Image {
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
readonly property real size: 72
|
|
|
|
source: "root:/assets/nixos-logo.svg"
|
|
width: size
|
|
height: size
|
|
sourceSize.width: size
|
|
sourceSize.height: size
|
|
}
|
|
|
|
CustomText {
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
text: "NixOS"
|
|
color: Config.colors.secondary
|
|
font.pointSize: Config.font.size.largest * 1.3
|
|
}
|
|
|
|
Column {
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
anchors.verticalCenterOffset: -2
|
|
|
|
CustomText {
|
|
text: "v" + root.nixosVersionShort(NixOS.currentGen?.nixosVersion)
|
|
font.pointSize: Config.font.size.larger
|
|
}
|
|
|
|
CustomText {
|
|
text: "Nix " + NixOS.nixVersion
|
|
}
|
|
}
|
|
}
|
|
|
|
CustomRect {
|
|
Layout.topMargin: 5
|
|
Layout.fillWidth: true
|
|
height: 180
|
|
|
|
radius: 17
|
|
color: Config.colors.container
|
|
|
|
CustomText {
|
|
id: genText
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
anchors.top: parent.top
|
|
anchors.topMargin: 7
|
|
|
|
text: "Generations"
|
|
color: Config.colors.secondary
|
|
font.pointSize: Config.font.size.normal
|
|
font.weight: 500
|
|
}
|
|
|
|
CustomListView {
|
|
id: list
|
|
|
|
anchors.top: genText.bottom
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
anchors.bottom: parent.bottom
|
|
anchors.margins: 6
|
|
anchors.topMargin: 8
|
|
|
|
spacing: 6
|
|
clip: true
|
|
|
|
model: ScriptModel {
|
|
values: [...NixOS.generations]
|
|
objectProp: "id"
|
|
}
|
|
|
|
CustomScrollBar.vertical: CustomScrollBar {
|
|
flickable: list
|
|
}
|
|
|
|
|
|
delegate: CustomRect {
|
|
required property NixOS.Generation modelData
|
|
|
|
width: list.width
|
|
height: 42
|
|
|
|
radius: 12
|
|
color: modelData.current ?
|
|
Qt.tint(Config.colors.container, Qt.alpha(Config.colors.nixos, 0.2)) :
|
|
Config.colors.containerAlt
|
|
|
|
Item {
|
|
anchors.fill: parent
|
|
anchors.margins: 7
|
|
anchors.topMargin: 2
|
|
anchors.bottomMargin: 1
|
|
|
|
CustomText {
|
|
anchors.top: parent.top
|
|
anchors.left: parent.left
|
|
anchors.topMargin: 2
|
|
|
|
text: `Generation ${modelData.id}`
|
|
color: modelData.current ? Config.colors.nixos : Config.colors.secondary
|
|
}
|
|
|
|
CustomText {
|
|
anchors.bottom: parent.bottom
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
anchors.rightMargin: 6
|
|
|
|
text: modelData.revision !== "Unknown" ? modelData.revision : ""
|
|
elide: Text.ElideRight
|
|
font.family: Config.font.family.mono
|
|
color: modelData.current ? Config.colors.secondary : Config.colors.primary
|
|
}
|
|
|
|
CustomText {
|
|
anchors.top: parent.top
|
|
anchors.right: parent.right
|
|
|
|
text: `NixOS ${root.nixosVersionShort(modelData.nixosVersion)} 🞄 Linux ${modelData.kernelVersion}`
|
|
color: modelData.current ? Config.colors.secondary : Config.colors.primary
|
|
}
|
|
|
|
CustomText {
|
|
anchors.bottom: parent.bottom
|
|
anchors.right: parent.right
|
|
|
|
text: Qt.formatDateTime(modelData.date, "yyyy-MM-dd ddd hh:mm")
|
|
font.family: Config.font.family.mono
|
|
color: modelData.current ? Config.colors.secondary : Config.colors.primary
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|