add: expanded profile selection to more than 6
This commit is contained in:
parent
b41ac6b6b2
commit
74df402710
2 changed files with 116 additions and 55 deletions
167
gui/__main__.py
167
gui/__main__.py
|
@ -1278,7 +1278,31 @@ class MenuPage(Page):
|
||||||
self.update_status = main_window
|
self.update_status = main_window
|
||||||
self.title.setGeometry(400, 40, 380, 30); self.title.setText("Load Profile")
|
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.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")
|
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.boton_edit.setEnabled(False)
|
||||||
self.profiles_data = self.match_core_profiles(ProfileController.get_all())
|
self.profiles_data = self.match_core_profiles(ProfileController.get_all())
|
||||||
|
|
||||||
|
|
||||||
self.number_of_profiles = len(self.profiles_data)
|
self.number_of_profiles = len(self.profiles_data)
|
||||||
self.profile_info.update(self.profiles_data)
|
self.profile_info.update(self.profiles_data)
|
||||||
|
|
||||||
|
@ -1451,18 +1474,28 @@ class MenuPage(Page):
|
||||||
for profile_name, profile_value in self.profiles_data.items():
|
for profile_name, profile_value in self.profiles_data.items():
|
||||||
self.create_profile_widget(profile_name, profile_value)
|
self.create_profile_widget(profile_name, profile_value)
|
||||||
|
|
||||||
|
self.update_scroll_widget_size()
|
||||||
|
|
||||||
def refresh_profiles_data(self):
|
def refresh_profiles_data(self):
|
||||||
self.profiles_data = self.match_core_profiles(ProfileController.get_all())
|
self.profiles_data = self.match_core_profiles(ProfileController.get_all())
|
||||||
self.number_of_profiles = len(self.profiles_data)
|
self.number_of_profiles = len(self.profiles_data)
|
||||||
self.profile_info.update(self.profiles_data)
|
self.profile_info.update(self.profiles_data)
|
||||||
for profile_name, profile_value in self.profiles_data.items():
|
for profile_name, profile_value in self.profiles_data.items():
|
||||||
self.create_profile_widget(profile_name, profile_value)
|
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):
|
def create_profile_widget(self, key, value):
|
||||||
profile_id = int(key.split('_')[1])
|
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)
|
button = self.create_profile_button(parent_label, profile_id, key)
|
||||||
|
|
||||||
self.profile_button_map[profile_id] = button
|
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_name_label(parent_label, value["name"])
|
||||||
self.create_profile_icons(parent_label, value)
|
self.create_profile_icons(parent_label, value)
|
||||||
|
|
||||||
def create_parent_label(self, profile_id, visible):
|
def create_parent_label(self, profile_id):
|
||||||
parent_label = QLabel(self)
|
parent_label = QLabel(self.scroll_widget)
|
||||||
index = profile_id - 1
|
profile_list = list(self.profiles_data.keys())
|
||||||
|
index = profile_list.index(f'Profile_{profile_id}')
|
||||||
row, column = divmod(index, 2)
|
row, column = divmod(index, 2)
|
||||||
|
|
||||||
parent_label.setGeometry(column * 185 + 420, row * 120 + 80, 175, 100)
|
parent_label.setGeometry(column * 185, row * 120, 175, 100)
|
||||||
parent_label.setVisible(visible)
|
parent_label.setVisible(True)
|
||||||
return parent_label
|
return parent_label
|
||||||
|
|
||||||
def create_profile_button(self, parent_label, profile_id, key):
|
def create_profile_button(self, parent_label, profile_id, key):
|
||||||
|
@ -1794,10 +1828,6 @@ class MenuPage(Page):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def create_prof(self):
|
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)
|
settings_page = self.page_stack.findChild(Settings)
|
||||||
if settings_page and settings_page.is_fast_registration_enabled():
|
if settings_page and settings_page.is_fast_registration_enabled():
|
||||||
if not self.connection_manager.is_synced():
|
if not self.connection_manager.is_synced():
|
||||||
|
@ -1880,11 +1910,16 @@ class MenuPage(Page):
|
||||||
self.main_window.on_label.setParent(None)
|
self.main_window.on_label.setParent(None)
|
||||||
self.main_window.off_label.setParent(None)
|
self.main_window.off_label.setParent(None)
|
||||||
|
|
||||||
for widget in self.findChildren(QLabel):
|
for widget in self.scroll_widget.findChildren(QLabel):
|
||||||
if widget != self.title:
|
widget.setParent(None)
|
||||||
widget.setParent(None)
|
|
||||||
|
for widget in self.scroll_widget.findChildren(QPushButton):
|
||||||
|
widget.setParent(None)
|
||||||
|
|
||||||
self.profile_info.clear()
|
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_bg.setParent(self.main_window.toggle_button)
|
||||||
self.main_window.toggle_handle.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))
|
self.update_status.enable_marquee(str(text))
|
||||||
else:
|
else:
|
||||||
self.update_status.update_status(str(text))
|
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.on_finished_update_gui(is_enabled, profile_id, profile_type, profile_connection)
|
||||||
self.boton_just.setEnabled(True)
|
self.boton_just.setEnabled(True)
|
||||||
self.boton_just_session.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}")
|
title.setStyleSheet(f"color: #808080; font-size: 12px; font-weight: bold; {self.font_style}")
|
||||||
layout.addWidget(title)
|
layout.addWidget(title)
|
||||||
|
|
||||||
grid = QGridLayout()
|
self.delete_scroll_area = QScrollArea()
|
||||||
grid.setSpacing(10)
|
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 = QButtonGroup()
|
||||||
self.profile_buttons.setExclusive(True)
|
self.profile_buttons.setExclusive(True)
|
||||||
|
|
||||||
profiles = ProfileController.get_all()
|
self.create_delete_profile_buttons()
|
||||||
|
|
||||||
for profile_id in range(1, 7):
|
layout.addWidget(self.delete_scroll_area)
|
||||||
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)
|
|
||||||
|
|
||||||
self.delete_button = QPushButton("Delete")
|
self.delete_button = QPushButton("Delete")
|
||||||
self.delete_button.setEnabled(False)
|
self.delete_button.setEnabled(False)
|
||||||
|
@ -4781,6 +4806,42 @@ class Settings(Page):
|
||||||
|
|
||||||
return 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):
|
def create_debug_page(self):
|
||||||
page = QWidget()
|
page = QWidget()
|
||||||
layout = QVBoxLayout(page)
|
layout = QVBoxLayout(page)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[project]
|
[project]
|
||||||
name = "sp-hydra-veil-gui"
|
name = "sp-hydra-veil-gui"
|
||||||
version = "1.1.4"
|
version = "1.1.5"
|
||||||
authors = [
|
authors = [
|
||||||
{ name = "Simplified Privacy" },
|
{ name = "Simplified Privacy" },
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue