From 319ee5387c4ffa6e829b8961784196b7af3da934 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Sat, 28 Oct 2023 07:00:53 -0500 Subject: [PATCH] save file uses last saved file now and saveas will pick a new one --- TODO.org | 4 ++-- src/qml/main.qml | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/TODO.org b/TODO.org index 524b326..0faae10 100644 --- a/TODO.org +++ b/TODO.org @@ -3,12 +3,12 @@ :CATEGORY: dev :END: -* Tasks [58%] [43/74] +* Tasks [60%] [44/73] ** TODO [#B] Fix updating things in the song editor [[file:~/dev/lumina/src/qml/presenter/SongEditor.qml::function updateLyrics(lyrics) {]] The core problem with this is that when we set the song, the index to get the item is the index of the item in the vector, not the ID in the DB. So, when we get a song, we can't use that index to update things, we need to make sure we are using the id so that all the new work in updating the right item is done correctly. -** TODO Make saving file auto use the last save file and go from there +** DONE Make saving file auto use the last save file and go from there [[file:~/dev/lumina/src/qml/main.qml::function save() {]] ** TODO Write a function to handle switching to the next fragment in revealjs [[file:~/dev/lumina/src/qml/presenter/Slide.qml::WebEngineView {]] diff --git a/src/qml/main.qml b/src/qml/main.qml index 9c5fd78..35465b5 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -258,28 +258,30 @@ Kirigami.ApplicationWindow { function save() { const saveFile = RSettings.lastSaveFile; - const file = fileHelper.saveFile(); - const saved = mainPage.serviceItems.save(file); - saved ? RSettings.setSaveFile(file) - : console.log("File: " + file + " wasn't saved"); - saved ? showPassiveNotification("SAVED! " + file) - : showPassiveNotification("FAILED!"); + console.log(saveFile.toString()); + let file = ""; + saveFile.length === 0 ? file = fileHelper.saveFile() : file = saveFile; + finalSave(file); } function saveAs() { const file = fileHelper.saveFile(); + finalSave(file); + } + + function finalSave(file) { const saved = mainPage.serviceItems.save(file); saved ? RSettings.setSaveFile(file) : console.log("File: " + file + " wasn't saved"); saved ? showPassiveNotification("SAVED! " + file) - : showPassiveNotification("FAILED!"); + : showPassiveNotification("Didn't save file"); } function load() { const file = fileHelper.loadFile("Load Presentation"); const loaded = mainPage.serviceItems.load(file); loaded ? showPassiveNotification("Loaded: " + file) - : showPassiveNotification("FAILED!"); + : showPassiveNotification("File wasn't loaded"); loaded ? RSettings.loadFile = file : showPassiveNotification("Didn't set loadfile!"); showPassiveNotification(RSettings.loadFile);