Run cargo fmt over the develop shortcuts and the star-range filter
bddf325and00c028cwent in unformatted, so the Desktop job's `cargo fmt --check` step failed on master (run 1693) and the release job that needs it was skipped. Whitespace only.
This commit is contained in:
+24
-24
File diff suppressed because one or more lines are too long
+31
-27
@@ -1958,37 +1958,41 @@ fn wire_settings_screen(
|
||||
|
||||
{
|
||||
let (weak, ctl, library, start) = (weak.clone(), ctl.clone(), library.clone(), start);
|
||||
window.global::<ExportOptions>().on_browse_open_picker(move || {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
// Opens on the library root rather than on whatever the
|
||||
// destination field happens to contain: a half-typed path
|
||||
// would list nothing and look like a broken picker.
|
||||
ctl.browser.replace(Some(launch::FolderBrowser {
|
||||
path: String::new(),
|
||||
entries: Vec::new(),
|
||||
loading: true,
|
||||
}));
|
||||
start(&ctl, &weak, &library, String::new());
|
||||
settings_ui::render(&w, &ctl);
|
||||
});
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.on_browse_open_picker(move || {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
// Opens on the library root rather than on whatever the
|
||||
// destination field happens to contain: a half-typed path
|
||||
// would list nothing and look like a broken picker.
|
||||
ctl.browser.replace(Some(launch::FolderBrowser {
|
||||
path: String::new(),
|
||||
entries: Vec::new(),
|
||||
loading: true,
|
||||
}));
|
||||
start(&ctl, &weak, &library, String::new());
|
||||
settings_ui::render(&w, &ctl);
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
let (weak, ctl, library, start) = (weak.clone(), ctl.clone(), library.clone(), start);
|
||||
window.global::<ExportOptions>().on_browse_into(move |name| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
let path = {
|
||||
let mut browser = ctl.browser.borrow_mut();
|
||||
let Some(b) = browser.as_mut() else { return };
|
||||
let path = b.child_path(&name);
|
||||
b.path = path.clone();
|
||||
b.entries.clear();
|
||||
b.loading = true;
|
||||
path
|
||||
};
|
||||
start(&ctl, &weak, &library, path);
|
||||
settings_ui::render(&w, &ctl);
|
||||
});
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.on_browse_into(move |name| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
let path = {
|
||||
let mut browser = ctl.browser.borrow_mut();
|
||||
let Some(b) = browser.as_mut() else { return };
|
||||
let path = b.child_path(&name);
|
||||
b.path = path.clone();
|
||||
b.entries.clear();
|
||||
b.loading = true;
|
||||
path
|
||||
};
|
||||
start(&ctl, &weak, &library, path);
|
||||
settings_ui::render(&w, &ctl);
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -1032,7 +1032,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn a_hovered_photograph_outside_the_selection_is_judged_alone() {
|
||||
let (a, b, c) = (dr_types::ImageId(1), dr_types::ImageId(2), dr_types::ImageId(3));
|
||||
let (a, b, c) = (
|
||||
dr_types::ImageId(1),
|
||||
dr_types::ImageId(2),
|
||||
dr_types::ImageId(3),
|
||||
);
|
||||
assert_eq!(judged_images(vec![a, b], Some(c)), vec![c]);
|
||||
}
|
||||
|
||||
|
||||
+172
-93
@@ -245,19 +245,33 @@ pub fn render(window: &AppWindow, controller: &SettingsController) {
|
||||
// Choice rows are sent as labels plus the selected index rather than as a
|
||||
// model of structs: the page draws a row of chips from them and nothing
|
||||
// else, so a label and an index is the whole of what it needs.
|
||||
window.global::<ExportOptions>().set_format_labels(labels(ExportFormat::ALL.iter().map(|f| f.label())));
|
||||
window.global::<ExportOptions>().set_format_selected(index_of(&ExportFormat::ALL, &s.export.format));
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_format_labels(labels(ExportFormat::ALL.iter().map(|f| f.label())));
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_format_selected(index_of(&ExportFormat::ALL, &s.export.format));
|
||||
|
||||
window.global::<ExportOptions>().set_quality(s.export.quality as i32);
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_quality(s.export.quality as i32);
|
||||
// Disabled rather than hidden for a lossless format: a control that
|
||||
// vanishes when PNG is picked reads as a bug, where a greyed one explains
|
||||
// itself.
|
||||
window.global::<ExportOptions>().set_quality_enabled(s.export.format.is_lossy());
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_quality_enabled(s.export.format.is_lossy());
|
||||
|
||||
window.global::<ExportOptions>().set_colour_labels(labels(ColourSpace::ALL.iter().map(|c| c.label())));
|
||||
window.global::<ExportOptions>().set_colour_selected(index_of(&ColourSpace::ALL, &s.export.colour_space));
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_colour_labels(labels(ColourSpace::ALL.iter().map(|c| c.label())));
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_colour_selected(index_of(&ColourSpace::ALL, &s.export.colour_space));
|
||||
|
||||
window.global::<ExportOptions>().set_sizing_labels(labels(SizingMode::CHOICES.iter().map(|m| m.label())));
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_sizing_labels(labels(SizingMode::CHOICES.iter().map(|m| m.label())));
|
||||
// Compared by variant, not by equality: `LongEdge(900)` after the user
|
||||
// typed their own number is still the "Long edge" choice, and equality
|
||||
// against `CHOICES` would light nothing.
|
||||
@@ -267,10 +281,14 @@ pub fn render(window: &AppWindow, controller: &SettingsController) {
|
||||
.position(|m| m.same_mode(s.export.sizing))
|
||||
.unwrap_or(0) as i32,
|
||||
);
|
||||
window.global::<ExportOptions>().set_sizing_value(s.export.sizing.value().unwrap_or(0) as i32);
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_sizing_value(s.export.sizing.value().unwrap_or(0) as i32);
|
||||
// `Original` carries no number, so the field beside the chips has nothing
|
||||
// to edit and is hidden rather than shown holding a meaningless zero.
|
||||
window.global::<ExportOptions>().set_sizing_has_value(s.export.sizing.value().is_some());
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_sizing_has_value(s.export.sizing.value().is_some());
|
||||
// TRACES: FR-EXP-3
|
||||
// The unit carries the axis for the box modes, so that two numeric fields
|
||||
// one above the other are not two anonymous numbers. It reads "3840 px
|
||||
@@ -297,14 +315,20 @@ pub fn render(window: &AppWindow, controller: &SettingsController) {
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
window.global::<ExportOptions>().set_sizing_height(s.export.sizing.height().unwrap_or(0) as i32);
|
||||
window.global::<ExportOptions>().set_sizing_has_height(s.export.sizing.height().is_some());
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_sizing_height(s.export.sizing.height().unwrap_or(0) as i32);
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_sizing_has_height(s.export.sizing.height().is_some());
|
||||
// TRACES: FR-EXP-3
|
||||
// The panels, offered as buttons. Lit only on an exact match, and -1 —
|
||||
// no chip lit — where the user has typed their own numbers: a preset that
|
||||
// stayed selected while the fields said something else would be the page
|
||||
// claiming the export is 4K when it is not.
|
||||
window.global::<ExportOptions>().set_screen_labels(labels(ScreenSize::ALL.iter().map(|p| p.label)));
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_screen_labels(labels(ScreenSize::ALL.iter().map(|p| p.label)));
|
||||
window.global::<ExportOptions>().set_screen_selected(
|
||||
ScreenSize::ALL
|
||||
.iter()
|
||||
@@ -314,37 +338,63 @@ pub fn render(window: &AppWindow, controller: &SettingsController) {
|
||||
})
|
||||
.map_or(-1, |i| i as i32),
|
||||
);
|
||||
window.global::<ExportOptions>().set_allow_upscaling(s.export.allow_upscaling);
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_allow_upscaling(s.export.allow_upscaling);
|
||||
|
||||
window.global::<ExportOptions>().set_sharpening_labels(labels(OutputSharpening::ALL.iter().map(|x| x.label())));
|
||||
window.global::<ExportOptions>().set_sharpening_selected(index_of(&OutputSharpening::ALL, &s.export.sharpening));
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_sharpening_labels(labels(OutputSharpening::ALL.iter().map(|x| x.label())));
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_sharpening_selected(index_of(&OutputSharpening::ALL, &s.export.sharpening));
|
||||
|
||||
window.global::<ExportOptions>().set_filename_template(s.export.filename_template.clone().into());
|
||||
window.global::<ExportOptions>().set_collision_labels(labels(CollisionPolicy::ALL.iter().map(|c| c.label())));
|
||||
window.global::<ExportOptions>().set_collision_selected(index_of(&CollisionPolicy::ALL, &s.export.collision));
|
||||
window.global::<ExportOptions>().set_strip_location(s.export.strip_location);
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_filename_template(s.export.filename_template.clone().into());
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_collision_labels(labels(CollisionPolicy::ALL.iter().map(|c| c.label())));
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_collision_selected(index_of(&CollisionPolicy::ALL, &s.export.collision));
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_strip_location(s.export.strip_location);
|
||||
|
||||
// `available()`, not `ALL`: Android cannot write to a device folder, and
|
||||
// offering a target that fails at the last step is what made export look
|
||||
// broken there rather than absent.
|
||||
let targets = ExportTarget::available();
|
||||
window.global::<ExportOptions>().set_target_labels(labels(targets.iter().map(|t| t.label())));
|
||||
window.global::<ExportOptions>().set_target_selected(index_of(targets, &s.export.target));
|
||||
window.global::<ExportOptions>().set_destination(s.export.active_destination().into());
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_target_labels(labels(targets.iter().map(|t| t.label())));
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_target_selected(index_of(targets, &s.export.target));
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_destination(s.export.active_destination().into());
|
||||
// Derived from the target itself, never from its position in a list whose
|
||||
// length differs by platform.
|
||||
window.global::<ExportOptions>().set_browse_available(s.export.target.is_remote());
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_browse_available(s.export.target.is_remote());
|
||||
// The field means different things either side of the choice, and a
|
||||
// placeholder saying which is cheaper than a paragraph under it.
|
||||
// The placeholder names what an empty field *means*, which differs by
|
||||
// target: on a filesystem it is a question, on the server it is the
|
||||
// library root.
|
||||
window.global::<ExportOptions>().set_destination_hint(s.export.destination_label().into());
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_destination_hint(s.export.destination_label().into());
|
||||
|
||||
// --- the remote folder picker --------------------------------------
|
||||
{
|
||||
let browser = controller.browser.borrow();
|
||||
window.global::<ExportOptions>().set_browse_open(browser.is_some());
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_browse_open(browser.is_some());
|
||||
match browser.as_ref() {
|
||||
Some(b) => {
|
||||
// The root is shown as a word rather than as an empty string,
|
||||
@@ -357,19 +407,28 @@ pub fn render(window: &AppWindow, controller: &SettingsController) {
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
window.global::<ExportOptions>().set_browse_loading(b.loading);
|
||||
window.global::<ExportOptions>().set_browse_at_root(b.parent_path().is_none());
|
||||
window.global::<ExportOptions>().set_browse_entries(slint::ModelRc::new(slint::VecModel::from(
|
||||
b.entries
|
||||
.iter()
|
||||
.map(|e| slint::SharedString::from(e.as_str()))
|
||||
.collect::<Vec<_>>(),
|
||||
)));
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_browse_loading(b.loading);
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_browse_at_root(b.parent_path().is_none());
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_browse_entries(slint::ModelRc::new(slint::VecModel::from(
|
||||
b.entries
|
||||
.iter()
|
||||
.map(|e| slint::SharedString::from(e.as_str()))
|
||||
.collect::<Vec<_>>(),
|
||||
)));
|
||||
}
|
||||
None => {
|
||||
window.global::<ExportOptions>().set_browse_entries(slint::ModelRc::new(slint::VecModel::from(
|
||||
Vec::<slint::SharedString>::new(),
|
||||
)));
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.set_browse_entries(slint::ModelRc::new(slint::VecModel::from(Vec::<
|
||||
slint::SharedString,
|
||||
>::new(
|
||||
))));
|
||||
window.global::<ExportOptions>().set_browse_loading(false);
|
||||
}
|
||||
}
|
||||
@@ -647,13 +706,15 @@ fn wire_export(window: &AppWindow, controller: &Rc<SettingsController>) {
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let ctl = controller.clone();
|
||||
window.global::<ExportOptions>().on_quality_changed(move |q| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
// Cast before clamping: a negative from the control would wrap to a
|
||||
// large `u8` and land on 100 instead of the floor.
|
||||
ctl.edit(|s| s.export.quality = q.clamp(1, 100) as u8);
|
||||
render(&w, &ctl);
|
||||
});
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.on_quality_changed(move |q| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
// Cast before clamping: a negative from the control would wrap to a
|
||||
// large `u8` and land on 100 instead of the floor.
|
||||
ctl.edit(|s| s.export.quality = q.clamp(1, 100) as u8);
|
||||
render(&w, &ctl);
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
@@ -715,27 +776,33 @@ fn wire_export(window: &AppWindow, controller: &Rc<SettingsController>) {
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let ctl = controller.clone();
|
||||
window.global::<ExportOptions>().on_sizing_value_changed(move |text| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
match text.trim().parse::<u32>() {
|
||||
Ok(v) if v > 0 => ctl.edit(|s| s.export.sizing = s.export.sizing.with_value(v)),
|
||||
_ => log::debug!("ignoring an unusable export size: {text:?}"),
|
||||
}
|
||||
render(&w, &ctl);
|
||||
});
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.on_sizing_value_changed(move |text| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
match text.trim().parse::<u32>() {
|
||||
Ok(v) if v > 0 => ctl.edit(|s| s.export.sizing = s.export.sizing.with_value(v)),
|
||||
_ => log::debug!("ignoring an unusable export size: {text:?}"),
|
||||
}
|
||||
render(&w, &ctl);
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let ctl = controller.clone();
|
||||
window.global::<ExportOptions>().on_sizing_height_changed(move |text| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
match text.trim().parse::<u32>() {
|
||||
Ok(v) if v > 0 => ctl.edit(|s| s.export.sizing = s.export.sizing.with_height(v)),
|
||||
_ => log::debug!("ignoring an unusable export height: {text:?}"),
|
||||
}
|
||||
render(&w, &ctl);
|
||||
});
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.on_sizing_height_changed(move |text| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
match text.trim().parse::<u32>() {
|
||||
Ok(v) if v > 0 => {
|
||||
ctl.edit(|s| s.export.sizing = s.export.sizing.with_height(v))
|
||||
}
|
||||
_ => log::debug!("ignoring an unusable export height: {text:?}"),
|
||||
}
|
||||
render(&w, &ctl);
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
@@ -761,65 +828,77 @@ fn wire_export(window: &AppWindow, controller: &Rc<SettingsController>) {
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let ctl = controller.clone();
|
||||
window.global::<ExportOptions>().on_upscaling_toggled(move |on| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
ctl.edit(|s| s.export.allow_upscaling = on);
|
||||
render(&w, &ctl);
|
||||
});
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.on_upscaling_toggled(move |on| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
ctl.edit(|s| s.export.allow_upscaling = on);
|
||||
render(&w, &ctl);
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let ctl = controller.clone();
|
||||
window.global::<ExportOptions>().on_sharpening_picked(move |i| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
if let Some(x) = OutputSharpening::ALL.get(i as usize).copied() {
|
||||
ctl.edit(|s| s.export.sharpening = x);
|
||||
}
|
||||
render(&w, &ctl);
|
||||
});
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.on_sharpening_picked(move |i| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
if let Some(x) = OutputSharpening::ALL.get(i as usize).copied() {
|
||||
ctl.edit(|s| s.export.sharpening = x);
|
||||
}
|
||||
render(&w, &ctl);
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let ctl = controller.clone();
|
||||
window.global::<ExportOptions>().on_template_changed(move |text| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
ctl.edit(|s| s.export.filename_template = text.to_string());
|
||||
render(&w, &ctl);
|
||||
});
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.on_template_changed(move |text| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
ctl.edit(|s| s.export.filename_template = text.to_string());
|
||||
render(&w, &ctl);
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let ctl = controller.clone();
|
||||
window.global::<ExportOptions>().on_collision_picked(move |i| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
if let Some(c) = CollisionPolicy::ALL.get(i as usize).copied() {
|
||||
ctl.edit(|s| s.export.collision = c);
|
||||
}
|
||||
render(&w, &ctl);
|
||||
});
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.on_collision_picked(move |i| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
if let Some(c) = CollisionPolicy::ALL.get(i as usize).copied() {
|
||||
ctl.edit(|s| s.export.collision = c);
|
||||
}
|
||||
render(&w, &ctl);
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let ctl = controller.clone();
|
||||
window.global::<ExportOptions>().on_strip_location_toggled(move |on| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
ctl.edit(|s| s.export.strip_location = on);
|
||||
render(&w, &ctl);
|
||||
});
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.on_strip_location_toggled(move |on| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
ctl.edit(|s| s.export.strip_location = on);
|
||||
render(&w, &ctl);
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let ctl = controller.clone();
|
||||
window.global::<ExportOptions>().on_destination_changed(move |text| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
ctl.edit(|s| s.export.set_active_destination(text.to_string()));
|
||||
render(&w, &ctl);
|
||||
});
|
||||
window
|
||||
.global::<ExportOptions>()
|
||||
.on_destination_changed(move |text| {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
ctl.edit(|s| s.export.set_active_destination(text.to_string()));
|
||||
render(&w, &ctl);
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user