update: fixed error on profile enable

This commit is contained in:
Your Name 2025-11-21 22:18:12 +01:00
parent f478505f68
commit fc944b0cb5

View file

@ -2257,19 +2257,22 @@ class MenuPage(Page):
try: try:
if is_enabled: if is_enabled:
self.connection_manager.add_connected_profile(profile_id) self.connection_manager.add_connected_profile(profile_id)
if profile_type == 1: target_button: QPushButton = self.connection_manager.get_profile_button_objects(profile_id)
target_button: QPushButton = self.connection_manager.get_profile_button_objects(profile_id)
icon_path = self.connected_tor_profile if profile_connection == 'tor' else self.connected_profile
target_button.setIcon(QIcon(icon_path))
self.button_states[profile_id] = icon_path
else:
target_button: QPushButton = self.connection_manager.get_profile_button_objects(profile_id)
target_button.setIcon(QIcon(self.system_wide_connected_profile))
self.update_status.update_image(appearance_value='background_connected')
self.button_states[profile_id] = self.system_wide_connected_profile
self.IsSystem += 1
self.show_disconnect_button(True, profile_type, target_button) if profile_type == 1:
if target_button:
icon_path = self.connected_tor_profile if profile_connection == 'tor' else self.connected_profile
target_button.setIcon(QIcon(icon_path))
self.button_states[profile_id] = icon_path
else:
if target_button:
target_button.setIcon(QIcon(self.system_wide_connected_profile))
self.update_status.update_image(appearance_value='background_connected')
self.button_states[profile_id] = self.system_wide_connected_profile
self.IsSystem += 1
if target_button:
self.show_disconnect_button(True, profile_type, target_button)
self.boton_edit.setEnabled(False) self.boton_edit.setEnabled(False)
if profile_id == self.reverse_id: if profile_id == self.reverse_id:
@ -2278,22 +2281,24 @@ class MenuPage(Page):
self.print_profile_details(f"Profile_{profile_id}") self.print_profile_details(f"Profile_{profile_id}")
else: else:
self.connection_manager.remove_connected_profile(profile_id) self.connection_manager.remove_connected_profile(profile_id)
target_button: QPushButton = self.connection_manager.get_profile_button_objects(profile_id)
if profile_type == 1: if profile_type == 1:
target_button: QPushButton = self.connection_manager.get_profile_button_objects(profile_id) if target_button:
target_button.setIcon(QIcon(self.not_connected_profile)) target_button.setIcon(QIcon(self.not_connected_profile))
if profile_id in self.button_states: if profile_id in self.button_states:
del self.button_states[profile_id] del self.button_states[profile_id]
else: else:
self.IsSystem -= 1 self.IsSystem -= 1
target_button: QPushButton = self.connection_manager.get_profile_button_objects(profile_id) if target_button:
target_button.setIcon(QIcon(self.not_connected_profile)) target_button.setIcon(QIcon(self.not_connected_profile))
if profile_id in self.button_states: if profile_id in self.button_states:
del self.button_states[profile_id] del self.button_states[profile_id]
if self.IsSystem == 0: if self.IsSystem == 0:
self.update_status.update_image() self.update_status.update_image()
self.show_disconnect_button(False, profile_type, target_button) if target_button:
self.show_disconnect_button(False, profile_type, target_button)
self.boton_edit.setEnabled(True) self.boton_edit.setEnabled(True)
if profile_id == self.reverse_id: if profile_id == self.reverse_id: