195 lines
6.6 KiB
QML
195 lines
6.6 KiB
QML
import QtQuick
|
|
import QtQuick.Layouts
|
|
import Quickshell
|
|
import Quickshell.Hyprland
|
|
import "../../config"
|
|
|
|
Item {
|
|
id: root
|
|
implicitWidth: row.implicitWidth + 6
|
|
implicitHeight: Appearance.barHeight
|
|
|
|
|
|
required property var barWindow
|
|
|
|
RowLayout {
|
|
id: row
|
|
anchors.centerIn: parent
|
|
spacing: 4
|
|
|
|
Text {
|
|
id: label
|
|
font.family: SystemUpdates.checking ? Appearance.iconFontFamilyRounded : Appearance.fontFamily
|
|
font.variableAxes: Appearance.iconFontAxes
|
|
font.pixelSize: SystemUpdates.checking ? 15 : 22
|
|
color: Colors.foreground
|
|
text: SystemUpdates.checking ? "progress_activity" : ""
|
|
|
|
RotationAnimation on rotation {
|
|
running: SystemUpdates.checking
|
|
loops: Animation.Infinite
|
|
from: 0
|
|
to: 360
|
|
duration: 900
|
|
onRunningChanged: if (!running) label.rotation = 0
|
|
}
|
|
}
|
|
|
|
Text {
|
|
font.family: Appearance.fontFamily
|
|
font.pixelSize: Appearance.fontSizeSmall
|
|
color: label.color
|
|
text: SystemUpdates.updateCount
|
|
}
|
|
}
|
|
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
cursorShape: Qt.PointingHandCursor
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
onClicked: (mouse) => {
|
|
if (mouse.button === Qt.RightButton) {
|
|
SystemUpdates.refresh()
|
|
} else {
|
|
panel.visible = !panel.visible
|
|
grab.active = panel.visible
|
|
}
|
|
}
|
|
}
|
|
|
|
PopupWindow {
|
|
id: panel
|
|
visible: false
|
|
color: "transparent"
|
|
readonly property int contentWidth: 200
|
|
readonly property int contentPadding: 16
|
|
implicitWidth: contentWidth + contentPadding * 2
|
|
implicitHeight: mainColumn.implicitHeight + contentPadding * 2
|
|
|
|
anchor {
|
|
window: root.barWindow
|
|
rect.x: 0
|
|
rect.y: 0
|
|
rect.width: root.barWindow.width
|
|
rect.height: root.barWindow.height
|
|
edges: Edges.Bottom
|
|
gravity: Edges.Bottom
|
|
margins.bottom: -4
|
|
}
|
|
|
|
HyprlandFocusGrab {
|
|
id: grab
|
|
windows: [panel]
|
|
onCleared: panel.visible = false
|
|
}
|
|
|
|
Rectangle {
|
|
anchors.fill: parent
|
|
radius: 0
|
|
color: Colors.surface
|
|
border.color: Colors.muted
|
|
border.width: 3
|
|
|
|
Column {
|
|
id: mainColumn
|
|
anchors.fill: parent
|
|
anchors.margins: panel.contentPadding
|
|
spacing: 10
|
|
|
|
RowLayout {
|
|
width: parent.width
|
|
spacing: 8
|
|
|
|
Text {
|
|
text: label.text
|
|
font.family: Appearance.fontFamily
|
|
font.pixelSize: 23
|
|
color: Colors.foreground
|
|
}
|
|
|
|
Text {
|
|
Layout.fillWidth: true
|
|
text: "System Update"
|
|
font.family: Appearance.fontFamily
|
|
font.pixelSize: 18
|
|
font.bold: true
|
|
color: Colors.foreground
|
|
}
|
|
}
|
|
|
|
Text {
|
|
width: parent.width
|
|
wrapMode: Text.WordWrap
|
|
font.family: Appearance.fontFamily
|
|
font.pixelSize: Appearance.fontSize
|
|
color: Colors.foreground
|
|
text: {
|
|
if (SystemUpdates.updating) return "Update running in a terminal…"
|
|
if (SystemUpdates.checking) return "Checking for updates…"
|
|
if (SystemUpdates.updateCount === 0) return "System is up to date."
|
|
return SystemUpdates.updateCount + (SystemUpdates.updateCount === 1 ? " update available." : " updates available.")
|
|
}
|
|
}
|
|
|
|
Rectangle {
|
|
id: updateBtn
|
|
width: parent.width
|
|
radius: 0
|
|
implicitHeight: btnContent.implicitHeight + 12
|
|
enabled: !SystemUpdates.updating
|
|
opacity: SystemUpdates.updating ? 0.5 : 1
|
|
color: btnMouse.containsMouse ? Colors.primary : "transparent"
|
|
|
|
Rectangle {
|
|
anchors.fill: parent
|
|
anchors.margins: -3
|
|
radius: 0
|
|
color: "transparent"
|
|
border.color: Colors.foreground
|
|
border.width: btnMouse.containsMouse ? 1 : 0
|
|
}
|
|
|
|
RowLayout {
|
|
id: btnContent
|
|
anchors.left: parent.left
|
|
anchors.right: parent.right
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
anchors.margins: 6
|
|
spacing: 8
|
|
|
|
Text {
|
|
Layout.preferredWidth: 20
|
|
horizontalAlignment: Text.AlignLeft
|
|
text: "download"
|
|
font.family: Appearance.iconFontFamilyRounded
|
|
font.variableAxes: Appearance.iconFontAxes
|
|
font.pixelSize: 14
|
|
color: btnMouse.containsMouse ? Colors.primaryText : Colors.foreground
|
|
}
|
|
Text {
|
|
Layout.fillWidth: true
|
|
text: "Update Now"
|
|
font.family: Appearance.fontFamily
|
|
font.pixelSize: Appearance.fontSize
|
|
color: btnMouse.containsMouse ? Colors.primaryText : Colors.foreground
|
|
}
|
|
}
|
|
|
|
MouseArea {
|
|
id: btnMouse
|
|
anchors.fill: parent
|
|
enabled: !SystemUpdates.updating
|
|
hoverEnabled: true
|
|
cursorShape: Qt.PointingHandCursor
|
|
onClicked: {
|
|
SystemUpdates.runUpdate(Quickshell.shellPath("scripts/update-system.sh"))
|
|
panel.visible = false
|
|
grab.active = false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|