Browse Source

Make more dialogs window-modal

Also remove some unnecessary imports
283
Neil Booth 9 years ago
parent
commit
0a3a0f12cc
  1. 2
      gui/qt/main_window.py
  2. 7
      gui/qt/seed_dialog.py
  3. 24
      plugins/audio_modem/qt.py
  4. 19
      plugins/email_requests/qt.py
  5. 7
      plugins/exchange_rate/qt.py
  6. 15
      plugins/labels/qt.py
  7. 6
      plugins/trustedcoin/qt.py

2
gui/qt/main_window.py

@ -2861,7 +2861,7 @@ class ElectrumWindow(QMainWindow, PrintError):
def enable_settings_widget(p, name, i): def enable_settings_widget(p, name, i):
widget = settings_widgets.get(name) widget = settings_widgets.get(name)
if not widget and p and p.requires_settings(): 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) grid.addWidget(widget, i, 1)
if widget: if widget:
widget.setEnabled(bool(p and p.is_enabled())) widget.setEnabled(bool(p and p.is_enabled()))

7
gui/qt/seed_dialog.py

@ -20,17 +20,14 @@ from PyQt4.QtGui import *
from PyQt4.QtCore import * from PyQt4.QtCore import *
import PyQt4.QtCore as QtCore import PyQt4.QtCore as QtCore
from electrum.i18n import _ from electrum.i18n import _
from electrum import mnemonic
from util import * from util import *
from qrtextedit import ShowQRTextEdit, ScanQRTextEdit from qrtextedit import ShowQRTextEdit, ScanQRTextEdit
class SeedDialog(QDialog): class SeedDialog(WindowModalDialog):
def __init__(self, parent, seed, imported_keys): def __init__(self, parent, seed, imported_keys):
QDialog.__init__(self, parent) WindowModalDialog.__init__(self, parent, ('Electrum - ' + _('Seed')))
self.setModal(1)
self.setMinimumWidth(400) self.setMinimumWidth(400)
self.setWindowTitle('Electrum' + ' - ' + _('Seed'))
vbox = show_seed_box_msg(seed) vbox = show_seed_box_msg(seed)
if imported_keys: if imported_keys:
vbox.addWidget(QLabel("<b>"+_("WARNING")+":</b> " + _("Your wallet contains imported keys. These keys cannot be recovered from seed.") + "</b><p>")) vbox.addWidget(QLabel("<b>"+_("WARNING")+":</b> " + _("Your wallet contains imported keys. These keys cannot be recovered from seed.") + "</b><p>"))

24
plugins/audio_modem/qt.py

@ -1,11 +1,4 @@
from electrum.plugins import BasePlugin, hook from functools import partial
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 *
import traceback import traceback
import zlib import zlib
import json import json
@ -13,6 +6,14 @@ from io import BytesIO
import sys import sys
import platform 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: try:
import amodem.audio import amodem.audio
import amodem.main import amodem.main
@ -42,11 +43,10 @@ class Plugin(BasePlugin):
return True return True
def settings_widget(self, window): def settings_widget(self, window):
return EnterButton(_('Settings'), self.settings_dialog) return EnterButton(_('Settings'), partial(self.settings_dialog, window))
def settings_dialog(self): def settings_dialog(self, window):
d = QDialog() d = WindowModalDialog(window, _("Audio Modem Settings"))
d.setWindowTitle("Settings")
layout = QGridLayout(d) layout = QGridLayout(d)
layout.addWidget(QLabel(_('Bit rate [kbps]: ')), 0, 0) layout.addWidget(QLabel(_('Bit rate [kbps]: ')), 0, 0)

19
plugins/email_requests/qt.py

@ -18,12 +18,10 @@
from __future__ import absolute_import from __future__ import absolute_import
import socket
import time import time
import threading import threading
import base64 import base64
from decimal import Decimal from functools import partial
from Queue import Queue
import smtplib import smtplib
import imaplib import imaplib
@ -37,12 +35,11 @@ from PyQt4.QtCore import *
import PyQt4.QtCore as QtCore import PyQt4.QtCore as QtCore
import PyQt4.QtGui as QtGui import PyQt4.QtGui as QtGui
from electrum.paymentrequest import PR_UNPAID, PR_PAID, PR_EXPIRED
from electrum.plugins import BasePlugin, hook from electrum.plugins import BasePlugin, hook
from electrum import util
from electrum.paymentrequest import PaymentRequest from electrum.paymentrequest import PaymentRequest
from electrum.i18n import _ 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 return True
def settings_widget(self, window): def settings_widget(self, window):
self.settings_window = window return EnterButton(_('Settings'), partial(self.settings_dialog, window))
return EnterButton(_('Settings'), self.settings_dialog)
def settings_dialog(self, x): def settings_dialog(self, window):
from electrum_gui.qt.util import Buttons, CloseButton, OkButton d = WindowModalDialog(window, _("Email settings"))
d = QDialog(self.settings_window)
d.setWindowTitle("Email settings")
d.setMinimumSize(500, 200) d.setMinimumSize(500, 200)
vbox = QVBoxLayout(d) vbox = QVBoxLayout(d)

7
plugins/exchange_rate/qt.py

@ -128,11 +128,10 @@ class Plugin(FxPlugin):
window.connect(window.app, SIGNAL('refresh_headers'), window.history_list.refresh_headers) window.connect(window.app, SIGNAL('refresh_headers'), window.history_list.refresh_headers)
def settings_widget(self, window): def settings_widget(self, window):
return EnterButton(_('Settings'), self.settings_dialog) return EnterButton(_('Settings'), partial(self.settings_dialog, window))
def settings_dialog(self): def settings_dialog(self, window):
d = QDialog() d = WindowModalDialog(window, _("Exchange Rate Settings"))
d.setWindowTitle("Settings")
layout = QGridLayout(d) layout = QGridLayout(d)
layout.addWidget(QLabel(_('Exchange rate API: ')), 0, 0) layout.addWidget(QLabel(_('Exchange rate API: ')), 0, 0)
layout.addWidget(QLabel(_('Currency: ')), 1, 0) layout.addWidget(QLabel(_('Currency: ')), 1, 0)

15
plugins/labels/qt.py

@ -6,7 +6,8 @@ from PyQt4.QtCore import *
from electrum.plugins import hook from electrum.plugins import hook
from electrum.i18n import _ from electrum.i18n import _
from electrum_gui.qt import EnterButton 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 from labels import LabelsPlugin
@ -25,25 +26,23 @@ class Plugin(LabelsPlugin):
partial(self.settings_dialog, window)) partial(self.settings_dialog, window))
def settings_dialog(self, window): def settings_dialog(self, window):
d = QDialog(window) wallet = window.parent().wallet
d = WindowModalDialog(window, _("Label Settings"))
vbox = QVBoxLayout(d) vbox = QVBoxLayout(d)
layout = QGridLayout() layout = QGridLayout()
vbox.addLayout(layout) vbox.addLayout(layout)
layout.addWidget(QLabel("Label sync options: "), 2, 0) layout.addWidget(QLabel("Label sync options: "), 2, 0)
self.upload = ThreadedButton("Force upload", self.upload = ThreadedButton("Force upload",
partial(self.push_thread, window.wallet), partial(self.push_thread, wallet),
self.done_processing) self.done_processing)
layout.addWidget(self.upload, 2, 1) layout.addWidget(self.upload, 2, 1)
self.download = ThreadedButton("Force download", self.download = ThreadedButton("Force download",
partial(self.pull_thread, window.wallet, True), partial(self.pull_thread, wallet, True),
self.done_processing) self.done_processing)
layout.addWidget(self.download, 2, 2) layout.addWidget(self.download, 2, 2)
self.accept = OkButton(d, _("Done")) self.accept = OkButton(d, _("Done"))
vbox.addLayout(Buttons(CancelButton(d), self.accept)) vbox.addLayout(Buttons(CancelButton(d), self.accept))
if d.exec_(): return bool(d.exec_())
return True
else:
return False
def on_pulled(self, wallet): def on_pulled(self, wallet):
self.obj.emit(SIGNAL('labels_changed'), wallet) self.obj.emit(SIGNAL('labels_changed'), wallet)

6
plugins/trustedcoin/qt.py

@ -58,8 +58,7 @@ class Plugin(TrustedCoinPlugin):
t.start() t.start()
def auth_dialog(self, window): def auth_dialog(self, window):
d = QDialog(window) d = WindowModalDialog(window, _("Authorization"))
d.setModal(1)
vbox = QVBoxLayout(d) vbox = QVBoxLayout(d)
pw = AmountEdit(None, is_int = True) pw = AmountEdit(None, is_int = True)
msg = _('Please enter your Google Authenticator code') msg = _('Please enter your Google Authenticator code')
@ -113,8 +112,7 @@ class Plugin(TrustedCoinPlugin):
return return
wallet = window.wallet wallet = window.wallet
d = QDialog(window) d = WindowModalDialog(window, _("TrustedCoin Information"))
d.setWindowTitle("TrustedCoin Information")
d.setMinimumSize(500, 200) d.setMinimumSize(500, 200)
vbox = QVBoxLayout(d) vbox = QVBoxLayout(d)
hbox = QHBoxLayout() hbox = QHBoxLayout()

Loading…
Cancel
Save