mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 21:29:11 +00:00
Save configure screen settings to app config yaml on clicking Start
This commit is contained in:
@@ -3,6 +3,7 @@ from PyQt6 import QtWidgets
|
|||||||
from PyQt6.QtCore import Qt
|
from PyQt6.QtCore import Qt
|
||||||
|
|
||||||
# Internal Packages
|
# Internal Packages
|
||||||
|
from src.utils import constants, yaml as yaml_utils
|
||||||
from src.utils.config import SearchType
|
from src.utils.config import SearchType
|
||||||
from src.interface.desktop.file_browser import FileBrowser
|
from src.interface.desktop.file_browser import FileBrowser
|
||||||
|
|
||||||
@@ -62,17 +63,25 @@ class ConfigureScreen(QtWidgets.QDialog):
|
|||||||
parent_layout.addWidget(action_bar)
|
parent_layout.addWidget(action_bar)
|
||||||
|
|
||||||
def save_settings(self, _):
|
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 settings_panel in self.settings_panels:
|
||||||
for child in settings_panel.children():
|
for child in settings_panel.children():
|
||||||
if isinstance(child, QtWidgets.QCheckBox):
|
if isinstance(child, CheckBox) and not child.isChecked():
|
||||||
if child.isChecked():
|
del config['content-type'][child.search_type]
|
||||||
print(f"{child.text()} is enabled")
|
elif isinstance(child, FileBrowser) and child.search_type in config['content-type']:
|
||||||
else:
|
config['content-type'][child.search_type]['input-files'] = child.getPaths()
|
||||||
print(f"{child.text()} is disabled")
|
|
||||||
elif isinstance(child, FileBrowser):
|
|
||||||
print(f"{child.search_type} files are {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):
|
class CheckBox(QtWidgets.QCheckBox):
|
||||||
def __init__(self, text, search_type: SearchType, parent=None):
|
def __init__(self, text, search_type: SearchType, parent=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user