mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-04 21:29:12 +00:00
Fix, Improve Desktop GUI Splash Screen and Main Window
-5e6625aFix file browser to not add empty line when no file/dir selected -8098b8cBring main window to Top when open from System Tray -1c122a8Place window near top so buttons are not hidden by OS bottom bar -dfe2546Set Khoj Icon on Main Desktop Window -1b1f8f9Move Splash screen text below icon. Set the text color to black -450f644Fix path to remove shared libraries when packaging the Windows app
This commit is contained in:
@@ -41,8 +41,9 @@ torch_lib_paths = {
|
||||
}
|
||||
a.datas = [entry for entry in a.datas if not entry[0] in torch_lib_paths]
|
||||
|
||||
a.datas = [entry for entry in a.datas if not 'torch/_C.cp' in entry[0]]
|
||||
a.datas = [entry for entry in a.datas if not 'torch/_dl.cp' in entry[0]]
|
||||
os_path_separator = '\\' if system() == 'Windows' else '/'
|
||||
a.datas = [entry for entry in a.datas if not f'torch{os_path_separator}_C.cp' in entry[0]]
|
||||
a.datas = [entry for entry in a.datas if not f'torch{os_path_separator}_dl.cp' in entry[0]]
|
||||
|
||||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
||||
|
||||
@@ -52,9 +53,9 @@ if system() != 'Darwin':
|
||||
'src/interface/web/assets/icons/favicon-144x144.png',
|
||||
binaries=a.binaries,
|
||||
datas=a.datas,
|
||||
text_pos=(10, 50),
|
||||
text_pos=(10, 160),
|
||||
text_size=12,
|
||||
text_color='blue',
|
||||
text_color='black',
|
||||
minify_script=True,
|
||||
always_on_top=True
|
||||
)
|
||||
|
||||
@@ -4,10 +4,11 @@ from PyQt6.QtCore import QDir
|
||||
|
||||
# Internal Packages
|
||||
from src.utils.config import SearchType
|
||||
from src.utils.helpers import is_none_or_empty
|
||||
|
||||
|
||||
class FileBrowser(QtWidgets.QWidget):
|
||||
def __init__(self, title, search_type: SearchType=None, default_files=[]):
|
||||
def __init__(self, title, search_type: SearchType=None, default_files:list=[]):
|
||||
QtWidgets.QWidget.__init__(self)
|
||||
layout = QtWidgets.QHBoxLayout()
|
||||
self.setLayout(layout)
|
||||
@@ -57,16 +58,11 @@ class FileBrowser(QtWidgets.QWidget):
|
||||
filter=self.filter_name)[0])
|
||||
self.setFiles(filepaths)
|
||||
|
||||
def setFiles(self, paths):
|
||||
self.filepaths = paths
|
||||
if not self.filepaths or len(self.filepaths) == 0:
|
||||
return
|
||||
elif len(self.filepaths) == 1:
|
||||
self.lineEdit.setPlainText(self.filepaths[0])
|
||||
else:
|
||||
self.lineEdit.setPlainText("\n".join(self.filepaths))
|
||||
def setFiles(self, paths:list):
|
||||
self.filepaths = [path for path in paths if not is_none_or_empty(path)]
|
||||
self.lineEdit.setPlainText("\n".join(self.filepaths))
|
||||
|
||||
def getPaths(self):
|
||||
def getPaths(self) -> list:
|
||||
if self.lineEdit.toPlainText() == '':
|
||||
return []
|
||||
else:
|
||||
|
||||
@@ -4,9 +4,8 @@ from pathlib import Path
|
||||
from copy import deepcopy
|
||||
import webbrowser
|
||||
|
||||
|
||||
# External Packages
|
||||
from PyQt6 import QtWidgets
|
||||
from PyQt6 import QtGui, QtWidgets
|
||||
from PyQt6.QtCore import Qt, QThread, QObject, pyqtSignal
|
||||
|
||||
# Internal Packages
|
||||
@@ -49,6 +48,10 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
self.setWindowTitle("Khoj")
|
||||
self.setFixedWidth(600)
|
||||
|
||||
# Set Window Icon
|
||||
icon_path = constants.web_directory / 'assets/icons/favicon-144x144.png'
|
||||
self.setWindowIcon(QtGui.QIcon(f'{icon_path.absolute()}'))
|
||||
|
||||
# Initialize Configure Window Layout
|
||||
self.layout = QtWidgets.QVBoxLayout()
|
||||
|
||||
@@ -72,7 +75,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
self.config_window = QtWidgets.QWidget()
|
||||
self.config_window.setLayout(self.layout)
|
||||
self.setCentralWidget(self.config_window)
|
||||
|
||||
self.position_window()
|
||||
|
||||
def add_settings_panel(self, current_content_config: dict, search_type: SearchType):
|
||||
"Add Settings Panel for specified Search Type. Toggle Editable Search Types"
|
||||
@@ -263,6 +266,20 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
self.thread.finished.connect(lambda: self.configure_button.setEnabled(True))
|
||||
self.thread.finished.connect(lambda: self.search_button.setEnabled(True))
|
||||
|
||||
def position_window(self):
|
||||
"Position the window at center of X axis and near top on Y axis"
|
||||
window_rectangle = self.geometry()
|
||||
screen_center = self.screen().availableGeometry().center()
|
||||
window_rectangle.moveCenter(screen_center)
|
||||
self.move(window_rectangle.topLeft().x(), 25)
|
||||
|
||||
def show_on_top(self):
|
||||
"Bring Window on Top"
|
||||
self.show()
|
||||
self.setWindowState(Qt.WindowState.WindowActive)
|
||||
self.activateWindow() # For Bringing to Top on Windows
|
||||
self.raise_() # For Bringing to Top from Minimized State on OSX
|
||||
|
||||
|
||||
class SettingsLoader(QObject):
|
||||
"Load Settings Thread"
|
||||
|
||||
@@ -25,7 +25,7 @@ def create_system_tray(gui: QtWidgets.QApplication, main_window: QtWidgets.QMain
|
||||
menu = QtWidgets.QMenu()
|
||||
menu_actions = [
|
||||
('Search', lambda: webbrowser.open(f'http://{state.host}:{state.port}/')),
|
||||
('Configure', main_window.show),
|
||||
('Configure', main_window.show_on_top),
|
||||
('Quit', gui.quit),
|
||||
]
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from os.path import join
|
||||
|
||||
|
||||
def is_none_or_empty(item):
|
||||
return item == None or (hasattr(item, '__iter__') and len(item) == 0)
|
||||
return item == None or (hasattr(item, '__iter__') and len(item) == 0) or item == ''
|
||||
|
||||
|
||||
def to_snake_case_from_dash(item: str):
|
||||
|
||||
Reference in New Issue
Block a user