summaryrefslogtreecommitdiff
path: root/iced_builder/src
diff options
context:
space:
mode:
authorpml68 <contact@pml68.dev>2024-12-31 00:00:09 +0100
committerpml68 <contact@pml68.dev>2024-12-31 00:00:09 +0100
commite39c7d037d3fa4b57a2ca80c3fc26ff900309e91 (patch)
tree132fb98d2c5f6701d2ab42ab7939100d28d1bc07 /iced_builder/src
parentfeat: add config loading, with theming support, limited to Palette for now (diff)
downloadiced-builder-e39c7d037d3fa4b57a2ca80c3fc26ff900309e91.tar.gz
refactor: unsaved_changes_dialog emits bool instead of MessageDialogResult
Diffstat (limited to '')
-rw-r--r--iced_builder/src/dialogs.rs14
-rw-r--r--iced_builder/src/main.rs5
2 files changed, 11 insertions, 8 deletions
diff --git a/iced_builder/src/dialogs.rs b/iced_builder/src/dialogs.rs
index c9a5ba2..56d22b2 100644
--- a/iced_builder/src/dialogs.rs
+++ b/iced_builder/src/dialogs.rs
@@ -18,13 +18,17 @@ pub fn warning_dialog(description: impl Into<String>) {
.show();
}
-pub fn unsaved_changes_dialog(
- description: impl Into<String>,
-) -> MessageDialogResult {
- MessageDialog::new()
+pub fn unsaved_changes_dialog(description: impl Into<String>) -> bool {
+ let result = MessageDialog::new()
.set_level(MessageLevel::Warning)
.set_buttons(MessageButtons::OkCancel)
.set_title("Unsaved changes")
.set_description(description)
- .show()
+ .show();
+
+ if let MessageDialogResult::Ok = result {
+ true
+ } else {
+ false
+ }
}
diff --git a/iced_builder/src/main.rs b/iced_builder/src/main.rs
index 02e1ae0..86e478d 100644
--- a/iced_builder/src/main.rs
+++ b/iced_builder/src/main.rs
@@ -14,7 +14,6 @@ use iced_builder::types::{
Action, DesignerPage, ElementName, Message, Project,
};
use iced_builder::{icon, Error};
-use rfd::MessageDialogResult;
use tokio::runtime;
fn main() -> Result<(), Box<dyn std::error::Error>> {
@@ -235,7 +234,7 @@ impl App {
self.project_path = None;
self.editor_content = text_editor::Content::new();
} else {
- if let MessageDialogResult::Ok = unsaved_changes_dialog("You have unsaved changes. Do you wish to discard these and create a new project?") {
+ if unsaved_changes_dialog("You have unsaved changes. Do you wish to discard these and create a new project?") {
self.is_dirty = false;
self.project = Project::new();
self.project_path = None;
@@ -254,7 +253,7 @@ impl App {
Message::FileOpened,
);
} else {
- if let MessageDialogResult::Ok = unsaved_changes_dialog("You have unsaved changes. Do you wish to discard these and open another project?") {
+ if unsaved_changes_dialog("You have unsaved changes. Do you wish to discard these and open another project?") {
self.is_dirty = false;
self.is_loading = true;
return Task::perform(Project::from_file(), Message::FileOpened);