summaryrefslogtreecommitdiffstats
path: root/logic/lists/MojangAccountList.h
diff options
context:
space:
mode:
authorAndrew <forkk@forkk.net>2013-11-19 12:53:30 -0600
committerAndrew <forkk@forkk.net>2013-11-19 12:53:30 -0600
commit928e0d0b151a4690a5849c2ec4a44d97338937c5 (patch)
tree817c32e38fd1492c1f3456be7764e7643a5ef433 /logic/lists/MojangAccountList.h
parenta9a0b65358b3799746fa9c8e1aa879e0b59ef526 (diff)
downloadMultiMC-928e0d0b151a4690a5849c2ec4a44d97338937c5.tar
MultiMC-928e0d0b151a4690a5849c2ec4a44d97338937c5.tar.gz
MultiMC-928e0d0b151a4690a5849c2ec4a44d97338937c5.tar.lz
MultiMC-928e0d0b151a4690a5849c2ec4a44d97338937c5.tar.xz
MultiMC-928e0d0b151a4690a5849c2ec4a44d97338937c5.zip
Implement saving account list to file
Currently it only saves when accounts are added or removed. We'll have to fix this, but we need signals for when account objects change first.
Diffstat (limited to 'logic/lists/MojangAccountList.h')
-rw-r--r--logic/lists/MojangAccountList.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/logic/lists/MojangAccountList.h b/logic/lists/MojangAccountList.h
index 37c928de..491abf6d 100644
--- a/logic/lists/MojangAccountList.h
+++ b/logic/lists/MojangAccountList.h
@@ -79,6 +79,15 @@ public:
* one doesn't exist.
*/
virtual MojangAccountPtr findAccount(const QString &username);
+
+ /*!
+ * Sets the default path to save the list file to.
+ * If autosave is true, this list will automatically save to the given path whenever it changes.
+ * THIS FUNCTION DOES NOT LOAD THE LIST. If you set autosave, be sure to call loadList() immediately
+ * after calling this function to ensure an autosaved change doesn't overwrite the list you intended
+ * to load.
+ */
+ virtual void setListFilePath(QString path, bool autosave=false);
/*!
* \brief Loads the account list from the given file path.
@@ -102,8 +111,23 @@ signals:
void listChanged();
protected:
+ /*!
+ * Called whenever the list changes.
+ * This emits the listChanged() signal and autosaves the list (if autosave is enabled).
+ */
+ void onListChanged();
+
QList<MojangAccountPtr> m_accounts;
+ //! Path to the account list file. Empty string if there isn't one.
+ QString m_listFilePath;
+
+ /*!
+ * If true, the account list will automatically save to the account list path when it changes.
+ * Ignored if m_listFilePath is blank.
+ */
+ bool m_autosave;
+
protected
slots:
/*!