Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracts About into a dedicated window #1301

Merged
merged 2 commits into from
Mar 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 52 additions & 17 deletions gui/src/main.rs
Original file line number Diff line number Diff line change
@@ -7,8 +7,8 @@ use self::log::LogWriter;
use self::profile::{DisplayResolution, Profile};
use self::setup::{SetupError, run_setup};
use self::ui::{
App, DesktopExt, MainWindow, ProfileModel, ResolutionModel, RuntimeExt, WaitForDebugger, error,
spawn_handler,
AboutWindow, App, DesktopExt, MainWindow, ProfileModel, ResolutionModel, RuntimeExt,
WaitForDebugger, error, spawn_handler,
};
use self::vmm::{CpuError, Vmm, VmmError, VmmEvent};
use async_net::{TcpListener, TcpStream};
@@ -59,6 +59,44 @@ struct MainProgram {
exe: PathBuf,
}

impl MainProgram {
async fn report_issue(win: MainWindow) {
let url = "https://github.com/obhq/obliteration/issues/new";

if let Err(e) = open::that_detached(url) {
let m = slint::format!("Failed to open {}: {}.", url, e.display());
error(Some(&win), m).await;
}
}

async fn about(main: MainWindow) {
// Setup window.
let win = match AboutWindow::new() {
Ok(v) => v,
Err(e) => {
let m = slint::format!("Failed to create about window: {}.", e.display());
error(Some(&main), m).await;
return;
}
};

// Run the window.
if let Err(e) = win.show() {
let m = slint::format!("Failed to show about window: {}.", e.display());
error(Some(&main), m).await;
return;
}

match win.set_modal(&main) {
Ok(w) => w.wait().await,
Err(e) => {
let m = slint::format!("Failed to enable modal on about window: {}.", e.display());
error(Some(&main), m).await;
}
}
}
}

impl App for MainProgram {
type Err = ProgramError;
type Args = ProgramArgs;
@@ -260,6 +298,18 @@ async fn run_launcher(
let profiles = Rc::new(ProfileModel::new(profiles, resolutions.clone()));
let exit = Rc::new(Cell::new(None));

win.on_report_issue({
let win = win.as_weak();

move || spawn_handler(&win, |w| MainProgram::report_issue(w))
});

win.on_about({
let win = win.as_weak();

move || spawn_handler(&win, |w| MainProgram::about(w))
});

win.on_profile_selected({
let win = win.as_weak();
let profiles = profiles.clone();
@@ -281,12 +331,6 @@ async fn run_launcher(
move || spawn_handler(&win, |w| save_profile(w, data.clone(), profiles.clone()))
});

win.on_report_issue({
let win = win.as_weak();

move || spawn_handler(&win, |w| report_issue(w))
});

win.on_start_vmm({
let win = win.as_weak();
let profiles = profiles.clone();
@@ -436,15 +480,6 @@ async fn save_profile(win: MainWindow, data: Arc<DataMgr>, profiles: Rc<ProfileM
}
}

async fn report_issue(win: MainWindow) {
let url = "https://github.com/obhq/obliteration/issues/new";

if let Err(e) = open::that_detached(url) {
let m = slint::format!("Failed to open {}: {}.", url, e.display());
error(Some(&win), m).await;
}
}

async fn start_vmm(
win: MainWindow,
profiles: Rc<ProfileModel>,
1 change: 1 addition & 0 deletions gui/src/ui/mod.rs
Original file line number Diff line number Diff line change
@@ -211,6 +211,7 @@ macro_rules! impl_wae {
};
}

impl_wae!(AboutWindow);
impl_wae!(ErrorWindow);
impl_wae!(InstallFirmware);
impl_wae!(MainWindow);
44 changes: 44 additions & 0 deletions gui/ui/about.slint
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { AboutSlint, VerticalBox, TabWidget } from "std-widgets.slint";

component Obliteration {
VerticalBox {
Image {
source: @image-url("about/logo.png");
}

Text {
text: "Obliteration is a free and open-source software to run PlayStation 4 system software on PC.";
wrap: word-wrap;
}
}
}

component Slint {
AboutSlint { }
}

export component AboutWindow inherits Window {
title: "About";
width: 500px;
height: 200px;

TabWidget {
Tab {
title: "Obliteration";

Obliteration {
width: 100%;
height: 100%;
}
}

Tab {
title: "Slint";

Slint {
width: 100%;
height: 100%;
}
}
}
}
Binary file added gui/ui/about/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions gui/ui/main.slint
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ import { Menu } from "main/menu.slint";
import { DisplayTab } from "main/display.slint";
import { CpuTab } from "main/cpu.slint";

export { AboutWindow } from "about.slint";
export { WaitForDebugger } from "debug.slint";
export { ErrorWindow } from "error.slint";
export { InstallFirmware, SetupWizard } from "setup.slint";
@@ -21,6 +22,7 @@ export component MainWindow inherits Window {
in property <[string]> profiles;
in-out property <int> selected-profile;

pure callback about();
callback profile-selected();
pure callback save-profile();
pure callback report-issue();
@@ -34,6 +36,22 @@ export component MainWindow inherits Window {

private property <Tab> tab: Tab.display;

// Menu.
MenuBar {
// Help.
Menu {
title: "Help";

MenuItem {
title: "About";
activated => {
about();
}
}
}
}

// Content.
VerticalBox {
// Tab bar.
HorizontalBox {
24 changes: 1 addition & 23 deletions gui/ui/main/menu.slint
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Button, StandardButton, AboutSlint, HorizontalBox, Palette, VerticalBox } from "std-widgets.slint";
import { Button, StandardButton, HorizontalBox, Palette, VerticalBox } from "std-widgets.slint";

enum Page {
help,
about
}

component SideBarItem {
@@ -61,14 +60,6 @@ component SideBar {
root.current-page = Page.help;
}
}

SideBarItem {
text: "About";
selected: root.current-page == Page.about;
clicked => {
root.current-page = Page.about;
}
}
}
}

@@ -83,17 +74,6 @@ component Help {
}
}

component About {
VerticalLayout {
Text {
text: "Obliteration is a free and open-source software to run PlayStation 4 system software on PC.";
horizontal-alignment: center;
}

AboutSlint { }
}
}

export component Menu {
pure callback report-issue();

@@ -107,7 +87,5 @@ export component Menu {
report-issue();
}
}

if nav.current-page == Page.about: About { }
}
}