forked from Support/sp-hydra-veil-gui
Edit Profile logic pushed to core. GUI nows passes just the profile id, key, and data. And core returns the results of the save
This commit is contained in:
parent
cfd9a92a24
commit
d52ca4842c
1 changed files with 12 additions and 35 deletions
|
|
@ -10,6 +10,8 @@ from PyQt6 import QtCore, QtGui
|
||||||
|
|
||||||
from core.controllers.ProfileController import ProfileController
|
from core.controllers.ProfileController import ProfileController
|
||||||
from core.controllers.LocationController import LocationController
|
from core.controllers.LocationController import LocationController
|
||||||
|
from core.models.Result import Result, ResultError
|
||||||
|
from core.controllers.profile_state.update_profile import update_profile
|
||||||
|
|
||||||
from gui.v2.ui.pages.Page import Page
|
from gui.v2.ui.pages.Page import Page
|
||||||
from gui.v2.ui.pages.browser_page import BrowserPage
|
from gui.v2.ui.pages.browser_page import BrowserPage
|
||||||
|
|
@ -795,49 +797,24 @@ class EditorPage(Page):
|
||||||
self._prefetched_profiles = None
|
self._prefetched_profiles = None
|
||||||
|
|
||||||
def update_core_profiles(self, key, new_value):
|
def update_core_profiles(self, key, new_value):
|
||||||
profile = ProfileController.get(
|
profile_id = int(self.update_status.current_profile_id)
|
||||||
int(self.update_status.current_profile_id))
|
|
||||||
self.update_res = False
|
# Sends to core directly,
|
||||||
if key == 'dimentions':
|
result = update_profile(profile_id, key, new_value)
|
||||||
profile.resolution = new_value
|
|
||||||
|
if result.valid:
|
||||||
|
self.update_status.update_status(
|
||||||
|
f'Updated profile {profile_id}')
|
||||||
|
|
||||||
|
if key == "resolution":
|
||||||
self.update_res = True
|
self.update_res = True
|
||||||
|
|
||||||
elif key == 'name':
|
if result.data == "edit_to_session":
|
||||||
profile.name = new_value
|
|
||||||
|
|
||||||
elif key == 'connection':
|
|
||||||
if new_value == 'tor':
|
|
||||||
profile.connection.code = new_value
|
|
||||||
profile.connection.masked = True
|
|
||||||
elif new_value == 'just proxy':
|
|
||||||
profile.connection.code = 'system'
|
|
||||||
profile.connection.masked = True
|
|
||||||
else:
|
|
||||||
self.update_status.update_status(
|
|
||||||
'System wide profiles not supported atm')
|
|
||||||
|
|
||||||
elif key == 'browser':
|
|
||||||
browser_type, browser_version = new_value.split(':', 1)
|
|
||||||
profile.application_version.application_code = browser_type
|
|
||||||
profile.application_version.version_number = browser_version
|
|
||||||
|
|
||||||
elif key == 'protocol':
|
|
||||||
if self.data_profile.get('connection') == 'system-wide':
|
|
||||||
self.edit_to_session()
|
self.edit_to_session()
|
||||||
else:
|
|
||||||
profile.connection.code = 'wireguard' if new_value == 'wireguard' else 'tor'
|
|
||||||
profile.connection.masked = False if new_value == 'wireguard' else True
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
location = self.connection_manager.get_location_info(new_value)
|
self.update_status.update_status(result.message)
|
||||||
|
|
||||||
if location:
|
|
||||||
profile.location.code = location.code
|
|
||||||
profile.location.country_code = location.country_code
|
|
||||||
profile.location.time_zone = location.time_zone
|
|
||||||
profile.subscription = None
|
|
||||||
|
|
||||||
ProfileController.update(profile)
|
|
||||||
|
|
||||||
def edit_to_session(self):
|
def edit_to_session(self):
|
||||||
id = int(self.update_status.current_profile_id)
|
id = int(self.update_status.current_profile_id)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue