electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 44a436e9640473367fcd368d4af61785dc4307e0
parent 8598f9ef9c8b012b8bc1aae5ad6a517ab3b44b5b
Author: Neil Booth <kyuupichan@gmail.com>
Date:   Tue, 22 Dec 2015 07:55:33 +0900

Make line_dialog, text_dialog window modal

Move new_wallet and get_wallet_folder from qt/__init__.py
to qt/main_window.py for correct centring and window modality.

Diffstat:
Mgui/qt/__init__.py | 26--------------------------
Mgui/qt/main_window.py | 30++++++++++++++++++++++++++++--
Mgui/qt/util.py | 8++------
Mplugins/email_requests/qt.py | 2+-
4 files changed, 31 insertions(+), 35 deletions(-)

diff --git a/gui/qt/__init__.py b/gui/qt/__init__.py @@ -162,32 +162,6 @@ class ElectrumGui: return wallet - def get_wallet_folder(self): - #return os.path.dirname(os.path.abspath(self.wallet.storage.path if self.wallet else self.wallet.storage.path)) - return os.path.dirname(os.path.abspath(self.config.get_wallet_path())) - - def new_wallet(self): - wallet_folder = self.get_wallet_folder() - i = 1 - while True: - filename = "wallet_%d"%i - if filename in os.listdir(wallet_folder): - i += 1 - else: - break - filename = line_dialog(None, _('New Wallet'), _('Enter file name') + ':', _('OK'), filename) - if not filename: - return - full_path = os.path.join(wallet_folder, filename) - storage = WalletStorage(full_path) - if storage.file_exists: - QMessageBox.critical(None, "Error", _("File exists")) - return - wizard = InstallWizard(self.app, self.config, self.network, storage) - wallet = wizard.run('new') - if wallet: - self.new_window(full_path) - def new_window(self, path, uri=None): # Use a signal as can be called from daemon thread self.app.emit(SIGNAL('new_window'), path, uri) diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -17,7 +17,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import sys, time, threading -import os.path, json, traceback +import os, json, traceback import shutil import socket import weakref @@ -360,13 +360,39 @@ class ElectrumWindow(QMainWindow, PrintError): self.recently_visited_menu.addAction(b, loader(k)).setShortcut(QKeySequence("Ctrl+%d"%(i+1))) self.recently_visited_menu.setEnabled(len(recent)) + def get_wallet_folder(self): + return os.path.dirname(os.path.abspath(self.config.get_wallet_path())) + + def new_wallet(self): + wallet_folder = self.get_wallet_folder() + i = 1 + while True: + filename = "wallet_%d" % i + if filename in os.listdir(wallet_folder): + i += 1 + else: + break + filename = line_dialog(self, _('New Wallet'), _('Enter file name') + + ':', _('OK'), filename) + if not filename: + return + full_path = os.path.join(wallet_folder, filename) + storage = WalletStorage(full_path) + if storage.file_exists: + QMessageBox.critical(self, "Error", _("File exists")) + return + wizard = InstallWizard(self.app, self.config, self.network, storage) + wallet = wizard.run('new') + if wallet: + self.new_window(full_path) + def init_menubar(self): menubar = QMenuBar() file_menu = menubar.addMenu(_("&File")) self.recently_visited_menu = file_menu.addMenu(_("&Recently open")) file_menu.addAction(_("&Open"), self.open_wallet).setShortcut(QKeySequence.Open) - file_menu.addAction(_("&New/Restore"), self.gui_object.new_wallet).setShortcut(QKeySequence.New) + file_menu.addAction(_("&New/Restore"), self.new_wallet).setShortcut(QKeySequence.New) file_menu.addAction(_("&Save Copy"), self.backup_wallet).setShortcut(QKeySequence.SaveAs) file_menu.addSeparator() file_menu.addAction(_("&Quit"), self.close) diff --git a/gui/qt/util.py b/gui/qt/util.py @@ -202,10 +202,8 @@ class WindowModalDialog(QDialog): self.setWindowTitle(title) def line_dialog(parent, title, label, ok_label, default=None): - dialog = QDialog(parent) + dialog = WindowModalDialog(parent, title) dialog.setMinimumWidth(500) - dialog.setWindowTitle(title) - dialog.setModal(1) l = QVBoxLayout() dialog.setLayout(l) l.addWidget(QLabel(label)) @@ -219,10 +217,8 @@ def line_dialog(parent, title, label, ok_label, default=None): def text_dialog(parent, title, label, ok_label, default=None): from qrtextedit import ScanQRTextEdit - dialog = QDialog(parent) + dialog = WindowModalDialog(parent, title) dialog.setMinimumWidth(500) - dialog.setWindowTitle(title) - dialog.setModal(1) l = QVBoxLayout() dialog.setLayout(l) l.addWidget(QLabel(label)) diff --git a/plugins/email_requests/qt.py b/plugins/email_requests/qt.py @@ -42,7 +42,7 @@ from electrum.plugins import BasePlugin, hook from electrum import util from electrum.paymentrequest import PaymentRequest from electrum.i18n import _ -from electrum_gui.qt.util import text_dialog, EnterButton +from electrum_gui.qt.util import EnterButton