diff --git a/gui/__main__.py b/gui/__main__.py index 038c7cd..42e0dd4 100644 --- a/gui/__main__.py +++ b/gui/__main__.py @@ -5611,7 +5611,7 @@ class DurationSelectionPage(Page): border: 2px solid #ccc; border-radius: 10px; background-color: cyan; - color: white; + color: black; font-weight: bold; } """) @@ -5984,8 +5984,10 @@ class PaymentDetailsPage(Page): self.page_stack.setCurrentWidget(currency_page) def show_qr_code(self): + full_amount = self.text_fields[2].text() if hasattr(self, 'full_address') and self.full_address: - qr_dialog = QRCodeDialog(self.full_address, self) + currency_type = getattr(self, 'selected_currency', None) + qr_dialog = QRCodeDialog(self.full_address, full_amount, currency_type, self) qr_dialog.exec() else: self.update_status.update_status('No address available for QR code') @@ -5999,8 +6001,9 @@ class PaymentDetailsPage(Page): return total_hours class QRCodeDialog(QDialog): - def __init__(self, address_text, parent=None): + def __init__(self, address_text, full_amount, currency_type=None, parent=None): super().__init__(parent) + self.currency_type = currency_type self.setWindowTitle("Payment Address QR Code") self.setFixedSize(400, 450) self.setModal(True) @@ -6016,9 +6019,17 @@ class QRCodeDialog(QDialog): qr_label.setAlignment(Qt.AlignmentFlag.AlignCenter) qr_label.setStyleSheet("margin: 10px; border: 2px solid #00ffff; border-radius: 10px;") - qr_pixmap = self.generate_qr_code(address_text) + qr_pixmap = self.generate_qr_code(address_text, full_amount) qr_label.setPixmap(qr_pixmap) layout.addWidget(qr_label) + + amount_label = QLabel("Amount:", self) + amount_label.setStyleSheet("font-size: 12px; color: #ffffff; margin-top: 10px;") + layout.addWidget(amount_label) + + amount_text_label = QLabel(full_amount, self) + amount_text_label.setStyleSheet("font-size: 10px; color: #cccccc; margin: 5px; padding: 5px; border: 1px solid #666; border-radius: 5px;") + layout.addWidget(amount_text_label) address_label = QLabel("Address:", self) address_label.setStyleSheet("font-size: 12px; color: #ffffff; margin-top: 10px;") @@ -6042,14 +6053,30 @@ class QRCodeDialog(QDialog): } """) - def generate_qr_code(self, text): + def generate_qr_code(self, text, full_amount): qr = qrcode.QRCode( version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=8, border=4, ) - qr.add_data(text) + + if self.currency_type: + currency_lower = self.currency_type.lower() + if currency_lower == 'bitcoin': + qr_data = f"bitcoin:{text}?amount={full_amount}" + elif currency_lower == 'monero': + qr_data = f"monero:{text}?amount={full_amount}" + elif currency_lower == 'lightning': + qr_data = f"bitcoin:{text}?amount={full_amount}&lightning=ln" + elif currency_lower == 'litecoin': + qr_data = f"litecoin:{text}?amount={full_amount}" + else: + qr_data = f"{text}?amount={full_amount}" + else: + qr_data = text + + qr.add_data(qr_data) qr.make(fit=True) qr_image = qr.make_image(fill_color="black", back_color="white") @@ -6061,7 +6088,7 @@ class QRCodeDialog(QDialog): pixmap = QPixmap() pixmap.loadFromData(buffer.getvalue()) - return pixmap.scaled(200, 200, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation) + return pixmap.scaled(150, 150, Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation)