commit 0a3a0f12cca84012676611cc17cf50fad0365e00
parent 0f431b23eb4f1219f9c971d551231f9d2ad87096
Author: Neil Booth <kyuupichan@gmail.com>
Date: Wed, 23 Dec 2015 12:20:19 +0900
Make more dialogs window-modal
Also remove some unnecessary imports
Diffstat:
7 files changed, 33 insertions(+), 47 deletions(-)
diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
@@ -2861,7 +2861,7 @@ class ElectrumWindow(QMainWindow, PrintError):
def enable_settings_widget(p, name, i):
widget = settings_widgets.get(name)
if not widget and p and p.requires_settings():
- widget = settings_widgets[name] = p.settings_widget(self)
+ widget = settings_widgets[name] = p.settings_widget(d)
grid.addWidget(widget, i, 1)
if widget:
widget.setEnabled(bool(p and p.is_enabled()))
diff --git a/gui/qt/seed_dialog.py b/gui/qt/seed_dialog.py
@@ -20,17 +20,14 @@ from PyQt4.QtGui import *
from PyQt4.QtCore import *
import PyQt4.QtCore as QtCore
from electrum.i18n import _
-from electrum import mnemonic
from util import *
from qrtextedit import ShowQRTextEdit, ScanQRTextEdit
-class SeedDialog(QDialog):
+class SeedDialog(WindowModalDialog):
def __init__(self, parent, seed, imported_keys):
- QDialog.__init__(self, parent)
- self.setModal(1)
+ WindowModalDialog.__init__(self, parent, ('Electrum - ' + _('Seed')))
self.setMinimumWidth(400)
- self.setWindowTitle('Electrum' + ' - ' + _('Seed'))
vbox = show_seed_box_msg(seed)
if imported_keys:
vbox.addWidget(QLabel("<b>"+_("WARNING")+":</b> " + _("Your wallet contains imported keys. These keys cannot be recovered from seed.") + "</b><p>"))
diff --git a/plugins/audio_modem/qt.py b/plugins/audio_modem/qt.py
@@ -1,11 +1,4 @@
-from electrum.plugins import BasePlugin, hook
-from electrum_gui.qt.util import WaitingDialog, EnterButton
-from electrum.util import print_msg, print_error
-from electrum.i18n import _
-
-from PyQt4.QtGui import *
-from PyQt4.QtCore import *
-
+from functools import partial
import traceback
import zlib
import json
@@ -13,6 +6,14 @@ from io import BytesIO
import sys
import platform
+from electrum.plugins import BasePlugin, hook
+from electrum_gui.qt.util import WaitingDialog, EnterButton, WindowModalDialog
+from electrum.util import print_msg, print_error
+from electrum.i18n import _
+
+from PyQt4.QtGui import *
+from PyQt4.QtCore import *
+
try:
import amodem.audio
import amodem.main
@@ -42,11 +43,10 @@ class Plugin(BasePlugin):
return True
def settings_widget(self, window):
- return EnterButton(_('Settings'), self.settings_dialog)
+ return EnterButton(_('Settings'), partial(self.settings_dialog, window))
- def settings_dialog(self):
- d = QDialog()
- d.setWindowTitle("Settings")
+ def settings_dialog(self, window):
+ d = WindowModalDialog(window, _("Audio Modem Settings"))
layout = QGridLayout(d)
layout.addWidget(QLabel(_('Bit rate [kbps]: ')), 0, 0)
diff --git a/plugins/email_requests/qt.py b/plugins/email_requests/qt.py
@@ -18,12 +18,10 @@
from __future__ import absolute_import
-import socket
import time
import threading
import base64
-from decimal import Decimal
-from Queue import Queue
+from functools import partial
import smtplib
import imaplib
@@ -37,12 +35,11 @@ from PyQt4.QtCore import *
import PyQt4.QtCore as QtCore
import PyQt4.QtGui as QtGui
-from electrum.paymentrequest import PR_UNPAID, PR_PAID, PR_EXPIRED
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 EnterButton
+from electrum_gui.qt.util import EnterButton, Buttons, CloseButton
+from electrum_gui.qt.util import OkButton, WindowModalDialog
@@ -166,14 +163,10 @@ class Plugin(BasePlugin):
return True
def settings_widget(self, window):
- self.settings_window = window
- return EnterButton(_('Settings'), self.settings_dialog)
+ return EnterButton(_('Settings'), partial(self.settings_dialog, window))
- def settings_dialog(self, x):
- from electrum_gui.qt.util import Buttons, CloseButton, OkButton
-
- d = QDialog(self.settings_window)
- d.setWindowTitle("Email settings")
+ def settings_dialog(self, window):
+ d = WindowModalDialog(window, _("Email settings"))
d.setMinimumSize(500, 200)
vbox = QVBoxLayout(d)
diff --git a/plugins/exchange_rate/qt.py b/plugins/exchange_rate/qt.py
@@ -128,11 +128,10 @@ class Plugin(FxPlugin):
window.connect(window.app, SIGNAL('refresh_headers'), window.history_list.refresh_headers)
def settings_widget(self, window):
- return EnterButton(_('Settings'), self.settings_dialog)
+ return EnterButton(_('Settings'), partial(self.settings_dialog, window))
- def settings_dialog(self):
- d = QDialog()
- d.setWindowTitle("Settings")
+ def settings_dialog(self, window):
+ d = WindowModalDialog(window, _("Exchange Rate Settings"))
layout = QGridLayout(d)
layout.addWidget(QLabel(_('Exchange rate API: ')), 0, 0)
layout.addWidget(QLabel(_('Currency: ')), 1, 0)
diff --git a/plugins/labels/qt.py b/plugins/labels/qt.py
@@ -6,7 +6,8 @@ from PyQt4.QtCore import *
from electrum.plugins import hook
from electrum.i18n import _
from electrum_gui.qt import EnterButton
-from electrum_gui.qt.util import ThreadedButton, Buttons, CancelButton, OkButton
+from electrum_gui.qt.util import ThreadedButton, Buttons, CancelButton
+from electrum_gui.qt.util import WindowModalDialog, OkButton
from labels import LabelsPlugin
@@ -25,25 +26,23 @@ class Plugin(LabelsPlugin):
partial(self.settings_dialog, window))
def settings_dialog(self, window):
- d = QDialog(window)
+ wallet = window.parent().wallet
+ d = WindowModalDialog(window, _("Label Settings"))
vbox = QVBoxLayout(d)
layout = QGridLayout()
vbox.addLayout(layout)
layout.addWidget(QLabel("Label sync options: "), 2, 0)
self.upload = ThreadedButton("Force upload",
- partial(self.push_thread, window.wallet),
+ partial(self.push_thread, wallet),
self.done_processing)
layout.addWidget(self.upload, 2, 1)
self.download = ThreadedButton("Force download",
- partial(self.pull_thread, window.wallet, True),
+ partial(self.pull_thread, wallet, True),
self.done_processing)
layout.addWidget(self.download, 2, 2)
self.accept = OkButton(d, _("Done"))
vbox.addLayout(Buttons(CancelButton(d), self.accept))
- if d.exec_():
- return True
- else:
- return False
+ return bool(d.exec_())
def on_pulled(self, wallet):
self.obj.emit(SIGNAL('labels_changed'), wallet)
diff --git a/plugins/trustedcoin/qt.py b/plugins/trustedcoin/qt.py
@@ -58,8 +58,7 @@ class Plugin(TrustedCoinPlugin):
t.start()
def auth_dialog(self, window):
- d = QDialog(window)
- d.setModal(1)
+ d = WindowModalDialog(window, _("Authorization"))
vbox = QVBoxLayout(d)
pw = AmountEdit(None, is_int = True)
msg = _('Please enter your Google Authenticator code')
@@ -113,8 +112,7 @@ class Plugin(TrustedCoinPlugin):
return
wallet = window.wallet
- d = QDialog(window)
- d.setWindowTitle("TrustedCoin Information")
+ d = WindowModalDialog(window, _("TrustedCoin Information"))
d.setMinimumSize(500, 200)
vbox = QVBoxLayout(d)
hbox = QHBoxLayout()