commit 5ae5c81c487715f103e5ea1fecc433dc5f2fdaae
parent 321adf600a565e71b1cc73bbf12d4cf4f282cf71
Author: ThomasV <thomasv@electrum.org>
Date: Sat, 8 Jul 2017 15:23:00 +0200
use a unique and non-modal network dialog window
Diffstat:
3 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/gui/qt/__init__.py b/gui/qt/__init__.py
@@ -87,6 +87,7 @@ class ElectrumGui:
self.app = QApplication(sys.argv)
self.app.installEventFilter(self.efilter)
self.timer = Timer()
+ self.nd = None
# init tray
self.dark_icon = self.config.get("dark_icon", False)
self.tray = QSystemTrayIcon(self.tray_icon(), None)
@@ -138,6 +139,18 @@ class ElectrumGui:
# Use a signal as can be called from daemon thread
self.app.emit(SIGNAL('new_window'), path, uri)
+ def show_network_dialog(self, parent):
+ from network_dialog import NetworkDialog
+ if not self.daemon.network:
+ parent.show_warning(_('You are using Electrum in offline mode; restart Electrum if you want to get connected'), title=_('Offline'))
+ return
+ if self.nd:
+ self.nd.show()
+ self.nd.raise_()
+ return
+ self.nd = NetworkDialog(self.daemon.network, self.config, parent)
+ self.nd.show()
+
def create_window_for_wallet(self, wallet):
w = ElectrumWindow(self, wallet)
self.windows.append(w)
diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
@@ -54,7 +54,6 @@ from electrum import SimpleConfig, paymentrequest
from electrum.wallet import Wallet, Multisig_Wallet
from amountedit import AmountEdit, BTCAmountEdit, MyLineEdit, BTCkBEdit
-from network_dialog import NetworkDialog
from qrcodewidget import QRCodeWidget, QRDialog
from qrtextedit import ShowQRTextEdit
from transaction_dialog import show_transaction
@@ -479,7 +478,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
# Settings / Preferences are all reserved keywords in OSX using this as work around
tools_menu.addAction(_("Electrum preferences") if sys.platform == 'darwin' else _("Preferences"), self.settings_dialog)
- tools_menu.addAction(_("&Network"), self.run_network_dialog)
+ tools_menu.addAction(_("&Network"), lambda: self.gui_object.show_network_dialog(self))
tools_menu.addAction(_("&Plugins"), self.plugins_dialog)
tools_menu.addSeparator()
tools_menu.addAction(_("&Sign/verify message"), self.sign_verify_message)
@@ -1729,7 +1728,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
sb.addPermanentWidget(StatusBarButton(QIcon(":icons/preferences.png"), _("Preferences"), self.settings_dialog ) )
self.seed_button = StatusBarButton(QIcon(":icons/seed.png"), _("Seed"), self.show_seed_dialog )
sb.addPermanentWidget(self.seed_button)
- self.status_button = StatusBarButton(QIcon(":icons/status_disconnected.png"), _("Network"), self.run_network_dialog )
+ self.status_button = StatusBarButton(QIcon(":icons/status_disconnected.png"), _("Network"), lambda: self.gui_object.show_network_dialog(self))
sb.addPermanentWidget(self.status_button)
run_hook('create_status_bar', sb)
self.setStatusBar(sb)
@@ -2725,14 +2724,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
self.show_warning(_('Please restart Electrum to activate the new GUI settings'), title=_('Success'))
-
-
- def run_network_dialog(self):
- if not self.network:
- self.show_warning(_('You are using Electrum in offline mode; restart Electrum if you want to get connected'), title=_('Offline'))
- return
- NetworkDialog(self.wallet.network, self.config, self).do_exec()
-
def closeEvent(self, event):
# It seems in some rare cases this closeEvent() is called twice
if not self.cleaned_up:
diff --git a/gui/qt/network_dialog.py b/gui/qt/network_dialog.py
@@ -37,9 +37,10 @@ from util import *
protocol_names = ['TCP', 'SSL']
protocol_letters = 'ts'
-class NetworkDialog(WindowModalDialog):
+class NetworkDialog(QDialog):
def __init__(self, network, config, parent):
- WindowModalDialog.__init__(self, parent, _('Network'))
+ QDialog.__init__(self, parent)
+ self.setWindowTitle(_('Network'))
self.setMinimumSize(400, 20)
self.nlayout = NetworkChoiceLayout(network, config)
vbox = QVBoxLayout(self)