sp-hydra-veil-gui/gui/v2/ui/pages/payment_confirmed_page.py
2026-06-13 16:19:11 -04:00

149 lines
5.2 KiB
Python
Executable file

import os
from PyQt6.QtWidgets import QApplication, QButtonGroup, QFrame, QLabel, QPushButton
from PyQt6.QtGui import QIcon, QPainter
from PyQt6.QtCore import Qt, QPointF, QRect, QSize, QTimer
from gui.v2.ui.pages.Page import Page
from gui.v2.ui.widgets.clickable_label import ClickableLabel
from gui.v2.ui.widgets.confetti import ConfettiThread
class PaymentConfirmed(Page):
def __init__(self, page_stack, main_window=None, parent=None):
super().__init__("Id", page_stack, main_window, parent)
self.update_status = main_window
self.buttonGroup = QButtonGroup(self)
self.display.setGeometry(QRect(-10, 50, 550, 460))
self.button_reverse.setVisible(False)
self.confetti = []
self.icon_label = QLabel(self)
icon = QIcon(os.path.join(self.btn_path, "check_icon.png"))
pixmap = icon.pixmap(QSize(64, 64))
self.icon_label.setPixmap(pixmap)
self.icon_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self.label = QLabel("Payment Completed!",
alignment=Qt.AlignmentFlag.AlignCenter, parent=self)
self.label.setStyleSheet(
"font-size: 24px; color: #2ecc71; font-weight: bold;")
self.billing_label = QLabel(
"Your billing code:", alignment=Qt.AlignmentFlag.AlignCenter, parent=self)
self.billing_label.setStyleSheet("font-size: 18px; color: white;")
self.billing_code = ClickableLabel(
"", alignment=Qt.AlignmentFlag.AlignCenter, parent=self)
self.billing_code.setStyleSheet("""
font-size: 24px;
color: white;
font-weight: bold;
padding: 5px;
border-radius: 5px;
""")
self.billing_code.clicked.connect(self.copy_billing_code)
self.billing_code.set_hover_width(450)
self.top_line = QFrame(self)
self.top_line.setFrameShape(QFrame.Shape.HLine)
self.top_line.setStyleSheet("color: #bdc3c7;")
self.bottom_line = QFrame(self)
self.bottom_line.setFrameShape(QFrame.Shape.HLine)
self.bottom_line.setStyleSheet("color: #bdc3c7;")
self.next_button = QPushButton("Next", self)
self.next_button.setStyleSheet("""
QPushButton {
background-color: #3498db;
color: white;
border: none;
padding: 10px;
font-size: 18px;
border-radius: 5px;
}
QPushButton:hover {
background-color: #2980b9;
}
""")
self.next_button.clicked.connect(self.on_next_button)
self.confetti_thread = ConfettiThread(self.width(), self.height())
self.confetti_thread.update_signal.connect(self.update_confetti)
self.confetti_thread.start()
def copy_billing_code(self):
clipboard = QApplication.clipboard()
clipboard.setText(self.billing_code.text())
original_style = self.billing_code.styleSheet()
self.billing_code.setText("Copied!")
self.billing_code.setStyleSheet(
original_style + "background-color: #27ae60;")
QTimer.singleShot(
1000, lambda: self.reset_billing_code_style(original_style))
def reset_billing_code_style(self, original_style):
self.billing_code.setStyleSheet(original_style)
self.billing_code.setText(self.current_billing_code)
def set_billing_code(self, code):
self.current_billing_code = code
self.billing_code.setText(code)
def update_confetti(self, confetti):
self.confetti = confetti
self.update()
def paintEvent(self, event):
super().paintEvent(event)
painter = QPainter(self)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
for particle in self.confetti:
painter.setBrush(particle.color)
painter.setPen(Qt.PenStyle.NoPen)
painter.drawEllipse(QPointF(particle.x, particle.y),
particle.size, particle.size)
painter.end()
def resizeEvent(self, event):
super().resizeEvent(event)
width = event.size().width()
height = event.size().height()
self.icon_label.setGeometry(
QRect(width // 2 - 32, height // 8, 64, 64))
self.label.setGeometry(QRect(0, height // 4, width, 50))
self.billing_label.setGeometry(QRect(0, height // 2 - 50, width, 30))
self.top_line.setGeometry(
QRect(width // 4, height // 2 + 20, width // 2, 1))
self.billing_code.setGeometry(QRect(0, height // 2 + 28, width, 40))
self.bottom_line.setGeometry(
QRect(width // 4, height // 2 + 75, width // 2, 1))
self.next_button.setGeometry(
QRect(width // 4, height * 3 // 4, width // 2, 50))
self.confetti_thread.update_dimensions(width, height)
def closeEvent(self, event):
self.confetti_thread.stop()
self.confetti_thread.wait()
super().closeEvent(event)
def on_next_button(self):
self.custom_window.navigator.navigate("menu")
def find_menu_page(self):
return self.custom_window.navigator.get_cached("menu")
def reverse(self):
self.custom_window.navigator.navigate("wireguard")