S018: site dialog, hidden run noted, plan done

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
astar76 2026-11-25 07:51:33 -06:00
commit 83ef4be3b7
7 changed files with 33 additions and 11 deletions

View file

@ -19,7 +19,7 @@ FEATURES 8.4 (shortcuts, palette), 8.5 (choice), 9.1, 9.8, D-012.
- [x] Command palette (Ctrl+K) over actions, downloads and settings, instant to open
- [x] First run: folder, colours, port explanation; skippable, three screens at most
- [x] Backup and restore of settings
- [ ] `docs/PROGRESS.md` entry, tick `Plans/INDEX.md`, commit `S018: …`, push
- [x] `docs/PROGRESS.md` entry, tick `Plans/INDEX.md`, commit `S018: …`, push
## End criteria
- `nice cargo test -j 2 -p medlar --test settings` green

View file

@ -29,7 +29,7 @@ Tracker: https://claude.ai/artifact/XouimfVJS6FYVKskGJ8s7H
- [x] [S015](03%20Interface/S015-main-window.md) Main window and list
- [ ] [S016](03%20Interface/S016-add-dialog.md) Add dialog, batch and duplicates
- [ ] [S017](03%20Interface/S017-details.md) Details panel and file actions
- [ ] [S018](03%20Interface/S018-settings-palette.md) Settings, colour, shortcuts and first run
- [x] [S018](03%20Interface/S018-settings-palette.md) Settings, colour, shortcuts and first run
## 04 Control

View file

@ -99,6 +99,11 @@ impl View {
self.search = what.into();
}
/// Asks for another site.
pub fn add_site(&mut self) {
self.sites.add();
}
/// Shows one row.
pub fn go_to(&mut self, ui: &Ui, row: &Row) {
self.go(row.page);
@ -325,7 +330,7 @@ impl View {
} else if on < 0.01 {
self.lit = None;
}
ui.painter().set(shape, eframe::egui::Shape::rect_filled(rect.shrink(space::XS), cr(radius::inner(radius::L, space::XS)), alpha(t.secondary_container, on)));
ui.painter().set(shape, eframe::egui::Shape::rect_filled(rect.shrink(space::XS), cr(radius::inner(radius::L, space::XS)), alpha(t.highest, on)));
}
fn row(&mut self, ui: &mut Ui, cx: &mut Cx, row: &Row) {

View file

@ -8,7 +8,7 @@ use crate::ui::dialog::{Answer, Dialog};
use crate::ui::field::{Field, Number};
use crate::ui::widgets::{Button, Kind, left, line};
use crate::{fonts, icons};
use eframe::egui::{Rect, Ui, UiBuilder, Vec2, pos2};
use eframe::egui::{Rect, Sense, Ui, UiBuilder, Vec2, pos2, vec2};
use medlar_core::auth::Login;
use medlar_core::manager::Command;
use medlar_core::model::TaskId;
@ -18,6 +18,8 @@ use medlar_core::tr;
use std::path::PathBuf;
const ROW: f32 = 60.0;
/// A number with its name above and its error below.
const NUMBER: f32 = size::CONTROL + 2.0 * (space::L + space::XS);
#[derive(Default)]
pub struct State {
@ -138,11 +140,15 @@ pub fn list(view: &mut View, cx: &mut Cx, ui: &mut Ui) {
cx.toasts.undo("delete", tr!("site.removed", site = site.pattern), crate::views::main::Reply::Settings(Box::new(before)));
}
if Button::new(&tr!("site.add")).with_icon("add").kind(Kind::Tonal).show(ui, t).clicked() {
view.sites.edit = Some(Edit::new(None, &Site::default()));
view.sites.add();
}
}
impl State {
pub fn add(&mut self) {
self.edit = Some(Edit::new(None, &Site::default()));
}
/// The rules of one site.
pub fn dialog(&mut self, ui: &Ui, cx: &mut Cx) {
let Some(e) = &mut self.edit else { return };
@ -163,12 +169,15 @@ impl State {
Field::new(&tr!("login.user")).help(&login_help).error(bad_login.as_deref()).width(side).show(ui, t, &mut e.login.user);
Field::new(&tr!("login.password")).password().width(side).show(ui, t, &mut e.login.password);
});
ui.horizontal_top(|ui| {
Number { label: &tr!("set.per_host"), unit: "", range: 0.0..=64.0, step: 1.0, enabled: true, width: side, bare: false }.show(ui, t, &mut e.connections);
Number { label: &tr!("set.speed"), unit: &tr!("unit.kb_s"), range: 0.0..=10_000_000.0, step: 64.0, enabled: true, width: side, bare: false }.show(ui, t, &mut e.speed);
});
// A number's buttons move the cursor back, so each gets a place of its own.
let (both, _) = ui.allocate_exact_size(vec2(ui.available_width(), NUMBER), Sense::hover());
let mut half = |x: f32, salt: &str| ui.new_child(UiBuilder::new().max_rect(Rect::from_min_size(pos2(x, both.top()), vec2(side, NUMBER))).id_salt(salt));
let mut first = half(both.left(), "connections");
Number { label: &tr!("set.per_host"), unit: "", range: 0.0..=64.0, step: 1.0, enabled: true, width: side, bare: false }.show(&mut first, t, &mut e.connections);
let mut second = half(both.right() - side, "speed");
Number { label: &tr!("set.speed"), unit: &tr!("unit.kb_s"), range: 0.0..=10_000_000.0, step: 64.0, enabled: true, width: side, bare: false }.show(&mut second, t, &mut e.speed);
Field::new(&tr!("set.folder")).error(bad_folder.as_deref()).show(ui, t, &mut e.folder);
Field::new(&tr!("set.proxy")).hint("direct").help(&tr!("site.proxy_help")).error(bad_proxy.as_deref()).show(ui, t, &mut e.proxy);
Field::new(&tr!("set.proxy")).hint("socks5://127.0.0.1:1080").help(&tr!("site.proxy_help")).error(bad_proxy.as_deref()).show(ui, t, &mut e.proxy);
Field::new(&tr!("site.agent")).show(ui, t, &mut e.agent);
});
let Some(answer) = answer else { return };

View file

@ -290,6 +290,8 @@ fn a_login_for_anyone_is_refused() {
let mut h = at(Page::Sites);
click(&mut h, "Add site");
h.run_steps(30);
let first = h.query_all_by_label("More").next().unwrap().rect();
assert!(first.right() < h.query_all_by_label("Speed limit").last().unwrap().rect().left(), "the numbers stand beside each other");
text(&mut h, "*.com");
click(&mut h, "User name");
text(&mut h, "me");

View file

@ -17,6 +17,7 @@ use medlar_app::ui::gallery;
use medlar_app::views::list::layout::Form;
use medlar_app::{fonts, icons};
use medlar_app::views::firstrun::FirstRun;
use medlar_app::views::main::Wish;
use medlar_app::views::settings::rows::Page;
use medlar_core::settings::{Appearance, Settings};
use medlar_core::site::Site;
@ -75,6 +76,11 @@ const SCENES: &[Scene] = &[("window", App::show), ("tokens", |app, ui| app.frame
app.open_settings(Page::Shortcuts);
})),
("set-backup", |app, ui| main_view(app, ui, |app| app.open_settings(Page::Backup))),
("set-site-dialog", |app, ui| main_view(app, ui, |app| {
app.open_settings(Page::Sites);
app.screen.as_mut().unwrap().add_site();
})),
("sign-in", |app, ui| main_view(app, ui, |app| app.main.wish = Some(Wish::SignIn("https://files.example.org/a".into(), vec![])))),
("set-search", |app, ui| main_view(app, ui, |app| {
app.open_settings(Page::Look);
app.screen.as_mut().unwrap().find("connection");

View file

@ -152,7 +152,7 @@ Seen: boxes 2 to 7 were ticked together after the tests, against rule 3. A relea
## S018 — Settings, colour, shortcuts and first run (2026-11-25)
Done: `views::{settings, palette, firstrun}`, `keys`; the app saves settings, sets the language and gives changes to the engine (`bridge.apply`), which now has `Sites` (logins, proxies). Sign in and Network settings do what they say. Choices: D-046 to D-048. Outside the plan's files: `app`, `bridge`, `views::{main, list, bar, rail}`, `ui::{field, menu}`, `theme::{seed, hue_of}`, settings `shortcuts`, shots, two icons.
Verified: `nice cargo test -j 2 -p medlar --test settings` green (26), all medlar tests and clippy; shots of every page, palette and first run seen at 1080×720 (dark) and 480×360 (light), some of them the other way round.
Verified: `nice cargo test -j 2 -p medlar --test settings` green (26), all medlar tests and clippy; shots of every page, palette and first run seen at 1080×720 (dark) and 480×360 (light), some of them the other way round. Hidden release run: first run by keyboard, palette, gone-to rows, settings written; idle 5 s = 0.00 % CPU on the Look page (9.6 % in the 5 s after a row was lit, with software rendering). The two dialogs seen in both. The dialog's numbers and the light's colour were changed after that run: tests and shots only.
- A settings row: a line in `views/settings/rows.rs::ROWS` (page, heading, id, the `Settings` keys it changes, `Kind`), texts `set.<id>`, `set.<id>.why` (one line), `set.<id>.<option>`, `set.group.<heading>`. Kinds: Switch, Choice (up to 4), List, Number, Text (with `check`), Own (draws itself with `(View, Cx, Ui)`). Search, undo, palette and the tests take it from there. A page shows once it has a row; a new page is a variant of `Page` with id, icon and the text `page.<id>`. Every key of `Settings` needs a row, or `every_setting_has_a_row` fails.
- An action: a variant of `keys::Action`, a line in `keys::ALL` (id, icon, group, usual keys), the text `action.<id>`, an arm in `App::run`, `Main::run` or `List::perform`. Shortcuts page and palette show it. Tooltips and menus: `keys::label(Action::…)`; asking: `keys::pressed(ui, Action::…)`.
- `app.open_settings(Page::…)`; `main.wish = Some(Wish::…)` for what only the window can do; `bridge.save_login(Place, Login, commands after it)`, `forget_login`. `app.paths` is None in tests: nothing is written or read then. First run shows while `desktop_colors` is None.