mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-06 05:39:12 +00:00
Split config settings GUI into functions. Convert Config Window to Dialog
This commit is contained in:
@@ -3,7 +3,7 @@ from PyQt6 import QtWidgets
|
|||||||
from PyQt6.QtCore import Qt
|
from PyQt6.QtCore import Qt
|
||||||
|
|
||||||
|
|
||||||
class ConfigureWindow(QtWidgets.QMainWindow):
|
class ConfigureWindow(QtWidgets.QDialog):
|
||||||
"""Create Window to Configure Khoj
|
"""Create Window to Configure Khoj
|
||||||
Allow user to
|
Allow user to
|
||||||
1. Enable/Disable search on 1. org-mode, 2. markdown, 3. beancount or 4. image content types
|
1. Enable/Disable search on 1. org-mode, 2. markdown, 3. beancount or 4. image content types
|
||||||
@@ -11,42 +11,47 @@ class ConfigureWindow(QtWidgets.QMainWindow):
|
|||||||
3. Save the configuration to khoj.yml and start the server
|
3. Save the configuration to khoj.yml and start the server
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, parent=None):
|
||||||
super().__init__()
|
super(ConfigureWindow, self).__init__(parent=parent)
|
||||||
|
|
||||||
# Initialize Configure Window
|
# Initialize Configure Window
|
||||||
self.setWindowTitle("Khoj - Configure")
|
self.setWindowTitle("Khoj - Configure")
|
||||||
self.layout = QtWidgets.QVBoxLayout()
|
|
||||||
|
|
||||||
# Org Mode Settings
|
# Initialize Configure Window Layout
|
||||||
|
layout = QtWidgets.QVBoxLayout()
|
||||||
|
self.setLayout(layout)
|
||||||
|
|
||||||
|
# Add Panels to Configure Window Layout
|
||||||
|
self.show_orgmode_settings(layout)
|
||||||
|
self.show_ledger_settings(layout)
|
||||||
|
self.show_action_bar(layout)
|
||||||
|
|
||||||
|
def show_orgmode_settings(self, parent_layout):
|
||||||
|
"Add Org Mode Settings to the Configure Window"
|
||||||
orgmode_settings = QtWidgets.QWidget()
|
orgmode_settings = QtWidgets.QWidget()
|
||||||
self.orgmode_layout = QtWidgets.QVBoxLayout(orgmode_settings)
|
self.orgmode_layout = QtWidgets.QVBoxLayout(orgmode_settings)
|
||||||
enable_orgmode_search = QtWidgets.QCheckBox("Search Org-Mode Files")
|
enable_orgmode_search = QtWidgets.QCheckBox("Search Org-Mode Files")
|
||||||
enable_orgmode_search.stateChanged.connect(self.show_orgmode_search_options)
|
enable_orgmode_search.stateChanged.connect(self.show_orgmode_search_options)
|
||||||
self.orgmode_layout.addWidget(enable_orgmode_search)
|
self.orgmode_layout.addWidget(enable_orgmode_search)
|
||||||
self.layout.addWidget(orgmode_settings)
|
parent_layout.addWidget(orgmode_settings)
|
||||||
|
|
||||||
# Ledger Settings
|
def show_ledger_settings(self, parent_layout):
|
||||||
|
"Add Ledger Settings to the Configure Window"
|
||||||
ledger_settings = QtWidgets.QWidget()
|
ledger_settings = QtWidgets.QWidget()
|
||||||
self.ledger_layout = QtWidgets.QVBoxLayout(ledger_settings)
|
self.ledger_layout = QtWidgets.QVBoxLayout(ledger_settings)
|
||||||
enable_ledger_search = QtWidgets.QCheckBox("Search Beancount Files")
|
enable_ledger_search = QtWidgets.QCheckBox("Search Beancount Files")
|
||||||
enable_ledger_search.stateChanged.connect(self.show_ledger_search_options)
|
enable_ledger_search.stateChanged.connect(self.show_ledger_search_options)
|
||||||
self.ledger_layout.addWidget(enable_ledger_search)
|
self.ledger_layout.addWidget(enable_ledger_search)
|
||||||
self.layout.addWidget(ledger_settings)
|
parent_layout.addWidget(ledger_settings)
|
||||||
|
|
||||||
|
def show_action_bar(self, parent_layout):
|
||||||
|
"Add Action Bar to the Configure Window"
|
||||||
# Button to Save Settings
|
# Button to Save Settings
|
||||||
action_bar = QtWidgets.QWidget()
|
action_bar = QtWidgets.QWidget()
|
||||||
action_bar_layout = QtWidgets.QHBoxLayout(action_bar)
|
action_bar_layout = QtWidgets.QHBoxLayout(action_bar)
|
||||||
save_button = QtWidgets.QPushButton("Start", clicked=self.save_settings)
|
save_button = QtWidgets.QPushButton("Start", clicked=self.save_settings)
|
||||||
action_bar_layout.addWidget(save_button)
|
action_bar_layout.addWidget(save_button)
|
||||||
self.layout.addWidget(action_bar)
|
parent_layout.addWidget(action_bar)
|
||||||
|
|
||||||
# Set the central widget of the Window. Widget will expand
|
|
||||||
# to take up all the space in the window by default.
|
|
||||||
self.config_window = QtWidgets.QWidget()
|
|
||||||
self.config_window.setLayout(self.layout)
|
|
||||||
|
|
||||||
self.setCentralWidget(self.config_window)
|
|
||||||
|
|
||||||
def save_settings(self, s):
|
def save_settings(self, s):
|
||||||
# Save the settings to khoj.yml
|
# Save the settings to khoj.yml
|
||||||
|
|||||||
Reference in New Issue
Block a user