Skip to content
This repository was archived by the owner on Feb 17, 2026. It is now read-only.

Commit c86cbcb

Browse files
committed
Refactor codebase
Breakt the component into smaller chunks. Hopefully making it more modular.
1 parent c4d458d commit c86cbcb

9 files changed

Lines changed: 87 additions & 36 deletions

File tree

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ version = "0.1.0"
44
edition = "2021"
55
license = "MPL-2.0"
66

7-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8-
97
[dependencies]
108
open = "5.3.2"
119
slint = "1.12.1"

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
// SPDX-License-Identifier: MPL-2.0
44

55
fn main() {
6-
slint_build::compile("ui/welcome.slint").expect("Salam build failed");
6+
slint_build::compile("ui/main.slint").expect("Salam build failed");
77
}

src/main.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@
33
// SPDX-License-Identifier: MPL-2.0
44

55
use std::process::Command;
6+
7+
use slint::ComponentHandle;
68
slint::include_modules!();
79

810
fn main() {
911
let app = MainWindow::new().unwrap();
1012

11-
app.on_close(move || {
13+
app.global::<Callbacks>().on_close(move || {
1214
std::process::exit(0);
1315
});
1416

15-
app.on_openUrl(move |url| {
17+
app.global::<Callbacks>().on_openUrl(move |url| {
1618
if let Err(err) = open::that(url.as_str()) {
1719
eprintln!("Failed to open link: {err}");
1820
}
1921
});
2022

21-
app.on_startInstaller(|| {
23+
app.global::<Callbacks>().on_startInstaller(|| {
2224
if let Err(err) = Command::new("calamares-gui").spawn() {
2325
eprintln!("Failed to launch installer: {err}");
2426
}

ui/components/callbacks.slint

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// SPDX-FileCopyrightText: Copyright © 2025 Muhammad Alfi Syahrin
2+
//
3+
// SPDX-License-Identifier: MPL-2.0
4+
5+
export global Callbacks {
6+
callback openUrl(string);
7+
callback close();
8+
callback startInstaller();
9+
}

ui/components/images.slint

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// SPDX-FileCopyrightText: Copyright © 2025 Muhammad Alfi Syahrin
2+
//
3+
// SPDX-License-Identifier: MPL-2.0
4+
5+
export global Images {
6+
in property <image> docs: @image-url("../assets/docs.png");
7+
in property <image> github: @image-url("../assets/github.png");
8+
in property <image> install: @image-url("../assets/install.png");
9+
in property <image> logo: @image-url("../assets/logo.svg");
10+
in property <image> mastodon: @image-url("../assets/mastodon.svg");
11+
in property <image> play: @image-url("../assets/play.png");
12+
in property <image> web: @image-url("../assets/web.png");
13+
}

ui/components/sidebar.slint

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SPDX-FileCopyrightText: Copyright © 2025 Muhammad Alfi Syahrin
2+
//
3+
// SPDX-License-Identifier: MPL-2.0
4+
5+
import { HorizontalBox, VerticalBox } from "std-widgets.slint";
6+
export component SideBar {
7+
VerticalBox {
8+
spacing: 0px;
9+
Rectangle {
10+
background: red;
11+
}
12+
13+
Rectangle {
14+
background: blue;
15+
}
16+
17+
Rectangle {
18+
background: yellow;
19+
}
20+
}
21+
}

ui/images.slint

Lines changed: 0 additions & 13 deletions
This file was deleted.

ui/main.slint

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// SPDX-FileCopyrightText: Copyright © 2025 Muhammad Alfi Syahrin
2+
//
3+
// SPDX-License-Identifier: MPL-2.0
4+
5+
import { StandardButton, VerticalBox, Button, HorizontalBox, Spinner, StyleMetrics, Palette, GridBox } from "std-widgets.slint";
6+
import { Images } from "components/images.slint";
7+
import { LiveISO } from "pages/liveiso.slint";
8+
import { Callbacks } from "components/callbacks.slint";
9+
import { SideBar} from "components/sidebar.slint";
10+
11+
export { Callbacks }
12+
13+
export component MainWindow inherits Window {
14+
title: "Welcome";
15+
background: Palette.background;
16+
icon: Images.logo;
17+
//padding: 20px;
18+
//no-frame: true;
19+
//min-width: 800px;
20+
//min-height: 500px;
21+
HorizontalBox {
22+
spacing: 0px;
23+
// It is not ready, disabled
24+
//SideBar { }
25+
26+
LiveISO { }
27+
}
28+
}
Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,10 @@
33
// SPDX-License-Identifier: MPL-2.0
44

55
import { StandardButton, VerticalBox, Button, HorizontalBox, Spinner, StyleMetrics, Palette, GridBox } from "std-widgets.slint";
6-
import { Images } from "images.slint";
7-
8-
export component MainWindow inherits Window {
9-
title: "Welcome";
10-
background: Palette.background;
11-
//padding: 20px;
12-
//no-frame: true;
13-
icon: Images.logo;
14-
callback openUrl(string);
15-
callback close();
16-
callback startInstaller();
6+
import { Images } from "../components/images.slint";
7+
import { Callbacks} from "../components/callbacks.slint";
8+
9+
export component LiveISO {
1710
VerticalBox {
1811
spacing: 30px;
1912
padding-right: 30px;
@@ -61,7 +54,7 @@ export component MainWindow inherits Window {
6154
}
6255

6356
clicked => {
64-
root.openUrl("https://getsol.us");
57+
Callbacks.openUrl("https://getsol.us");
6558
}
6659
}
6760

@@ -82,7 +75,7 @@ export component MainWindow inherits Window {
8275
}
8376

8477
clicked => {
85-
root.openUrl("https://dev.getsol.us");
78+
Callbacks.openUrl("https://dev.getsol.us");
8679
}
8780
}
8881

@@ -103,7 +96,7 @@ export component MainWindow inherits Window {
10396
}
10497

10598
clicked => {
106-
root.openUrl("https://floss.social/@getsolus");
99+
Callbacks.openUrl("https://floss.social/@getsolus");
107100
}
108101
}
109102

@@ -124,7 +117,7 @@ export component MainWindow inherits Window {
124117
}
125118

126119
clicked => {
127-
root.openUrl("https://help.getsol.us");
120+
Callbacks.openUrl("https://help.getsol.us");
128121
}
129122
}
130123

@@ -151,7 +144,7 @@ export component MainWindow inherits Window {
151144
icon: Images.install;
152145
colorize-icon: true;
153146
clicked => {
154-
root.startInstaller();
147+
Callbacks.startInstaller();
155148
}
156149
}
157150

@@ -160,7 +153,7 @@ export component MainWindow inherits Window {
160153
icon: Images.play;
161154
colorize-icon: true;
162155
clicked => {
163-
root.close();
156+
Callbacks.close();
164157
}
165158
}
166159
}

0 commit comments

Comments
 (0)