Skip to content

PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust

ui: remove misleading cancel button from preferences dialog

Combiler0180ffea6df419
diff --git a/crates/ui-egui/src/dialogs/preferences.rs b/crates/ui-egui/src/dialogs/preferences.rs
index 5ee1c4f61..b8b85f3c4 100644
--- a/crates/ui-egui/src/dialogs/preferences.rs
+++ b/crates/ui-egui/src/dialogs/preferences.rs
@@ -775,7 +775,7 @@ fn card_javascript(ui: &mut egui::Ui, app: &mut PdfCraftApp, t: &Tokens, ctx: &m
);
}
-/// Preferences dialog buttons: Cancel and OK on the right. Returns true to close.
+/// Preferences dialog buttons: OK on the right. Returns true to close.
pub(crate) fn preferences_buttons(ui: &mut egui::Ui) -> bool {
ui.add_space(10.0);
let mut close = false;
@@ -784,9 +784,6 @@ pub(crate) fn preferences_buttons(ui: &mut egui::Ui) -> bool {
if widgets::pill_button(ui, tl!("OK"), true).clicked() {
close = true;
}
- if widgets::pill_button(ui, tl!("Cancel"), false).clicked() {
- close = true;
- }
});
});
close
diff --git a/crates/ui-egui/tests/it/preferences_layout.rs b/crates/ui-egui/tests/it/preferences_layout.rs
index 43e1019c1..cb5e2570d 100644
--- a/crates/ui-egui/tests/it/preferences_layout.rs
+++ b/crates/ui-egui/tests/it/preferences_layout.rs
@@ -150,15 +150,6 @@ fn segmented_pill_controls_switch_modes_and_layouts() {
assert_eq!(h.state().units, pdfcraft_ui_egui::units::Unit::Points);
}
-#[test]
-fn cancel_button_closes_preferences_dialog() {
- let mut h = harness(900.0);
- assert!(h.state().dialog.is_some());
- h.get_by_label("Cancel").click();
- h.run_steps(3);
- assert!(h.state().dialog.is_none());
-}
-
#[test]
fn search_settings_scans_and_highlights_in_situ_without_hiding_cards() {
let mut h = harness(900.0);
@@ -213,10 +204,7 @@ fn preferences_dialog_scrollbar_spacing_and_controls() {
let title = h.get_by(|n| n.role() == egui::accesskit::Role::Label && n.value().as_deref() == Some("Preferences")).rect();
let search = h.get_by_role_and_label(egui::accesskit::Role::TextInput, "Search settings…").rect();
let ok = h.get_by_label("OK").rect();
- let cancel = h.get_by_label("Cancel").rect();
- assert!(cancel.min.x < ok.min.x);
assert!(on_screen(ok, 600.0));
- assert!(on_screen(cancel, 600.0));
// Header title and search box are vertically aligned
assert!((title.center().y - search.center().y).abs() <= 2.0);
// Search box right edge is aligned within the dialog