diff --git a/filmatyk/gui.py b/filmatyk/gui.py index da1e787..b6b442e 100644 --- a/filmatyk/gui.py +++ b/filmatyk/gui.py @@ -146,7 +146,7 @@ def __init__(self, debugMode=False, isOnLinux=False): self.dataManager = DataManager(self.getFilename(), VERSION) userdata = self.dataManager.load() # create the options manager - self.options = Options() + self.options = Options(userdata.options_json) # construct the window: first the notebook for tabbed view self.notebook = ttk.Notebook(root) self.notebook.grid(row=0, column=0, padx=5, pady=5, sticky=tk.NW) @@ -255,7 +255,9 @@ def saveUserData(self): # if there is no need to save anything - stop right there too if not ( any([db.isDirty for db in self.databases]) or - any([ps.isDirty for ps in self.presenters])): + any([ps.isDirty for ps in self.presenters]) or + self.options.isDirty + ): return # construct the UserData object serialized_data = UserData( @@ -265,7 +267,8 @@ def saveUserData(self): series_conf=self.presenters[1].storeToString(), series_data=self.databases[1].storeToString(), games_conf=self.presenters[2].storeToString(), - games_data=self.databases[2].storeToString() + games_data=self.databases[2].storeToString(), + options_json=self.options.storeToString(), ) # request the manager to save it self.dataManager.save(serialized_data) diff --git a/filmatyk/userdata.py b/filmatyk/userdata.py index cbcf130..9aa9ea1 100644 --- a/filmatyk/userdata.py +++ b/filmatyk/userdata.py @@ -28,9 +28,12 @@ translation of the old data format (as seen in the file) to the current format (as required by UserData and thus Main). -If a new version changes the UserData layout, *ALL* previous loaders have to be -updated to return this new layout. Therefore it is best not to modify the order -and names of UserData arguments. +If a new version changes the UserData layout, the DataManager.save method must +be updated to reflect that. Additionally, all previously registered loaders +must be able to return the new object. When adding a new element to UserData, +it should go without problems (just provide a default argument), but if a new +layout removes some fields... this will need special handling - probably for +*all* legacy loaders. """ import os @@ -49,6 +52,7 @@ def __init__( series_data='', games_conf='', games_data='', + options_json='{}', is_empty=True ): self.username = username @@ -58,6 +62,7 @@ def __init__( self.series_data = series_data self.games_conf = games_conf self.games_data = games_data + self.options_json = options_json self.is_empty = is_empty @@ -97,6 +102,8 @@ def save(self, userData): user_file.write(self.version + '\n') user_file.write('#USERNAME\n') user_file.write(userData.username + '\n') + user_file.write('#OPTIONS\n') + user_file.write(userData.options_json + '\n') user_file.write('#MOVIES\n') user_file.write(userData.movies_conf + '\n') user_file.write(userData.movies_data + '\n') @@ -212,3 +219,16 @@ def loader100b(user_data): games_conf=user_data[6], games_data=user_data[7] ) + + @DataManager.registerLoaderSince('1.0.0-beta.4') + def loader100b4(user_data): + return UserData( + username=user_data[1], + options_json=user_data[2], + movies_conf=user_data[3], + movies_data=user_data[4], + series_conf=user_data[5], + series_data=user_data[6], + games_conf=user_data[7], + games_data=user_data[8], + )