hydraveil-gui/gui/v2/ui/popups/generic_choice.py

166 lines
5.2 KiB
Python
Executable file

import sys
from PyQt6.QtWidgets import QApplication, QDialog, QWidget, QVBoxLayout, QLabel, QPushButton
from PyQt6.QtCore import Qt
from PyQt6.QtGui import QFont, QColor
from PyQt6.QtWidgets import QGraphicsDropShadowEffect
class GenericOptionMenu(QDialog):
def __init__(self, title, option_one, option_two, option_three):
super().__init__()
self.selected_option = None
self.init_ui(title, option_one, option_two, option_three)
def init_ui(self, title, option_one, option_two, option_three):
self.setWindowTitle(title)
self.setGeometry(100, 100, 500, 600)
self.setModal(True)
# Main container
layout = QVBoxLayout(self)
layout.setSpacing(25)
layout.setContentsMargins(40, 50, 40, 50)
# Apply dark cyberpunk background
self.setStyleSheet("""
QDialog {
background-color: #0a0e27;
color: #00ff88;
}
""")
# Title Label
title_label = QLabel(title)
title_label.setFont(QFont("Courier New", 16, QFont.Weight.Bold))
title_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
title_label.setStyleSheet("""
QLabel {
color: #00ff88;
background-color: transparent;
padding: 20px;
border: 2px solid #00ff88;
border-radius: 5px;
letter-spacing: 2px;
}
""")
# Add glow effect to title
title_shadow = QGraphicsDropShadowEffect()
title_shadow.setBlurRadius(15)
title_shadow.setColor(QColor(0, 255, 136, 200))
title_shadow.setOffset(0, 0)
title_label.setGraphicsEffect(title_shadow)
layout.addWidget(title_label)
layout.addSpacing(30)
# Button 1
btn1 = self.create_button(option_one, 1)
layout.addWidget(btn1)
# Button 2
btn2 = self.create_button(option_two, 2)
layout.addWidget(btn2)
# Button 3
btn3 = self.create_button(option_three, 3)
layout.addWidget(btn3)
layout.addStretch()
# Status label
status_label = QLabel("▓░ READY FOR INPUT ░▓")
status_label.setFont(QFont("Courier New", 10))
status_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
status_label.setStyleSheet("""
QLabel {
color: #ff0088;
background-color: transparent;
padding: 10px;
letter-spacing: 1px;
}
""")
layout.addWidget(status_label)
def create_button(self, text, button_num):
button = QPushButton(text)
button.setFont(QFont("Courier New", 12, QFont.Weight.Bold))
button.setMinimumHeight(60)
button.setCursor(Qt.CursorShape.PointingHandCursor)
# Color variations for each button
if button_num == 1:
neon_color = "#00ff88" # Cyan green
rgb_color = QColor(0, 255, 136)
elif button_num == 2:
neon_color = "#00d4ff" # Cyan blue
rgb_color = QColor(0, 212, 255)
else:
neon_color = "#ff0088" # Magenta
rgb_color = QColor(255, 0, 136)
button.setStyleSheet(f"""
QPushButton {{
background-color: #1a1f3a;
color: {neon_color};
border: 2px solid {neon_color};
border-radius: 8px;
padding: 10px 20px;
font-weight: bold;
letter-spacing: 2px;
}}
QPushButton:hover {{
background-color: {neon_color};
color: #0a0e27;
border: 2px solid {neon_color};
}}
QPushButton:pressed {{
background-color: #0a0e27;
border: 3px solid {neon_color};
}}
""")
# Add drop shadow glow effect
shadow = QGraphicsDropShadowEffect()
shadow.setBlurRadius(20)
shadow.setColor(rgb_color)
shadow.setOffset(0, 0)
button.setGraphicsEffect(shadow)
button.clicked.connect(lambda: self.on_button_clicked(button_num))
return button
def on_button_clicked(self, button_num):
self.selected_option = button_num
self.accept()
# prior version as standalone helper:
# def show_generic_options(
# app: QApplication,
# title: str,
# option_one: str,
# option_two: str,
# option_three: str
# ) -> int:
# # app = QApplication(sys.argv)
# # Create the menu with custom title and options
# menu = GenericOptionMenu(
# title=title,
# option_one=option_one,
# option_two=option_two,
# option_three=option_three
# )
# # Show the menu and get the result
# result = menu.show()
# if result == QDialog.DialogCode.Accepted:
# print(f"User selected option: {menu.selected_option}")
# return menu.selected_option
# else:
# print("User cancelled")
# return None
# sys.exit(0)