From 74df402710ff28c945abf23b51838e002154ee67 Mon Sep 17 00:00:00 2001 From: John Date: Sat, 4 Oct 2025 18:20:53 +0100 Subject: [PATCH] add: expanded profile selection to more than 6 --- gui/__main__.py | 169 ++++++++++++++++++++++++++++++++---------------- pyproject.toml | 2 +- 2 files changed, 116 insertions(+), 55 deletions(-) diff --git a/gui/__main__.py b/gui/__main__.py index 7432c34..fe9122e 100755 --- a/gui/__main__.py +++ b/gui/__main__.py @@ -1278,7 +1278,31 @@ class MenuPage(Page): self.update_status = main_window self.title.setGeometry(400, 40, 380, 30); self.title.setText("Load Profile") - + self.scroll_area = QScrollArea(self) + self.scroll_area.setGeometry(420, 80, 370, 350) + self.scroll_area.setWidgetResizable(True) + self.scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) + self.scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded) + self.scroll_area.setStyleSheet(""" + QScrollArea { + background-color: transparent; + border: none; + } + QScrollBar:vertical { + background-color: transparent; + width: 0px; + } + QScrollBar::handle:vertical { + background-color: transparent; + } + QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical { + background-color: transparent; + } + """) + + self.scroll_widget = QWidget() + self.scroll_widget.setStyleSheet("background-color: transparent;") + self.scroll_area.setWidget(self.scroll_widget) self.not_connected_profile = os.path.join(self.btn_path, "button_profile.png") self.connected_profile = os.path.join(self.btn_path, "button_session_profile.png") @@ -1441,7 +1465,6 @@ class MenuPage(Page): self.boton_edit.setEnabled(False) self.profiles_data = self.match_core_profiles(ProfileController.get_all()) - self.number_of_profiles = len(self.profiles_data) self.profile_info.update(self.profiles_data) @@ -1450,6 +1473,8 @@ class MenuPage(Page): for profile_name, profile_value in self.profiles_data.items(): self.create_profile_widget(profile_name, profile_value) + + self.update_scroll_widget_size() def refresh_profiles_data(self): self.profiles_data = self.match_core_profiles(ProfileController.get_all()) @@ -1457,12 +1482,20 @@ class MenuPage(Page): self.profile_info.update(self.profiles_data) for profile_name, profile_value in self.profiles_data.items(): self.create_profile_widget(profile_name, profile_value) + self.update_scroll_widget_size() + + def update_scroll_widget_size(self): + if self.number_of_profiles == 0: + return + + rows = (self.number_of_profiles + 1) // 2 + height = rows * 120 + self.scroll_widget.setFixedSize(370, height) def create_profile_widget(self, key, value): profile_id = int(key.split('_')[1]) - visible = profile_id <= 6 - parent_label = self.create_parent_label(profile_id, visible) + parent_label = self.create_parent_label(profile_id) button = self.create_profile_button(parent_label, profile_id, key) self.profile_button_map[profile_id] = button @@ -1470,13 +1503,14 @@ class MenuPage(Page): self.create_profile_name_label(parent_label, value["name"]) self.create_profile_icons(parent_label, value) - def create_parent_label(self, profile_id, visible): - parent_label = QLabel(self) - index = profile_id - 1 + def create_parent_label(self, profile_id): + parent_label = QLabel(self.scroll_widget) + profile_list = list(self.profiles_data.keys()) + index = profile_list.index(f'Profile_{profile_id}') row, column = divmod(index, 2) - parent_label.setGeometry(column * 185 + 420, row * 120 + 80, 175, 100) - parent_label.setVisible(visible) + parent_label.setGeometry(column * 185, row * 120, 175, 100) + parent_label.setVisible(True) return parent_label def create_profile_button(self, parent_label, profile_id, key): @@ -1794,10 +1828,6 @@ class MenuPage(Page): pass def create_prof(self): - if len(self.profile_info) == 6: - self.update_status.update_status('Maximum number of profiles reached!') - return - settings_page = self.page_stack.findChild(Settings) if settings_page and settings_page.is_fast_registration_enabled(): if not self.connection_manager.is_synced(): @@ -1880,11 +1910,16 @@ class MenuPage(Page): self.main_window.on_label.setParent(None) self.main_window.off_label.setParent(None) - for widget in self.findChildren(QLabel): - if widget != self.title: - widget.setParent(None) + for widget in self.scroll_widget.findChildren(QLabel): + widget.setParent(None) + + for widget in self.scroll_widget.findChildren(QPushButton): + widget.setParent(None) self.profile_info.clear() + self.profile_button_map.clear() + self.button_states.clear() + self.buttons.clear() self.main_window.toggle_bg.setParent(self.main_window.toggle_button) self.main_window.toggle_handle.setParent(self.main_window.toggle_button) @@ -1952,7 +1987,7 @@ class MenuPage(Page): self.update_status.enable_marquee(str(text)) else: self.update_status.update_status(str(text)) - if profile_id <= 6 and profile_id is not None: + if profile_id is not None: self.on_finished_update_gui(is_enabled, profile_id, profile_type, profile_connection) self.boton_just.setEnabled(True) self.boton_just_session.setEnabled(True) @@ -4706,48 +4741,38 @@ class Settings(Page): title.setStyleSheet(f"color: #808080; font-size: 12px; font-weight: bold; {self.font_style}") layout.addWidget(title) - grid = QGridLayout() - grid.setSpacing(10) + self.delete_scroll_area = QScrollArea() + self.delete_scroll_area.setFixedSize(510, 300) + self.delete_scroll_area.setWidgetResizable(True) + self.delete_scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) + self.delete_scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAsNeeded) + self.delete_scroll_area.setStyleSheet(""" + QScrollArea { + background-color: transparent; + border: none; + } + QScrollBar:vertical { + background-color: transparent; + width: 0px; + } + QScrollBar::handle:vertical { + background-color: transparent; + } + QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical { + background-color: transparent; + } + """) + + self.delete_scroll_widget = QWidget() + self.delete_scroll_widget.setStyleSheet("background-color: transparent;") + self.delete_scroll_area.setWidget(self.delete_scroll_widget) self.profile_buttons = QButtonGroup() self.profile_buttons.setExclusive(True) - profiles = ProfileController.get_all() + self.create_delete_profile_buttons() - for profile_id in range(1, 7): - row = (profile_id - 1) // 2 - col = (profile_id - 1) % 2 - - profile = profiles.get(profile_id) - if profile: - btn = QPushButton(f"Profile {profile_id}\n{profile.name}") - btn.setCheckable(True) - btn.setFixedSize(180, 60) - btn.setStyleSheet(f""" - QPushButton {{ - background: rgba(255, 255, 255, 0.1); - border: none; - color: white; - border-radius: 5px; - text-align: center; - {self.font_style} - }} - QPushButton:checked {{ - background: rgba(255, 255, 255, 0.3); - border: 2px solid #007AFF; - }} - QPushButton:hover:!checked {{ - background: rgba(255, 255, 255, 0.2); - }} - """) - self.profile_buttons.addButton(btn, profile_id) - else: - btn = QWidget() - btn.setFixedSize(180, 60) - - grid.addWidget(btn, row, col) - - layout.addLayout(grid) + layout.addWidget(self.delete_scroll_area) self.delete_button = QPushButton("Delete") self.delete_button.setEnabled(False) @@ -4781,6 +4806,42 @@ class Settings(Page): return page + def create_delete_profile_buttons(self): + profiles = ProfileController.get_all() + + for index, (profile_id, profile) in enumerate(profiles.items()): + row = index // 2 + col = index % 2 + + btn = QPushButton(f"Profile {profile_id}\n{profile.name}") + btn.setCheckable(True) + btn.setFixedSize(180, 60) + btn.setParent(self.delete_scroll_widget) + btn.setGeometry(col * 220 + 50, row * 100, 180, 60) + btn.setStyleSheet(f""" + QPushButton {{ + background: rgba(255, 255, 255, 0.1); + border: none; + color: white; + border-radius: 5px; + text-align: center; + {self.font_style} + }} + QPushButton:checked {{ + background: rgba(255, 255, 255, 0.3); + border: 2px solid #007AFF; + }} + QPushButton:hover:!checked {{ + background: rgba(255, 255, 255, 0.2); + }} + """) + self.profile_buttons.addButton(btn, profile_id) + + if profiles: + rows = (len(profiles) + 1) // 2 + height = rows * 100 + self.delete_scroll_widget.setFixedSize(510, height) + def create_debug_page(self): page = QWidget() layout = QVBoxLayout(page) diff --git a/pyproject.toml b/pyproject.toml index 255b602..29c791f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "sp-hydra-veil-gui" -version = "1.1.4" +version = "1.1.5" authors = [ { name = "Simplified Privacy" }, ]