updated qr code
This commit is contained in:
parent
69f3b7cb46
commit
6ecf1d0615
1 changed files with 34 additions and 7 deletions
|
@ -5611,7 +5611,7 @@ class DurationSelectionPage(Page):
|
||||||
border: 2px solid #ccc;
|
border: 2px solid #ccc;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
background-color: cyan;
|
background-color: cyan;
|
||||||
color: white;
|
color: black;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
""")
|
""")
|
||||||
|
@ -5984,8 +5984,10 @@ class PaymentDetailsPage(Page):
|
||||||
self.page_stack.setCurrentWidget(currency_page)
|
self.page_stack.setCurrentWidget(currency_page)
|
||||||
|
|
||||||
def show_qr_code(self):
|
def show_qr_code(self):
|
||||||
|
full_amount = self.text_fields[2].text()
|
||||||
if hasattr(self, 'full_address') and self.full_address:
|
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()
|
qr_dialog.exec()
|
||||||
else:
|
else:
|
||||||
self.update_status.update_status('No address available for QR code')
|
self.update_status.update_status('No address available for QR code')
|
||||||
|
@ -5999,8 +6001,9 @@ class PaymentDetailsPage(Page):
|
||||||
return total_hours
|
return total_hours
|
||||||
|
|
||||||
class QRCodeDialog(QDialog):
|
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)
|
super().__init__(parent)
|
||||||
|
self.currency_type = currency_type
|
||||||
self.setWindowTitle("Payment Address QR Code")
|
self.setWindowTitle("Payment Address QR Code")
|
||||||
self.setFixedSize(400, 450)
|
self.setFixedSize(400, 450)
|
||||||
self.setModal(True)
|
self.setModal(True)
|
||||||
|
@ -6016,10 +6019,18 @@ class QRCodeDialog(QDialog):
|
||||||
qr_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
qr_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||||
qr_label.setStyleSheet("margin: 10px; border: 2px solid #00ffff; border-radius: 10px;")
|
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)
|
qr_label.setPixmap(qr_pixmap)
|
||||||
layout.addWidget(qr_label)
|
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 = QLabel("Address:", self)
|
||||||
address_label.setStyleSheet("font-size: 12px; color: #ffffff; margin-top: 10px;")
|
address_label.setStyleSheet("font-size: 12px; color: #ffffff; margin-top: 10px;")
|
||||||
layout.addWidget(address_label)
|
layout.addWidget(address_label)
|
||||||
|
@ -6042,14 +6053,30 @@ class QRCodeDialog(QDialog):
|
||||||
}
|
}
|
||||||
""")
|
""")
|
||||||
|
|
||||||
def generate_qr_code(self, text):
|
def generate_qr_code(self, text, full_amount):
|
||||||
qr = qrcode.QRCode(
|
qr = qrcode.QRCode(
|
||||||
version=1,
|
version=1,
|
||||||
error_correction=qrcode.constants.ERROR_CORRECT_L,
|
error_correction=qrcode.constants.ERROR_CORRECT_L,
|
||||||
box_size=8,
|
box_size=8,
|
||||||
border=4,
|
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.make(fit=True)
|
||||||
|
|
||||||
qr_image = qr.make_image(fill_color="black", back_color="white")
|
qr_image = qr.make_image(fill_color="black", back_color="white")
|
||||||
|
@ -6061,7 +6088,7 @@ class QRCodeDialog(QDialog):
|
||||||
pixmap = QPixmap()
|
pixmap = QPixmap()
|
||||||
pixmap.loadFromData(buffer.getvalue())
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue