Skip to content
Snippets Groups Projects
Commit 9499b6e6 authored by Vincent Texier's avatar Vincent Texier
Browse files

fix account not opened if preferences default account is empty

parent 88ccac76
No related branches found
No related tags found
No related merge requests found
...@@ -404,7 +404,22 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -404,7 +404,22 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def showEvent(self, event): def showEvent(self, event):
super().showEvent(event) super().showEvent(event)
if not self.initialized: if not self.initialized:
# if default account in preferences...
if self.app.preferences['account'] != "": if self.app.preferences['account'] != "":
logging.debug("Loading default account") logging.debug("Loading default account")
self.action_change_account(self.app.preferences['account']) self.action_change_account(self.app.preferences['account'])
# no default account...
else:
# if at least one account exists, set it as default...
if len(self.app.accounts) > 0:
# capture names sorted alphabetically
names = list(self.app.accounts.keys())
names.sort()
# set first name in list as default in preferences
self.app.preferences['account'] = names[0]
self.app.save_preferences(self.app.preferences)
# open it
logging.debug("No default account in preferences. Set %s as default account." % names[0])
self.action_change_account(self.app.preferences['account'])
self.initialized = True self.initialized = True
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment