Skip to content

Commit b7b4f62

Browse files
committed
add app version in settings
1 parent 1aef01f commit b7b4f62

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

src/api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::borrow::Cow;
22
use std::process::{Command, Output};
33

4-
s
4+
#[derive(Clone, Copy)]
55
pub struct Api {}
66

77
impl Api {

src/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ mod api;
1717

1818
use api::Api;
1919
use slint::{SharedString, Model, Weak, Timer, TimerMode};
20-
use std::thread;
2120
use std::time::Duration;
2221

2322
fn show_dialog(weak: &Weak<CustomDialogWindow>, dialog_type: &str, text: &str) {
@@ -28,6 +27,8 @@ fn show_dialog(weak: &Weak<CustomDialogWindow>, dialog_type: &str, text: &str) {
2827
}
2928
}
3029

30+
const APP_VERSION: &str = "0.0.1";
31+
3132
fn main() -> Result<(), slint::PlatformError> {
3233
let app = AppWindow::new()?;
3334
let dialog = CustomDialogWindow::new()?;
@@ -41,6 +42,9 @@ fn main() -> Result<(), slint::PlatformError> {
4142
let dialog_weak = dialog.as_weak();
4243
let setting_weak = settings.as_weak();
4344

45+
// Set app version
46+
setting_weak.unwrap().set_app_version(SharedString::from(APP_VERSION));
47+
4448
// Set default switch On/Off value
4549
if app_weak.upgrade().unwrap().get_connection_switch_enabled() {
4650
let connected_status: bool = api.is_connected();

ui/settings.slint

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export component SettingsWindow inherits Window {
88
in-out property <bool> account_register_enabled <=> account_register.enabled;
99
in-out property <bool> account_delete_enabled <=> account_delete.enabled;
1010

11+
in-out property <string> app_version;
12+
1113
callback warp_mode_setting_choose <=> warp_mode_setting.choose;
1214
callback account_register_clicked;
1315
callback account_delete_clicked;
@@ -96,5 +98,33 @@ export component SettingsWindow inherits Window {
9698
}
9799
}
98100
}
101+
// App info
102+
HorizontalBox {
103+
height: 40px;
104+
105+
VerticalLayout {
106+
alignment: end;
107+
108+
Text {
109+
text: "Version: ";
110+
color: white;
111+
font-size: 16px;
112+
}
113+
}
114+
HorizontalLayout {
115+
alignment: end;
116+
117+
VerticalLayout {
118+
alignment: center;
119+
120+
Text {
121+
text: app_version;
122+
color: white;
123+
font-size: 16px;
124+
font-weight: 600;
125+
}
126+
}
127+
}
128+
}
99129
}
100130
}

0 commit comments

Comments
 (0)