electrum

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

commit 06d0c67b9cc15ae7eecc598b60623e2b4ca5441d
parent 8614c0544c7c4af41c49152ad19e424ca1b3478e
Author: thomasv <thomasv@gitorious>
Date:   Wed, 11 Sep 2013 14:52:44 +0200

remove ElectrumGui class for lite window

Diffstat:
Mgui/gui_classic/__init__.py | 44++++++++++++++++++++++++++++++++++++++++++--
Mgui/gui_classic/lite_window.py | 87-------------------------------------------------------------------------------
Mgui/gui_classic/main_window.py | 4++--
3 files changed, 44 insertions(+), 91 deletions(-)

diff --git a/gui/gui_classic/__init__.py b/gui/gui_classic/__init__.py @@ -18,7 +18,7 @@ import sys, time, datetime, re, threading from electrum.i18n import _, set_language -from electrum.util import print_error, print_msg +from electrum.util import print_error, print_msg, parse_url import os.path, json, ast, traceback import shutil @@ -75,6 +75,40 @@ class ElectrumGui: self.app = QApplication(sys.argv) self.app.installEventFilter(self.efilter) + def expand(self): + """Hide the lite mode window and show pro-mode.""" + self.config.set_key('lite_mode', False, True) + self.mini.hide() + self.expert.show() + + def minimize(self, wallet, expert, url): + import lite_window + actuator = lite_window.MiniActuator(self.config, wallet) + # Should probably not modify the current path but instead + # change the behaviour of rsrc(...) + old_path = QDir.currentPath() + actuator.load_theme() + + self.mini = lite_window.MiniWindow(actuator, self.expand, self.config) + driver = lite_window.MiniDriver(wallet, self.mini) + + # Reset path back to original value now that loading the GUI + # is completed. + QDir.setCurrent(old_path) + + if url: + payto, amount, label, message, signature, identity, url = parse_url(url) + self.mini.set_payment_fields(payto, amount) + + self.expert = expert + + def check_qt_version(self): + qtVersion = qVersion() + if not(int(qtVersion[0]) >= 4 and int(qtVersion[2]) >= 7): + app = QApplication(sys.argv) + QMessageBox.warning(None,"Could not start Lite GUI.", "Electrum was unable to load the 'Lite GUI' because it needs Qt version >= 4.7.\nChanging your config to use the 'Classic' GUI") + self.config.set_key('lite_mode', False, True) + sys.exit(0) def main(self, url): @@ -92,6 +126,7 @@ class ElectrumGui: s = Timer() s.start() + w = ElectrumWindow(self.config, self.network) w.load_wallet(wallet) @@ -100,7 +135,12 @@ class ElectrumGui: w.app = self.app w.connect_slots(s) w.update_wallet() - w.show() + + if self.config.get('lite_mode'): + self.check_qt_version() + self.minimize(wallet, w, url) + else: + w.show() self.app.exec_() diff --git a/gui/gui_classic/lite_window.py b/gui/gui_classic/lite_window.py @@ -134,93 +134,6 @@ def csv_transaction(wallet): QMessageBox.critical(None,"Unable to create csv", export_error_label + "\n" + str(reason)) -class ElectrumGui(QObject): - - def __init__(self, config, interface, blockchain, expert=None): - super(QObject, self).__init__() - - self.config = config - self.check_qt_version() - self.expert = expert - self.interface = interface - self.blockchain = blockchain - - - - - def check_qt_version(self): - qtVersion = qVersion() - if not(int(qtVersion[0]) >= 4 and int(qtVersion[2]) >= 7): - app = QApplication(sys.argv) - QMessageBox.warning(None,"Could not start Lite GUI.", "Electrum was unable to load the 'Lite GUI' because it needs Qt version >= 4.7.\nChanging your config to use the 'Classic' GUI") - self.config.set_key('gui','classic',True) - sys.exit(0) - - - def main(self, url): - - if self.expert is None: - self.app = QApplication(sys.argv) - storage = WalletStorage(self.config) - if not storage.file_exists: - exit() - self.wallet = Wallet(storage) - self.wallet.start_threads(self.interface, self.blockchain) - else: - self.app = self.expert.app - self.wallet = self.expert.wallet - - actuator = MiniActuator(self.config, self.wallet) - # Should probably not modify the current path but instead - # change the behaviour of rsrc(...) - old_path = QDir.currentPath() - actuator.load_theme() - - self.mini = MiniWindow(actuator, self.expand, self.config) - driver = MiniDriver(self.wallet, self.mini) - - # Reset path back to original value now that loading the GUI - # is completed. - QDir.setCurrent(old_path) - - if url: - self.set_url(url) - - if self.expert is None: - self.expert = ElectrumWindow(self.config) - self.expert.load_wallet(self.wallet) - self.expert.app = self.app - timer = Timer() - timer.start() - self.expert.connect_slots(timer) - self.expert.update_wallet() - - self.app.exec_() - - - def expand(self): - """Hide the lite mode window and show pro-mode.""" - self.config.set_key('gui', 'classic', True) - self.mini.hide() - self.expert.show() - - def set_url(self, url): - payto, amount, label, message, signature, identity, url = \ - self.wallet.parse_url(url, self.show_message, self.show_question) - self.mini.set_payment_fields(payto, amount) - - def show_message(self, message): - QMessageBox.information(self.mini, _("Message"), message, _("OK")) - - def show_question(self, message): - choice = QMessageBox.question(self.mini, _("Message"), message, - QMessageBox.Yes|QMessageBox.No, - QMessageBox.No) - return choice == QMessageBox.Yes - - def restore_or_create(self): - qt_gui_object = ElectrumGui(self.wallet, self.app) - return qt_gui_object.restore_or_create() class TransactionWindow(QDialog): diff --git a/gui/gui_classic/main_window.py b/gui/gui_classic/main_window.py @@ -1376,7 +1376,7 @@ class ElectrumWindow(QMainWindow): def go_lite(self): import lite_window - self.config.set_key('gui', 'lite', True) + self.config.set_key('lite_mode', True, True) self.hide() if self.lite: self.lite.mini.show() @@ -1958,7 +1958,7 @@ class ElectrumWindow(QMainWindow): lang_label=QLabel(_('Language') + ':') grid_ui.addWidget(lang_label, 1, 0) lang_combo = QComboBox() - from i18n import languages + from electrum.i18n import languages lang_combo.addItems(languages.values()) try: index = languages.keys().index(self.config.get("language",''))