From ff82804e5bf33a3b0d2e3c4ebe44e6bc401bca2b Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 5 Oct 2024 15:32:03 +0300 Subject: [PATCH] implement restore action --- src/app/browser.rs | 13 ++++++++++++- src/app/browser/widget.rs | 17 +++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/app/browser.rs b/src/app/browser.rs index 24592b88..ca16c320 100644 --- a/src/app/browser.rs +++ b/src/app/browser.rs @@ -248,7 +248,18 @@ impl Browser { } pub fn restore(&self, app_id: &i64) { - // @TODO + match self.database.records(app_id) { + Ok(records) => { + for record in records { + // Delegate restore action to childs + // @TODO + // self.header.restore(record.id); + // self.main.restore(record.id); + self.widget.restore(&record.id); + } + } + Err(error) => panic!("{error}"), // @TODO + } } pub fn save(&self, app_id: &i64) { diff --git a/src/app/browser/widget.rs b/src/app/browser/widget.rs index 175428ec..8fb71441 100644 --- a/src/app/browser/widget.rs +++ b/src/app/browser/widget.rs @@ -62,8 +62,21 @@ impl Widget { } } - pub fn restore(&self) { - // @TODO + pub fn restore(&self, app_browser_id: &i64) { + match self.database.records(app_browser_id) { + Ok(records) => { + for record in records { + // Restore widget + self.application_window.set_maximized(record.is_maximized); + self.application_window + .set_default_size(record.default_width, record.default_height); + + // Delegate restore action to childs + // nothing yet.. + } + } + Err(error) => panic!("{error}"), // @TODO + } } pub fn save(&self, app_browser_id: &i64) {