forked from Support/sp-hydra-veil-gui
105 lines
3.9 KiB
Python
Executable file
105 lines
3.9 KiB
Python
Executable file
import random
|
|
|
|
from PyQt6.QtWidgets import QHBoxLayout, QLabel, QPushButton, QVBoxLayout, QWidget
|
|
from PyQt6 import QtCore
|
|
|
|
from core.controllers.ProfileController import ProfileController
|
|
|
|
from gui.v2.ui.pages.Page import Page
|
|
|
|
|
|
class FastModePromptPage(Page):
|
|
def __init__(self, page_stack, main_window):
|
|
super().__init__("FastModePrompt", page_stack, main_window)
|
|
self.page_stack = page_stack
|
|
self.update_status = main_window
|
|
self.title.setGeometry(500, 40, 350, 40)
|
|
self.title.setText("Quick Setup Option")
|
|
self.button_back.setVisible(False)
|
|
self.button_apply.setVisible(False)
|
|
|
|
container = QWidget(self)
|
|
container.setGeometry(QtCore.QRect(80, 100, 640, 360))
|
|
v = QVBoxLayout(container)
|
|
v.setContentsMargins(0, 0, 0, 0)
|
|
v.setSpacing(20)
|
|
|
|
large_text = QLabel(
|
|
"Would you like to switch to convenient \"fast mode\" for profile creation going forward? (recommended)")
|
|
large_text.setWordWrap(True)
|
|
large_text.setStyleSheet("color: white; font-size: 18px;")
|
|
large_text.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
|
|
v.addWidget(large_text)
|
|
|
|
buttons_row = QWidget()
|
|
h = QHBoxLayout(buttons_row)
|
|
h.setContentsMargins(0, 0, 0, 0)
|
|
h.setSpacing(20)
|
|
|
|
yes_btn = QPushButton("Yes Fast Mode")
|
|
yes_btn.setCursor(QtCore.Qt.CursorShape.PointingHandCursor)
|
|
yes_btn.setFixedSize(240, 56)
|
|
yes_btn.setStyleSheet(
|
|
"background-color: #27ae60; color: white; font-weight: bold; font-size: 16px; border: none; border-radius: 6px;")
|
|
yes_btn.clicked.connect(self.choose_yes)
|
|
|
|
no_btn = QPushButton("No Keep This")
|
|
no_btn.setCursor(QtCore.Qt.CursorShape.PointingHandCursor)
|
|
no_btn.setFixedSize(160, 42)
|
|
no_btn.setStyleSheet(
|
|
"background-color: #c0392b; color: white; font-size: 14px; border: none; border-radius: 6px;")
|
|
no_btn.clicked.connect(self.choose_no)
|
|
|
|
h.addStretch()
|
|
h.addWidget(yes_btn)
|
|
h.addWidget(no_btn)
|
|
h.addStretch()
|
|
v.addWidget(buttons_row)
|
|
|
|
small_text = QLabel(
|
|
"You can toggle this anytime in the \"Options\" Menu, under \"Create/Edit\"")
|
|
small_text.setWordWrap(True)
|
|
small_text.setStyleSheet("color: #999999; font-size: 12px;")
|
|
small_text.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
|
|
v.addWidget(small_text)
|
|
|
|
def finalize(self):
|
|
self.update_status.mark_fast_mode_prompt_shown()
|
|
menu_page = self.custom_window.navigator.get_cached("menu")
|
|
if menu_page is not None and hasattr(menu_page, 'refresh_menu_buttons'):
|
|
menu_page.refresh_menu_buttons()
|
|
self.custom_window.navigator.navigate("menu")
|
|
|
|
def choose_yes(self):
|
|
self.update_status.set_fast_mode_enabled(True)
|
|
self.finalize()
|
|
|
|
def choose_no(self):
|
|
self.update_status.set_fast_mode_enabled(False)
|
|
self.finalize()
|
|
|
|
def initialize_default_selections(self):
|
|
if not self.selected_values['location']:
|
|
locations = self.connection_manager.get_location_list()
|
|
if locations:
|
|
random_index = random.randint(0, len(locations) - 1)
|
|
self.selected_values['location'] = locations[random_index]
|
|
|
|
if not self.selected_values['browser']:
|
|
browsers = self.connection_manager.get_browser_list()
|
|
if browsers:
|
|
random_index = random.randint(0, len(browsers) - 1)
|
|
self.selected_values['browser'] = browsers[random_index]
|
|
|
|
def get_next_available_profile_id(self) -> int:
|
|
profiles = ProfileController.get_all()
|
|
if not profiles:
|
|
return 1
|
|
|
|
existing_ids = sorted(profiles.keys())
|
|
|
|
for i in range(1, max(existing_ids) + 2):
|
|
if i not in existing_ids:
|
|
return i
|
|
|
|
return 1
|