From bbb9f910d0bb938c8dc17f3be7f8bb0ac889e462 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Mon, 17 Jun 2024 16:52:31 -0500 Subject: [PATCH] making loading work and allow for canceling --- src/qml/main.qml | 18 +++++++++++------- src/rust/file_helper.rs | 4 ++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/qml/main.qml b/src/qml/main.qml index 915001a..bd31803 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -307,13 +307,17 @@ Kirigami.ApplicationWindow { /* } */ function load() { - const file = fileHelper.loadFile("Load Presentation"); - const loaded = mainPage.serviceItems.load(file); - loaded ? showPassiveNotification("Loaded: " + file) - : showPassiveNotification("File wasn't loaded"); - loaded ? RSettings.loadFile = file - : showPassiveNotification("Didn't set loadfile!"); - showPassiveNotification(RSettings.loadFile); + const file = fileHelper.loadFile("Load Presentation", "pres"); + if (file != "") { + const loaded = mainPage.serviceItems.load(file); + loaded ? showPassiveNotification("Loaded: " + file) + : showPassiveNotification("File wasn't loaded"); + loaded ? RSettings.loadFile = file + : showPassiveNotification("Didn't set loadfile!"); + showPassiveNotification(RSettings.loadFile); + } else { + showPassiveNotification("Loading Canceled"); + } } Component.onCompleted: { diff --git a/src/rust/file_helper.rs b/src/rust/file_helper.rs index b89d369..d92b2c2 100644 --- a/src/rust/file_helper.rs +++ b/src/rust/file_helper.rs @@ -113,6 +113,7 @@ impl file_helper::FileHelper { "jpg", "png", "gif", "jpeg", "JPG", "PNG", "webp", "gif", ]; let audio_filters = ["mp3", "opus", "ogg", "flac", "wav"]; + let pres_filter = ["pres"]; let title = title.to_string(); let filter = filter.to_string(); let mut file = FileDialog::new().set_title(title); @@ -126,6 +127,9 @@ impl file_helper::FileHelper { "audio" => { file = file.add_filter(filter, &audio_filters); } + "pres" => { + file = file.add_filter(filter, &pres_filter); + } _ => debug!("nothing"), }; debug!("trying to load file");