| | @@ -212,6 +212,8 @@ pub struct ArchiveApp { |
| 212 | 212 | zip_password: String, |
| 213 | 213 | zip_password_confirm: String, |
| 214 | 214 | zip_password_visible: bool, |
| 215 | +추가: /// 암호를 지웠으면 입력창의 실행 취소 기록도 다음 그리기 전에 지움. |
| 216 | +추가: forget_password_history: Vec<&'static str>, |
| 215 | 217 | /// 작업을 시작한 뒤 작업자가 암호를 요청하면 넘길 암호. 넘기거나 작업이 끝나면 지움. |
| 216 | 218 | pending_zip_password: Option<String>, |
| 217 | 219 | custom_frame: bool, |
| | @@ -264,6 +266,7 @@ impl ArchiveApp { |
| 264 | 266 | zip_password: String::new(), |
| 265 | 267 | zip_password_confirm: String::new(), |
| 266 | 268 | zip_password_visible: false, |
| 269 | +추가: forget_password_history: Vec::new(), |
| 267 | 270 | pending_zip_password: None, |
| 268 | 271 | custom_frame: false, |
| 269 | 272 | release_after_move: false, |
| | @@ -318,6 +321,25 @@ impl ArchiveApp { |
| 318 | 321 | bytes.fill(0); |
| 319 | 322 | } |
| 320 | 323 | self.password_visible = false; |
| 324 | +추가: // 이 함수는 암호 요청이 없는 동안 매 프레임 불리므로, 암호 창을 쓴 뒤에만 기록을 지움. |
| 325 | +추가: if self.password_challenge.is_some() { |
| 326 | +추가: self.forget_password_history |
| 327 | +추가: .extend(["archive-password-input", "archive-password-confirm"]); |
| 328 | +추가: } |
| 329 | +추가: } |
| 330 | +추가: |
| 331 | +추가: /// 지운 암호가 입력창의 실행 취소(Ctrl+Z)로 되살아나지 않게 egui가 보관하는 |
| 332 | +추가: /// 입력창 상태(실행 취소 기록 포함)를 지움. |
| 333 | +추가: fn forget_password_history(&mut self, ctx: &egui::Context) { |
| 334 | +추가: if self.forget_password_history.is_empty() { |
| 335 | +추가: return; |
| 336 | +추가: } |
| 337 | +추가: let names = std::mem::take(&mut self.forget_password_history); |
| 338 | +추가: ctx.data_mut(|data| { |
| 339 | +추가: for name in names { |
| 340 | +추가: data.remove::<egui::text_edit::TextEditState>(egui::Id::unique(name)); |
| 341 | +추가: } |
| 342 | +추가: }); |
| 321 | 343 | } |
| 322 | 344 | |
| 323 | 345 | fn clear_zip_password(&mut self) { |
| | @@ -327,6 +349,8 @@ impl ArchiveApp { |
| 327 | 349 | wipe(&mut pending); |
| 328 | 350 | } |
| 329 | 351 | self.zip_password_visible = false; |
| 352 | +추가: self.forget_password_history |
| 353 | +추가: .extend(["zip-password-input", "zip-password-confirm"]); |
| 330 | 354 | } |
| 331 | 355 | |
| 332 | 356 | /// 암호로 보호하지 않거나, 두 암호가 같고 1~1024바이트이면 만들 수 있음. |
| | @@ -770,7 +794,13 @@ impl ArchiveApp { |
| 770 | 794 | |
| 771 | 795 | fn poll(&mut self) { |
| 772 | 796 | let busy = self.model.busy(); |
| 797 | +추가: let close_before = self.model.close; |
| 773 | 798 | self.model.poll(); |
| 799 | +추가: if close_before == Close::Confirm && self.model.close == Close::Review { |
| 800 | +추가: // 종료 확인 창에 답하기 전에 작업이 끝났음. 사용자가 닫기를 승인하지 않았으므로 |
| 801 | +추가: // 바로 닫지 않고 계속 물음(close_dialog가 작업이 끝난 문구로 바꿔 보여 줌). |
| 802 | +추가: self.model.close = Close::Confirm; |
| 803 | +추가: } |
| 774 | 804 | if busy && !self.model.busy() { |
| 775 | 805 | if let Some(path) = self.owned_destination.take() { |
| 776 | 806 | if !self.model.confirmed |
| | @@ -788,6 +818,7 @@ impl ArchiveApp { |
| 788 | 818 | |
| 789 | 819 | pub fn show(&mut self, root: &mut egui::Ui) { |
| 790 | 820 | let ctx = root.ctx().clone(); |
| 821 | +추가: self.forget_password_history(&ctx); |
| 791 | 822 | if !self.initialized { |
| 792 | 823 | theme::apply(&ctx); |
| 793 | 824 | self.initialized = true; |
| | @@ -955,6 +986,7 @@ impl ArchiveApp { |
| 955 | 986 | self.empty(ui); |
| 956 | 987 | } |
| 957 | 988 | }); |
| 989 | +추가: self.forget_password_history(&ctx); |
| 958 | 990 | self.work_window(&ctx); |
| 959 | 991 | self.create_window(&ctx); |
| 960 | 992 | if self.model.challenge.is_some() { |
| | @@ -2288,11 +2320,13 @@ impl ArchiveApp { |
| 2288 | 2320 | ui.colored_label(theme::ERROR, "두 암호가 같지 않습니다"); |
| 2289 | 2321 | } |
| 2290 | 2322 | ui.label(RichText::new("암호를 잊으면 파일을 열 수 없습니다.").color(theme::MUTED)); |
| 2291 | | -삭제: } else if !self.zip_password.is_empty() || !self.zip_password_confirm.is_empty() { |
| 2292 | | -삭제: // 체크를 해제하면 입력한 암호를 남겨 두지 않음. |
| 2293 | | -삭제: wipe(&mut self.zip_password); |
| 2294 | | -삭제: wipe(&mut self.zip_password_confirm); |
| 2295 | | -삭제: self.zip_password_visible = false; |
| 2323 | +추가: } else if check.changed() |
| 2324 | +추가: || !self.zip_password.is_empty() |
| 2325 | +추가: || !self.zip_password_confirm.is_empty() |
| 2326 | +추가: { |
| 2327 | +추가: // 체크를 해제하면 입력한 암호와 그 실행 취소 기록을 남겨 두지 않음. |
| 2328 | +추가: // 입력했다가 모두 지운 경우도 기록에는 남아 있으므로 해제한 순간 함께 지움. |
| 2329 | +추가: self.clear_zip_password(); |
| 2296 | 2330 | } |
| 2297 | 2331 | false |
| 2298 | 2332 | } |
| | @@ -2416,13 +2450,30 @@ impl ArchiveApp { |
| 2416 | 2450 | ui.set_width(420.0); |
| 2417 | 2451 | match self.model.close { |
| 2418 | 2452 | Close::Confirm => { |
| 2419 | | -삭제: ui.heading("작업 중 닫기"); |
| 2420 | | -삭제: ui.label("작업을 취소하고 닫을까요?"); |
| 2453 | +추가: // 답하기 전에 작업이 끝났으면 취소할 작업이 없으므로 닫을지만 물음. |
| 2454 | +추가: let busy = self.model.busy(); |
| 2455 | +추가: let (heading, text, keep, close) = if busy { |
| 2456 | +추가: ( |
| 2457 | +추가: "작업 중 닫기", |
| 2458 | +추가: "작업을 취소하고 닫을까요?", |
| 2459 | +추가: "계속 작업", |
| 2460 | +추가: "취소하고 닫기", |
| 2461 | +추가: ) |
| 2462 | +추가: } else { |
| 2463 | +추가: ( |
| 2464 | +추가: "닫기", |
| 2465 | +추가: "작업이 끝났습니다. 창을 닫을까요?", |
| 2466 | +추가: "열어 두기", |
| 2467 | +추가: "닫기", |
| 2468 | +추가: ) |
| 2469 | +추가: }; |
| 2470 | +추가: ui.heading(heading); |
| 2471 | +추가: ui.label(text); |
| 2421 | 2472 | ui.horizontal(|ui| { |
| 2422 | | -삭제: if theme::action(ui, "계속 작업", false, true).clicked() { |
| 2473 | +추가: if theme::action(ui, keep, false, true).clicked() { |
| 2423 | 2474 | self.model.keep_open(); |
| 2424 | 2475 | } |
| 2425 | | -삭제: if theme::action(ui, "취소하고 닫기", true, true).clicked() { |
| 2476 | +추가: if theme::action(ui, close, true, true).clicked() { |
| 2426 | 2477 | self.clear_password(); |
| 2427 | 2478 | self.model.confirm_close(); |
| 2428 | 2479 | } |