unify util.parse_URI
[electrum-nvc.git] / gui / qt / __init__.py
index c3c7da7..1acdca5 100644 (file)
@@ -18,7 +18,7 @@
 
 import sys, time, datetime, re, threading
 from electrum.i18n import _, set_language
-from electrum.util import print_error, print_msg, parse_url
+from electrum.util import print_error, print_msg
 from electrum.plugins import run_hook
 import os.path, json, ast, traceback
 import shutil
@@ -71,6 +71,7 @@ class ElectrumGui:
             self.app = QApplication(sys.argv)
         self.app.installEventFilter(self.efilter)
         init_plugins(self)
+        self.payment_request = None
 
 
     def build_tray_menu(self):
@@ -127,8 +128,6 @@ class ElectrumGui:
                 self.config.set_key('lite_mode', False, True)
                 sys.exit(0)
             self.lite_window = None
-            self.main_window.show()
-            self.main_window.raise_()
             return
 
         actuator = lite_window.MiniActuator(self.main_window)
@@ -136,10 +135,6 @@ class ElectrumGui:
         self.lite_window = lite_window.MiniWindow(actuator, self.go_full, self.config)
         driver = lite_window.MiniDriver(self.main_window, self.lite_window)
 
-        if self.config.get('lite_mode') is True:
-            self.go_lite()
-        else:
-            self.go_full()
 
 
     def check_qt_version(self):
@@ -147,28 +142,27 @@ class ElectrumGui:
         return int(qtVersion[0]) >= 4 and int(qtVersion[2]) >= 7
 
 
+    def set_url(self, uri):
+        self.current_window.pay_from_URI(uri)
+
 
     def main(self, url):
 
         storage = WalletStorage(self.config)
-        if not storage.file_exists:
-            import installwizard
-            wizard = installwizard.InstallWizard(self.config, self.network, storage)
-            wallet = wizard.run()
-            if not wallet: 
-                exit()
+        if storage.file_exists:
+            wallet = Wallet(storage)
+            action = wallet.get_action()
+        else:
+            action = 'new'
 
-        elif storage.get('wallet_type') in ['2of3'] and storage.get('seed') is None:
+        if action is not None:
             import installwizard
             wizard = installwizard.InstallWizard(self.config, self.network, storage)
-            wallet = wizard.run(action= 'create2of3')
+            wallet = wizard.run(action)
             if not wallet: 
                 exit()
-
         else:
-            wallet = Wallet(storage)
             wallet.start_threads(self.network)
-            
 
         # init tray
         self.dark_icon = self.config.get("dark_icon", False)
@@ -186,6 +180,16 @@ class ElectrumGui:
         #lite window
         self.init_lite()
 
+        # initial configuration
+        if self.config.get('hide_gui') is True and self.tray.isVisible():
+            self.main_window.hide()
+            self.lite_window.hide()
+        else:
+            if self.config.get('lite_mode') is True:
+                self.go_lite()
+            else:
+                self.go_full()
+
         # plugins that need to change the GUI do it here
         run_hook('init')
 
@@ -195,13 +199,20 @@ class ElectrumGui:
         s.start()
 
         self.windows.append(w)
-        if url: w.set_url(url)
+        if url: 
+            self.set_url(url)
+
         w.app = self.app
         w.connect_slots(s)
         w.update_wallet()
 
         self.app.exec_()
 
+        # clipboard persistence
+        # see http://www.mail-archive.com/pyqt@riverbankcomputing.com/msg17328.html
+        event = QtCore.QEvent(QtCore.QEvent.Clipboard)
+        self.app.sendEvent(self.app.clipboard(), event)
+
         wallet.stop_threads()