From fb477baa4b9458635435de7a89005dd6d828f498 Mon Sep 17 00:00:00 2001 From: SimplifiedPrivacy Date: Sat, 7 Nov 2026 20:29:01 -0500 Subject: [PATCH] Remake of Editor page, using the same elements as Creation page --- gui/v2/infrastructure/navigator.py | 13 +- gui/v2/infrastructure/page_registry.py | 8 +- .../image_tools/arrow_presenters.py | 68 +++++ gui/v2/presenters/state/arrow_sync_state.py | 17 ++ .../state/fast_registration_state.py | 81 ++++-- gui/v2/ui/pages/create_edit/components.py | 176 ++++++++++++ gui/v2/ui/pages/create_edit/edit_page.py | 146 ++++++++++ .../ui/pages/create_edit/fast_create_page.py | 115 ++++++++ .../resolution_widget.py | 0 gui/v2/ui/pages/editor_page.py | 85 +++--- gui/v2/ui/pages/fast7b.py | 251 ------------------ gui/v2/ui/pages/menu_page.py | 7 +- gui/v2/ui/styles/css/editor_css.py | 34 +++ 13 files changed, 684 insertions(+), 317 deletions(-) create mode 100644 gui/v2/presenters/image_tools/arrow_presenters.py create mode 100644 gui/v2/presenters/state/arrow_sync_state.py create mode 100644 gui/v2/ui/pages/create_edit/components.py create mode 100644 gui/v2/ui/pages/create_edit/edit_page.py create mode 100644 gui/v2/ui/pages/create_edit/fast_create_page.py rename gui/v2/ui/pages/{profile_creation => create_edit}/resolution_widget.py (100%) delete mode 100644 gui/v2/ui/pages/fast7b.py create mode 100644 gui/v2/ui/styles/css/editor_css.py diff --git a/gui/v2/infrastructure/navigator.py b/gui/v2/infrastructure/navigator.py index 6a6aad2..e8cb9b9 100755 --- a/gui/v2/infrastructure/navigator.py +++ b/gui/v2/infrastructure/navigator.py @@ -14,7 +14,6 @@ from gui.v2.infrastructure.page_registry import ( from gui.v2.workers.page_data_worker import PageDataWorker from gui.v2.actions.flags import is_fast_registration_enabled from core.errors.logger import logger -# from core.errors.logger import logger as core_logger class Navigator(QObject): @@ -58,15 +57,25 @@ class Navigator(QObject): self.page_stack.addWidget(page) self._instances[name] = page - def navigate(self, name): + def navigate(self, name, profile_id = None): page = self._instances.get(name) + if page is None: if name not in PAGE_REGISTRY: self._warn_not_migrated(name) return None page = self._instantiate(name) self.register_instance(name, page) + + # Inject variables directly into the object + if profile_id is not None: + logger.info(f"Navigator is setting profile_id data of {profile_id}") + page.profile_id = profile_id + + + # Make it visible: self.page_stack.setCurrentIndex(self.page_stack.indexOf(page)) + return page def get_cached(self, name): diff --git a/gui/v2/infrastructure/page_registry.py b/gui/v2/infrastructure/page_registry.py index f353fe5..bb7134a 100755 --- a/gui/v2/infrastructure/page_registry.py +++ b/gui/v2/infrastructure/page_registry.py @@ -12,7 +12,7 @@ PAGE_REGISTRY = { "screen": ("gui.v2.ui.pages.screen_page", "ScreenPage"), "resume": ("gui.v2.ui.pages.resume_page", "ResumePage"), "browser": ("gui.v2.ui.pages.browser_page", "BrowserPage"), - "editor": ("gui.v2.ui.pages.editor_page", "EditorPage"), + "editor": ("gui.v2.ui.pages.create_edit.edit_page", "EditPage"), "install_system_package": ("gui.v2.ui.pages.install_system_package", "InstallSystemPackage"), "wireguard": ("gui.v2.ui.pages.wireguard_page", "WireGuardPage"), "sync_screen": ("gui.v2.ui.pages.sync_screen", "SyncScreen"), @@ -28,7 +28,7 @@ PAGE_REGISTRY = { "ticket_crypto_picker": ("gui.v2.ui.pages.ticket_crypto_picker_page", "TicketCryptoPickerPage"), "ticket_prep": ("gui.v2.ui.pages.ticket_prep_page", "TicketPrepPage"), "ticket_or_billing_choice": ("gui.v2.ui.pages.ticket_or_billing_choice_page", "TicketOrBillingChoicePage"), - "fast_registration": ("gui.v2.ui.pages.fast7b", "FastRegistrationPage"), + "fast_registration": ("gui.v2.ui.pages.create_edit.fast_create_page", "FastRegistrationPage"), "fast_mode_prompt": ("gui.v2.ui.pages.fast_mode_prompt_page", "FastModePromptPage"), } @@ -41,7 +41,7 @@ PRELOAD_SKIP = { ASYNC_PREPARE = { "settings", - "editor", + # "editor", } # "fast_registration", @@ -62,7 +62,7 @@ REGULAR_FLOW_ONLY = { PRELOAD_ORDER = [ "settings", - "editor", + # "editor", "plan_picker", "ticket_crypto_picker", "policy_suggestion", diff --git a/gui/v2/presenters/image_tools/arrow_presenters.py b/gui/v2/presenters/image_tools/arrow_presenters.py new file mode 100644 index 0000000..9972a33 --- /dev/null +++ b/gui/v2/presenters/image_tools/arrow_presenters.py @@ -0,0 +1,68 @@ +from gui.v2.ui.styles.css.editor_css import PRE_SYNC_LAYOUT + +from PyQt6.QtCore import Qt, QSize, QPointF +from PyQt6.QtGui import QPixmap, QPainter, QPen, QColor, QIcon, QPolygonF + + +def apply_arrow_images(button, button_path: str, direction: str = "left"): + """Place an arrow image on the button""" + # 1. Set the image + button_path = f"{button_path}/{direction}.png" + button.setIcon(QIcon(button_path)) + + # 2. general sizing + button.setIconSize(QSize(64, 64)) + + # 3. Set button size to fit the image + button.setFixedSize(64, 64) + + +def apply_green_glow(button, direction: str = "left", set_size: bool = True): + """Create a green triangle effect on the button""" + if set_size: + button.setFixedSize(60, 60) + + # Get current dimensions of the button + w = button.width() + h = button.height() + + # If the button hasn't been rendered yet, width/height might be 0. + # We provide a fallback size to prevent the code from crashing. + if w <= 0 or h <= 0: + w, h = 60, 60 + + # Create the transparent canvas + outline_pix = QPixmap(w, h) + outline_pix.fill(Qt.GlobalColor.transparent) + + painter = QPainter(outline_pix) + painter.setRenderHint(QPainter.RenderHint.Antialiasing) + + # Set up the green pen + pen = QPen(QColor(0, 255, 0)) + pen.setWidth(3) + painter.setPen(pen) + painter.setBrush(Qt.BrushStyle.NoBrush) + + # Define points based on direction + if direction == "left": + points = [ + QPointF(w * 0.65, h * 0.15), + QPointF(w * 0.25, h * 0.50), + QPointF(w * 0.65, h * 0.85) + ] + else: # Right arrow + points = [ + QPointF(w * 0.35, h * 0.15), + QPointF(w * 0.75, h * 0.50), + QPointF(w * 0.35, h * 0.85) + ] + + painter.drawPolygon(QPolygonF(points)) + painter.end() + + # Apply the drawing to the button + button.setIcon(QIcon(outline_pix)) + button.setIconSize(button.size()) + button.setStyleSheet(PRE_SYNC_LAYOUT) + diff --git a/gui/v2/presenters/state/arrow_sync_state.py b/gui/v2/presenters/state/arrow_sync_state.py new file mode 100644 index 0000000..714c749 --- /dev/null +++ b/gui/v2/presenters/state/arrow_sync_state.py @@ -0,0 +1,17 @@ +from core.infrastructure.state_management.global_state_controller import is_synced +from gui.v2.presenters.image_tools.arrow_presenters import apply_green_glow, apply_arrow_images + +from PyQt6.QtWidgets import QPushButton +from typing import Callable + +def apply_arrow_state(sync_required: bool, button: QPushButton, direction: str, button_path: str): + if not sync_required: + apply_arrow_images(button=button, button_path=button_path, direction=direction) + return + + if is_synced(): + apply_arrow_images(button=button, button_path=button_path, direction=direction) + return + + apply_green_glow(button=button, direction=direction) + diff --git a/gui/v2/presenters/state/fast_registration_state.py b/gui/v2/presenters/state/fast_registration_state.py index e044121..2f57f49 100644 --- a/gui/v2/presenters/state/fast_registration_state.py +++ b/gui/v2/presenters/state/fast_registration_state.py @@ -1,3 +1,4 @@ +from core.controllers.ProfileController import ProfileController from core.services.profiles.attribute_filters import protocol_matches_profile_type, app_or_display_matches_profile_type from core.controllers.profile_state.data_filters import protocol_is_supported_for_location from gui.v2.presenters.data.location_data import get_location_display_data @@ -6,54 +7,81 @@ from gui.v2.presenters.data.protocol_data import get_protocol_button_data from gui.v2.presenters.data.resolution_data import get_resolution_data, validate_selected_resolution from gui.v2.presenters.data.type_data import get_profile_type_data from gui.v2.presenters.image_tools.button_factory import create_button_image, create_resolution_button_image, blank_button +from core.errors.logger import logger from pathlib import Path +from typing import Optional class RegistrationState: - def __init__(self, btn_path): + def __init__(self, btn_path, profile_id: Optional[int] = None): self.btn_path = btn_path self.all_options = {} self.selections = {} self.order_map = {} self.pixmap_cache = {} + self.profile_id = profile_id # Maps a category to the function that validates its current selection. self._filter_map = { - "Protocol": self.is_protocol_valid, - "Browser": self.is_app_valid, - "Resolution": self.is_resolution_valid, + "protocol": self.is_protocol_valid, + "browser": self.is_app_valid, + "resolution": self.is_resolution_valid, } # Maps a "Trigger" category to the categories it affects. self._dependency_map = { - "Type": ["Protocol", "Browser", "Resolution"], - "Location": ["Protocol"], + "type": ["protocol", "browser", "resolution"], + "location": ["protocol"], } # Callbacks to notify the UI. Store functions here: { "Category": callback_func } self.listeners = {} - self._load_all_data() + # Gets this profile's available data: + if self.profile_id is not None: + logger.info(f"RegistrationState got a profile id of {self.profile_id}") + default_data = ProfileController.get_default_state_dict(profile_id) + else: + default_data = None + + # Gets ALL available data: + self._load_all_data(default_data) + def register_listener(self, category, callback): """UI elements call this to be notified when their category changes.""" self.listeners[category] = callback - def _load_all_data(self): + + def _no_premade_choices(self, category: str, default_data: Optional[dict]): + """For categories without premade choices, we see if default data is available. If not, then it's None""" + if default_data: + self.selections[category] = default_data.get(category) + else: + self.selections[category] = None + + + def _load_all_data(self, default_data: Optional[dict] = None): """Load the data for a given category, and then register that data""" load_config = { - "Type": (get_profile_type_data, 0), - "Protocol": (get_protocol_button_data, 0), - "Resolution": (get_resolution_data, 0), - "Location": (get_location_display_data, 0), - "Browser": (get_app_display_data, 0), + "type": (get_profile_type_data, 0), + "protocol": (get_protocol_button_data, 0), + "resolution": (get_resolution_data, 0), + "location": (get_location_display_data, 0), + "browser": (get_app_display_data, 0), + "name": (None, None) } for category, (loader_func, default_idx) in load_config.items(): - data = loader_func(self.btn_path) - self._register_category(category, data, default_idx) + if loader_func is None: + self._no_premade_choices(category=category, default_data=default_data) + continue - def _register_category(self, category, data, default_idx=0): + data = loader_func(self.btn_path) + self._register_category(category=category, data=data, default_data=default_data, default_idx=default_idx) + + + def _register_category(self, category: str, data: dict, default_data: Optional[dict], default_idx: int = 0): """Setup a category with a given data set and default index""" if isinstance(data, list): data = {item: item for item in data} @@ -61,8 +89,14 @@ class RegistrationState: self.order_map[category] = list(data.keys()) # Default selection logic - ids = self.order_map[category] - self.selections[category] = ids[default_idx] if ids and default_idx < len(ids) else (ids[0] if ids else None) + if default_data is not None: + # If default_data is provided, we use it exclusively. + # .get() returns None if the category key is missing. + self.selections[category] = default_data.get(category) + else: + # Fall back to index-based selection only if default_data was not provided. + ids = self.order_map[category] + self.selections[category] = ids[default_idx] if ids and default_idx < len(ids) else (ids[0] if ids else None) def _ensure_valid(self, category): @@ -132,6 +166,7 @@ class RegistrationState: """Returns an image or a path to one depending on the category and data format""" current_id = self.selections.get(category) + if current_id is None: return blank_button(self.btn_path) @@ -142,7 +177,7 @@ class RegistrationState: # 1. HANDLE DYNAMIC CATEGORIES FIRST # These categories build images from the ID itself and don't need a lookup table - if category == "Resolution": + if category == "resolution": res_img = create_resolution_button_image( btn_path=f"{self.btn_path}/resolution_template.png", resolution_text=str(current_id) @@ -178,13 +213,13 @@ class RegistrationState: # Validation logic, used by the generic _ensure_valid def is_app_valid(self, app_choice): - current_type = self.selections.get("Type") + current_type = self.selections.get("type") return app_or_display_matches_profile_type(app_choice=app_choice, profile_type=current_type) def is_protocol_valid(self, protocol_id): """Checks if a protocol is valid by the other choices of type and location.""" - current_type = self.selections.get("Type") - current_location = self.selections.get("Location") + current_type = self.selections.get("type") + current_location = self.selections.get("location") if not protocol_matches_profile_type(protocol=protocol_id, profile_type=current_type): return False @@ -192,7 +227,7 @@ class RegistrationState: return protocol_is_supported_for_location(location_id=current_location, protocol_choice=protocol_id) def is_resolution_valid(self, resolution_choice): - current_type = self.selections.get("Type") + current_type = self.selections.get("type") # same criteria as app: if not app_or_display_matches_profile_type(app_choice=resolution_choice, profile_type=current_type): diff --git a/gui/v2/ui/pages/create_edit/components.py b/gui/v2/ui/pages/create_edit/components.py new file mode 100644 index 0000000..7276bc7 --- /dev/null +++ b/gui/v2/ui/pages/create_edit/components.py @@ -0,0 +1,176 @@ +from core.infrastructure.state_management.global_state_controller import is_synced +from gui.v2.actions.menu_coordinator import sync_now +from core.models.Result import Result +from gui.v2.presenters.state.arrow_sync_state import apply_arrow_state +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.styles.css.editor_css import PRE_SYNC_LAYOUT + +from pathlib import Path + +from PyQt6 import QtCore +from PyQt6.QtWidgets import QWidget, QLabel, QPushButton, QVBoxLayout, QHBoxLayout, QSizePolicy, QLineEdit +from PyQt6.QtGui import QPixmap +from PyQt6.QtCore import Qt +from PyQt6.QtGui import QIcon +from PyQt6.QtCore import QSize + + +class TextInputGroup(QWidget): + """Create Text Input Boxes of a particular style""" + def __init__(self, parent, title, category, state): + super().__init__(parent) + self.category = category + self.state = state + + # Match the width of the SelectionGroup + self.setMinimumWidth(260) + + self.main_layout = QVBoxLayout(self) + self.main_layout.setContentsMargins(0, 0, 0, 0) + self.main_layout.setSpacing(5) + self.main_layout.setAlignment(Qt.AlignmentFlag.AlignTop) + + # Same title style as SelectionGroup + self.title_label = QLabel(title) + self.title_label.setStyleSheet(NAME_TEXT_STYLE) + self.main_layout.addWidget(self.title_label) + + # Row layout to hold the input field + self.row_layout = QHBoxLayout() + self.row_layout.setSpacing(10) + + self.text_input = QLineEdit() + + # Match the display_box styling + self.text_input.setFixedSize(240, 35) # Slightly shorter than the image box for better text look + self.text_input.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed) + self.text_input.setStyleSheet(ENTER_NAME_TEXT) + + self.row_layout.addWidget(self.text_input) + + # Center the input field within the row layout + self.row_layout.setAlignment(Qt.AlignmentFlag.AlignCenter) + + self.main_layout.addLayout(self.row_layout) + + # DEFAULT OPTIONS: + current_state = self.state.get_final_choices() + if current_state[category] is not None: + self.text_input.setText(current_state[category]) + + + +class SelectionGroup(QWidget): + def __init__(self, parent, title, category, state, sync_required: bool = False, btn_path = None): + super().__init__(parent) + self.category = category + self.state = state + self.btn_path = btn_path + self.sync_required = sync_required + + # Tell the state: "When this category changes, run my update_display method" + self.state.register_listener(category, self.update_display) + + self.main_layout = QVBoxLayout(self) + self.main_layout.setContentsMargins(0, 0, 0, 0) + self.main_layout.setSpacing(5) + self.main_layout.setAlignment(Qt.AlignmentFlag.AlignTop) + + self.title_label = QLabel(title) + self.title_label.setStyleSheet(GROUP_TITLE_LABEL) + self.main_layout.addWidget(self.title_label) + + self.row_layout = QHBoxLayout() + self.row_layout.setSpacing(10) + + self.btn_prev = QPushButton() + self.btn_prev.clicked.connect(lambda: self.sync_or_continue(-1)) + + self.display_box = QLabel() + self.display_box.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) + self.display_box.setFixedSize(185, 75) + self.display_box.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed) + self.display_box.setStyleSheet(DISPLAY_BOX_STYLE) + + self.btn_next = QPushButton() + self.btn_next.clicked.connect(lambda: self.sync_or_continue(1)) + + self.apply_styles_to_buttons(sync_required=self.sync_required) + + # These stretchers force buttons to the edges and image to the center + self.row_layout.addWidget(self.btn_prev) + self.row_layout.addStretch(1) + self.row_layout.addWidget(self.display_box) + self.row_layout.addStretch(1) + self.row_layout.addWidget(self.btn_next) + + self.main_layout.addLayout(self.row_layout) + + self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Preferred) + self.setMinimumHeight(110) + + + def showEvent(self, event): + super().showEvent(event) + self.update_display() + + def apply_styles_to_buttons(self, sync_required: bool): + buttons = { + self.btn_next: "right", + self.btn_prev: "left" + } + for each_button in buttons: + apply_arrow_state(sync_required=sync_required, button=each_button, direction=buttons[each_button], button_path=self.btn_path) + + def after_sync(self, result: Result): + if result.valid: + self.apply_styles_to_buttons(sync_required=False) + + def sync_or_continue(self, direction: int): + if not self.sync_required: + self.change_image(direction) + return + + is_it_synced = is_synced() + if is_it_synced: + self.change_image(direction) + else: + sync_now(ui_caller=self.after_sync) + + + def change_image(self, direction): + """Toggle the next image change by category and direction""" + self.state.cycle_selection(self.category, direction) + + def update_display(self): + """Get and Change the currently displayed image. This function is passed as a callback to the state""" + path = self.state.get_current_image(self.category) + self.set_image(path) + + + def set_image(self, image_source): + # 1. Convert source to QPixmap regardless of what it is + if isinstance(image_source, Path): + pixmap = QPixmap(str(image_source)) + elif isinstance(image_source, QPixmap): + pixmap = image_source + else: + return + + if pixmap.isNull(): + return + + # 2. Apply the scaling logic, built in the previous step + box_width = self.display_box.width() + box_height = self.display_box.height() + + if pixmap.width() > box_width or pixmap.height() > box_height: + scaled_pixmap = pixmap.scaled( + box_width, + box_height, + QtCore.Qt.AspectRatioMode.KeepAspectRatio, + QtCore.Qt.TransformationMode.SmoothTransformation + ) + self.display_box.setPixmap(scaled_pixmap) + else: + self.display_box.setPixmap(pixmap) diff --git a/gui/v2/ui/pages/create_edit/edit_page.py b/gui/v2/ui/pages/create_edit/edit_page.py new file mode 100644 index 0000000..400b70b --- /dev/null +++ b/gui/v2/ui/pages/create_edit/edit_page.py @@ -0,0 +1,146 @@ +from core.observers.Notifications import Notifications, EventType +from core.models.Result import Result +from core.errors.logger import logger + +from gui.v2.ui.pages.create_edit.components import SelectionGroup, TextInputGroup +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 FAST_REGISTER_ONE, FAST_REGISTER_TWO +from gui.v2.ui.pages.Page import Page +from gui.v2.ui.pages.create_edit.resolution_widget import CustomResolutionDialog + +from PyQt6.QtWidgets import QWidget, QPushButton, QGridLayout, QVBoxLayout +from PyQt6.QtCore import Qt + +from typing import Optional + + +class EditPage(Page): + def __init__(self, page_stack, main_window, prepared=None, profile_id: Optional[int] = None): + super().__init__("EditPage", page_stack, main_window) + + # Navigator passes in profile id: + self.profile_id = profile_id + + self.content_area = QWidget() + + self.setFixedSize(800, 600) + + self.main_layout = QVBoxLayout(self) + self.main_layout.setContentsMargins(40, 60, 40, 60) + + # Bottom right buttons: + self.button_apply.setVisible(True) + self.button_back.setVisible(True) + self.button_apply.clicked.connect(self.submit_edits) + self.button_back.clicked.connect(self.reverse) + + # Flag for the showEvent not repeating redraws: + self.created_display = False + + + def showEvent(self, event): + """Refresh data. This runs every time the widget is displayed""" + if not self.created_display and self.profile_id is not None: + logger.info(f"Recreating UI for profile {self.profile_id}") + self.create_ui(self.profile_id) + self.created_display = True + + def create_ui(self, profile_id: int): + if profile_id is None: + logger.error("No profile id to edit.") + return + + self.grid = QGridLayout(self.content_area) + self.grid.setSpacing(30) + self.grid.setContentsMargins(0, 0, 0, 0) + + # 1. Initialize State + self.state = RegistrationState(btn_path=self.btn_path, profile_id=profile_id) + + # 2. Create groups, passing the category string and the state object + self.group_type = SelectionGroup(self.content_area, title="Profile Type", category="type", state=self.state, sync_required=False, btn_path=self.btn_path) + self.group_name = TextInputGroup(self.content_area, title="Name", category="name", state=self.state) + self.group_proto = SelectionGroup(self.content_area, title="Protocol", category="protocol", state=self.state, sync_required=False, btn_path=self.btn_path) + self.group_loc = SelectionGroup(self.content_area, title="Location", category="location", state=self.state, sync_required=True, btn_path=self.btn_path) + self.group_browser = SelectionGroup(self.content_area, title="Browser", category="browser", state=self.state, sync_required=True, btn_path=self.btn_path) + self.group_res = SelectionGroup(self.content_area, title="Resolution", category="resolution", state=self.state, sync_required=False, btn_path=self.btn_path) + + # 3. Quality Control: Force columns to share width equally + self.grid.setColumnStretch(0, 1) + self.grid.setColumnStretch(1, 1) + + # 4. adding groups in rows of 2 items each: + self.grid.addWidget(self.group_type, 0, 0) + self.grid.addWidget(self.group_name, 0, 1) + self.grid.addWidget(self.group_proto, 1, 0) + self.grid.addWidget(self.group_loc, 1, 1) + self.grid.addWidget(self.group_browser, 2, 0) + self.grid.addWidget(self.group_res, 2, 1) + + # Add the content area to the main window layout + self.main_layout.addWidget(self.content_area) + + # 5. Custom options, such as Resolution: + custom_button = QPushButton("Custom Res", self) + custom_button.setStyleSheet(FAST_REGISTER_ONE) + custom_button.clicked.connect(self.show_custom_res_dialog) + + self.grid.addWidget(custom_button, 3, 1, Qt.AlignmentFlag.AlignCenter) + self.grid.setRowStretch(4, 1) + + # 6. Subscribe to state change on sync: + Notifications.subscribe(EventType.SYNC_COMPLETE, self.update_post_sync) + + + def update_post_sync(self, string_notification: str): + """At the completion of the sync, update the button styles""" + buttons_required_sync = [self.group_loc, self.group_browser] + for each_button in buttons_required_sync: + each_button.apply_styles_to_buttons(sync_required=False) + + def show_custom_res_dialog(self): + # Shows the popup asking for the custom choice: + dialog = CustomResolutionDialog( + style_sheet=FAST_REGISTER_TWO, + parent=self + ) + + # if it passes the validation screen inside it, then update state: + dialog.resolution_selected.connect(self.handle_resolution_update) + dialog.exec() + + def handle_resolution_update(self, resolution): + """Update State with the selected Resolution""" + success = self.state.set_selection("resolution", resolution) + if success: + print(f"Resolution updated to {resolution}") + else: + print("Custom resolution failed validation.") + + 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_edits(self): + self.created_display = False # reset for next time + print(f"hit button. self.profile_id is {self.profile_id}") + + final_choices = self.state.get_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}") + + # swap for edit: + # create_profile(potential_data=final_choices, ui_caller=self.after_submission) + + def reverse(self): + self.created_display = False # reset for next time + self.custom_window.navigator.navigate("menu") + diff --git a/gui/v2/ui/pages/create_edit/fast_create_page.py b/gui/v2/ui/pages/create_edit/fast_create_page.py new file mode 100644 index 0000000..0ae9ae7 --- /dev/null +++ b/gui/v2/ui/pages/create_edit/fast_create_page.py @@ -0,0 +1,115 @@ + +from core.models.Result import Result + +from gui.v2.ui.pages.create_edit.components import SelectionGroup, TextInputGroup +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 FAST_REGISTER_ONE, FAST_REGISTER_TWO +from gui.v2.ui.pages.Page import Page +from gui.v2.ui.pages.create_edit.resolution_widget import CustomResolutionDialog + +from PyQt6.QtWidgets import QWidget, QPushButton, QGridLayout, QVBoxLayout +from PyQt6.QtCore import Qt + +class FastRegistrationPage(Page): + def __init__(self, page_stack, main_window, prepared=None): + super().__init__("FastRegistration", page_stack, main_window) + + # 1. Initialize State + self.state = RegistrationState(btn_path=self.btn_path) + + # Banner temp disabled: + # self.title.setGeometry(550, 40, 250, 40) + # self.title.setText("Fast Registration") + + self.button_apply.setVisible(True) + self.button_back.setVisible(True) + self.button_apply.clicked.connect(self.submit_registration) + self.button_back.clicked.connect(self.reverse) + + self.setFixedSize(800, 600) + + self.content_area = QWidget(self) + + self.main_layout = QVBoxLayout(self) + self.main_layout.setContentsMargins(40, 60, 40, 60) + + self.grid = QGridLayout(self.content_area) + self.grid.setSpacing(30) + self.grid.setContentsMargins(0, 0, 0, 0) + + # 1. Create groups, passing the category string and the state object + self.group_type = SelectionGroup(self.content_area, title="Profile Type", category="type", state=self.state, sync_required=False, btn_path=self.btn_path) + self.group_name = TextInputGroup(self.content_area, title="Name", category="name", state=self.state) + self.group_proto = SelectionGroup(self.content_area, title="Protocol", category="protocol", state=self.state, sync_required=False, btn_path=self.btn_path) + self.group_loc = SelectionGroup(self.content_area, title="Location", category="location", state=self.state, sync_required=False, btn_path=self.btn_path) + self.group_browser = SelectionGroup(self.content_area, title="Browser", category="browser", state=self.state, sync_required=False, btn_path=self.btn_path) + self.group_res = SelectionGroup(self.content_area, title="Resolution", category="resolution", state=self.state, sync_required=False, btn_path=self.btn_path) + + # 2. Quality Control: Force columns to share width equally + self.grid.setColumnStretch(0, 1) + self.grid.setColumnStretch(1, 1) + + # 3. adding groups in rows of 2 items each: + self.grid.addWidget(self.group_type, 0, 0, Qt.AlignmentFlag.AlignTop) + self.grid.addWidget(self.group_name, 0, 1, Qt.AlignmentFlag.AlignTop) + self.grid.addWidget(self.group_proto, 1, 0, Qt.AlignmentFlag.AlignTop) + self.grid.addWidget(self.group_loc, 1, 1, Qt.AlignmentFlag.AlignTop) + self.grid.addWidget(self.group_browser, 2, 0, Qt.AlignmentFlag.AlignTop) + self.grid.addWidget(self.group_res, 2, 1, Qt.AlignmentFlag.AlignTop) + self.grid.setRowStretch(3, 1) + + # Add the content area to the main window layout + self.main_layout.addWidget(self.content_area) + + # 4. Custom options, such as Resolution: + custom_button = QPushButton("Custom Res", self) + custom_button.setGeometry(307, 500, 185, 30) + custom_button.setStyleSheet(FAST_REGISTER_ONE) + custom_button.clicked.connect(self.show_custom_res_dialog) + custom_button.show() + + self.grid.addWidget(custom_button, 3, 1, Qt.AlignmentFlag.AlignCenter) + self.grid.setRowStretch(4, 1) + + + def show_custom_res_dialog(self): + # Shows the popup asking for the custom choice: + dialog = CustomResolutionDialog( + style_sheet=FAST_REGISTER_TWO, + parent=self + ) + + # if it passes the validation screen inside it, then update state: + dialog.resolution_selected.connect(self.handle_resolution_update) + dialog.exec() + + def handle_resolution_update(self, resolution): + """Update State with the selected Resolution""" + success = self.state.set_selection("resolution", resolution) + if success: + print(f"Resolution updated to {resolution}") + else: + print("Custom resolution failed validation.") + + 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() + 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) + + def reverse(self): + self.custom_window.navigator.navigate("menu") + diff --git a/gui/v2/ui/pages/profile_creation/resolution_widget.py b/gui/v2/ui/pages/create_edit/resolution_widget.py similarity index 100% rename from gui/v2/ui/pages/profile_creation/resolution_widget.py rename to gui/v2/ui/pages/create_edit/resolution_widget.py diff --git a/gui/v2/ui/pages/editor_page.py b/gui/v2/ui/pages/editor_page.py index a960087..bf0f298 100755 --- a/gui/v2/ui/pages/editor_page.py +++ b/gui/v2/ui/pages/editor_page.py @@ -8,12 +8,14 @@ from PyQt6.QtGui import QPixmap, QIcon, QPainter, QColor, QTransform from PyQt6.QtCore import Qt, QSize, QTimer, QPointF from PyQt6 import QtCore, QtGui +from core.infrastructure.state_management.global_state_controller import is_synced from core.controllers.ProfileController import ProfileController from core.controllers.LocationController import LocationController from core.models.Result import Result, ResultError from core.controllers.profile_state.data_filters import get_supported_protocols_for_location from core.models.BaseProfile import ProfileType +from gui.v2.ui.styles.css.editor_css import BUTTON_STYLE_ONE from gui.v2.ui.pages.Page import Page from gui.v2.ui.pages.browser_page import BrowserPage from gui.v2.ui.pages.location_page import LocationPage @@ -22,8 +24,7 @@ from gui.v2.ui.popups.confirmation_popup import ConfirmationPopup from gui.v2.ui.popups.error_popup import ErrorPopup from gui.v2.workers.page_data_worker import PageDataWorker from gui.v2.actions.menu_profiles import match_core_profiles -from gui.v2.actions.menu_coordinator import edit_profile - +from gui.v2.actions.menu_coordinator import edit_profile, sync_now class EditorPage(Page): SINGBOX_PROTOCOLS = ("hysteria2", "vless") PROTOCOL_BUTTON_ASSETS = { @@ -93,6 +94,11 @@ class EditorPage(Page): self._prefetched_profiles = prepared self._editor_workers = set() + self.is_synced = is_synced() + + def showEvent(self, event): + """Refresh data. This runs every time the widget is displayed""" + self.is_synced = is_synced() @staticmethod def prepare_data(custom_window): @@ -273,6 +279,12 @@ class EditorPage(Page): protocol = data_profile.get('protocol', "") connection = data_profile.get('connection', "") location = data_profile.get('location', "") + profile_id = data_profile.get('id') + profile_obj = ProfileController.get(profile_id) + + operator_name_string = profile_obj.location.operator.name + print(f"operator_name_string is {operator_name_string}") + country_garaje = location name = data_profile.get('name', "") self.name.setText(name) @@ -316,9 +328,14 @@ class EditorPage(Page): # self.display.setPixmap(self._encrypted_proxy_display_pixmap( # protocol, location).scaled( - self.display.setPixmap(QPixmap(os.path.join( - self.btn_path, f"{protocol}_{location}.png")).scaled( + if operator_name_string == 'Simplified Privacy': + singbox_image_path = f"{protocol}_{location}.png" + else: + singbox_image_path = "system_wide_global.png" + print(f"using singbox_image_path of {singbox_image_path}") + self.display.setPixmap(QPixmap(os.path.join( + self.btn_path, singbox_image_path)).scaled( self.display.size(), Qt.AspectRatioMode.KeepAspectRatio, Qt.TransformationMode.SmoothTransformation)) @@ -336,8 +353,8 @@ class EditorPage(Page): self.garaje.setPixmap(QPixmap(os.path.join( self.btn_path, f"{country_garaje} garaje.png"))) - profile_id = data_profile.get('id') - profile_obj = ProfileController.get(profile_id) + # profile_id = data_profile.get('id') + # profile_obj = ProfileController.get(profile_id) location_info = None if location: @@ -563,7 +580,7 @@ class EditorPage(Page): prev_button.setIcon(QIcon(rotated_icon)) prev_button.setIconSize(prev_button.size()) - if (key == 'location' or key == 'browser') and not self.connection_manager.is_synced(): + if (key == 'location' or key == 'browser') and not is_synced(): w = prev_button.width() h = prev_button.height() outline_pix = QPixmap(w, h) @@ -581,21 +598,8 @@ class EditorPage(Page): prev_button.setIcon(QIcon(outline_pix)) prev_button.setIconSize(prev_button.size()) - if (key == 'location' or key == 'browser') and not self.connection_manager.is_synced(): - prev_button.setStyleSheet(""" - QPushButton { - background-color: transparent; - border: none; - } - QPushButton:hover { - background-color: rgba(0, 255, 0, 0.1); - border-radius: 3px; - } - QPushButton:pressed { - background-color: rgba(0, 255, 0, 0.2); - border-radius: 3px; - } - """) + if (key == 'location' or key == 'browser') and not is_synced(): + prev_button.setStyleSheet(BUTTON_STYLE_ONE) self.buttons.append(prev_button) @@ -609,7 +613,7 @@ class EditorPage(Page): next_button.setIcon( QIcon(os.path.join(self.btn_path, f"UP_button.png"))) next_button.setIconSize(next_button.size()) - if (key == 'location' or key == 'browser') and not self.connection_manager.is_synced(): + if (key == 'location' or key == 'browser') and not is_synced(): w = next_button.width() h = next_button.height() outline_pix_r = QPixmap(w, h) @@ -627,7 +631,7 @@ class EditorPage(Page): next_button.setIcon(QIcon(outline_pix_r)) next_button.setIconSize(next_button.size()) - if (key == 'location' or key == 'browser') and not self.connection_manager.is_synced(): + if (key == 'location' or key == 'browser') and not is_synced(): next_button.setStyleSheet(""" QPushButton { background-color: transparent; @@ -701,8 +705,17 @@ class EditorPage(Page): # painter.end() # return pixmap - def on_sync_complete_for_edit_profile(self, available_locations, available_browsers, status, is_tor, locations, all_browsers): - if status: + # def on_sync_complete_for_edit_profile(self, available_locations, available_browsers, status, is_tor, locations, all_browsers): + # if status: + # self.update_status.update_status('Sync complete.') + # self.extraccion() + # else: + # self.update_status.update_status( + # 'Sync failed. Please try again later.') + + def on_sync_complete(self, result: Result): + if result.valid: + self.is_synced = True self.update_status.update_status('Sync complete.') self.extraccion() else: @@ -711,11 +724,13 @@ class EditorPage(Page): def show_previous_value(self, key: str, index: int, parameters: dict) -> None: if key == 'browser' or key == 'location': - if not self.connection_manager.is_synced(): + if not is_synced(): self.update_status.update_status('Syncing in progress..') - self.update_status.sync() - self.update_status.worker_thread.sync_output.connect( - self.on_sync_complete_for_edit_profile) + sync_now(ui_caller=self.on_sync_complete) + + # self.update_status.sync() + # self.update_status.worker_thread.sync_output.connect( + # self.on_sync_complete_for_edit_profile) return values = parameters.get(key, []) @@ -730,11 +745,13 @@ class EditorPage(Page): def show_next_value(self, key: str, index: int, parameters: dict) -> None: if key == 'browser' or key == 'location': - if not self.connection_manager.is_synced(): + if not is_synced(): self.update_status.update_status('Syncing in progress..') - self.update_status.sync() - self.update_status.worker_thread.sync_output.connect( - self.on_sync_complete_for_edit_profile) + sync_now(ui_caller=self.on_sync_complete) + + # self.update_status.sync() + # self.update_status.worker_thread.sync_output.connect( + # self.on_sync_complete_for_edit_profile) return values = parameters.get(key, []) diff --git a/gui/v2/ui/pages/fast7b.py b/gui/v2/ui/pages/fast7b.py deleted file mode 100644 index d1da9d1..0000000 --- a/gui/v2/ui/pages/fast7b.py +++ /dev/null @@ -1,251 +0,0 @@ - -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, FAST_REGISTER_ONE, FAST_REGISTER_TWO -from gui.v2.ui.pages.Page import Page -from gui.v2.ui.pages.profile_creation.resolution_widget import CustomResolutionDialog - -from pathlib import Path - -from PyQt6 import QtWidgets, QtCore, QtGui -from PyQt6.QtWidgets import QWidget, QLabel, QPushButton, QVBoxLayout, QHBoxLayout, QGridLayout, QSizePolicy, QLineEdit -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 - self.state = state - - # Match the width of the SelectionGroup - self.setMinimumWidth(260) - - self.main_layout = QVBoxLayout(self) - self.main_layout.setContentsMargins(0, 0, 0, 0) - self.main_layout.setSpacing(5) - self.main_layout.setAlignment(Qt.AlignmentFlag.AlignTop) - - # Same title style as SelectionGroup - self.title_label = QLabel(title) - self.title_label.setStyleSheet(NAME_TEXT_STYLE) - self.main_layout.addWidget(self.title_label) - - # Row layout to hold the input field - self.row_layout = QHBoxLayout() - self.row_layout.setSpacing(10) - - self.text_input = QLineEdit() - - # Set initial value from state if it exists - # initial_text = self.state.get_value(self.category) if hasattr(self.state, 'get_value') else "" - # self.text_input.setText(initial_text) - - # Match the display_box styling - self.text_input.setFixedSize(240, 35) # Slightly shorter than the image box for better text look - self.text_input.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed) - self.text_input.setStyleSheet(ENTER_NAME_TEXT) - - # Update state in real-time as user types - # self.text_input.textChanged.connect(self.update_state) - - self.row_layout.addWidget(self.text_input) - - # Center the input field within the row layout - self.row_layout.setAlignment(Qt.AlignmentFlag.AlignCenter) - - 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) - -class SelectionGroup(QWidget): - """Create Image/Value Select Boxes of a particular style""" - - def __init__(self, parent, title, category, state): - super().__init__(parent) - self.category = category - self.state = state - - # Tell the state: "When this category changes, run my update_display method" - self.state.register_listener(category, self.update_display) - - # Ensure the group widget itself is wide enough to hold the layout - # (Legacy specs were: 30px prev + 185px box + 30px next + spacing) - self.setMinimumWidth(260) - - self.main_layout = QVBoxLayout(self) - self.main_layout.setContentsMargins(0, 0, 0, 0) - self.main_layout.setSpacing(5) - self.main_layout.setAlignment(Qt.AlignmentFlag.AlignTop) - - self.title_label = QLabel(title) - self.title_label.setStyleSheet(GROUP_TITLE_LABEL) - self.main_layout.addWidget(self.title_label) - - self.row_layout = QHBoxLayout() - self.row_layout.setSpacing(10) # Add a little gap between buttons and box - - self.btn_prev = QPushButton("<") - self.btn_prev.setFixedWidth(30) - self.btn_prev.clicked.connect(lambda: self.change_image(-1)) - - self.display_box = QLabel() - self.display_box.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter) - - # --- STRICT SIZE POLICY --- - self.display_box.setFixedSize(185, 75) - # widget MUST be exactly this size - self.display_box.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed) - - self.display_box.setStyleSheet(DISPLAY_BOX_STYLE) - - self.btn_next = QPushButton(">") - self.btn_next.setFixedWidth(30) - self.btn_next.clicked.connect(lambda: self.change_image(1)) - - # Add widgets without stretch factors to maintain the fixed-size integrity - self.row_layout.addWidget(self.btn_prev) - self.row_layout.addWidget(self.display_box) - self.row_layout.addWidget(self.btn_next) - - self.main_layout.addLayout(self.row_layout) - - - def showEvent(self, event): - super().showEvent(event) - self.update_display() - - def change_image(self, direction): - """Toggle the next image change by category and direction""" - self.state.cycle_selection(self.category, direction) - - def update_display(self): - """Get and Change the currently displayed image. This function is passed as a callback to the state""" - path = self.state.get_current_image(self.category) - self.set_image(path) - - - def set_image(self, image_source): - # 1. Convert source to QPixmap regardless of what it is - if isinstance(image_source, Path): - pixmap = QPixmap(str(image_source)) - elif isinstance(image_source, QPixmap): - pixmap = image_source - else: - return - - if pixmap.isNull(): - return - - # 2. Apply the scaling logic, built in the previous step - box_width = self.display_box.width() - box_height = self.display_box.height() - - if pixmap.width() > box_width or pixmap.height() > box_height: - scaled_pixmap = pixmap.scaled( - box_width, - box_height, - QtCore.Qt.AspectRatioMode.KeepAspectRatio, - QtCore.Qt.TransformationMode.SmoothTransformation - ) - self.display_box.setPixmap(scaled_pixmap) - else: - self.display_box.setPixmap(pixmap) - - -class FastRegistrationPage(Page): - def __init__(self, page_stack, main_window, prepared=None): - super().__init__("FastRegistration", page_stack, main_window) - - # 1. Initialize State - self.state = RegistrationState(btn_path=self.btn_path) - - # Banner temp disabled: - # self.title.setGeometry(550, 40, 250, 40) - # self.title.setText("Fast Registration") - - self.button_apply.setVisible(True) - self.button_back.setVisible(True) - self.button_apply.clicked.connect(self.submit_registration) - self.button_back.clicked.connect(self.reverse) - - self.setFixedSize(800, 600) - - self.content_area = QWidget(self) - self.content_area.setGeometry(100, 60, 600, 370) - - self.grid = QGridLayout(self.content_area) - self.grid.setSpacing(30) - self.grid.setContentsMargins(0, 0, 0, 0) - - # 2. Create groups, passing the category string and the state object - self.group_type = SelectionGroup(self.content_area, "Profile Type", "Type", self.state) - self.group_name = TextInputGroup(self.content_area, "Name", "Name", self.state) - self.group_proto = SelectionGroup(self.content_area, "Protocol", "Protocol", self.state) - self.group_loc = SelectionGroup(self.content_area, "Location", "Location", self.state) - self.group_browser = SelectionGroup(self.content_area, "Browser", "Browser", self.state) - self.group_res = SelectionGroup(self.content_area, "Resolution", "Resolution", self.state) - - # 3. adding groups in rows of 2 items each: - self.grid.addWidget(self.group_type, 0, 0, Qt.AlignmentFlag.AlignTop) - self.grid.addWidget(self.group_name, 0, 1, Qt.AlignmentFlag.AlignTop) - self.grid.addWidget(self.group_proto, 1, 0, Qt.AlignmentFlag.AlignTop) - self.grid.addWidget(self.group_loc, 1, 1, Qt.AlignmentFlag.AlignTop) - self.grid.addWidget(self.group_browser, 2, 0, Qt.AlignmentFlag.AlignTop) - self.grid.addWidget(self.group_res, 2, 1, Qt.AlignmentFlag.AlignTop) - self.grid.setRowStretch(3, 1) - - # 4. Custom options, such as Resolution: - custom_button = QPushButton("Custom Res", self) - custom_button.setGeometry(435, 430, 185, 30) - custom_button.setStyleSheet(FAST_REGISTER_ONE) - custom_button.clicked.connect(self.show_custom_res_dialog) - custom_button.show() - self.buttons.append(custom_button) - - def show_custom_res_dialog(self): - # Shows the popup asking for the custom choice: - dialog = CustomResolutionDialog( - style_sheet=FAST_REGISTER_TWO, - parent=self - ) - - # if it passes the validation screen inside it, then update state: - dialog.resolution_selected.connect(self.handle_resolution_update) - dialog.exec() - - def handle_resolution_update(self, resolution): - """Update State with the selected Resolution""" - success = self.state.set_selection("Resolution", resolution) - if success: - print(f"Resolution updated to {resolution}") - else: - print("Custom resolution failed validation.") - - 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() - 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) - - def reverse(self): - self.custom_window.navigator.navigate("menu") - diff --git a/gui/v2/ui/pages/menu_page.py b/gui/v2/ui/pages/menu_page.py index 340fbe2..7ff9b06 100755 --- a/gui/v2/ui/pages/menu_page.py +++ b/gui/v2/ui/pages/menu_page.py @@ -722,9 +722,10 @@ class MenuPage(Page): status_handlers[state["use_marquee"]](state["message"]) def edit_prof(self): - self._set_task_busy(True) - self.worker = edit_profile(getattr(self.update_status, "gui_config_file", None), - self.connection_manager.is_synced(), self.handle_task_result) + """Go to the edit profile page""" + profile_id = self.reverse_id + self.custom_window.navigator.navigate(name="editor", profile_id=profile_id) + def settings_gui(self): self.custom_window.navigator.navigate("settings") diff --git a/gui/v2/ui/styles/css/editor_css.py b/gui/v2/ui/styles/css/editor_css.py new file mode 100644 index 0000000..9098801 --- /dev/null +++ b/gui/v2/ui/styles/css/editor_css.py @@ -0,0 +1,34 @@ + +BUTTON_STYLE_ONE = """ + QPushButton { + background-color: transparent; + border: none; + } + QPushButton:hover { + background-color: rgba(0, 255, 0, 0.1); + border-radius: 3px; + } + QPushButton:pressed { + background-color: rgba(0, 255, 0, 0.2); + border-radius: 3px; + } +""" + + +PRE_SYNC_LAYOUT = """ + QPushButton { + background-color: transparent; + border: none; + color: #00FF00; /* green */ + font-size: 48px; /* larger */ + font-weight: bold; + } + QPushButton:hover { + background-color: rgba(0, 255, 0, 0.1); + border-radius: 5px; + } + QPushButton:pressed { + background-color: rgba(0, 255, 0, 0.2); + border-radius: 5px; + } +""" \ No newline at end of file