Add basic slint app

This commit is contained in:
2025-12-14 19:09:13 +01:00
parent 4860851dba
commit e965518284
7 changed files with 6174 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
[target.x86_64-pc-windows-msvc]
# Increase default stack size to avoid running out of stack
# space in debug builds. The size matches Linux's default.
rustflags = [
"-C", "link-arg=/STACK:8000000"
]
[target.aarch64-pc-windows-msvc]
# Increase default stack size to avoid running out of stack
# space in debug builds. The size matches Linux's default.
rustflags = [
"-C", "link-arg=/STACK:8000000"
]
+3
View File
@@ -0,0 +1,3 @@
/target/
**/*.rs.bk
+6074
View File
File diff suppressed because it is too large Load Diff
+10
View File
@@ -0,0 +1,10 @@
[package]
name = "inköpslista"
version = "0.0.0"
edition = "2024"
[dependencies]
slint = "1.14.1"
[build-dependencies]
slint-build = "1.14.1"
+4
View File
@@ -0,0 +1,4 @@
fn main() {
let config = slint_build::CompilerConfiguration::new().with_style("cosmic-dark".into());
slint_build::compile_with_config("ui/app.slint", config).expect("Slint build failed");
}
+14
View File
@@ -0,0 +1,14 @@
// Prevent console window in addition to Slint window in Windows release builds when, e.g., starting the app via file manager. Ignored on other platforms.
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use std::error::Error;
slint::include_modules!();
fn main() -> Result<(), Box<dyn Error>> {
let ui = App::new()?;
ui.run()?;
Ok(())
}
+56
View File
@@ -0,0 +1,56 @@
import { AboutSlint, Button, VerticalBox, ListView, CheckBox, HorizontalBox, TextEdit, GridBox } from "std-widgets.slint";
component GoodsList {
in property <[string]> items: ["Mjölk", "Ost", "Ägg"];
ListView {
for item in items: Rectangle {
HorizontalBox {
CheckBox {}
Text {
text: item;
}
}
}
}
}
component GoodButtons {
in property <[string]> favorites: ["Mjölk", "Ost", "Ägg", "Bullens", "Oboy", "Mjöl", "Havregryn", "KrosTom"];
in property <int> button-width: 100;
in property <int> button-height: 60;
in property <int> button-spacing: 10;
height: 200px;
property <int> count_x: root.width / 1px / (button-width + button-spacing);
Rectangle {
for item[idx] in favorites: Button {
x: mod(idx, count_x) * (root.button-width + root.button-spacing) * 1px ;
y: floor(idx / count_x) * (root.button-height + root.button-spacing) * 1px;
width: root.button-width * 1px;
height: root.button-height * 1px;
text: item;
}
}
}
export component App inherits Window {
VerticalBox {
goods:= GoodsList {
height: 200px;
}
input:= TextEdit {
height:50px;
}
Button {
height: 42px;
text: "Add";
clicked => {
goods.items[goods.items.length] = input.text;
}
}
GoodButtons {
}
}
}