dashboard: persist state
This commit is contained in:
parent
53f7da32e4
commit
2fa949139a
4 changed files with 44 additions and 15 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
|
|
||||||
import qs.components
|
import qs.components
|
||||||
|
import qs.components.filedialog
|
||||||
import qs.config
|
import qs.config
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Widgets
|
import Quickshell.Widgets
|
||||||
|
|
@ -12,6 +13,7 @@ Item {
|
||||||
|
|
||||||
required property PersistentProperties visibilities
|
required property PersistentProperties visibilities
|
||||||
required property PersistentProperties state
|
required property PersistentProperties state
|
||||||
|
required property FileDialog facePicker
|
||||||
readonly property real nonAnimWidth: view.implicitWidth + viewWrapper.anchors.margins * 2
|
readonly property real nonAnimWidth: view.implicitWidth + viewWrapper.anchors.margins * 2
|
||||||
|
|
||||||
implicitWidth: nonAnimWidth
|
implicitWidth: nonAnimWidth
|
||||||
|
|
@ -87,6 +89,7 @@ Item {
|
||||||
sourceComponent: Dash {
|
sourceComponent: Dash {
|
||||||
visibilities: root.visibilities
|
visibilities: root.visibilities
|
||||||
state: root.state
|
state: root.state
|
||||||
|
facePicker: root.facePicker
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import qs.components
|
import qs.components
|
||||||
|
import qs.components.filedialog
|
||||||
import qs.services
|
import qs.services
|
||||||
import qs.config
|
import qs.config
|
||||||
import "dash"
|
import "dash"
|
||||||
|
|
@ -10,6 +11,7 @@ GridLayout {
|
||||||
|
|
||||||
required property PersistentProperties visibilities
|
required property PersistentProperties visibilities
|
||||||
required property PersistentProperties state
|
required property PersistentProperties state
|
||||||
|
required property FileDialog facePicker
|
||||||
|
|
||||||
rowSpacing: Appearance.spacing.normal
|
rowSpacing: Appearance.spacing.normal
|
||||||
columnSpacing: Appearance.spacing.normal
|
columnSpacing: Appearance.spacing.normal
|
||||||
|
|
@ -25,6 +27,7 @@ GridLayout {
|
||||||
|
|
||||||
visibilities: root.visibilities
|
visibilities: root.visibilities
|
||||||
state: root.state
|
state: root.state
|
||||||
|
facePicker: root.facePicker
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,20 +13,21 @@ Item {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
required property PersistentProperties visibilities
|
required property PersistentProperties visibilities
|
||||||
readonly property PersistentProperties state: PersistentProperties {
|
readonly property PersistentProperties dashState: PersistentProperties {
|
||||||
property int currentTab
|
property int currentTab
|
||||||
property date currentDate: new Date()
|
property date currentDate: new Date()
|
||||||
|
|
||||||
readonly property FileDialog facePicker: FileDialog {
|
reloadableId: "dashboardState"
|
||||||
title: qsTr("Select a profile picture")
|
}
|
||||||
filterLabel: qsTr("Image files")
|
readonly property FileDialog facePicker: FileDialog {
|
||||||
filters: Images.validImageExtensions
|
title: qsTr("Select a profile picture")
|
||||||
onAccepted: path => {
|
filterLabel: qsTr("Image files")
|
||||||
if (CUtils.copyFile(Qt.resolvedUrl(path), Qt.resolvedUrl(`${Paths.home}/.face`)))
|
filters: Images.validImageExtensions
|
||||||
Quickshell.execDetached(["notify-send", "-a", "caelestia-shell", "-u", "low", "-h", `STRING:image-path:${path}`, "Profile picture changed", `Profile picture changed to ${Paths.shortenHome(path)}`]);
|
onAccepted: path => {
|
||||||
else
|
if (CUtils.copyFile(Qt.resolvedUrl(path), Qt.resolvedUrl(`${Paths.home}/.face`)))
|
||||||
Quickshell.execDetached(["notify-send", "-a", "caelestia-shell", "-u", "critical", "Unable to change profile picture", `Failed to change profile picture to ${Paths.shortenHome(path)}`]);
|
Quickshell.execDetached(["notify-send", "-a", "caelestia-shell", "-u", "low", "-h", `STRING:image-path:${path}`, "Profile picture changed", `Profile picture changed to ${Paths.shortenHome(path)}`]);
|
||||||
}
|
else
|
||||||
|
Quickshell.execDetached(["notify-send", "-a", "caelestia-shell", "-u", "critical", "Unable to change profile picture", `Failed to change profile picture to ${Paths.shortenHome(path)}`]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -34,6 +35,13 @@ Item {
|
||||||
implicitHeight: 0
|
implicitHeight: 0
|
||||||
implicitWidth: content.implicitWidth
|
implicitWidth: content.implicitWidth
|
||||||
|
|
||||||
|
onStateChanged: {
|
||||||
|
if (state === "visible" && timer.running) {
|
||||||
|
timer.triggered();
|
||||||
|
timer.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
states: State {
|
states: State {
|
||||||
name: "visible"
|
name: "visible"
|
||||||
when: root.visibilities.dashboard && Config.dashboard.enabled
|
when: root.visibilities.dashboard && Config.dashboard.enabled
|
||||||
|
|
@ -73,17 +81,30 @@ Item {
|
||||||
onCleared: root.visibilities.dashboard = false
|
onCleared: root.visibilities.dashboard = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: timer
|
||||||
|
|
||||||
|
running: true
|
||||||
|
interval: Appearance.anim.durations.extraLarge
|
||||||
|
onTriggered: {
|
||||||
|
content.active = Qt.binding(() => (root.visibilities.dashboard && Config.dashboard.enabled) || root.visible);
|
||||||
|
content.visible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
id: content
|
id: content
|
||||||
|
|
||||||
Component.onCompleted: active = Qt.binding(() => (root.visibilities.dashboard && Config.dashboard.enabled) || root.visible)
|
|
||||||
|
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
|
|
||||||
|
visible: false
|
||||||
|
active: true
|
||||||
|
|
||||||
sourceComponent: Content {
|
sourceComponent: Content {
|
||||||
visibilities: root.visibilities
|
visibilities: root.visibilities
|
||||||
state: root.state
|
state: root.dashState
|
||||||
|
facePicker: root.facePicker
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import qs.components
|
import qs.components
|
||||||
import qs.components.effects
|
import qs.components.effects
|
||||||
import qs.components.images
|
import qs.components.images
|
||||||
|
import qs.components.filedialog
|
||||||
import qs.services
|
import qs.services
|
||||||
import qs.config
|
import qs.config
|
||||||
import qs.utils
|
import qs.utils
|
||||||
|
|
@ -12,6 +13,7 @@ Row {
|
||||||
|
|
||||||
required property PersistentProperties visibilities
|
required property PersistentProperties visibilities
|
||||||
required property PersistentProperties state
|
required property PersistentProperties state
|
||||||
|
required property FileDialog facePicker
|
||||||
|
|
||||||
padding: Appearance.padding.large
|
padding: Appearance.padding.large
|
||||||
spacing: Appearance.spacing.normal
|
spacing: Appearance.spacing.normal
|
||||||
|
|
@ -72,7 +74,7 @@ Row {
|
||||||
|
|
||||||
function onClicked(): void {
|
function onClicked(): void {
|
||||||
root.visibilities.launcher = false;
|
root.visibilities.launcher = false;
|
||||||
root.state.facePicker.open();
|
root.facePicker.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue