chore: clear repo, license, etc
This commit is contained in:
+3
-1
@@ -1,2 +1,4 @@
|
|||||||
/target
|
/target
|
||||||
refs/browser-logos-75.0.1.zip
|
tools/out/
|
||||||
|
*.log
|
||||||
|
coldstart.txt
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ HTML-макеты → PNG: **headless Edge** (`--headless --screenshot`), он
|
|||||||
|
|
||||||
## Этап A — порядок в репозитории
|
## Этап A — порядок в репозитории
|
||||||
|
|
||||||
- [ ] Удалена `example/` — копия примера Slint с копирайтом SixtyFPS и битыми path-deps
|
- [x] Удалена `example/` — копия примера Slint с копирайтом SixtyFPS и битыми path-deps
|
||||||
- [ ] Zip `browser-logos` удалён (не был в git; перезаливаемо с github alrrr/browser-logos);
|
- [x] Zip `browser-logos` удалён (не был в git; перезаливаемо с github alrrr/browser-logos);
|
||||||
LICENSE логотипов сохранён в `logos/LICENSE-browser-logos.txt`;
|
LICENSE логотипов сохранён в `logos/LICENSE-browser-logos.txt`;
|
||||||
в `logos/` уже лежат отобранные PNG (chrome, firefox, opera, yandex, brave)
|
в `logos/` уже лежат отобранные PNG (chrome, firefox, opera, yandex, brave)
|
||||||
- [ ] `.gitignore`: `tools/out/`, `*.log`, `coldstart.txt`
|
- [x] `.gitignore`: `tools/out/`, `*.log`, `coldstart.txt`
|
||||||
|
|
||||||
Коммит: `chore: repo hygiene`
|
Коммит: `chore: repo hygiene`
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
# Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
||||||
# SPDX-License-Identifier: MIT
|
|
||||||
|
|
||||||
[package]
|
|
||||||
name = "todo"
|
|
||||||
version = "1.17.0"
|
|
||||||
authors = ["Slint Developers <info@slint.dev>"]
|
|
||||||
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 }
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<!-- Copyright © SixtyFPS GmbH <info@slint.dev> -->
|
|
||||||
<!-- SPDX-License-Identifier: MIT -->
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<!--
|
|
||||||
This is a static html file used to display the wasm build.
|
|
||||||
In order to generate the build
|
|
||||||
- Run `wasm-pack build --release --target web` in this directory.
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>Slint Todo Demo (Web Assembly version)</title>
|
|
||||||
<link rel="stylesheet" href="https://slint.dev/css/demos-v1.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<p>This is the <a href="https://slint.dev">Slint</a> Todo Demo compiled to WebAssembly.</p>
|
|
||||||
<div id="spinner" style="position: relative;">
|
|
||||||
<div class="spinner">Loading...</div>
|
|
||||||
</div>
|
|
||||||
<canvas id="canvas" unselectable="on" data-slint-auto-resize-to-preferred="true"></canvas>
|
|
||||||
<p class="links">
|
|
||||||
<a href="https://github.com/slint-ui/slint/blob/master/examples/todo/">
|
|
||||||
View Source Code on GitHub</a> -
|
|
||||||
<a href="https://slint.dev/editor?load_demo=examples/todo/ui/todo.slint">
|
|
||||||
Open in SlintPad
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
<script type="module">
|
|
||||||
import init from './pkg/todo_lib.js';
|
|
||||||
init().finally(() => {
|
|
||||||
document.getElementById("spinner").remove();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
-204
@@ -1,204 +0,0 @@
|
|||||||
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
||||||
// 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::<TodoItem>::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<u8> = 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<slint::VecModel<TodoItem>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
|
||||||
thread_local! {
|
|
||||||
static STATE : core::cell::RefCell<Option<State>> = Default::default();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(target_os = "android")]
|
|
||||||
#[derive(serde::Serialize, serde::Deserialize)]
|
|
||||||
struct SerializedState {
|
|
||||||
items: Vec<TodoItem>,
|
|
||||||
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(), "");
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
||||||
// 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();
|
|
||||||
}
|
|
||||||
@@ -1,161 +0,0 @@
|
|||||||
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
||||||
// 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 <bool> show-header: false;
|
|
||||||
in-out property <bool> is-sort-by-name: false;
|
|
||||||
in-out property <bool> 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";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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.
|
||||||
Reference in New Issue
Block a user