Reworked the logic for the send button, you can only press it when the amount and...
authorMaran <maran.hidskes@gmail.com>
Tue, 24 Jul 2012 12:58:10 +0000 (14:58 +0200)
committerMaran <maran.hidskes@gmail.com>
Tue, 24 Jul 2012 12:58:10 +0000 (14:58 +0200)
data/lighter.css
lib/gui_lite.py

index 4138d85..2f3a3f2 100644 (file)
@@ -25,6 +25,17 @@ MiniWindow QPushButton {
   padding: 2px;
 }
 
+#send_button:disabled{
+  color: #D3E8FE;
+  border: 1px solid #6DAEF7;
+  border-radius: 4px;
+  background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+  stop: 0 #A5CFFA, stop: 1 #72B2F8);
+  min-width: 80px;
+  min-height: 23px;
+  padding: 2px;
+}
+
 #address_input[readOnly=true], #amount_input[readOnly=true]
 {
     color: #ABABAB;
index 80d4b0a..f38f441 100644 (file)
@@ -191,9 +191,10 @@ class MiniWindow(QDialog):
         amount_layout.addWidget(self.amount_input)
         amount_layout.addStretch()
 
-        send_button = QPushButton(_("&Send"))
-        send_button.setObjectName("send_button")
-        self.connect(send_button, SIGNAL("clicked()"), self.send)
+        self.send_button = QPushButton(_("&Send"))
+        self.send_button.setObjectName("send_button")
+        self.send_button.setDisabled(True);
+        self.connect(self.send_button, SIGNAL("clicked()"), self.send)
 
         main_layout = QGridLayout(self)
         main_layout.addWidget(accounts_button, 0, 0)
@@ -206,7 +207,7 @@ class MiniWindow(QDialog):
         main_layout.addLayout(address_layout, 1, 1, 1, -1)
 
         main_layout.addLayout(amount_layout, 2, 1)
-        main_layout.addWidget(send_button, 2, 2)
+        main_layout.addWidget(self.send_button, 2, 2)
 
         quit_shortcut = QShortcut(QKeySequence("Ctrl+Q"), self)
         self.connect(quit_shortcut, SIGNAL("activated()"), self.close)
@@ -272,6 +273,8 @@ class MiniWindow(QDialog):
                                                     quote_text))
 
     def amount_input_changed(self, amount_text):
+        self.check_button_status()
+
         try:
             amount = D(str(amount_text))
         except decimal.InvalidOperation:
@@ -300,11 +303,19 @@ class MiniWindow(QDialog):
             self.address_input.become_inactive()
             self.amount_input.become_inactive()
 
+    def check_button_status(self):
+      if self.amount_input.text() != _("... and amount") and len(self.amount_input.text()) != 0:
+        self.send_button.setDisabled(False)
+      else:
+        self.send_button.setDisabled(True)
+
     def address_field_changed(self, address):
         if self.actuator.is_valid(address):
             self.valid_address.setChecked(True)
+            self.check_button_status()
         else:
             self.valid_address.setChecked(False)
+            self.send_button.setDisabled(True)
 
     def copy_address(self):
         receive_popup = ReceivePopup(self.receive_button)