add switch-gui button for qt
authorbkkcoins <chrissavery@gmail.com>
Sat, 5 Jan 2013 12:44:20 +0000 (19:44 +0700)
committerbkkcoins <chrissavery@gmail.com>
Sat, 5 Jan 2013 12:44:20 +0000 (19:44 +0700)
icons.qrc
icons/switchgui.png [new file with mode: 0644]
lib/gui_lite.py
lib/gui_qt.py

index ef3c6f1..5ad965f 100644 (file)
--- a/icons.qrc
+++ b/icons.qrc
@@ -13,6 +13,7 @@
     <file>icons/status_connected.png</file>
     <file>icons/status_disconnected.png</file>
     <file>icons/status_waiting.png</file>
+    <file>icons/switchgui.png</file>
     <file>icons/unconfirmed.png</file>
     <file>icons/network.png</file>
   </qresource>
diff --git a/icons/switchgui.png b/icons/switchgui.png
new file mode 100644 (file)
index 0000000..ec18650
Binary files /dev/null and b/icons/switchgui.png differ
index 2989709..dc7b434 100644 (file)
@@ -88,14 +88,17 @@ def load_theme_paths():
 
 class ElectrumGui(QObject):
 
-    def __init__(self, wallet, config):
+    def __init__(self, wallet, config, expert=None):
         super(QObject, self).__init__()
 
         self.wallet = wallet
         self.config = config
         self.check_qt_version()
-        self.app = QApplication(sys.argv)
-
+        self.expert = expert
+        if self.expert != None:
+            self.app = self.expert.app
+        else:
+            self.app = QApplication(sys.argv)
 
     def check_qt_version(self):
         qtVersion = qVersion()
@@ -122,14 +125,15 @@ class ElectrumGui(QObject):
 
         if url:
             self.set_url(url)
-
-        timer = Timer()
-        timer.start()
-        self.expert = gui_qt.ElectrumWindow(self.wallet, self.config)
-        self.expert.app = self.app
-        self.expert.connect_slots(timer)
-        self.expert.update_wallet()
-        self.app.exec_()
+            
+        if self.expert == None:
+            timer = Timer()
+            timer.start()
+            self.expert = gui_qt.ElectrumWindow(self.wallet, self.config)
+            self.expert.app = self.app
+            self.expert.connect_slots(timer)
+            self.expert.update_wallet()
+            self.app.exec_()
 
     def expand(self):
         """Hide the lite mode window and show pro-mode."""
index adcadf6..1c364af 100644 (file)
@@ -294,6 +294,7 @@ class ElectrumWindow(QMainWindow):
 
     def __init__(self, wallet, config):
         QMainWindow.__init__(self)
+        self.lite = None
         self.wallet = wallet
         self.config = config
         self.wallet.interface.register_callback('updated', self.update_callback)
@@ -1108,6 +1109,9 @@ class ElectrumWindow(QMainWindow):
     def create_status_bar(self):
         sb = QStatusBar()
         sb.setFixedHeight(35)
+        qtVersion = qVersion()
+        if (int(qtVersion[0]) >= 4 and int(qtVersion[2]) >= 7):
+            sb.addPermanentWidget( StatusBarButton( QIcon(":icons/switchgui.png"), "Switch to Lite Mode", self.go_lite ) )
         if self.wallet.seed:
             sb.addPermanentWidget( StatusBarButton( QIcon(":icons/lock.png"), "Password", lambda: self.change_password_dialog(self.wallet, self) ) )
         sb.addPermanentWidget( StatusBarButton( QIcon(":icons/preferences.png"), "Preferences", self.settings_dialog ) )
@@ -1116,6 +1120,15 @@ class ElectrumWindow(QMainWindow):
         self.status_button = StatusBarButton( QIcon(":icons/status_disconnected.png"), "Network", lambda: self.network_dialog(self.wallet, self) ) 
         sb.addPermanentWidget( self.status_button )
         self.setStatusBar(sb)
+        
+    def go_lite(self):
+        import gui_lite
+        self.hide()
+        if self.lite:
+            self.lite.mini.show()
+        else:
+            self.lite = gui_lite.ElectrumGui(self.wallet, self.config, self)
+            self.lite.main(None)
 
     def new_contact_dialog(self):
         text, ok = QInputDialog.getText(self, _('New Contact'), _('Address') + ':')