save file uses last saved file now and saveas will pick a new one

This commit is contained in:
Chris Cochrun 2023-10-28 07:00:53 -05:00
parent e8ac59bcbf
commit 319ee5387c
2 changed files with 12 additions and 10 deletions

View file

@ -3,12 +3,12 @@
:CATEGORY: dev :CATEGORY: dev
:END: :END:
* Tasks [58%] [43/74] * Tasks [60%] [44/73]
** TODO [#B] Fix updating things in the song editor ** TODO [#B] Fix updating things in the song editor
[[file:~/dev/lumina/src/qml/presenter/SongEditor.qml::function updateLyrics(lyrics) {]] [[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. 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() {]] [[file:~/dev/lumina/src/qml/main.qml::function save() {]]
** TODO Write a function to handle switching to the next fragment in revealjs ** TODO Write a function to handle switching to the next fragment in revealjs
[[file:~/dev/lumina/src/qml/presenter/Slide.qml::WebEngineView {]] [[file:~/dev/lumina/src/qml/presenter/Slide.qml::WebEngineView {]]

View file

@ -258,28 +258,30 @@ Kirigami.ApplicationWindow {
function save() { function save() {
const saveFile = RSettings.lastSaveFile; const saveFile = RSettings.lastSaveFile;
const file = fileHelper.saveFile(); console.log(saveFile.toString());
const saved = mainPage.serviceItems.save(file); let file = "";
saved ? RSettings.setSaveFile(file) saveFile.length === 0 ? file = fileHelper.saveFile() : file = saveFile;
: console.log("File: " + file + " wasn't saved"); finalSave(file);
saved ? showPassiveNotification("SAVED! " + file)
: showPassiveNotification("FAILED!");
} }
function saveAs() { function saveAs() {
const file = fileHelper.saveFile(); const file = fileHelper.saveFile();
finalSave(file);
}
function finalSave(file) {
const saved = mainPage.serviceItems.save(file); const saved = mainPage.serviceItems.save(file);
saved ? RSettings.setSaveFile(file) saved ? RSettings.setSaveFile(file)
: console.log("File: " + file + " wasn't saved"); : console.log("File: " + file + " wasn't saved");
saved ? showPassiveNotification("SAVED! " + file) saved ? showPassiveNotification("SAVED! " + file)
: showPassiveNotification("FAILED!"); : showPassiveNotification("Didn't save file");
} }
function load() { function load() {
const file = fileHelper.loadFile("Load Presentation"); const file = fileHelper.loadFile("Load Presentation");
const loaded = mainPage.serviceItems.load(file); const loaded = mainPage.serviceItems.load(file);
loaded ? showPassiveNotification("Loaded: " + file) loaded ? showPassiveNotification("Loaded: " + file)
: showPassiveNotification("FAILED!"); : showPassiveNotification("File wasn't loaded");
loaded ? RSettings.loadFile = file loaded ? RSettings.loadFile = file
: showPassiveNotification("Didn't set loadfile!"); : showPassiveNotification("Didn't set loadfile!");
showPassiveNotification(RSettings.loadFile); showPassiveNotification(RSettings.loadFile);