forked from Support/sp-hydra-veil-gui
Operator display data logic is moved to isolated helper functions
This commit is contained in:
parent
49d4bdc87b
commit
17341a4dc7
3 changed files with 43 additions and 21 deletions
|
|
@ -198,3 +198,32 @@ def convert_to_dto(raw_dict: dict) -> ProfileDto:
|
|||
needs_warning=needs_warning
|
||||
)
|
||||
|
||||
|
||||
####################################################
|
||||
### Above this line is the creation of the DTO
|
||||
|
||||
### Below is the use of the DTO in the display
|
||||
|
||||
|
||||
def get_display_text(dto: RenderProfileDto) -> tuple:
|
||||
"""Create the display text for when a profile is selected on the menu page."""
|
||||
location_text = dto.location_text
|
||||
operator_name = dto.operator_name
|
||||
nostr_public_key = dto.nostr_public_key
|
||||
needs_warning = dto.needs_warning
|
||||
|
||||
if needs_warning:
|
||||
top_text = "Upgrade browser!"
|
||||
bottom_text = "Go to Edit Profile, and Pick a New Browser."
|
||||
else:
|
||||
top_text = f"Location: {location_text}\n\nOperator: {operator_name}"
|
||||
bottom_text = f"Nostr: {nostr_public_key}"
|
||||
|
||||
return top_text, bottom_text
|
||||
|
||||
|
||||
def get_display_color(dto: RenderProfileDto) -> str:
|
||||
"""Pick the display color, based on the profile type, from the DTO"""
|
||||
profile_type = dto.profile_type
|
||||
color = "black" if profile_type == ProfileType.SESSION else "white"
|
||||
return color
|
||||
|
|
@ -34,7 +34,7 @@ from gui.v2.actions.menu_results import MenuResult
|
|||
from gui.v2.ui.pages.Page import Page
|
||||
from gui.v2.ui.pages.location_verification_page import LocationVerificationPage
|
||||
from gui.v2.ui.styles.styles import SCROLLBAR_CYAN_QSS
|
||||
from gui.v2.ui.styles.css.menu_css import CREATE_BUTTON_STYLE, verification_style_one, VERIFICATION_STYLE_TWO
|
||||
from gui.v2.ui.styles.css.menu_css import CREATE_BUTTON_STYLE, verification_style_one, VERIFICATION_STYLE_TWO, left_panel_profile_style, check_mark_style
|
||||
from gui.v2.ui.popups.confirmation_popup import ConfirmationPopup
|
||||
from gui.v2.ui.popups.endpoint_verification_popup import EndpointVerificationPopup
|
||||
from gui.v2.ui.popups.ticket_data_loss_popup import TicketDataLossPopup
|
||||
|
|
@ -43,7 +43,7 @@ from gui.v2.infrastructure.setup_observers import (
|
|||
application_version_observer, connection_observer,
|
||||
profile_observer
|
||||
)
|
||||
from gui.v2.presenters.data.profile_data import ProfileDto, RenderProfileDto, convert_one_render_dto
|
||||
from gui.v2.presenters.data.profile_data import ProfileDto, RenderProfileDto, convert_one_render_dto, get_display_text, get_display_color
|
||||
|
||||
from gui.v2.infrastructure.thread_singleton import get_main_thread_dispatcher
|
||||
mainthread = get_main_thread_dispatcher()
|
||||
|
|
@ -438,8 +438,7 @@ class MenuPage(Page):
|
|||
container_layout.addWidget(value_widget, 1)
|
||||
|
||||
checkmark_widget = QLabel("✓")
|
||||
checkmark_widget.setStyleSheet(
|
||||
f"color: #4CAF50; font-size: 20px; font-weight: bold; {self.font_style}")
|
||||
checkmark_widget.setStyleSheet(check_mark_style(self.font_style))
|
||||
checkmark_widget.setFixedSize(20, 20)
|
||||
checkmark_widget.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
checkmark_widget.setVisible(bool(value and value != "N/A"))
|
||||
|
|
@ -541,22 +540,9 @@ class MenuPage(Page):
|
|||
|
||||
def _render_operator_details(self, dto: RenderProfileDto):
|
||||
"""Create the left display for the profile, based on the DTO data"""
|
||||
profile_type = dto.profile_type
|
||||
location_text = dto.location_text
|
||||
operator_name = dto.operator_name
|
||||
nostr_public_key = dto.nostr_public_key
|
||||
detail_image = dto.detail_image
|
||||
needs_warning = dto.needs_warning
|
||||
|
||||
if needs_warning:
|
||||
top_text = "Upgrade browser!"
|
||||
bottom_text = "Go to Edit Profile, and Pick a New Browser."
|
||||
else:
|
||||
top_text = f"Location: {location_text}\n\nOperator: {operator_name}"
|
||||
bottom_text = f"Nostr: {nostr_public_key}"
|
||||
|
||||
|
||||
color = "black" if profile_type == ProfileType.SESSION else "white"
|
||||
top_text, bottom_text = get_display_text(dto)
|
||||
color = get_display_color(dto)
|
||||
|
||||
self._detail_image(detail_image, (20, 125, 100, 100))
|
||||
text_blocks = [
|
||||
|
|
@ -569,7 +555,7 @@ class MenuPage(Page):
|
|||
widget.setGeometry(*geometry)
|
||||
widget.setReadOnly(True)
|
||||
widget.setFrameStyle(QFrame.Shape.NoFrame)
|
||||
widget.setStyleSheet(f"background: transparent; border: none; color: {color}; font-size: 17px;")
|
||||
widget.setStyleSheet(left_panel_profile_style(color))
|
||||
widget.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
|
||||
widget.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
|
||||
widget.setWordWrapMode(wrapping)
|
||||
|
|
|
|||
|
|
@ -37,4 +37,11 @@ VERIFICATION_STYLE_TWO = f"""
|
|||
background: rgba(255, 255, 255, 0.1);
|
||||
border-radius: 4px;
|
||||
}}
|
||||
"""
|
||||
"""
|
||||
|
||||
def left_panel_profile_style(color: str) -> str:
|
||||
return f"background: transparent; border: none; color: {color}; font-size: 17px;"
|
||||
|
||||
|
||||
def check_mark_style(font_style: str) -> str:
|
||||
return f"color: #4CAF50; font-size: 20px; font-weight: bold; {font_style}"
|
||||
|
|
|
|||
Loading…
Reference in a new issue