adding a loading of last saved file for jumping right back in

This commit is contained in:
Chris Cochrun 2022-10-17 10:15:22 -05:00
parent 7f1fc126fd
commit 798c682df9
3 changed files with 33 additions and 11 deletions

View file

@ -45,7 +45,13 @@ Controls.Page {
property var currentWindow: presentation
Component.onCompleted: {changeServiceItem(0); presentation.forceActiveFocus();}
Component.onCompleted: {
changeServiceItem(0);
presentation.forceActiveFocus();
/* const loaded = serviceItemModel.loadLastSaved(); */
/* if (!loaded) */
/* showPassiveNotification("Failed loading last file"); */
}
Item {
id: mainItem

View file

@ -19,21 +19,24 @@
#include <QTemporaryFile>
#include <QDir>
#include <QUrl>
#include <QSettings>
ServiceItemModel::ServiceItemModel(QObject *parent)
: QAbstractListModel(parent) {
addItem(new ServiceItem("10,000 Reasons", "song",
"file:/home/chris/nextcloud/tfc/openlp/CMG - Nature King 21.jpg",
"image", QStringList("Yip Yip"),
"file:/home/chris/nextcloud/tfc/openlp/music/Eden-Phil Wickham [lyrics].mp3"));
addItem(new ServiceItem("Marvelous Light", "song",
"file:/home/chris/nextcloud/tfc/openlp/Fire Embers_Loop.mp4",
"video", QStringList("Hallelujah!")));
addItem(new ServiceItem("BP Text", "video",
"file:/home/chris/nextcloud/tfc/openlp/videos/test.mp4",
"video", QStringList()));
if (!loadLastSaved()) {
addItem(new ServiceItem("10,000 Reasons", "song",
"file:/home/chris/nextcloud/tfc/openlp/CMG - Nature King 21.jpg",
"image", QStringList("Yip Yip"),
"file:/home/chris/nextcloud/tfc/openlp/music/Eden-Phil Wickham [lyrics].mp3"));
addItem(new ServiceItem("Marvelous Light", "song",
"file:/home/chris/nextcloud/tfc/openlp/Fire Embers_Loop.mp4",
"video", QStringList("Hallelujah!")));
addItem(new ServiceItem("BP Text", "video",
"file:/home/chris/nextcloud/tfc/openlp/videos/test.mp4",
"video", QStringList()));
}
}
int ServiceItemModel::rowCount(const QModelIndex &parent) const {
@ -546,6 +549,13 @@ bool ServiceItemModel::save(QUrl file) {
//close the archive so that everything is done
tar.close();
QSettings settings;
settings.setValue("lastSaveFile", file);
settings.sync();
qDebug() << settings.value("lastSaveFile");
return true;
}
@ -611,3 +621,8 @@ void ServiceItemModel::clearAll() {
removeItem(i);
}
}
bool ServiceItemModel::loadLastSaved() {
QSettings settings;
return load(settings.value("lastSaveFile").toUrl());
}

View file

@ -93,6 +93,7 @@ public:
Q_INVOKABLE bool save(QUrl file);
Q_INVOKABLE bool load(QUrl file);
Q_INVOKABLE bool loadLastSaved();
private:
QList<ServiceItem *> m_items;