From 7ba5f07629d11efa69df30234e44390a99a89755 Mon Sep 17 00:00:00 2001 From: Maran Date: Tue, 24 Jul 2012 14:58:10 +0200 Subject: [PATCH] Reworked the logic for the send button, you can only press it when the amount and a valid address is given --- data/lighter.css | 11 +++++++++++ lib/gui_lite.py | 19 +++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/data/lighter.css b/data/lighter.css index 4138d85..2f3a3f2 100644 --- a/data/lighter.css +++ b/data/lighter.css @@ -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; diff --git a/lib/gui_lite.py b/lib/gui_lite.py index 80d4b0a..f38f441 100644 --- a/lib/gui_lite.py +++ b/lib/gui_lite.py @@ -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) -- 1.7.1