Skip to content
Snippets Groups Projects
Commit 92832f62 authored by inso's avatar inso
Browse files

Factorizing accounts list refreshing

parent f650a8a6
Branches
Tags
No related merge requests found
...@@ -272,6 +272,17 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -272,6 +272,17 @@ class MainWindow(QMainWindow, Ui_MainWindow):
str(e), str(e),
QMessageBox.Ok) QMessageBox.Ok)
def refresh_accounts(self):
self.menu_change_account.clear()
signal_mapper = QSignalMapper(self)
for account_name in sorted(self.app.accounts.keys()):
action = QAction(account_name, self)
self.menu_change_account.addAction(action)
signal_mapper.setMapping(action, account_name)
action.triggered.connect(signal_mapper.map)
signal_mapper.mapped[str].connect(self.action_change_account)
def refresh_contacts(self): def refresh_contacts(self):
self.menu_contacts_list.clear() self.menu_contacts_list.clear()
if self.app.current_account: if self.app.current_account:
...@@ -297,15 +308,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): ...@@ -297,15 +308,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
in the window have to be refreshed in the window have to be refreshed
''' '''
logging.debug("Refresh started") logging.debug("Refresh started")
self.menu_change_account.clear() self.refresh_accounts()
signal_mapper = QSignalMapper(self)
for account_name in sorted(self.app.accounts.keys()):
action = QAction(account_name, self)
self.menu_change_account.addAction(action)
signal_mapper.setMapping(action, account_name)
action.triggered.connect(signal_mapper.map)
signal_mapper.mapped[str].connect(self.action_change_account)
if self.app.current_account is None: if self.app.current_account is None:
self.currencies_tabwidget.hide() self.currencies_tabwidget.hide()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment