restore opened file and position

This commit is contained in:
Agel committed 2026-03-16 15:34:15 +01:00
1 parent fcacd0495d
commit 2ecf9f4178
12 files changed
+491 -11

No files matched your search

+60 -1
View File
@@ -3,24 +3,83 @@
#include <QObject>
#include <QString>
#include <QUrl>
class AppState : public QObject {
Q_OBJECT
Q_PROPERTY(QString lastFilePath READ lastFilePath NOTIFY lastFilePathChanged)
Q_PROPERTY(QString lastFilePath READ lastFilePath WRITE setLastFilePath NOTIFY lastFilePathChanged)
Q_PROPERTY(int lastChapter READ lastChapter WRITE setLastChapter NOTIFY lastChapterChanged)
Q_PROPERTY(qreal lastScrollPosition READ lastScrollPosition WRITE setLastScrollPosition NOTIFY lastScrollPositionChanged)
Q_PROPERTY(int lastScrollIndex READ lastScrollIndex WRITE setLastScrollIndex NOTIFY lastScrollIndexChanged)
Q_PROPERTY(qreal lastScrollOffset READ lastScrollOffset WRITE setLastScrollOffset NOTIFY lastScrollOffsetChanged)
Q_PROPERTY(QString pageFlipMode READ pageFlipMode WRITE setPageFlipMode NOTIFY pageFlipModeChanged)
Q_PROPERTY(int windowWidth READ windowWidth WRITE setWindowWidth NOTIFY windowWidthChanged)
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)
public:
explicit AppState(QObject *parent = nullptr);
QString lastFilePath() const;
void setLastFilePath(const QString &path);
int lastChapter() const;
void setLastChapter(int chapter);
qreal lastScrollPosition() const;
void setLastScrollPosition(qreal position);
int lastScrollIndex() const;
void setLastScrollIndex(int index);
qreal lastScrollOffset() const;
void setLastScrollOffset(qreal offset);
QString pageFlipMode() const;
void setPageFlipMode(const QString &mode);
int windowWidth() const;
void setWindowWidth(int width);
int windowHeight() const;
void setWindowHeight(int height);
int windowX() const;
void setWindowX(int x);
int windowY() const;
void setWindowY(int y);
Q_INVOKABLE QUrl lastFileUrl() const;
Q_INVOKABLE void save();
Q_INVOKABLE void restore();
signals:
void lastFilePathChanged();
void lastChapterChanged();
void lastScrollPositionChanged();
void lastScrollIndexChanged();
void lastScrollOffsetChanged();
void pageFlipModeChanged();
void stateRestored();
void windowWidthChanged();
void windowHeightChanged();
void windowXChanged();
void windowYChanged();
private:
QString m_lastFilePath;
int m_lastChapter = 0;
qreal m_lastScrollPosition = 0.0;
int m_lastScrollIndex = 0;
qreal m_lastScrollOffset = 0.0;
QString m_pageFlipMode = QStringLiteral("scroll");
int m_windowWidth = 1024;
int m_windowHeight = 768;
int m_windowX = -1;
int m_windowY = -1;
};
#endif // APPSTATE_H