add library with reading history, progress tracking, and view persistence

This commit is contained in:
Agel committed 2026-03-20 11:20:16 +01:00
1 parent c62733bc26
commit c4046d8533
15 files changed
+685 -40

No files matched your search

+20
View File
@@ -4,6 +4,8 @@
#include <QObject>
#include <QString>
#include <QUrl>
#include <QVariantMap>
#include <QVariantList>
class AppState : public QObject {
Q_OBJECT
@@ -17,6 +19,8 @@ class AppState : public QObject {
Q_PROPERTY(int windowHeight READ windowHeight WRITE setWindowHeight NOTIFY windowHeightChanged)
Q_PROPERTY(int windowX READ windowX WRITE setWindowX NOTIFY windowXChanged)
Q_PROPERTY(int windowY READ windowY WRITE setWindowY NOTIFY windowYChanged)
Q_PROPERTY(QVariantList libraryBooks READ libraryBooks NOTIFY libraryBooksChanged)
Q_PROPERTY(QString lastPage READ lastPage WRITE setLastPage NOTIFY lastPageChanged)
public:
explicit AppState(QObject *parent = nullptr);
@@ -53,6 +57,16 @@ public:
Q_INVOKABLE QUrl lastFileUrl() const;
Q_INVOKABLE void saveBookPosition(const QString &filePath, int chapter, int scrollIndex, qreal scrollOffset);
Q_INVOKABLE QVariantMap loadBookPosition(const QString &filePath) const;
QString lastPage() const;
void setLastPage(const QString &page);
Q_INVOKABLE void addOrUpdateLibraryBook(const QString &filePath, const QString &title, const QString &author, double progress);
Q_INVOKABLE void removeLibraryBook(const QString &filePath);
Q_INVOKABLE QVariantList libraryBooks() const;
Q_INVOKABLE void save();
Q_INVOKABLE void restore();
@@ -68,8 +82,12 @@ signals:
void windowHeightChanged();
void windowXChanged();
void windowYChanged();
void libraryBooksChanged();
void lastPageChanged();
private:
void loadLibraryBooks();
void saveLibraryBooks();
QString m_lastFilePath;
int m_lastChapter = 0;
qreal m_lastScrollPosition = 0.0;
@@ -80,6 +98,8 @@ private:
int m_windowHeight = 768;
int m_windowX = -1;
int m_windowY = -1;
QVariantList m_libraryBooks;
QString m_lastPage = QStringLiteral("starter");
};
#endif // APPSTATE_H