mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-30 19:03:01 +01:00
Save configure screen settings to app config yaml on clicking Start
This commit is contained in:
parent
dae65c5b6b
commit
cc6ef0f450
1 changed files with 16 additions and 7 deletions
|
@ -3,6 +3,7 @@ from PyQt6 import QtWidgets
|
|||
from PyQt6.QtCore import Qt
|
||||
|
||||
# Internal Packages
|
||||
from src.utils import constants, yaml as yaml_utils
|
||||
from src.utils.config import SearchType
|
||||
from src.interface.desktop.file_browser import FileBrowser
|
||||
|
||||
|
@ -62,17 +63,25 @@ class ConfigureScreen(QtWidgets.QDialog):
|
|||
parent_layout.addWidget(action_bar)
|
||||
|
||||
def save_settings(self, _):
|
||||
# Save the settings to khoj.yml
|
||||
"Save the settings to khoj.yml"
|
||||
# Load the default config
|
||||
config = yaml_utils.load_config_from_file(constants.app_root_directory / 'config/khoj_sample.yml')
|
||||
|
||||
# Update the default config with the settings from the UI
|
||||
for settings_panel in self.settings_panels:
|
||||
for child in settings_panel.children():
|
||||
if isinstance(child, QtWidgets.QCheckBox):
|
||||
if child.isChecked():
|
||||
print(f"{child.text()} is enabled")
|
||||
else:
|
||||
print(f"{child.text()} is disabled")
|
||||
elif isinstance(child, FileBrowser):
|
||||
if isinstance(child, CheckBox) and not child.isChecked():
|
||||
del config['content-type'][child.search_type]
|
||||
elif isinstance(child, FileBrowser) and child.search_type in config['content-type']:
|
||||
config['content-type'][child.search_type]['input-files'] = child.getPaths()
|
||||
print(f"{child.search_type} files are {child.getPaths()}")
|
||||
|
||||
# Save the config to app config file
|
||||
del config['processor']['conversation']
|
||||
yaml_utils.save_config_to_file(config, self.config_file)
|
||||
|
||||
self.hide()
|
||||
|
||||
|
||||
class CheckBox(QtWidgets.QCheckBox):
|
||||
def __init__(self, text, search_type: SearchType, parent=None):
|
||||
|
|
Loading…
Reference in a new issue