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

122 lines
4 KiB
Python
Executable file

from PyQt6.QtWidgets import (
QWidget, QPushButton, QLabel, QFrame, QVBoxLayout, QHBoxLayout, QScrollArea
)
from PyQt6.QtGui import QFont
from PyQt6.QtCore import Qt, pyqtSignal
from gui.v2.ui.styles.styles import (
POPUP_BG_QSS,
POPUP_CANCEL_BUTTON_QSS,
POPUP_CLOSE_BUTTON_QSS,
)
class EndpointVerificationPopup(QWidget):
finished = pyqtSignal(bool, str)
def __init__(self, parent=None, message=""):
super().__init__(parent)
self.parent_window = parent
self.message = message
self.initUI()
def initUI(self):
self.setMinimumSize(500, 250)
self.setWindowFlags(Qt.WindowType.FramelessWindowHint)
self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
main_layout = QVBoxLayout()
self.setLayout(main_layout)
bg_widget = QWidget(self)
bg_widget.setStyleSheet(POPUP_BG_QSS)
main_layout.addWidget(bg_widget)
content_layout = QVBoxLayout(bg_widget)
close_button = QPushButton("", self)
close_button.setStyleSheet(POPUP_CLOSE_BUTTON_QSS)
close_button.setFixedSize(30, 30)
close_button.clicked.connect(lambda: self.close_with_action("abort"))
content_layout.addWidget(
close_button, alignment=Qt.AlignmentFlag.AlignRight)
scroll_area = QScrollArea()
scroll_area.setWidgetResizable(True)
scroll_area.setFrameShape(QFrame.Shape.NoFrame)
content_layout.addWidget(scroll_area)
scroll_content = QWidget()
scroll_layout = QVBoxLayout(scroll_content)
message_label = QLabel(self.message)
message_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
message_label.setFont(QFont("Arial", 14))
message_label.setStyleSheet("color: #333333; margin: 10px 0;")
message_label.setWordWrap(True)
scroll_layout.addWidget(message_label)
scroll_area.setWidget(scroll_content)
button_layout = QHBoxLayout()
content_layout.addLayout(button_layout)
sync_button = QPushButton("Sync")
sync_button.setFixedSize(120, 50)
sync_button.setFont(QFont("Arial", 12))
sync_button.setStyleSheet("""
QPushButton {
background-color: #4CAF50;
border: none;
color: white;
border-radius: 5px;
font-weight: bold;
}
QPushButton:hover {
background-color: #45a049;
}
""")
sync_button.clicked.connect(lambda: self.close_with_action("sync"))
button_layout.addWidget(sync_button)
abort_button = QPushButton("Abort")
abort_button.setFixedSize(120, 50)
abort_button.setFont(QFont("Arial", 12))
abort_button.setStyleSheet(POPUP_CANCEL_BUTTON_QSS)
abort_button.clicked.connect(lambda: self.close_with_action("abort"))
button_layout.addWidget(abort_button)
continue_button = QPushButton("Continue Anyway")
continue_button.setFixedSize(150, 50)
continue_button.setFont(QFont("Arial", 12))
continue_button.setStyleSheet("""
QPushButton {
background-color: #ff9800;
border: none;
color: white;
border-radius: 5px;
font-weight: bold;
}
QPushButton:hover {
background-color: #fb8c00;
}
""")
continue_button.clicked.connect(
lambda: self.close_with_action("continue"))
button_layout.addWidget(continue_button)
def close_with_action(self, action):
self.finished.emit(True, action)
self.close()
def closeEvent(self, event):
self.finished.emit(False, "abort")
event.accept()
def mousePressEvent(self, event):
self.oldPos = event.globalPosition().toPoint()
def mouseMoveEvent(self, event):
delta = event.globalPosition().toPoint() - self.oldPos
self.move(self.x() + delta.x(), self.y() + delta.y())
self.oldPos = event.globalPosition().toPoint()