mirror of
https://github.com/obhq/obliteration.git
synced 2024-11-26 20:50:22 +00:00
Revises main tab for Slint (#1106)
This commit is contained in:
parent
264e5d72c1
commit
23748a0650
1
.vscode/extensions.json
vendored
1
.vscode/extensions.json
vendored
@ -5,6 +5,7 @@
|
||||
"ms-vscode.hexeditor",
|
||||
"redhat.vscode-yaml",
|
||||
"rust-lang.rust-analyzer",
|
||||
"Slint.slint",
|
||||
"tamasfe.even-better-toml",
|
||||
"vadimcn.vscode-lldb"
|
||||
]
|
||||
|
@ -1,15 +1,12 @@
|
||||
import { Game } from "structs.slint";
|
||||
import { Tabs } from "main/tabs.slint";
|
||||
import { Menu } from "main/menu.slint";
|
||||
import { Actions } from "main/actions.slint";
|
||||
|
||||
export component MainWindow inherits Window {
|
||||
preferred-width: 1920px;
|
||||
preferred-height: 1080px;
|
||||
icon: @image-url("../resources/obliteration-icon.png");
|
||||
title: "Obliteration";
|
||||
min-width: 1000px;
|
||||
min-height: 500px;
|
||||
|
||||
in property <[Game]> games: [];
|
||||
in property <[string]> profiles: [];
|
||||
in property <[string]> devices: [];
|
||||
|
||||
@ -25,23 +22,10 @@ export component MainWindow inherits Window {
|
||||
pure callback quit();
|
||||
|
||||
VerticalLayout {
|
||||
Menu {
|
||||
background: root.background;
|
||||
popup_width: root.width / 2;
|
||||
popup_height: root.height / 2;
|
||||
popup_x: root.width / 4;
|
||||
popup_y: root.height / 4;
|
||||
|
||||
quit => { quit(); }
|
||||
open_new_issue_link => { open_new_issue_link(); }
|
||||
install_pkg => { install_pkg(); }
|
||||
open_system_folder => { open_system_folder(); }
|
||||
}
|
||||
Tabs {
|
||||
devices: devices;
|
||||
games: games;
|
||||
select_game(index) => { }
|
||||
}
|
||||
|
||||
Actions {
|
||||
profiles: profiles;
|
||||
start_game => {
|
||||
|
@ -1,28 +1,24 @@
|
||||
import { ComboBox, Button } from "std-widgets.slint";
|
||||
import { Button, ComboBox, HorizontalBox } from "std-widgets.slint";
|
||||
|
||||
export component Actions {
|
||||
in property <[string]> profiles: [];
|
||||
|
||||
pure callback start_game();
|
||||
|
||||
HorizontalLayout {
|
||||
|
||||
alignment: stretch;
|
||||
spacing: 5px;
|
||||
|
||||
HorizontalBox {
|
||||
ComboBox {
|
||||
model: profiles;
|
||||
horizontal-stretch: 1;
|
||||
}
|
||||
|
||||
Button {
|
||||
text: "Start";
|
||||
horizontal-stretch: 0;
|
||||
icon: @image-url("../../resources/play.svg");
|
||||
clicked => { start_game(); }
|
||||
}
|
||||
|
||||
Button {
|
||||
text: "Save";
|
||||
horizontal-stretch: 0;
|
||||
icon: @image-url("../../resources/content-save.svg");
|
||||
}
|
||||
}
|
||||
|
1
gui/slint/main/menu.svg
Normal file
1
gui/slint/main/menu.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z" /></svg>
|
After Width: | Height: | Size: 125 B |
@ -1,43 +1,50 @@
|
||||
|
||||
import { TabWidget } from "std-widgets.slint";
|
||||
import { TabWidget, Button, HorizontalBox } from "std-widgets.slint";
|
||||
import { DisplayTab } from "tabs/display.slint";
|
||||
import { CpuTab } from "tabs/cpu.slint";
|
||||
import { GamesTab } from "tabs/games.slint";
|
||||
import { Game } from "../structs.slint";
|
||||
import { Menu } from "menu.slint";
|
||||
|
||||
export component Tabs {
|
||||
in property <[string]> devices: [];
|
||||
in property <[Game]> games: [];
|
||||
|
||||
pure callback select_game(int);
|
||||
property <int> tab: 1;
|
||||
|
||||
TabWidget {
|
||||
Tab {
|
||||
title: "Display";
|
||||
//icon: @image-url("resources/darkmode/card-text-outline.svg");
|
||||
VerticalLayout {
|
||||
alignment: start;
|
||||
VerticalLayout {
|
||||
HorizontalBox {
|
||||
Button {
|
||||
icon: @image-url("menu.svg");
|
||||
primary: root.tab == 0;
|
||||
clicked => { root.tab = 0 }
|
||||
}
|
||||
|
||||
DisplayTab { devices: devices; }
|
||||
Button {
|
||||
text: "Display";
|
||||
icon: @image-url("../../resources/monitor.svg");
|
||||
horizontal-stretch: 1;
|
||||
primary: root.tab == 1;
|
||||
clicked => { root.tab = 1 }
|
||||
}
|
||||
|
||||
Button {
|
||||
text: "CPU";
|
||||
icon: @image-url("../../resources/cpu-64-bit.svg");
|
||||
horizontal-stretch: 1;
|
||||
primary: root.tab == 2;
|
||||
clicked => { root.tab = 2 }
|
||||
}
|
||||
}
|
||||
Tab {
|
||||
title: "CPU";
|
||||
//icon: @image-url("resources/darkmode/card-text-outline.svg");
|
||||
VerticalLayout {
|
||||
alignment: start;
|
||||
|
||||
CpuTab {}
|
||||
}
|
||||
if root.tab == 0: Menu {
|
||||
vertical-stretch: 1;
|
||||
}
|
||||
Tab {
|
||||
title: "Games";
|
||||
//icon: @image-url("resources/darkmode/view-comfy.png");
|
||||
VerticalLayout {
|
||||
alignment: start;
|
||||
|
||||
GamesTab { games: games; }
|
||||
}
|
||||
if root.tab == 1: DisplayTab {
|
||||
devices: devices;
|
||||
vertical-stretch: 1;
|
||||
}
|
||||
|
||||
if root.tab == 2: CpuTab {
|
||||
vertical-stretch: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,57 +0,0 @@
|
||||
import { Game } from "../../structs.slint";
|
||||
|
||||
export component GamesTab {
|
||||
in-out property <[Game]> games: [];
|
||||
|
||||
VerticalLayout {
|
||||
alignment: start;
|
||||
|
||||
HorizontalLayout {
|
||||
alignment: stretch;
|
||||
height: 30px;
|
||||
|
||||
Text {
|
||||
text: "Name";
|
||||
horizontal-alignment: center;
|
||||
}
|
||||
Text {
|
||||
text: "ID";
|
||||
width: 100px;
|
||||
horizontal-alignment: center;
|
||||
}
|
||||
}
|
||||
|
||||
for game[i] in games: HorizontalLayout {
|
||||
alignment: stretch;
|
||||
|
||||
HorizontalLayout {
|
||||
alignment: stretch;
|
||||
height: 30px;
|
||||
|
||||
Rectangle {
|
||||
width: 15px;
|
||||
|
||||
Text {
|
||||
text: i;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
Image {
|
||||
source: game.icon;
|
||||
width: 30px;
|
||||
}
|
||||
Text {
|
||||
padding-left: 10px;
|
||||
text: game.name;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: game.id;
|
||||
vertical-alignment: center;
|
||||
width: 80px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
export struct Game {
|
||||
id: string,
|
||||
name: string,
|
||||
dir: string,
|
||||
icon: image,
|
||||
}
|
@ -63,8 +63,6 @@ fn run() -> Result<(), ApplicationError> {
|
||||
|
||||
struct App {
|
||||
main_window: ui::MainWindow,
|
||||
|
||||
games: ModelRc<ui::Game>,
|
||||
profiles: ModelRc<SharedString>,
|
||||
}
|
||||
|
||||
@ -83,10 +81,6 @@ impl App {
|
||||
|
||||
main_window.set_devices(ModelRc::new(VecModel::from(devices)));
|
||||
|
||||
let games = ModelRc::new(VecModel::from(Vec::new()));
|
||||
|
||||
main_window.set_games(games.clone());
|
||||
|
||||
let profiles = ModelRc::new(
|
||||
VecModel::from(vec![profile::Profile::default()])
|
||||
.map(|p| SharedString::from(String::from(p.name().to_string_lossy()))),
|
||||
@ -102,7 +96,6 @@ impl App {
|
||||
|
||||
Ok(Self {
|
||||
main_window,
|
||||
games,
|
||||
profiles,
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user