mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-07 21:29:13 +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):
|
def __init__(self, url: str):
|
||||||
super(MainWindow, self).__init__()
|
super(MainWindow, self).__init__()
|
||||||
|
self.base_url = url
|
||||||
|
|
||||||
# Initialize Configure Window
|
# Initialize Configure Window
|
||||||
self.setWindowTitle("Khoj")
|
self.setWindowTitle("Khoj")
|
||||||
@@ -36,10 +37,17 @@ class MainWindow(QWebEngineView):
|
|||||||
# Open Khoj Web App Root
|
# Open Khoj Web App Root
|
||||||
self.webpage = QWebEnginePage()
|
self.webpage = QWebEnginePage()
|
||||||
self.setPage(self.webpage)
|
self.setPage(self.webpage)
|
||||||
self.webpage.load(QUrl(url))
|
self.webpage.load(QUrl(self.base_url))
|
||||||
|
|
||||||
self.position_window()
|
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):
|
def position_window(self):
|
||||||
"Position the window at center of X axis and near top on Y axis"
|
"Position the window at center of X axis and near top on Y axis"
|
||||||
window_rectangle = self.geometry()
|
window_rectangle = self.geometry()
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
# Standard Packages
|
|
||||||
import webbrowser
|
|
||||||
|
|
||||||
# External Packages
|
# External Packages
|
||||||
from PySide6 import QtGui, QtWidgets
|
from PySide6 import QtGui, QtWidgets
|
||||||
|
|
||||||
# Internal Packages
|
# Internal Packages
|
||||||
from khoj.utils import constants, state
|
from khoj.utils import constants
|
||||||
from khoj.interface.desktop.main_window import MainWindow
|
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
|
# Create the menu and menu actions
|
||||||
menu = QtWidgets.QMenu()
|
menu = QtWidgets.QMenu()
|
||||||
menu_actions = [
|
menu_actions = [
|
||||||
("Search", lambda: webbrowser.open(f"http://{state.host}:{state.port}/")),
|
("Search", main_window.show_page()),
|
||||||
("Configure", lambda: webbrowser.open(f"http://{state.host}:{state.port}/config")),
|
("Chat", main_window.show_page("chat")),
|
||||||
("App", main_window.show),
|
("Configure", main_window.show_page("config")),
|
||||||
("Quit", gui.quit),
|
("Quit", gui.quit),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user