update: fixes to v2 version / delete fixes

This commit is contained in:
JOhn 2026-06-16 07:52:58 -04:00
parent e615715223
commit f376cf9b61
3 changed files with 44 additions and 5 deletions

View file

@ -189,6 +189,8 @@ class MenuPage(Page):
def delete_status_update(self, text):
self.update_status.update_status(text)
if not text.startswith('Could not delete'):
self.clear_profile_details()
self.eliminacion()
def show_disconnect_button(self, toggle, profile_type, target_button):
@ -267,7 +269,7 @@ class MenuPage(Page):
ProfileController.get_all())
self.number_of_profiles = len(self.profiles_data)
self.profile_info.update(self.profiles_data)
self.profile_info = dict(self.profiles_data)
self.button_group = QButtonGroup(self)
self.buttons = []
@ -281,7 +283,7 @@ class MenuPage(Page):
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)
self.profile_info = dict(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()
@ -323,12 +325,35 @@ class MenuPage(Page):
def update_scroll_widget_size(self):
if self.number_of_profiles == 0:
self.scroll_widget.setFixedSize(370, 0)
return
rows = (self.number_of_profiles + 1) // 2
height = rows * 120
self.scroll_widget.setFixedSize(370, height)
def clear_profile_details(self):
for label in self.additional_labels:
label.deleteLater()
self.additional_labels.clear()
self.selected_profiles.clear()
self.selected_wireguard.clear()
self.selected_residential.clear()
self.update_status.current_profile_id = None
self.current_profile_location = None
self.reverse_id = None
self.boton_edit.setEnabled(False)
self.boton_launch.setEnabled(False)
self.boton_just.setVisible(False)
self.boton_just_session.setVisible(False)
self.disconnect_button.setVisible(False)
self.disconnect_system_wide_button.setVisible(False)
if hasattr(self, 'button_group'):
self.button_group.setExclusive(False)
for button in getattr(self, 'buttons', []):
button.setChecked(False)
self.button_group.setExclusive(True)
def create_profile_widget(self, key, value):
profile_id = int(key.split('_')[1])
@ -1062,8 +1087,6 @@ class MenuPage(Page):
self.is_animating = current_state['is_animating']
self.animation_step = current_state['animation_step']
self.create()
def get_billing_code_by_id(self, force: bool = False):
profile_id = self.update_status.current_profile_id
profile_data = {

View file

@ -789,6 +789,12 @@ class Settings(Page):
def delete_status_update(self, message):
self.update_status.update_status(message)
if not message.startswith('Could not delete'):
menu_page = self.custom_window.navigator.get_cached("menu")
if menu_page is not None and hasattr(menu_page, 'clear_profile_details'):
menu_page.clear_profile_details()
if menu_page is not None and hasattr(menu_page, 'refresh_menu_buttons'):
menu_page.refresh_menu_buttons()
self.content_layout.removeWidget(self.delete_page)
self.delete_page = self.create_delete_page()
self.content_layout.addWidget(self.delete_page)

View file

@ -142,10 +142,20 @@ class WorkerThread(QThread):
profile = ProfileController.get(profile_id)
if profile is not None:
try:
ProfileController.destroy(profile)
except Exception as e:
error_name = type(e).__name__
error_text = str(e) or 'Unknown deletion error'
self.text_output.emit(
f'Could not delete profile {profile_id}: {error_name}: {error_text}')
self.finished.emit(False)
return
self.text_output.emit(f'Profile {profile_id} deleted')
self.finished.emit(True)
else:
self.text_output.emit(f'Profile {profile_id} does not exist')
self.finished.emit(False)
def list_profiles(self):
profiles = ProfileController.get_all()