forked from Support/sp-hydra-veil-gui
Profile Creation Updates. Changes in Type update Protocol in Fast Registration. Also the menu page refreshes by a notification signal.
This commit is contained in:
parent
373253fa22
commit
330fabfcb4
4 changed files with 47 additions and 12 deletions
|
|
@ -337,8 +337,8 @@ def disconnect_active(ui_caller: Callable) -> Result:
|
|||
system_disconnected = literally_disconnect(system_profile_id)
|
||||
if not system_disconnected.valid:
|
||||
error_msg = f'Could not disconnect systemwide profile {system_profile_id}. Exit canceled.'
|
||||
disconnected.message = error_msg
|
||||
return disconnected
|
||||
system_disconnected.message = error_msg
|
||||
return system_disconnected
|
||||
|
||||
ui_caller(Result(valid=True))
|
||||
|
||||
|
|
|
|||
14
gui/v2/actions/profile_actions.py
Normal file
14
gui/v2/actions/profile_actions.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from core.controllers.ProfileController import ProfileController
|
||||
from gui.v2.infrastructure.take_plumbing_action import take_action
|
||||
from gui.v2.infrastructure.setup_observers import profile_observer
|
||||
|
||||
from typing import Callable
|
||||
|
||||
def create_profile(potential_data: dict, ui_caller: Callable):
|
||||
"""Pass the data through the plumbing, to the controller to create a profile."""
|
||||
take_action(
|
||||
action=ProfileController.create,
|
||||
ui_caller=ui_caller,
|
||||
potential_data=potential_data,
|
||||
profile_observer=profile_observer
|
||||
)
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
|
||||
from core.models.Result import Result
|
||||
|
||||
from gui.v2.actions.profile_actions import create_profile
|
||||
from gui.v2.presenters.state.fast_registration_state import RegistrationState
|
||||
from gui.v2.ui.styles.css.fast_register import ENTER_NAME_TEXT, NAME_TEXT_STYLE, GROUP_TITLE_LABEL, DISPLAY_BOX_STYLE
|
||||
from gui.v2.ui.pages.Page import Page
|
||||
|
|
@ -10,6 +14,7 @@ from PyQt6.QtGui import QPixmap
|
|||
from PyQt6.QtCore import Qt, pyqtSignal
|
||||
|
||||
class TextInputGroup(QWidget):
|
||||
"""Create Text Input Boxes of a particular style"""
|
||||
def __init__(self, parent, title, category, state):
|
||||
super().__init__(parent)
|
||||
self.category = category
|
||||
|
|
@ -44,7 +49,7 @@ class TextInputGroup(QWidget):
|
|||
self.text_input.setStyleSheet(ENTER_NAME_TEXT)
|
||||
|
||||
# Update state in real-time as user types
|
||||
self.text_input.textChanged.connect(self.update_state)
|
||||
# self.text_input.textChanged.connect(self.update_state)
|
||||
|
||||
self.row_layout.addWidget(self.text_input)
|
||||
|
||||
|
|
@ -53,13 +58,14 @@ class TextInputGroup(QWidget):
|
|||
|
||||
self.main_layout.addLayout(self.row_layout)
|
||||
|
||||
def update_state(self, text):
|
||||
if hasattr(self.state, 'set_value'):
|
||||
self.state.set_value(self.category, text)
|
||||
# def update_state(self, text):
|
||||
# if hasattr(self.state, 'set_value'):
|
||||
# self.state.set_value(self.category, text)
|
||||
|
||||
class SelectionGroup(QWidget):
|
||||
# Define a signal that tells the world this widget's value changed
|
||||
valueChanged = pyqtSignal(str) # Pass the category name
|
||||
"""Create Image/Value Select Boxes of a particular style"""
|
||||
|
||||
valueChanged = pyqtSignal(str)
|
||||
|
||||
def __init__(self, parent, title, category, state):
|
||||
super().__init__(parent)
|
||||
|
|
@ -67,7 +73,7 @@ class SelectionGroup(QWidget):
|
|||
self.state = state
|
||||
|
||||
# Ensure the group widget itself is wide enough to hold the layout
|
||||
# (30px prev + 185px box + 30px next + spacing)
|
||||
# (Legacy specs were: 30px prev + 185px box + 30px next + spacing)
|
||||
self.setMinimumWidth(260)
|
||||
|
||||
self.main_layout = QVBoxLayout(self)
|
||||
|
|
@ -134,7 +140,7 @@ class SelectionGroup(QWidget):
|
|||
if pixmap.isNull():
|
||||
return
|
||||
|
||||
# 2. Apply the scaling logic we built in the previous step
|
||||
# 2. Apply the scaling logic, built in the previous step
|
||||
box_width = self.display_box.width()
|
||||
box_height = self.display_box.height()
|
||||
|
||||
|
|
@ -182,7 +188,7 @@ class FastRegistrationPage(Page):
|
|||
self.group_browser = SelectionGroup(self.content_area, "Browser", "Browser", self.state)
|
||||
self.group_res = SelectionGroup(self.content_area, "Resolution", "Resolution", self.state)
|
||||
|
||||
# Connect the signal: When Type changes, tell Protocol to refresh
|
||||
# Connect the signal: When Type changes, tell other groups (such as Protocol) to refresh
|
||||
self.group_type.valueChanged.connect(self.handle_type_change)
|
||||
|
||||
self.grid.addWidget(self.group_type, 0, 0, Qt.AlignmentFlag.AlignTop)
|
||||
|
|
@ -199,8 +205,21 @@ class FastRegistrationPage(Page):
|
|||
# Protocol is affected by Type
|
||||
self.group_proto.update_display()
|
||||
|
||||
|
||||
def after_submission(self, result: Result):
|
||||
"""Navigate to the homepage after the completion of the registration"""
|
||||
if result.valid:
|
||||
self.custom_window.navigator.navigate("menu")
|
||||
|
||||
def submit_registration(self):
|
||||
"""Get current choices from state, and submit."""
|
||||
final_choices = self.state.get_final_choices()
|
||||
print(f"Submitting choices: {final_choices}")
|
||||
input_text = self.group_name.text_input.text()
|
||||
|
||||
if not input_text:
|
||||
self.show_a_popup("Pick a name in the top right box.")
|
||||
return
|
||||
|
||||
final_choices["Name"] = input_text
|
||||
print(f"Submitting choices: {final_choices}")
|
||||
create_profile(potential_data=final_choices, ui_caller=self.after_submission)
|
||||
|
|
@ -225,6 +225,7 @@ class MenuPage(Page):
|
|||
print("refresh_profiles_data triggered")
|
||||
self.refresh_menu_buttons()
|
||||
|
||||
@mainthread
|
||||
def refresh_menu_buttons(self, state_change=None):
|
||||
|
||||
print("refresh_menu_buttons triggered")
|
||||
|
|
@ -895,6 +896,7 @@ class MenuPage(Page):
|
|||
Notifications.subscribe(EventType.SYSTEM_DISABLE, self.turn_off_system_visuals)
|
||||
Notifications.subscribe(EventType.RESUME_ACTIONS, self.trigger_action_button_visuals)
|
||||
Notifications.subscribe(EventType.SHOW_POPUP, self.show_a_popup)
|
||||
Notifications.subscribe(EventType.PROFILES_CHANGED, self.refresh_menu_buttons)
|
||||
|
||||
take_action(
|
||||
action=evaluate_state_on_startup,
|
||||
|
|
|
|||
Loading…
Reference in a new issue