From e1b374e3753c207f788ac8169e812ac45c994ed5 Mon Sep 17 00:00:00 2001 From: Bart De Vries Date: Sat, 10 Apr 2021 09:36:55 +0200 Subject: [PATCH] Make app restore last playing item --- src/datamanager.h | 2 +- src/main.cpp | 1 + src/qml/main.qml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/datamanager.h b/src/datamanager.h index 2db317f6..a2916cc9 100644 --- a/src/datamanager.h +++ b/src/datamanager.h @@ -24,7 +24,7 @@ public: Feed* getFeed(QString const feedurl) const; Entry* getEntry(int const feed_index, int const entry_index) const; Entry* getEntry(const Feed* feed, int const entry_index) const; - Entry* getEntry(const QString id) const; + Q_INVOKABLE Entry* getEntry(const QString id) const; int feedCount() const; int entryCount(const int feed_index) const; int entryCount(const Feed* feed) const; diff --git a/src/main.cpp b/src/main.cpp index 88f59b84..b3cf42df 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -67,6 +67,7 @@ int main(int argc, char *argv[]) engine->setObjectOwnership(SettingsManager::self(), QQmlEngine::CppOwnership); return SettingsManager::self(); }); + qRegisterMetaType("const Entry*"); // "hack" to make qml understand Entry* QQmlApplicationEngine engine; engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); diff --git a/src/qml/main.qml b/src/qml/main.qml index 129d70f1..49bfe05b 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -82,7 +82,7 @@ Kirigami.ApplicationWindow { Audio { id: audio - property var entry + property var entry: SettingsManager.lastPlayingEntry !== "none" ? DataManager.getEntry(SettingsManager.lastPlayingEntry) : undefined property bool playerOpen: false onEntryChanged: SettingsManager.lastPlayingEntry = entry.id