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

@ -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());
}