mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-05 05:39:11 +00:00
Open the search, chat or config view in app from the system tray menu
This commit is contained in:
@@ -25,6 +25,7 @@ class MainWindow(QWebEngineView):
|
||||
|
||||
def __init__(self, url: str):
|
||||
super(MainWindow, self).__init__()
|
||||
self.base_url = url
|
||||
|
||||
# Initialize Configure Window
|
||||
self.setWindowTitle("Khoj")
|
||||
@@ -36,10 +37,17 @@ class MainWindow(QWebEngineView):
|
||||
# Open Khoj Web App Root
|
||||
self.webpage = QWebEnginePage()
|
||||
self.setPage(self.webpage)
|
||||
self.webpage.load(QUrl(url))
|
||||
self.webpage.load(QUrl(self.base_url))
|
||||
|
||||
self.position_window()
|
||||
|
||||
def show_page(self, page: str = ""):
|
||||
def load_page():
|
||||
self.webpage.load(QUrl(f"{self.base_url}/{page}"))
|
||||
self.show()
|
||||
|
||||
return load_page
|
||||
|
||||
def position_window(self):
|
||||
"Position the window at center of X axis and near top on Y axis"
|
||||
window_rectangle = self.geometry()
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
# Standard Packages
|
||||
import webbrowser
|
||||
|
||||
# External Packages
|
||||
from PySide6 import QtGui, QtWidgets
|
||||
|
||||
# Internal Packages
|
||||
from khoj.utils import constants, state
|
||||
from khoj.utils import constants
|
||||
from khoj.interface.desktop.main_window import MainWindow
|
||||
|
||||
|
||||
@@ -25,9 +22,9 @@ def create_system_tray(gui: QtWidgets.QApplication, main_window: MainWindow):
|
||||
# Create the menu and menu actions
|
||||
menu = QtWidgets.QMenu()
|
||||
menu_actions = [
|
||||
("Search", lambda: webbrowser.open(f"http://{state.host}:{state.port}/")),
|
||||
("Configure", lambda: webbrowser.open(f"http://{state.host}:{state.port}/config")),
|
||||
("App", main_window.show),
|
||||
("Search", main_window.show_page()),
|
||||
("Chat", main_window.show_page("chat")),
|
||||
("Configure", main_window.show_page("config")),
|
||||
("Quit", gui.quit),
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user