From 0378e830c40a1d7302a8108d460940b6cd15201e Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 3 May 2019 22:56:42 +0900 Subject: Connection::stateCacheDir Same as stateCachePath but returns QDir. --- lib/connection.h | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'lib/connection.h') diff --git a/lib/connection.h b/lib/connection.h index 42e678ff..2ff27ea6 100644 --- a/lib/connection.h +++ b/lib/connection.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -305,8 +306,8 @@ namespace QMatrixClient * Call this before first sync to load from previously saved file. * * \param fromFile A local path to read the state from. Uses QUrl - * to be QML-friendly. Empty parameter means using a path - * defined by stateCachePath(). + * to be QML-friendly. Empty parameter means saving to the directory + * defined by stateCachePath() / stateCacheDir(). */ Q_INVOKABLE void loadState(); /** @@ -315,23 +316,30 @@ namespace QMatrixClient * loadState() on a next run of the client. * * \param toFile A local path to save the state to. Uses QUrl to be - * QML-friendly. Empty parameter means using a path defined by - * stateCachePath(). + * QML-friendly. Empty parameter means saving to the directory + * defined by stateCachePath() / stateCacheDir(). */ Q_INVOKABLE void saveState() const; /// This method saves the current state of a single room. void saveRoomState(Room* r) const; + /// Get the default directory path to save the room state to + /** \sa stateCacheDir */ + Q_INVOKABLE QString stateCachePath() const; + + /// Get the default directory to save the room state to /** - * The default path to store the cached room state, defined as - * follows: + * This function returns the default directory to store the cached + * room state, defined as follows: + * \code * QStandardPaths::writeableLocation(QStandardPaths::CacheLocation) + _safeUserId + "_state.json" - * where `_safeUserId` is userId() with `:` (colon) replaced with - * `_` (underscore) - * /see loadState(), saveState() + * \endcode + * where `_safeUserId` is userId() with `:` (colon) replaced by + * `_` (underscore), as colons are reserved characters on Windows. + * \sa loadState, saveState, stateCachePath */ - Q_INVOKABLE QString stateCachePath() const; + QDir stateCacheDir() const; bool cacheState() const; void setCacheState(bool newValue); -- cgit v1.2.3