obliteration/gui/ui/setup.slint
2025-03-23 11:03:26 +01:00

119 lines
3.2 KiB
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Intro } from "setup/intro.slint";
import { Firmware, InstallFirmware } from "setup/firmware.slint";
import { Conclusion } from "setup/conclusion.slint";
import { NavBar } from "setup/nav.slint";
import { Palette } from "std-widgets.slint";
import { DataRoot } from "setup/root.slint";
export { InstallFirmware }
// https://github.com/slint-ui/slint/issues/6880
enum SetupPage {
Intro,
DataRoot,
Firmware,
Conclusion
}
export component SetupWizard inherits Window {
in-out property <string> data-root;
in-out property <string> firmware-dump;
pure callback cancel <=> nav.cancel;
pure callback get-dumper();
pure callback browse-data-root();
pure callback set-data-root();
pure callback browse-firmware();
pure callback install-firmware();
pure callback finish();
title: "Setup Obliteration";
icon: @image-url("@root/assets/icon.png");
min-width: 500px;
preferred-width: 500px;
min-height: 400px;
preferred-height: 400px;
private property <SetupPage> page: SetupPage.Intro;
states [
finished when page == SetupPage.Conclusion: {
nav.next-text: "Finish";
}
]
// Content.
VerticalLayout {
// Intro.
if page == SetupPage.Intro: Intro {
vertical-stretch: 1;
get-dumper => {
get-dumper();
}
}
// Data root.
if page == SetupPage.DataRoot: DataRoot {
path <=> data-root;
vertical-stretch: 1;
browse => {
browse-data-root();
}
}
// Firmware.
if page == SetupPage.Firmware: Firmware {
firmware-dump <=> firmware-dump;
vertical-stretch: 1;
browse => {
browse-firmware();
}
}
// Conclusion.
if page == SetupPage.Conclusion: Conclusion {
vertical-stretch: 1;
}
// Navigation.
nav := NavBar {
back-text: " Back";
back-enabled: root.page != SetupPage.Intro && root.page != SetupPage.Conclusion;
next-text: "Next ";
back-clicked => {
if page == SetupPage.DataRoot {
page = SetupPage.Intro;
} else if page == SetupPage.Firmware {
page = SetupPage.DataRoot;
}
}
next-clicked => {
if page == SetupPage.Intro {
page = SetupPage.DataRoot;
} else if page == SetupPage.DataRoot {
// https://github.com/slint-ui/slint/issues/2752
set-data-root();
} else if page == SetupPage.Firmware {
install-firmware();
} else if page == SetupPage.Conclusion {
finish();
}
}
}
}
// Functions.
public function set-data-root-ok(has-firmware: bool) {
if has-firmware {
page = SetupPage.Conclusion;
} else {
page = SetupPage.Firmware;
}
}
public function set-firmware-finished() {
page = SetupPage.Conclusion;
}
}