From 83f3f7bd127c1d1f3808f1c6e4a1a8a78cb2779b Mon Sep 17 00:00:00 2001 From: Ku6epXBOCTuK Date: Tue, 25 Aug 2026 16:18:05 +0500 Subject: [PATCH] chore: clear repo, license, etc --- .gitignore | 4 +- docs/dev-workflow.md | 6 +- example/Cargo.toml | 35 ------ example/index.html | 41 ------- example/lib.rs | 204 -------------------------------- example/main.rs | 9 -- example/todo.slint | 161 ------------------------- logos/LICENSE-browser-logos.txt | 29 +++++ 8 files changed, 35 insertions(+), 454 deletions(-) delete mode 100644 example/Cargo.toml delete mode 100644 example/index.html delete mode 100644 example/lib.rs delete mode 100644 example/main.rs delete mode 100644 example/todo.slint create mode 100644 logos/LICENSE-browser-logos.txt diff --git a/.gitignore b/.gitignore index fa893f9..809abbf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /target -refs/browser-logos-75.0.1.zip +tools/out/ +*.log +coldstart.txt diff --git a/docs/dev-workflow.md b/docs/dev-workflow.md index dbd08e2..d6e01d9 100644 --- a/docs/dev-workflow.md +++ b/docs/dev-workflow.md @@ -32,11 +32,11 @@ HTML-макеты → PNG: **headless Edge** (`--headless --screenshot`), он ## Этап A — порядок в репозитории -- [ ] Удалена `example/` — копия примера Slint с копирайтом SixtyFPS и битыми path-deps -- [ ] Zip `browser-logos` удалён (не был в git; перезаливаемо с github alrrr/browser-logos); +- [x] Удалена `example/` — копия примера Slint с копирайтом SixtyFPS и битыми path-deps +- [x] Zip `browser-logos` удалён (не был в git; перезаливаемо с github alrrr/browser-logos); LICENSE логотипов сохранён в `logos/LICENSE-browser-logos.txt`; в `logos/` уже лежат отобранные PNG (chrome, firefox, opera, yandex, brave) -- [ ] `.gitignore`: `tools/out/`, `*.log`, `coldstart.txt` +- [x] `.gitignore`: `tools/out/`, `*.log`, `coldstart.txt` Коммит: `chore: repo hygiene` diff --git a/example/Cargo.toml b/example/Cargo.toml deleted file mode 100644 index 5e2f4df..0000000 --- a/example/Cargo.toml +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright © SixtyFPS GmbH -# SPDX-License-Identifier: MIT - -[package] -name = "todo" -version = "1.17.0" -authors = ["Slint Developers "] -edition.workspace = true -build = "build.rs" -publish = false -license = "MIT" - -[lib] -crate-type = ["lib", "cdylib"] -path = "lib.rs" -name = "todo_lib" - -[[bin]] -path = "main.rs" -name = "todo" - -[dependencies] -slint = { path = "../../../api/rs/slint", features = ["serde", "backend-android-activity-06"] } -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" - -[target.'cfg(target_arch = "wasm32")'.dependencies] -wasm-bindgen = { version = "0.2" } -console_error_panic_hook = "0.1.5" - -[build-dependencies] -slint-build = { path = "../../../api/rs/build" } - -[dev-dependencies] -i-slint-backend-testing = { workspace = true } diff --git a/example/index.html b/example/index.html deleted file mode 100644 index eae2e46..0000000 --- a/example/index.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - Slint Todo Demo (Web Assembly version) - - - - -

This is the Slint Todo Demo compiled to WebAssembly.

-
-
Loading...
-
- - - - - - diff --git a/example/lib.rs b/example/lib.rs deleted file mode 100644 index 2c15a4e..0000000 --- a/example/lib.rs +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright © SixtyFPS GmbH -// SPDX-License-Identifier: MIT - -use slint::{FilterModel, Model, SortModel}; -use std::rc::Rc; - -#[cfg(target_arch = "wasm32")] -use wasm_bindgen::prelude::*; - -slint::include_modules!(); - -#[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))] -pub fn main() { - let state = init(); - let main_window = state.main_window.clone_strong(); - #[cfg(target_os = "android")] - STATE.with(|ui| *ui.borrow_mut() = Some(state)); - main_window.run().unwrap(); -} - -fn init() -> State { - // 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 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 main_window = MainWindow::new().unwrap(); - - main_window.on_todo_added({ - let todo_model = todo_model.clone(); - move |text| todo_model.push(TodoItem { checked: false, title: text }) - }); - main_window.on_remove_done({ - let todo_model = todo_model.clone(); - move || { - let mut offset = 0; - for i in 0..todo_model.row_count() { - if todo_model.row_data(i - offset).unwrap().checked { - todo_model.remove(i - offset); - offset += 1; - } - } - } - }); - - 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 - } - }); - } - - main_window.on_apply_sorting_and_filtering({ - let weak_window = main_window.as_weak(); - let todo_model = todo_model.clone(); - - move || { - let window = weak_window.unwrap(); - window.set_todo_model(todo_model.clone().into()); - - if window.get_hide_done_items() { - window.set_todo_model( - Rc::new(FilterModel::new(window.get_todo_model(), |e| !e.checked)).into(), - ); - } - - if window.get_is_sort_by_name() { - window.set_todo_model( - Rc::new(SortModel::new(window.get_todo_model(), |lhs, rhs| { - lhs.title.to_lowercase().cmp(&rhs.title.to_lowercase()) - })) - .into(), - ); - } - } - }); - - main_window.set_show_header(true); - main_window.set_todo_model(todo_model.clone().into()); - State { main_window, todo_model } -} - -#[cfg(target_os = "android")] -#[unsafe(no_mangle)] -fn android_main(app: slint::android::AndroidApp) { - use slint::android::android_activity::{MainEvent, PollEvent}; - slint::android::init_with_event_listener(app, |event| { - match event { - PollEvent::Main(MainEvent::SaveState { saver, .. }) => { - STATE.with(|state| -> Option<()> { - let todo_state = SerializedState::save(state.borrow().as_ref()?); - saver.store(&serde_json::to_vec(&todo_state).ok()?); - Some(()) - }); - } - PollEvent::Main(MainEvent::Resume { loader, .. }) => { - STATE.with(|state| -> Option<()> { - let bytes: Vec = loader.load()?; - let todo_state: SerializedState = serde_json::from_slice(&bytes).ok()?; - todo_state.restore(state.borrow().as_ref()?); - Some(()) - }); - } - _ => {} - }; - }) - .unwrap(); - main(); -} - -pub struct State { - pub main_window: MainWindow, - pub todo_model: Rc>, -} - -#[cfg(target_os = "android")] -thread_local! { - static STATE : core::cell::RefCell> = Default::default(); -} - -#[cfg(target_os = "android")] -#[derive(serde::Serialize, serde::Deserialize)] -struct SerializedState { - items: Vec, - sort: bool, - hide_done: bool, -} - -#[cfg(target_os = "android")] -impl SerializedState { - fn restore(self, state: &State) { - state.todo_model.set_vec(self.items); - state.main_window.set_hide_done_items(self.hide_done); - state.main_window.set_is_sort_by_name(self.sort); - state.main_window.invoke_apply_sorting_and_filtering(); - } - fn save(state: &State) -> Self { - Self { - items: state.todo_model.iter().collect(), - sort: state.main_window.get_is_sort_by_name(), - hide_done: state.main_window.get_hide_done_items(), - } - } -} - -#[test] -fn press_add_adds_one_todo() { - if option_env!("SLINT_EMIT_DEBUG_INFO").unwrap_or_default() != "1" { - println!("This test needs to be build with `SLINT_EMIT_DEBUG_INFO=1` in the environment"); - return; - } - i_slint_backend_testing::init_no_event_loop(); - use i_slint_backend_testing::{ElementHandle, ElementQuery}; - let state = init(); - state.todo_model.set_vec(vec![TodoItem { checked: false, title: "first".into() }]); - let line_edit = ElementQuery::from_root(&state.main_window) - .match_id("MainWindow::text-edit") - .find_first() - .unwrap(); - assert_eq!(line_edit.accessible_value().unwrap(), ""); - line_edit.set_accessible_value("second"); - - let button = ElementHandle::find_by_accessible_label(&state.main_window, "Add New Entry") - .next() - .unwrap(); - button.invoke_accessible_default_action(); - - assert_eq!(state.todo_model.row_count(), 2); - assert_eq!( - state.todo_model.row_data(0).unwrap(), - TodoItem { checked: false, title: "first".into() } - ); - assert_eq!( - state.todo_model.row_data(1).unwrap(), - TodoItem { checked: false, title: "second".into() } - ); - - assert_eq!(line_edit.accessible_value().unwrap(), ""); -} diff --git a/example/main.rs b/example/main.rs deleted file mode 100644 index a1bbc86..0000000 --- a/example/main.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright © SixtyFPS GmbH -// SPDX-License-Identifier: MIT - -// In order to be compatible with both desktop, wasm, and android, the example is both a binary and a library. -// Just forward to the library in main - -fn main() { - todo_lib::main(); -} diff --git a/example/todo.slint b/example/todo.slint deleted file mode 100644 index 0882e87..0000000 --- a/example/todo.slint +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright © SixtyFPS GmbH -// SPDX-License-Identifier: MIT - -import { - SpinBox, - Button, - CheckBox, - Slider, - LineEdit, - ScrollView, - ListView, - HorizontalBox, - VerticalBox, - GridBox, - StandardButton, - Palette, -} from "std-widgets.slint"; - -@rust-attr(derive(serde::Serialize, serde::Deserialize)) -export struct TodoItem { - title: string, - checked: bool, -} - -export component MainWindow inherits Window { - 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 }, - ]; - - in property show-header: false; - in-out property is-sort-by-name: false; - in-out property hide-done-items: false; - - callback todo-added(string); - callback remove-done(); - callback popup_confirmed; - callback show_confirm_popup; - callback apply_sorting_and_filtering(); - - show_confirm_popup => { - confirm_popup.show(); - } - - preferred-width: 400px; - preferred-height: 600px; - - confirm_popup := PopupWindow { - x: 40px; - y: 100px; - width: min(confirm_popup_layout.preferred-width, root.width - 80px); - - Rectangle { - background: Palette.background; - border-color: Palette.border; - border-width: 1px; - } - - confirm_popup_layout := Dialog { - height: 100%; - width: 100%; - background: transparent; - - confirm_popup_text := Text { - text: "Some items are not done, are you sure you wish to quit?"; - wrap: word-wrap; - } - - StandardButton { - kind: yes; - clicked => { - root.popup_confirmed(); - } - } - - StandardButton { - kind: no; - } - } - } - - VerticalBox { - x: root.safe-area-insets.left; - y: root.safe-area-insets.top; - width: root.width - root.safe-area-insets.right - root.safe-area-insets.left; - height: root.height - root.safe-area-insets.bottom - root.safe-area-insets.top; - - HorizontalBox { - padding: 0px; - text-edit := LineEdit { - accepted(text) => { - root.todo-added(self.text); - self.text = ""; - } - - placeholder-text: "What needs to be done?"; - } - - btn := Button { - clicked => { - root.todo-added(text-edit.text); - text-edit.text = ""; - } - - text: "Add New Entry"; - enabled: text-edit.text != ""; - } - } - - if (root.show-header): HorizontalBox { - padding: 0px; - alignment: start; - - CheckBox { - toggled => { - root.apply_sorting_and_filtering(); - } - - text: "Sort by name"; - checked <=> root.is-sort-by-name; - } - - CheckBox { - toggled => { - root.apply_sorting_and_filtering(); - } - - text: "Hide done items"; - checked <=> root.hide-done-items; - } - } - - list-view := ListView { - for todo in root.todo-model: HorizontalLayout { - CheckBox { - text: todo.title; - // checked <=> todo.checked; - } - } - } - - HorizontalBox { - padding: 0px; - alignment: end; - - Button { - clicked => { - root.remove-done(); - } - - text: "Remove Done Items"; - } - } - } -} diff --git a/logos/LICENSE-browser-logos.txt b/logos/LICENSE-browser-logos.txt new file mode 100644 index 0000000..69e6032 --- /dev/null +++ b/logos/LICENSE-browser-logos.txt @@ -0,0 +1,29 @@ +Browser logos in this directory are taken from: + https://github.com/alrrr/browser-logos +Version: v75.0.1 (release zip) +Files used: brave_48x48.png, chrome_48x48.png, chrome_64x64.png, + firefox_48x48.png, firefox_64x64.png, opera_48x48.png, + opera_64x64.png, yandex_48x48.png, yandex_64x64.png + +Upstream license (MIT) text follows. +---------------------------------------------------------------------- + +Copyright (c) Cătălin Mariș + +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.