mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-06 13:22:12 +00:00
Quit GUI via SysTray instead of sys.exit to cleanly terminate server
This commit is contained in:
@@ -28,7 +28,7 @@ def run():
|
|||||||
# Setup GUI
|
# Setup GUI
|
||||||
gui = QtWidgets.QApplication([])
|
gui = QtWidgets.QApplication([])
|
||||||
gui.setQuitOnLastWindowClosed(False)
|
gui.setQuitOnLastWindowClosed(False)
|
||||||
tray = create_system_tray()
|
tray = create_system_tray(gui)
|
||||||
window = ConfigureWindow()
|
window = ConfigureWindow()
|
||||||
|
|
||||||
# Start Application Server
|
# Start Application Server
|
||||||
@@ -102,7 +102,7 @@ class ConfigureWindow(QtWidgets.QMainWindow):
|
|||||||
self.config_window.layout().removeWidget(self.config_window.layout().itemAt(2).widget())
|
self.config_window.layout().removeWidget(self.config_window.layout().itemAt(2).widget())
|
||||||
|
|
||||||
|
|
||||||
def create_system_tray():
|
def create_system_tray(gui: QtWidgets.QApplication):
|
||||||
"""Create System Tray with Menu
|
"""Create System Tray with Menu
|
||||||
Menu Actions should contain
|
Menu Actions should contain
|
||||||
1. option to open search page at localhost:8000/
|
1. option to open search page at localhost:8000/
|
||||||
@@ -121,7 +121,7 @@ def create_system_tray():
|
|||||||
menu_actions = [
|
menu_actions = [
|
||||||
('Search', lambda: webbrowser.open('http://localhost:8000/')),
|
('Search', lambda: webbrowser.open('http://localhost:8000/')),
|
||||||
('Configure', lambda: webbrowser.open('http://localhost:8000/config')),
|
('Configure', lambda: webbrowser.open('http://localhost:8000/config')),
|
||||||
('Quit', sys.exit),
|
('Quit', gui.quit),
|
||||||
]
|
]
|
||||||
|
|
||||||
# Add the menu actions to the menu
|
# Add the menu actions to the menu
|
||||||
|
|||||||
Reference in New Issue
Block a user