adding a loading of last saved file for jumping right back in
This commit is contained in:
parent
7f1fc126fd
commit
798c682df9
3 changed files with 33 additions and 11 deletions
|
@ -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
|
||||||
|
|
|
@ -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"),
|
||||||
|
@ -35,6 +37,7 @@ ServiceItemModel::ServiceItemModel(QObject *parent)
|
||||||
"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 {
|
||||||
// For list models only the root node (an invalid parent) should return the
|
// For list models only the root node (an invalid parent) should return the
|
||||||
|
@ -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());
|
||||||
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue