Organize preferences into tabs
Gitea/Deckstride/pipeline/head This commit looks good
Details
Gitea/Deckstride/pipeline/head This commit looks good
Details
This commit is contained in:
parent
aad895bc61
commit
d41b8ab614
|
|
@ -670,7 +670,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deckstride"
|
||||
version = "0.1.98"
|
||||
version = "0.1.99"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"chrono",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ default-members = ["crates/deckstride"]
|
|||
resolver = "3"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.98"
|
||||
version = "0.1.99"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
repository = "https://proxy.dandaedre.com/gitea/idle-org/deckstride"
|
||||
|
|
|
|||
|
|
@ -2468,6 +2468,156 @@ fn appearance_preferences(ui: &mut Ui, s: &mut Studio) {
|
|||
});
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Default, PartialEq, Eq)]
|
||||
enum PreferencesTab {
|
||||
#[default]
|
||||
General,
|
||||
Performance,
|
||||
Storage,
|
||||
}
|
||||
|
||||
fn general_preferences(ui: &mut Ui, s: &mut Studio) {
|
||||
let locale = ui.ctx().clone();
|
||||
appearance_preferences(ui, s);
|
||||
ui.add_space(8.);
|
||||
layout_section(ui, tr(&locale, "Blank Slides image"), |ui| {
|
||||
ui.label(if s.settings.blank_picture {
|
||||
tr(&locale, "Custom picture selected")
|
||||
} else {
|
||||
tr(&locale, "Solid black")
|
||||
});
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
if ui
|
||||
.add_enabled(
|
||||
s.initialized && !s.dialog_busy && !s.blank_busy,
|
||||
egui::Button::new(tr(&locale, "Choose picture…")),
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
s.actions.push(Action::PickBlankPicture);
|
||||
}
|
||||
if ui
|
||||
.add_enabled(
|
||||
s.initialized && !s.dialog_busy && (s.settings.blank_picture || s.blank_busy),
|
||||
egui::Button::new(tr(&locale, "Use solid black")),
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
s.actions.push(Action::ClearBlankPicture);
|
||||
}
|
||||
if s.blank_busy {
|
||||
ui.spinner();
|
||||
}
|
||||
});
|
||||
ui.small(tr(
|
||||
&locale,
|
||||
"A copy is saved and fitted to all Slides screens against a black background.",
|
||||
));
|
||||
});
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
ui.add_space(8.);
|
||||
layout_section(ui, tr(&locale, "Default PDF application"), |ui| {
|
||||
ui.label(tr(
|
||||
&locale,
|
||||
"Register Deckstride and its icon for PDF files in your Windows account.",
|
||||
));
|
||||
if ui.button(tr(&locale, "Set as default PDF app…")).clicked() {
|
||||
s.actions.push(Action::RegisterPdfAssociation);
|
||||
}
|
||||
ui.small(tr(
|
||||
&locale,
|
||||
"Windows will open Default Apps; select Deckstride for .pdf to confirm.",
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn performance_preferences(ui: &mut Ui, s: &mut Studio) {
|
||||
let locale = ui.ctx().clone();
|
||||
layout_section(ui, tr(&locale, "Memory and cache"), |ui| {
|
||||
ui.label(tr(
|
||||
&locale,
|
||||
"RAM budget per process (presenter + output each use this allowance):",
|
||||
));
|
||||
if ui
|
||||
.add(egui::Slider::new(&mut s.settings.buffer_mib, 64..=16384).text("MiB"))
|
||||
.changed()
|
||||
{
|
||||
s.remember_buffer_budget();
|
||||
}
|
||||
ui.small(tr(
|
||||
&locale,
|
||||
"Raise only within available RAM; OS paging can cause delays. Screen rendering is capped at 4096 px.",
|
||||
));
|
||||
ui.separator();
|
||||
let mut changed = false;
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.label(tr(&locale, "Maximum total size (MiB)"));
|
||||
changed |= ui
|
||||
.add(
|
||||
egui::DragValue::new(&mut s.settings.disk_cache.max_mib)
|
||||
.range(64..=1048576)
|
||||
.speed(64),
|
||||
)
|
||||
.changed();
|
||||
});
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.label(tr(&locale, "Expire after (days since rendering)"));
|
||||
changed |= ui
|
||||
.add(egui::DragValue::new(&mut s.settings.disk_cache.max_days).range(1..=3650))
|
||||
.changed();
|
||||
});
|
||||
if changed {
|
||||
s.remember_cache_policy();
|
||||
}
|
||||
ui.small(tr(
|
||||
&locale,
|
||||
"Oldest files are removed first. Active decks are protected and may exceed the limit. Automatic cleanup runs once at startup, after loading and preparation finish.",
|
||||
));
|
||||
if ui
|
||||
.add_enabled(
|
||||
!s.cache_busy && !s.loading && s.initialized,
|
||||
egui::Button::new(tr(&locale, "Expunge unused cache now")),
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
s.clean_cache(true);
|
||||
}
|
||||
if s.cache_busy {
|
||||
ui.spinner();
|
||||
}
|
||||
ui.small(&s.cache_status);
|
||||
});
|
||||
}
|
||||
|
||||
fn storage_preferences(ui: &mut Ui, s: &Studio) {
|
||||
let locale = ui.ctx().clone();
|
||||
layout_section(ui, tr(&locale, "Storage and preparation"), |ui| {
|
||||
ui.label(s.preparation_status());
|
||||
ui.separator();
|
||||
ui.label(egui::RichText::new(tr(&locale, "Application executable")).strong());
|
||||
let executable = s.executable_path().display().to_string();
|
||||
ui.add(
|
||||
egui::Label::new(egui::RichText::new(&executable).monospace())
|
||||
.selectable(true)
|
||||
.wrap(),
|
||||
)
|
||||
.on_hover_text(&executable);
|
||||
ui.small(tr(
|
||||
&locale,
|
||||
"This is the running portable executable. Use its containing folder to find or remove the application.",
|
||||
));
|
||||
ui.separator();
|
||||
ui.label(format!(
|
||||
"{}: {}",
|
||||
tr(&locale, "Processed slides"),
|
||||
s.cache_path.display()
|
||||
));
|
||||
ui.label(format!("Configuration: {}", s.settings_path.display()));
|
||||
});
|
||||
}
|
||||
|
||||
fn preferences_window(ctx: &egui::Context, s: &mut Studio, open: &mut bool) {
|
||||
let locale = ctx.clone();
|
||||
let mut window_open = true;
|
||||
|
|
@ -2483,165 +2633,33 @@ fn preferences_window(ctx: &egui::Context, s: &mut Studio, open: &mut bool) {
|
|||
.max_size((screen - Vec2::splat(24.)).max(Vec2::splat(1.)))
|
||||
.show(ctx, |ui| {
|
||||
ui.spacing_mut().item_spacing = Vec2::new(8., 8.);
|
||||
let tab_id = egui::Id::new("preferences-tab");
|
||||
let mut tab = ctx
|
||||
.data(|data| data.get_temp::<PreferencesTab>(tab_id))
|
||||
.unwrap_or_default();
|
||||
ui.horizontal(|ui| {
|
||||
ui.selectable_value(&mut tab, PreferencesTab::General, tr(&locale, "General"));
|
||||
ui.selectable_value(
|
||||
&mut tab,
|
||||
PreferencesTab::Performance,
|
||||
tr(&locale, "Performance"),
|
||||
);
|
||||
ui.selectable_value(&mut tab, PreferencesTab::Storage, tr(&locale, "Storage"));
|
||||
});
|
||||
ctx.data_mut(|data| data.insert_temp(tab_id, tab));
|
||||
ui.separator();
|
||||
let scroll_height = (ui.available_height() - 52.).max(180.);
|
||||
egui::ScrollArea::vertical()
|
||||
.id_salt("preferences-scroll")
|
||||
.id_salt(("preferences-scroll", tab as u8))
|
||||
.auto_shrink([false, false])
|
||||
.max_height(scroll_height)
|
||||
.show(ui, |ui| {
|
||||
appearance_preferences(ui, s);
|
||||
ui.add_space(8.);
|
||||
layout_section(
|
||||
ui,
|
||||
tr(&locale, "Blank Slides image"),
|
||||
|ui| {
|
||||
ui.label(if s.settings.blank_picture {
|
||||
tr(&locale, "Custom picture selected")
|
||||
} else {
|
||||
tr(&locale, "Solid black")
|
||||
});
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
if ui
|
||||
.add_enabled(
|
||||
s.initialized && !s.dialog_busy && !s.blank_busy,
|
||||
egui::Button::new(tr(&locale, "Choose picture…")),
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
s.actions.push(Action::PickBlankPicture);
|
||||
}
|
||||
if ui
|
||||
.add_enabled(
|
||||
s.initialized
|
||||
&& !s.dialog_busy
|
||||
&& (s.settings.blank_picture || s.blank_busy),
|
||||
egui::Button::new(tr(&locale, "Use solid black")),
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
s.actions.push(Action::ClearBlankPicture);
|
||||
}
|
||||
if s.blank_busy {
|
||||
ui.spinner();
|
||||
}
|
||||
});
|
||||
ui.small(tr(
|
||||
&locale,
|
||||
"A copy is saved and fitted to all Slides screens against a black background.",
|
||||
));
|
||||
},
|
||||
);
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
ui.add_space(8.);
|
||||
layout_section(
|
||||
ui,
|
||||
tr(&locale, "Default PDF application"),
|
||||
|ui| {
|
||||
ui.label(tr(
|
||||
&locale,
|
||||
"Register Deckstride and its icon for PDF files in your Windows account.",
|
||||
));
|
||||
if ui
|
||||
.button(tr(&locale, "Set as default PDF app…"))
|
||||
.clicked()
|
||||
{
|
||||
s.actions.push(Action::RegisterPdfAssociation);
|
||||
}
|
||||
ui.small(tr(
|
||||
&locale,
|
||||
"Windows will open Default Apps; select Deckstride for .pdf to confirm.",
|
||||
));
|
||||
},
|
||||
);
|
||||
ui.set_width(ui.available_width());
|
||||
match tab {
|
||||
PreferencesTab::General => general_preferences(ui, s),
|
||||
PreferencesTab::Performance => performance_preferences(ui, s),
|
||||
PreferencesTab::Storage => storage_preferences(ui, s),
|
||||
}
|
||||
ui.add_space(8.);
|
||||
layout_section(ui, tr(&locale, "Memory and cache"), |ui| {
|
||||
ui.label(tr(
|
||||
&locale,
|
||||
"RAM budget per process (presenter + output each use this allowance):",
|
||||
));
|
||||
if ui
|
||||
.add(
|
||||
egui::Slider::new(&mut s.settings.buffer_mib, 64..=16384)
|
||||
.text("MiB"),
|
||||
)
|
||||
.changed()
|
||||
{
|
||||
s.remember_buffer_budget();
|
||||
}
|
||||
ui.small(tr(
|
||||
&locale,
|
||||
"Raise only within available RAM; OS paging can cause delays. Screen rendering is capped at 4096 px.",
|
||||
));
|
||||
ui.separator();
|
||||
let mut changed = false;
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.label(tr(&locale, "Maximum total size (MiB)"));
|
||||
changed |= ui
|
||||
.add(
|
||||
egui::DragValue::new(&mut s.settings.disk_cache.max_mib)
|
||||
.range(64..=1048576)
|
||||
.speed(64),
|
||||
)
|
||||
.changed();
|
||||
});
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.label(tr(&locale, "Expire after (days since rendering)"));
|
||||
changed |= ui
|
||||
.add(
|
||||
egui::DragValue::new(&mut s.settings.disk_cache.max_days)
|
||||
.range(1..=3650),
|
||||
)
|
||||
.changed();
|
||||
});
|
||||
if changed {
|
||||
s.remember_cache_policy();
|
||||
}
|
||||
ui.small(tr(
|
||||
&locale,
|
||||
"Oldest files are removed first. Active decks are protected and may exceed the limit. Automatic cleanup runs once at startup, after loading and preparation finish.",
|
||||
));
|
||||
if ui
|
||||
.add_enabled(
|
||||
!s.cache_busy && !s.loading && s.initialized,
|
||||
egui::Button::new(tr(&locale, "Expunge unused cache now")),
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
s.clean_cache(true);
|
||||
}
|
||||
if s.cache_busy {
|
||||
ui.spinner();
|
||||
}
|
||||
ui.small(&s.cache_status);
|
||||
});
|
||||
ui.add_space(8.);
|
||||
layout_section(ui, tr(&locale, "Storage and preparation"), |ui| {
|
||||
ui.label(s.preparation_status());
|
||||
ui.separator();
|
||||
ui.label(
|
||||
egui::RichText::new(tr(&locale, "Application executable")).strong(),
|
||||
);
|
||||
let executable = s.executable_path().display().to_string();
|
||||
ui.add(
|
||||
egui::Label::new(egui::RichText::new(&executable).monospace())
|
||||
.selectable(true)
|
||||
.wrap(),
|
||||
)
|
||||
.on_hover_text(&executable);
|
||||
ui.small(tr(
|
||||
&locale,
|
||||
"This is the running portable executable. Use its containing folder to find or remove the application.",
|
||||
));
|
||||
ui.separator();
|
||||
ui.label(format!(
|
||||
"{}: {}",
|
||||
tr(&locale, "Processed slides"),
|
||||
s.cache_path.display()
|
||||
));
|
||||
ui.label(format!("Configuration: {}", s.settings_path.display()));
|
||||
});
|
||||
});
|
||||
ui.separator();
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
|
|
|
|||
|
|
@ -549,6 +549,7 @@ fn quick_settings_and_preferences_window_remain_interactive() {
|
|||
click(&mut s, "Preferences…");
|
||||
assert!(s.preferences_open);
|
||||
assert!(!s.menu_open);
|
||||
click(&mut s, "Performance");
|
||||
click(&mut s, "Expunge unused cache now");
|
||||
assert!(s.cache_busy, "The Preferences window must submit cleanup");
|
||||
assert!(s.preferences_open);
|
||||
|
|
@ -1801,7 +1802,7 @@ fn preferences_window_stays_on_the_presenter_that_opened_it() {
|
|||
output
|
||||
.shapes
|
||||
.iter()
|
||||
.any(|shape| contains(&shape.shape, "Memory and cache"))
|
||||
.any(|shape| contains(&shape.shape, "Appearance"))
|
||||
};
|
||||
assert!(render(0, "one"));
|
||||
assert!(!render(1, "two"));
|
||||
|
|
@ -1809,11 +1810,13 @@ fn preferences_window_stays_on_the_presenter_that_opened_it() {
|
|||
|
||||
#[test]
|
||||
fn preferences_show_the_running_executable_path() {
|
||||
fn contains(shape: &egui::Shape, text: &str) -> bool {
|
||||
fn find(shape: &egui::Shape, text: &str) -> Option<Pos2> {
|
||||
match shape {
|
||||
egui::Shape::Text(label) => label.galley.text() == text,
|
||||
egui::Shape::Vec(shapes) => shapes.iter().any(|shape| contains(shape, text)),
|
||||
_ => false,
|
||||
egui::Shape::Text(label) if label.galley.text() == text => {
|
||||
Some(label.pos + label.galley.size() * 0.5)
|
||||
}
|
||||
egui::Shape::Vec(shapes) => shapes.iter().find_map(|shape| find(shape, text)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
let ctx = Context::default();
|
||||
|
|
@ -1829,17 +1832,35 @@ fn preferences_show_the_running_executable_path() {
|
|||
presenter_ui::presenter(root, &mut s, &mut ui)
|
||||
});
|
||||
}
|
||||
let storage = output
|
||||
.shapes
|
||||
.iter()
|
||||
.find_map(|shape| find(&shape.shape, "Storage"))
|
||||
.expect("Preferences should expose a Storage tab");
|
||||
for pressed in [true, false] {
|
||||
let mut raw = input(Vec2::new(1280., 900.));
|
||||
raw.events = vec![
|
||||
egui::Event::PointerMoved(storage),
|
||||
egui::Event::PointerButton {
|
||||
pos: storage,
|
||||
button: egui::PointerButton::Primary,
|
||||
pressed,
|
||||
modifiers: Default::default(),
|
||||
},
|
||||
];
|
||||
output = ctx.run_ui(raw, |root| presenter_ui::presenter(root, &mut s, &mut ui));
|
||||
}
|
||||
assert!(
|
||||
output
|
||||
.shapes
|
||||
.iter()
|
||||
.any(|shape| contains(&shape.shape, "Application executable"))
|
||||
.any(|shape| find(&shape.shape, "Application executable").is_some())
|
||||
);
|
||||
assert!(
|
||||
output
|
||||
.shapes
|
||||
.iter()
|
||||
.any(|shape| contains(&shape.shape, &expected))
|
||||
.any(|shape| find(&shape.shape, &expected).is_some())
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
### 0.1.99
|
||||
|
||||
- Organize Preferences into General, Performance and Storage tabs. Each tab has its
|
||||
own small-screen scroll position, and every Presenter remembers its selected tab.
|
||||
|
||||
### 0.1.98
|
||||
|
||||
- Shorten the Presenter menu by removing its duplicate All slides command and moving
|
||||
|
|
|
|||
Loading…
Reference in New Issue