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 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 { Item {
id: mainItem id: mainItem

View file

@ -19,11 +19,13 @@
#include <QTemporaryFile> #include <QTemporaryFile>
#include <QDir> #include <QDir>
#include <QUrl> #include <QUrl>
#include <QSettings>
ServiceItemModel::ServiceItemModel(QObject *parent) ServiceItemModel::ServiceItemModel(QObject *parent)
: QAbstractListModel(parent) { : QAbstractListModel(parent) {
if (!loadLastSaved()) {
addItem(new ServiceItem("10,000 Reasons", "song", addItem(new ServiceItem("10,000 Reasons", "song",
"file:/home/chris/nextcloud/tfc/openlp/CMG - Nature King 21.jpg", "file:/home/chris/nextcloud/tfc/openlp/CMG - Nature King 21.jpg",
"image", QStringList("Yip Yip"), "image", QStringList("Yip Yip"),
@ -34,6 +36,7 @@ ServiceItemModel::ServiceItemModel(QObject *parent)
addItem(new ServiceItem("BP Text", "video", addItem(new ServiceItem("BP Text", "video",
"file:/home/chris/nextcloud/tfc/openlp/videos/test.mp4", "file:/home/chris/nextcloud/tfc/openlp/videos/test.mp4",
"video", QStringList())); "video", QStringList()));
}
} }
int ServiceItemModel::rowCount(const QModelIndex &parent) const { int ServiceItemModel::rowCount(const QModelIndex &parent) const {
@ -546,6 +549,13 @@ bool ServiceItemModel::save(QUrl file) {
//close the archive so that everything is done //close the archive so that everything is done
tar.close(); tar.close();
QSettings settings;
settings.setValue("lastSaveFile", file);
settings.sync();
qDebug() << settings.value("lastSaveFile");
return true; return true;
} }
@ -611,3 +621,8 @@ void ServiceItemModel::clearAll() {
removeItem(i); 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 save(QUrl file);
Q_INVOKABLE bool load(QUrl file); Q_INVOKABLE bool load(QUrl file);
Q_INVOKABLE bool loadLastSaved();
private: private:
QList<ServiceItem *> m_items; QList<ServiceItem *> m_items;