From e6360fd7010edc99cb340b1f8b73ac7fc8806eaa Mon Sep 17 00:00:00 2001 From: Vincent Texier <vit@free.fr> Date: Fri, 15 May 2015 19:10:43 +0200 Subject: [PATCH] Open automatically the imported account as current account --- src/cutecoin/core/app.py | 3 ++- src/cutecoin/gui/mainwindow.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/cutecoin/core/app.py b/src/cutecoin/core/app.py index 93e228e6..c3596948 100644 --- a/src/cutecoin/core/app.py +++ b/src/cutecoin/core/app.py @@ -336,7 +336,7 @@ class Application(QObject): def import_account(self, file, name): ''' - Import an account from a tar file + Import an account from a tar file and open it :param str file: The file path of the tar file :param str name: The account name @@ -359,6 +359,7 @@ class Application(QObject): account.name = name self.add_account(account) self.save(account) + self.change_current_account(account) def export_account(self, file, account): ''' diff --git a/src/cutecoin/gui/mainwindow.py b/src/cutecoin/gui/mainwindow.py index 0acfa4ba..9371811f 100644 --- a/src/cutecoin/gui/mainwindow.py +++ b/src/cutecoin/gui/mainwindow.py @@ -101,6 +101,7 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.open_ucoin_info = lambda: QDesktopServices.openUrl(QUrl("http://ucoin.io/theoretical/")) self.homescreen.button_info.clicked.connect(self.open_ucoin_info) + self.import_dialog = None self.export_dialog = None # TODO: There are too much refresh() calls on startup @@ -343,12 +344,16 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.refresh_contacts() def import_account(self): - dialog = ImportAccountDialog(self.app, self) - dialog.accepted.connect(self.refresh) - dialog.exec_() + self.import_dialog = ImportAccountDialog(self.app, self) + self.import_dialog.accepted.connect(self.import_account_accepted) + self.import_dialog.exec_() + + def import_account_accepted(self): + # open account after import + self.action_change_account(self.import_dialog.edit_name.text()) def export_account(self): - # Testable way off using a QFileDialog + # Testable way of using a QFileDialog self.export_dialog = QFileDialog(self) self.export_dialog.setObjectName('ExportFileDialog') self.export_dialog.setWindowTitle(self.tr("Export an account")) -- GitLab