Skip to content

Commit

Permalink
Global singletons object created
Browse files Browse the repository at this point in the history
  • Loading branch information
edfloreshz committed Jan 17, 2024
1 parent 1b211d8 commit fc5789a
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 20 deletions.
4 changes: 3 additions & 1 deletion src/ui/slint/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
fn main() {
slint_build::compile("ui/appwindow.slint").unwrap();
let config = slint_build::CompilerConfiguration::new().with_style("fluent-dark".into());

slint_build::compile_with_config("ui/appwindow.slint", config).unwrap();
}
4 changes: 4 additions & 0 deletions src/ui/slint/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ slint::include_modules!();
fn main() -> Result<(), slint::PlatformError> {
let ui = AppWindow::new()?;

ui.global::<Logic>().on_clone(move |url| {
println!("{url}");
});

ui.run()
}
12 changes: 8 additions & 4 deletions src/ui/slint/ui/appwindow.slint
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Button, VerticalBox, HorizontalBox, GroupBox, TabWidget, CheckBox } from "std-widgets.slint";
import { Clone } from "pages/clone.slint";
import { ClonePage } from "pages/clone.slint";
import { Open } from "pages/open.slint";
import { Workspaces } from "pages/workspaces.slint";
import { Configuration } from "pages/configuration.slint";
import { Logic } from "pages/logic.slint";

export { Logic }

export component AppWindow inherits Window {
VerticalBox {
Expand All @@ -12,7 +15,7 @@ export component AppWindow inherits Window {
TabWidget {
Tab {
title: "Clone";
Clone {}
ClonePage {}
}

Tab {
Expand All @@ -22,13 +25,14 @@ export component AppWindow inherits Window {

Tab {
title: "Workspaces";
Workspaces {}
Workspaces {
}
}

Tab {
title: "Configuration";
Configuration {
custom-editor: false;
custom-editor-enabled: false;
}
}
}
Expand Down
34 changes: 27 additions & 7 deletions src/ui/slint/ui/pages/clone.slint
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { VerticalBox , StandardListView, GroupBox , TextEdit, Button, HorizontalBox, Switch} from "std-widgets.slint";
export component Clone inherits VerticalBox {
import { VerticalBox , StandardListView, GroupBox , LineEdit, Button, HorizontalBox, Switch } from "std-widgets.slint";
import { Logic } from "logic.slint";

export component ClonePage inherits VerticalBox {

in-out property <bool> upstream-toggled;
callback clone(string);

GroupBox {
title: "Repositories";
VerticalBox {
Expand All @@ -16,15 +22,29 @@ export component Clone inherits VerticalBox {
vertical-alignment: center;
text: "URL:";
}
TextEdit {
url := LineEdit {
height: 40px;
text: "Test";
}
Switch {
checked: false;
text: "Upstream?";
checked <=> root.upstream-toggled;
text: "Upstream";
}
Button {
text: "Clone";
}
HorizontalBox {
visible: root.upstream-toggled;
Text {
vertical-alignment: center;
text: "Upstream:";
}
upstream := LineEdit {
height: 40px;
}
}
Button {
text: "Clone";
clicked => {
Logic.clone(url.text)
}
}
}
Expand Down
18 changes: 10 additions & 8 deletions src/ui/slint/ui/pages/configuration.slint
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { VerticalBox, HorizontalBox, StandardListView, TextEdit, ComboBox , Switch, GroupBox} from "std-widgets.slint";
import { VerticalBox, HorizontalBox, StandardListView, LineEdit, ComboBox , Switch, GroupBox} from "std-widgets.slint";

export component Configuration inherits VerticalBox {
in-out property <bool> custom-editor;

in-out property <bool> custom-editor-enabled;
in-out property <string> custom-editor;

GroupBox {
title: "Git";
VerticalBox {
Expand All @@ -16,13 +17,13 @@ export component Configuration inherits VerticalBox {
}
}
HorizontalBox {
visible: true;
Text {
vertical-alignment: center;
text: "Username:";
}
TextEdit {
custom-editor-input := LineEdit {
height: 40px;
text <=> root.custom-editor;
}
}
}
Expand All @@ -32,20 +33,21 @@ export component Configuration inherits VerticalBox {
VerticalBox {
HorizontalBox {
ComboBox {
enabled: !root.custom-editor-enabled;
model: ["Vim", "VSCode", "Helix"];
}
Switch {
checked <=> root.custom-editor;
checked <=> root.custom-editor-enabled;
text: "Custom";
}
}
HorizontalBox {
visible: root.custom-editor;
visible: root.custom-editor-enabled;
Text {
vertical-alignment: center;
text: "Editor command:";
}
TextEdit {
LineEdit {
height: 40px;
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/ui/slint/ui/pages/logic.slint
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

export global Logic {
callback clone(string);
}

0 comments on commit fc5789a

Please sign in to comment.