diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f2e972d --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ + +# These are backup files generated by rustfmt +**/*.rs.bk diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..8a69292 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "rust-lang.rust-analyzer", + "vadimcn.vscode-lldb", + "Slint.slint" + ] +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..242da62 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/testbackend/Cargo.toml b/testbackend/Cargo.toml new file mode 100644 index 0000000..602b4a5 --- /dev/null +++ b/testbackend/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "testbackend" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +slint = "1.0" +# testfrontend.workspace = true +testfrontend = "*" +chrono = { version = "0.4", default-features = false, features = ["clock", "std"]} + + +[build-dependencies] +slint-build = "1.0" \ No newline at end of file diff --git a/testbackend/src/main.rs b/testbackend/src/main.rs new file mode 100644 index 0000000..1992fbc --- /dev/null +++ b/testbackend/src/main.rs @@ -0,0 +1,103 @@ +// slint::include_modules!(); +#[cfg(target_arch = "wasm32")] + +use slint_ui::*; +extern crate testfrontend; +use std::rc::Rc; + +/// Returns the current time formated as a string +fn current_time() -> slint::SharedString { + #[cfg(not(target_arch = "wasm32"))] + return chrono::Local::now().format("%H:%M:%S %d/%m/%Y").to_string().into(); + #[cfg(target_arch = "wasm32")] + return "".into(); +} + +// use crate::slint_ui::TodoItem; +// use crate::slint_ui::MainWindow; + +fn main() { + // fn main() -> Result<(), slint::PlatformError> { + // This provides better error messages in debug mode. + // It's disabled in release mode so it doesn't bloat up the file size. + #[cfg(all(debug_assertions, target_arch = "wasm32"))] + console_error_panic_hook::set_once(); + + let main_window = MainWindow::new().unwrap(); + + main_window.set_todo_model( + [ + TodoItem { checked: true, title: "Implement the .slint file".into() }, + TodoItem { checked: true, title: "Do the Rust part".into() }, + TodoItem { checked: false, title: "Make the C++ code".into() }, + TodoItem { checked: false, title: "Write some JavaScript code".into() }, + TodoItem { checked: false, title: "Test the application".into() }, + TodoItem { checked: false, title: "Ship to customer".into() }, + TodoItem { checked: false, title: "???".into() }, + TodoItem { checked: false, title: "Profit".into() }, + ] + .into(), + ); + // let todo_model = Rc::new(slint::VecModel::::from(vec![ + // TodoItem { checked: true, title: "Implement the .slint file".into() }, + // TodoItem { checked: true, title: "Do the Rust part".into() }, + // TodoItem { checked: false, title: "Make the C++ code".into() }, + // TodoItem { checked: false, title: "Write some JavaScript code".into() }, + // TodoItem { checked: false, title: "Test the application".into() }, + // TodoItem { checked: false, title: "Ship to customer".into() }, + // TodoItem { checked: false, title: "???".into() }, + // TodoItem { checked: false, title: "Profit".into() }, + // ])); + + // let ui = AppWindow::new()?; + main_window.on_todo_added({ + let todo_model = todo_model.clone(); + move |text| todo_model.push(TodoItem { checked: false, title: text }) + }); + + main_window.on_quit(move || { + #[cfg(not(target_arch = "wasm32"))] + std::process::exit(0); + }); + + let weak_window = main_window.as_weak(); + // main_window.on_popup_confirmed(move || { + // let window = weak_window.unwrap(); + // window.hide().unwrap(); + // }); + + { + let weak_window = main_window.as_weak(); + let todo_model = todo_model.clone(); + // main_window.window().on_close_requested(move || { + // let window = weak_window.unwrap(); + + // // if todo_model.iter().any(|t| !t.checked) { + // // // window.invoke_show_confirm_popup(); + // // slint::CloseRequestResponse::KeepWindowShown + // // } else { + // // slint::CloseRequestResponse::HideWindow + // // } + // }); + } + + + // let ui_handle = main_window.as_weak(); + // main_window.on_request_increase_value(move || { + // let ui = ui_handle.unwrap(); + // ui.set_counter(main_window.get_counter() + 1); + // }); + + // main_window.run() + + main_window.set_show_header(true); + main_window.set_todo_model(todo_model.into()); + + main_window.run().unwrap(); +} + +mod slint_ui { + pub use testfrontend::*; + // pub use ui_settings_profile_server_window::*; + // pub use ui_settings_profile_window::*; +} \ No newline at end of file diff --git a/testfrontend/Cargo.toml b/testfrontend/Cargo.toml new file mode 100644 index 0000000..7a48b4f --- /dev/null +++ b/testfrontend/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "testfrontend" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +slint = "1.0" + +[build-dependencies] +slint-build = "1.0" \ No newline at end of file diff --git a/testfrontend/build.rs b/testfrontend/build.rs new file mode 100644 index 0000000..1bae90c --- /dev/null +++ b/testfrontend/build.rs @@ -0,0 +1,15 @@ +fn main() { + slint_build::compile("src/appwindow.slint").unwrap(); +} + +// fn main() { +// // let style = "fluent"; +// let style = "material"; +// slint_build::compile_with_config( +// "src/appwindow.slint", +// slint_build::CompilerConfiguration::new() +// .with_style(style.to_string()) +// .into(), +// ) +// .unwrap(); +// } diff --git a/testfrontend/src/appwindow.slint b/testfrontend/src/appwindow.slint new file mode 100644 index 0000000..f30200d --- /dev/null +++ b/testfrontend/src/appwindow.slint @@ -0,0 +1,111 @@ +import { Button, VerticalBox, CheckBox, ComboBox, ListView, HorizontalBox, LineEdit } from "std-widgets.slint"; + +import { DemoPalette, Page } from "common.slint"; +import { HomePage, TodoItem } from "./homepage.slint"; +import { DevicesPage } from "welcome.slint"; + +// export struct TodoItem { +// title: string, +// checked: bool, +// } + +component AppNavigation inherits Rectangle { + in-out property active; + callback activate; + + GridLayout { + padding: 0px; + @children + } + + TouchArea { + clicked => { root.activate(); } + } +} +export component MainWindow inherits Window { + callback quit(); + + preferred-width: 400px; + preferred-height: 600px; + title: @tr("Serial"); + + out property active-page: 0; + // out property active-page: home; + callback todo-added(string); + + in property <[TodoItem]> todo-model: [ + { title: "Implement the .slint file", checked: true }, + { title: "Do the Rust part", checked: false }, + { title: "Make the C++ code", checked: false }, + { title: "Write some JavaScript code", checked: false }, + { title: "Test the application", checked: false }, + { title: "Ship to customer", checked: false }, + { title: "???", checked: false }, + { title: "Profit", checked: false }, + ]; + + HorizontalLayout { + padding: 10px; + // padding-left: 67px; + // alignment: center; + + main-view := Rectangle { + // height: 100%; + // border-radius: 30px; + // background: DemoPalette.page-background-color; + + + Rectangle { + clip: true; + x: main-view.border-radius / 2; + y: main-view.border-radius / 2; + width: main-view.width - main-view.border-radius; + height: main-view.height - main-view.border-radius; + + home-page := DevicesPage { + y: root.active-page == 0 ? 0 : root.active-page < 0 ? - self.height - 1px : parent.height + 1px; + animate y { duration: 125ms; easing: ease; } + } + HomePage { + y: root.active-page == 1 ? 0 : root.active-page < 1 ? - self.height - 1px : parent.height + 1px; + animate y { duration: 125ms; easing: ease; } + } + } + } + } + navigation := Rectangle { + width: 57px; + x: 10px; + + function icon-y(index: int) -> length { + return 200px // top padding + + index * 72px; + } + + for page-icon[idx] in [ + @image-url("images/home.svg"), + @image-url("images/scan.svg"), + // @image-url("images/ink.svg"), + ] : AppNavigation { + y: navigation.icon-y(idx); + x: 16px; + height: 35px; + width: 30px; + + icon := Image { + // colorize: (root.active-page == idx) ? DemoPalette.active-page-icon-color : DemoPalette.inactive-page-icon-color; + // animate colorize { + // duration: 125ms; + // } + source: page-icon; + image-fit: contain; + width: 100%; + height: 100%; + } + + activate => { + root.active-page = idx; + } + } + } +} diff --git a/testfrontend/src/common.slint b/testfrontend/src/common.slint new file mode 100644 index 0000000..6ceb298 --- /dev/null +++ b/testfrontend/src/common.slint @@ -0,0 +1,89 @@ + +struct ButtonColors { + base: color, + pressed: color, + hovered: color, +} +export global DemoPalette { + // Color of the home/settings/ink buttons on the left side bar + out property active-page-icon-color: root.night-mode ? #6284FF : #122F7B; + out property inactive-page-icon-color: #BDC0D1; + + out property main-background: #0E133F; + out property neutral-box: #BDC0D1; + + out property page-background-color: root.night-mode ? #122F7B : white; + + out property text-foreground-color: root.night-mode ? #F4F6FF : black; + out property secondary-foreground-color: root.night-mode ? #C1C3CA : #6C6E7A; + + out property printer-action-background-color: root.night-mode ? root.main-background : white; + out property printer-queue-item-background-color: root.page-background-color; + + out property status-label-text-color: root.night-mode ? #F1FF98 : #6284FF; + + // Color used for the border / outline of items that can be clicked on, such as the + // "Print"/"Scan" buttons, the printer queue items (for expansion) or controls such + // as the combo box or spin box. + out property control-outline-color: #FFBF63; + out property control-secondary: #6284FF; + out property control-foreground: root.night-mode ? white : #122F7B; // FIXME: the night mode color was not part of the design + + out property primary-push-button-base: #6284FF; + out property primary-push-button-colors: { + base: root.primary-push-button-base, + pressed: root.primary-push-button-base.darker(40%), + hovered: root.primary-push-button-base.darker(20%), + }; + + out property secondary-push-button-base: #FFBF63; + out property secondary-push-button-colors: { + base: root.secondary-push-button-base, + pressed: root.secondary-push-button-base.darker(40%), + hovered: root.secondary-push-button-base.darker(20%), + }; + + + out property push-button-text-color: white; + + out property base-font-size: 16px; + + in property night-mode: false; +} + +export component Page inherits Rectangle { + in property header <=> h.text; + // background: DemoPalette.page-background-color; + in property has-back-button: false; + callback back; + + TouchArea {} // protect underneath controls + + if (root.has-back-button) : Image { + x:0; + source: @image-url("images/back.svg"); + image-fit: contain; + colorize: DemoPalette.control-secondary; + y: h.y + (h.height - self.height) / 2; + width: 14px; + height: 24px; + TouchArea { + x:0; + clicked => { root.back() } + width: 150%; + } + } + + h := Text { + font-weight: 900; + font-size: DemoPalette.base-font-size * 2; + color: DemoPalette.text-foreground-color; + y: 46px - self.font-size; + x: root.has-back-button ? 24px + 16px : 0px; + // Allow clicking on the title as well to get back easier when just + // using fingers on a small screen. + if (root.has-back-button) : TouchArea { + clicked => { root.back() } + } + } +} diff --git a/testfrontend/src/homepage.slint b/testfrontend/src/homepage.slint new file mode 100644 index 0000000..77a439f --- /dev/null +++ b/testfrontend/src/homepage.slint @@ -0,0 +1,125 @@ +import { DemoPalette, Page } from "./common.slint"; +// import { WidePrinterQueueList } from "./printer_queue.slint"; +import { Button, VerticalBox, CheckBox, ComboBox, ListView, HorizontalBox, LineEdit } from "std-widgets.slint"; + +export struct TodoItem { + title: string, + checked: bool, +} +export component HomePage inherits Page { + // has-back-button: true; + // header: @tr("Print"); + + // preferred-width: 400px; + // preferred-height: 600px; + // title: @tr("Serial"); + + callback todo-added(string); + + in-out property counter: 42; + callback request-increase-value(); + + callback apply_sorting_and_filtering(); + in property <[TodoItem]> todo-model; + + + + + + in property show-header: true; + in-out property is-sort-by-name: false; + in-out property hide-done-items: false; + + VerticalBox { + HorizontalBox { + // ComboBox { + // value: @tr("119200"); + // choices: [@tr("300"), @tr("1200"), @tr("2400"), @tr("4800"), @tr("19200"), @tr("38400"), @tr("57600")]; + // } + ComboBox { + model: [@tr("Select Port"), @tr("300"), @tr("1200"), @tr("2400"), @tr("4800"), @tr("19200"), @tr("38400"), @tr("57600")]; + // enabled: GallerySettings.widgets-enabled; + } + connectbtn := Button { + text: "Connect"; + enabled: text-edit.text != ""; + clicked => { + root.todo-added(text-edit.text); + text-edit.text = ""; + } + } + disconectbtn := Button { + text: "Disconnect"; + enabled: text-edit.text != ""; + clicked => { + root.todo-added(text-edit.text); + text-edit.text = ""; + } + } + } + if (root.show-header) : HorizontalBox { + alignment: start; + + CheckBox { + text: "Sort by name"; + checked <=> root.is-sort-by-name; + + toggled => { + root.apply_sorting_and_filtering(); + } + } + + CheckBox { + text: "Hide done items"; + checked <=> root.hide-done-items; + + toggled => { + root.apply_sorting_and_filtering(); + } + } + } + list-view := ListView { + for todo in root.todo-model: HorizontalLayout { + Text { + padding: 2px; + text: todo.title; + } + // CheckBox { + // text: todo.title; + // checked: todo.checked; + // toggled => { + // todo.checked = self.checked; + // } + // } + } + } + HorizontalBox { + padding: 0px; + text-edit := LineEdit { + placeholder-text: "Enter Command"; + accepted(text) => { + root.todo-added(self.text); + self.text = ""; + } + } + btn := Button { + text: "Send"; + enabled: text-edit.text != ""; + clicked => { + root.todo-added(text-edit.text); + text-edit.text = ""; + } + } + } + + // Text { + // text: "Counter: \{root.counter}"; + // } + // Button { + // text: "Increase value"; + // clicked => { + // root.request-increase-value(); + // } + // } + } +} diff --git a/testfrontend/src/images/back.svg b/testfrontend/src/images/back.svg new file mode 100644 index 0000000..251522b --- /dev/null +++ b/testfrontend/src/images/back.svg @@ -0,0 +1,3 @@ + + + diff --git a/testfrontend/src/images/cat.jpg b/testfrontend/src/images/cat.jpg new file mode 100644 index 0000000..d7952ad Binary files /dev/null and b/testfrontend/src/images/cat.jpg differ diff --git a/testfrontend/src/images/cat.jpg.license b/testfrontend/src/images/cat.jpg.license new file mode 100644 index 0000000..a0e516e --- /dev/null +++ b/testfrontend/src/images/cat.jpg.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2013 zaimoku_woodpile +SPDX-License-Identifier: CC-BY-2.0 +Comment: Taken from: https://www.flickr.com/photos/11250735@N07/8561945042 with Modifications: Cropped, resized the image diff --git a/testfrontend/src/images/check.svg b/testfrontend/src/images/check.svg new file mode 100644 index 0000000..342ee2b --- /dev/null +++ b/testfrontend/src/images/check.svg @@ -0,0 +1,3 @@ + + + diff --git a/testfrontend/src/images/copy.svg b/testfrontend/src/images/copy.svg new file mode 100644 index 0000000..e10d422 --- /dev/null +++ b/testfrontend/src/images/copy.svg @@ -0,0 +1,3 @@ + + + diff --git a/testfrontend/src/images/delete.svg b/testfrontend/src/images/delete.svg new file mode 100644 index 0000000..9dceb65 --- /dev/null +++ b/testfrontend/src/images/delete.svg @@ -0,0 +1,3 @@ + + + diff --git a/testfrontend/src/images/dog.jpg b/testfrontend/src/images/dog.jpg new file mode 100644 index 0000000..4928fef Binary files /dev/null and b/testfrontend/src/images/dog.jpg differ diff --git a/testfrontend/src/images/dog.jpg.license b/testfrontend/src/images/dog.jpg.license new file mode 100644 index 0000000..e70b668 --- /dev/null +++ b/testfrontend/src/images/dog.jpg.license @@ -0,0 +1,3 @@ +SPDX-License-Identifier: CC-PDDC +SPDX-FileCopyrightText: This work has been released into the public domain by its author, Imk0278 at the Wikipedia project. This applies worldwide. +Comment: Taken from: https://commons.wikimedia.org/wiki/File:Kintamani_dog_white.jpg with Modifications: Cropped, resized diff --git a/testfrontend/src/images/down.svg b/testfrontend/src/images/down.svg new file mode 100644 index 0000000..3772187 --- /dev/null +++ b/testfrontend/src/images/down.svg @@ -0,0 +1,3 @@ + + + diff --git a/testfrontend/src/images/elephant.jpg b/testfrontend/src/images/elephant.jpg new file mode 100644 index 0000000..4f6e062 Binary files /dev/null and b/testfrontend/src/images/elephant.jpg differ diff --git a/testfrontend/src/images/elephant.jpg.license b/testfrontend/src/images/elephant.jpg.license new file mode 100644 index 0000000..cd18879 --- /dev/null +++ b/testfrontend/src/images/elephant.jpg.license @@ -0,0 +1,3 @@ +SPDX-License-Identifier: CC-PDDC +SPDX-FileCopyrightText: This work is in the public domain in the United States +Comment: Taken from: https://commons.wikimedia.org/wiki/File:1968-elefante.jpg with Modifications: Cropped, resized diff --git a/testfrontend/src/images/home.svg b/testfrontend/src/images/home.svg new file mode 100644 index 0000000..6b12b64 --- /dev/null +++ b/testfrontend/src/images/home.svg @@ -0,0 +1 @@ + diff --git a/testfrontend/src/images/ink.svg b/testfrontend/src/images/ink.svg new file mode 100644 index 0000000..170d6fc --- /dev/null +++ b/testfrontend/src/images/ink.svg @@ -0,0 +1 @@ + diff --git a/testfrontend/src/images/laptop.svg b/testfrontend/src/images/laptop.svg new file mode 100644 index 0000000..4f798a2 --- /dev/null +++ b/testfrontend/src/images/laptop.svg @@ -0,0 +1 @@ + diff --git a/testfrontend/src/images/list.svg b/testfrontend/src/images/list.svg new file mode 100644 index 0000000..f3d566e --- /dev/null +++ b/testfrontend/src/images/list.svg @@ -0,0 +1 @@ + diff --git a/testfrontend/src/images/minus.svg b/testfrontend/src/images/minus.svg new file mode 100644 index 0000000..16aecea --- /dev/null +++ b/testfrontend/src/images/minus.svg @@ -0,0 +1,3 @@ + + + diff --git a/testfrontend/src/images/moon.svg b/testfrontend/src/images/moon.svg new file mode 100644 index 0000000..fdf7a03 --- /dev/null +++ b/testfrontend/src/images/moon.svg @@ -0,0 +1 @@ + diff --git a/testfrontend/src/images/moon_full.svg b/testfrontend/src/images/moon_full.svg new file mode 100644 index 0000000..bfceabb --- /dev/null +++ b/testfrontend/src/images/moon_full.svg @@ -0,0 +1,3 @@ + + + diff --git a/testfrontend/src/images/night_mode.svg b/testfrontend/src/images/night_mode.svg new file mode 100644 index 0000000..fb34ee8 --- /dev/null +++ b/testfrontend/src/images/night_mode.svg @@ -0,0 +1,3 @@ + + + diff --git a/testfrontend/src/images/page_selection.svg b/testfrontend/src/images/page_selection.svg new file mode 100644 index 0000000..632b994 --- /dev/null +++ b/testfrontend/src/images/page_selection.svg @@ -0,0 +1 @@ + diff --git a/testfrontend/src/images/pause.svg b/testfrontend/src/images/pause.svg new file mode 100644 index 0000000..75969ac --- /dev/null +++ b/testfrontend/src/images/pause.svg @@ -0,0 +1,4 @@ + + + + diff --git a/testfrontend/src/images/plus.svg b/testfrontend/src/images/plus.svg new file mode 100644 index 0000000..5b0ea37 --- /dev/null +++ b/testfrontend/src/images/plus.svg @@ -0,0 +1,4 @@ + + + + diff --git a/testfrontend/src/images/power.svg b/testfrontend/src/images/power.svg new file mode 100644 index 0000000..97cffe4 --- /dev/null +++ b/testfrontend/src/images/power.svg @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testfrontend/src/images/print.svg b/testfrontend/src/images/print.svg new file mode 100644 index 0000000..10c2754 --- /dev/null +++ b/testfrontend/src/images/print.svg @@ -0,0 +1,3 @@ + + + diff --git a/testfrontend/src/images/printer.svg b/testfrontend/src/images/printer.svg new file mode 100644 index 0000000..ecc0276 --- /dev/null +++ b/testfrontend/src/images/printer.svg @@ -0,0 +1 @@ + diff --git a/testfrontend/src/images/replicate.svg b/testfrontend/src/images/replicate.svg new file mode 100644 index 0000000..a9cdaee --- /dev/null +++ b/testfrontend/src/images/replicate.svg @@ -0,0 +1 @@ + diff --git a/testfrontend/src/images/scan.svg b/testfrontend/src/images/scan.svg new file mode 100644 index 0000000..d3bb24f --- /dev/null +++ b/testfrontend/src/images/scan.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/testfrontend/src/images/settings.svg b/testfrontend/src/images/settings.svg new file mode 100644 index 0000000..3d67ca6 --- /dev/null +++ b/testfrontend/src/images/settings.svg @@ -0,0 +1 @@ + diff --git a/testfrontend/src/images/snake.jpg b/testfrontend/src/images/snake.jpg new file mode 100644 index 0000000..7f9547a Binary files /dev/null and b/testfrontend/src/images/snake.jpg differ diff --git a/testfrontend/src/images/snake.jpg.license b/testfrontend/src/images/snake.jpg.license new file mode 100644 index 0000000..d8c3cf9 --- /dev/null +++ b/testfrontend/src/images/snake.jpg.license @@ -0,0 +1,3 @@ +SPDX-License-Identifier: CC-PDDC +SPDX-FileCopyrightText: This work is in the public domain in the United States because it is a work prepared by an officer or employee of the United States Government as part of that person’s official duties under the terms of Title 17, Chapter 1, Section 105 of the US Code +Comment: Taken from: https://commons.wikimedia.org/wiki/File:Gopher_Snake_(11970141595).jpg with Modifications: Cropped, resized diff --git a/testfrontend/src/images/usb.svg b/testfrontend/src/images/usb.svg new file mode 100644 index 0000000..11e9456 --- /dev/null +++ b/testfrontend/src/images/usb.svg @@ -0,0 +1,3 @@ + + + diff --git a/testfrontend/src/lib.rs b/testfrontend/src/lib.rs new file mode 100644 index 0000000..d174e0c --- /dev/null +++ b/testfrontend/src/lib.rs @@ -0,0 +1 @@ +slint::include_modules!(); diff --git a/testfrontend/src/welcome.slint b/testfrontend/src/welcome.slint new file mode 100644 index 0000000..8098c7f --- /dev/null +++ b/testfrontend/src/welcome.slint @@ -0,0 +1,78 @@ + +import { DemoPalette, Page } from "./common.slint"; +import { HomePage } from "./homepage.slint"; +import { Button, VerticalBox, CheckBox, ComboBox, ListView, HorizontalBox, LineEdit } from "std-widgets.slint"; + + +component ActionButton inherits Rectangle { + + in property icon <=> img.source; + in property text <=> label.text; + callback clicked; + + VerticalLayout { + spacing: 4px; + + Rectangle { + border-radius: 25px; + border-width: 5px; + // border-color: DemoPalette.control-outline-color; + background: DemoPalette.printer-action-background-color; + + img := Image { + x: (parent.width / 2) - (self.width / 2); + y: (parent.height / 2) - (self.height / 2); + colorize: DemoPalette.text-foreground-color; + } + } + + label := Text { + font-size: DemoPalette.base-font-size * 1.375; + font-weight: 800; + horizontal-alignment: center; + color: DemoPalette.text-foreground-color; + } + } + + TouchArea { clicked => { root.clicked() } } +} + +export component DevicesPage inherits Page { + in-out property header-row-height: 40px; + + in-out property button-spacing: 105px; + in-out property button-width: 127px; + in-out property button-height: root.button-width + 37px; + + pure callback validate-date(string) -> bool; + // header: @tr("Slint Printer Demo"); + private property message-visible; + + in-out property current-subpage: 0; + VerticalBox { + width: root.button-width; + height: root.button-height; + combo := ComboBox { + // row: 0; + model: ["/dev/device", "bluetooth"]; + current-value: "bluetooth"; + current-index: 0; + } + Button { + // row: 3; + text: "Connect"; + clicked() => { root.message-visible = true; } + // enabled: combo.current-index != 1 ? root.validate-date(t1.text) : root.compare-date(t1.text, t2.text); + } + for action[idx] in [ + { name: @tr("Scan"), icon: @image-url("images/scan.svg") }, + // { name: @tr("USB"), icon: @image-url("images/usb.svg") }, + ]: ActionButton { + width: root.button-width; + height: root.button-height; + icon: action.icon; + text: action.name; + clicked => { root.current-subpage = idx + 1; } + } + } +} \ No newline at end of file