tadd recently open files to menu. fixes #1273 - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit eef49a328a9af499c616a5bd41355ba26ed31906 DIR parent e93ff187768853e2ab7734286a9f69019b210dd4 HTML Author: ThomasV <thomasv@gitorious> Date: Thu, 6 Aug 2015 16:27:49 +0200 add recently open files to menu. fixes #1273 Diffstat: M gui/qt/main_window.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) --- DIR diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py t@@ -276,9 +276,12 @@ class ElectrumWindow(QMainWindow): def open_wallet(self): wallet_folder = self.wallet.storage.path - filename = unicode( QFileDialog.getOpenFileName(self, "Select your wallet file", wallet_folder) ) + filename = unicode(QFileDialog.getOpenFileName(self, "Select your wallet file", wallet_folder)) if not filename: return + self.load_wallet_file(filename) + + def load_wallet_file(self, filename): try: storage = WalletStorage(filename) except Exception as e: t@@ -312,7 +315,8 @@ class ElectrumWindow(QMainWindow): # save path if self.config.get('wallet_path') is None: self.config.set_key('gui_last_wallet', filename) - + # add to recently visited + self.update_recently_visited(filename) def backup_wallet(self): path = self.wallet.storage.path t@@ -364,6 +368,18 @@ class ElectrumWindow(QMainWindow): self.load_wallet(self.wallet) self.show() + def update_recently_visited(self, filename=None): + recent = self.config.get('recently_open', []) + if filename and filename not in recent: + recent.insert(filename, 0) + recent = recent[:10] + self.config.set_key('recently_open', recent) + self.recently_visited_menu.clear() + for i, k in enumerate(recent): + b = os.path.basename(k) + def loader(k): + return lambda: self.load_wallet_file(k) + self.recently_visited_menu.addAction(b, loader(k)).setShortcut(QKeySequence("Ctrl+%d"%i)) def init_menubar(self): menubar = QMenuBar() t@@ -371,8 +387,10 @@ class ElectrumWindow(QMainWindow): file_menu = menubar.addMenu(_("&File")) file_menu.addAction(_("&Open"), self.open_wallet).setShortcut(QKeySequence.Open) file_menu.addAction(_("&New/Restore"), self.new_wallet).setShortcut(QKeySequence.New) - file_menu.addAction(_("&Save Copy"), self.backup_wallet).setShortcut(QKeySequence.SaveAs) + self.recently_visited_menu = file_menu.addMenu(_("&Recently open")) + file_menu.addSeparator() file_menu.addAction(_("&Quit"), self.close) + self.update_recently_visited() wallet_menu = menubar.addMenu(_("&Wallet")) wallet_menu.addAction(_("&New contact"), self.new_contact_dialog)