Skip to content

Commit

Permalink
Initializes firmware installation popup (#1150)
Browse files Browse the repository at this point in the history
  • Loading branch information
ultimaweapon authored Nov 30, 2024
1 parent a98aa13 commit f0835e9
Show file tree
Hide file tree
Showing 15 changed files with 107 additions and 206 deletions.
1 change: 0 additions & 1 deletion gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ endif()
# Setup GUI.
add_executable(obliteration WIN32 MACOSX_BUNDLE
app_data.cpp
cpu_settings.cpp
display_settings.cpp
initialize_wizard.cpp
launch_settings.cpp
Expand Down
107 changes: 0 additions & 107 deletions gui/cpu_settings.cpp

This file was deleted.

19 changes: 0 additions & 19 deletions gui/cpu_settings.hpp

This file was deleted.

11 changes: 0 additions & 11 deletions gui/launch_settings.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "launch_settings.hpp"
#include "cpu_settings.hpp"
#include "display_settings.hpp"
#include "resources.hpp"

Expand All @@ -26,7 +25,6 @@ LaunchSettings::LaunchSettings(
#endif
QWidget(parent),
m_display(nullptr),
m_cpu(nullptr),
m_profiles(nullptr)
{
auto layout = new QVBoxLayout();
Expand Down Expand Up @@ -71,15 +69,6 @@ QWidget *LaunchSettings::buildSettings(QList<VkPhysicalDevice> &&vkDevices)

tab->addTab(m_display, loadIcon(":/resources/monitor.svg", iconSize), "Display");

// CPU settings.
m_cpu = new CpuSettings();

connect(m_cpu, &CpuSettings::debugClicked, [this](const QString &addr) {
emit startClicked(addr);
});

tab->addTab(m_cpu, loadIcon(":/resources/cpu-64-bit.svg", iconSize), "CPU");

return tab;
}

Expand Down
4 changes: 0 additions & 4 deletions gui/launch_settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@
#endif
#include <QWidget>

class CpuSettings;
#ifndef __APPLE__
class DisplayDevice;
#endif
class DisplaySettings;
class GameListModel;
class ProfileList;
class QComboBox;
class QLayout;
class QTableView;
Expand Down Expand Up @@ -43,6 +40,5 @@ class LaunchSettings final : public QWidget {
QLayout *buildActions();

DisplaySettings *m_display;
CpuSettings *m_cpu;
QComboBox *m_profiles;
};
2 changes: 0 additions & 2 deletions gui/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<RCC version="1.0">
<qresource>
<file>resources/content-save.svg</file>
<file>resources/cpu-64-bit.svg</file>
<file>resources/fallbackicon0.png</file>
<file>resources/monitor.svg</file>
<file>resources/obliteration-icon.png</file>
<file>resources/play.svg</file>
Expand Down
Binary file removed gui/resources/fallbackicon0.png
Binary file not shown.
28 changes: 11 additions & 17 deletions gui/src/setup/mod.rs
Original file line number Diff line number Diff line change
@@ -1,42 +1,36 @@
use crate::dialogs::{open_file, FileType};
use crate::ui::SetupWizard;
use slint::{CloseRequestResponse, ComponentHandle, PlatformError};
use slint::{ComponentHandle, PlatformError};
use std::cell::Cell;
use std::rc::Rc;
use thiserror::Error;

pub fn run_setup() -> Result<bool, SetupError> {
// TODO: Check if already configured and skip wizard.
let win = SetupWizard::new().map_err(SetupError::CreateWindow)?;
let cancel = Rc::new(Cell::new(false));
let finish = Rc::new(Cell::new(false));

win.on_cancel({
let win = win.as_weak();
let cancel = cancel.clone();

move || {
win.unwrap().hide().unwrap();
cancel.set(true);
}
move || win.unwrap().hide().unwrap()
});

win.window().on_close_requested({
win.on_browse_firmware({
let win = win.as_weak();
let cancel = cancel.clone();

move || {
win.unwrap().hide().unwrap();
cancel.set(true);

CloseRequestResponse::HideWindow
slint::spawn_local(browse_firmware(win.unwrap())).unwrap();
}
});

win.on_browse_firmware({
win.on_finish({
let win = win.as_weak();
let finish = finish.clone();

move || {
slint::spawn_local(browse_firmware(win.unwrap())).unwrap();
win.unwrap().hide().unwrap();
finish.set(true);
}
});

Expand All @@ -46,9 +40,9 @@ pub fn run_setup() -> Result<bool, SetupError> {
drop(win);

// Extract GUI states.
let cancel = Rc::into_inner(cancel).unwrap().into_inner();
let finish = Rc::into_inner(finish).unwrap().into_inner();

Ok(!cancel)
Ok(finish)
}

async fn browse_firmware(win: SetupWizard) {
Expand Down
File renamed without changes
File renamed without changes.
File renamed without changes.
13 changes: 7 additions & 6 deletions gui/ui/main/tabs.slint
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button, HorizontalBox, VerticalBox } from "std-widgets.slint";
import { DisplayTab } from "tabs/display.slint";
import { CpuTab } from "tabs/cpu.slint";
import { DisplayTab } from "display.slint";
import { CpuTab } from "cpu.slint";
import { Menu } from "menu.slint";

enum Tab {
Expand All @@ -10,10 +10,10 @@ enum Tab {
}

export component Tabs {
property <Tab> tab: Tab.Display;

in property <[string]> devices;

private property <Tab> tab: Tab.Display;

VerticalBox {
padding: 0;

Expand All @@ -40,9 +40,10 @@ export component Tabs {

Button {
text: "CPU";
icon: @image-url("../../resources/cpu-64-bit.svg");
horizontal-stretch: 1;
icon: @image-url("cpu-64-bit.svg");
colorize-icon: true;
primary: root.tab == Tab.Cpu;
horizontal-stretch: 1;
clicked => {
root.tab = Tab.Cpu
}
Expand Down
68 changes: 30 additions & 38 deletions gui/ui/setup.slint
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { HorizontalBox, Button, Palette, StandardButton } from "std-widgets.slint";
import { Intro } from "setup/intro.slint";
import { Firmware } from "setup/firmware.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";

// https://github.com/slint-ui/slint/issues/6880
enum WizardPage {
Expand All @@ -13,20 +14,20 @@ enum WizardPage {
export component SetupWizard inherits Window {
title: "Setup Obliteration";
icon: @image-url("icon.png");
min-width: 500px;
min-height: 400px;
preferred-width: 500px; // Force word-wrap instead of expand the window.
width: 500px; // PopupWindow does not resize with the window somehow.
height: 400px; // Same here.

in-out property <string> firmware-dump;

pure callback cancel();
pure callback cancel <=> nav.cancel;
pure callback browse-firmware();
pure callback finish();

private property <WizardPage> page: WizardPage.Intro;

states [
finished when page == WizardPage.Conclusion: {
next.text: "Finish";
nav.next-text: "Finish";
}
]

Expand All @@ -48,40 +49,31 @@ export component SetupWizard inherits Window {
vertical-stretch: 1;
}

Rectangle {
background: Palette.alternate-background;

HorizontalBox {
alignment: end;

Button {
text: "< Back";
enabled: root.page != WizardPage.Intro && root.page != WizardPage.Conclusion;
clicked => {
if root.page == WizardPage.Firmware {
root.page = WizardPage.Intro;
}
}
}

next := Button {
text: "Next >";
clicked => {
if root.page == WizardPage.Intro {
root.page = WizardPage.Firmware;
} else if root.page == WizardPage.Firmware {
root.page = WizardPage.Conclusion;
}
}
nav := NavBar {
back-text: "< Back";
back-enabled: root.page != WizardPage.Intro && root.page != WizardPage.Conclusion;
next-text: "Next >";
back-clicked => {
if root.page == WizardPage.Firmware {
root.page = WizardPage.Intro;
}

StandardButton {
kind: StandardButtonKind.cancel;
clicked => {
cancel();
}
}
next-clicked => {
if root.page == WizardPage.Intro {
root.page = WizardPage.Firmware;
} else if root.page == WizardPage.Firmware {
install-firmware.show();
} else if root.page == WizardPage.Conclusion {
finish();
}
}
}
}

install-firmware := InstallFirmware {
x: 10px;
y: 150px;
width: parent.width - 20px;
height: parent.height - 300px;
}
}
Loading

0 comments on commit f0835e9

Please sign in to comment.