mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-07 21:29:13 +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 entry[0] in torch_lib_paths]
|
||||||
|
|
||||||
a.datas = [entry for entry in a.datas if not 'torch/_C.cp' in entry[0]]
|
os_path_separator = '\\' if system() == 'Windows' else '/'
|
||||||
a.datas = [entry for entry in a.datas if not 'torch/_dl.cp' in entry[0]]
|
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)
|
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',
|
'src/interface/web/assets/icons/favicon-144x144.png',
|
||||||
binaries=a.binaries,
|
binaries=a.binaries,
|
||||||
datas=a.datas,
|
datas=a.datas,
|
||||||
text_pos=(10, 50),
|
text_pos=(10, 160),
|
||||||
text_size=12,
|
text_size=12,
|
||||||
text_color='blue',
|
text_color='black',
|
||||||
minify_script=True,
|
minify_script=True,
|
||||||
always_on_top=True
|
always_on_top=True
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ from PyQt6.QtCore import QDir
|
|||||||
|
|
||||||
# Internal Packages
|
# Internal Packages
|
||||||
from src.utils.config import SearchType
|
from src.utils.config import SearchType
|
||||||
|
from src.utils.helpers import is_none_or_empty
|
||||||
|
|
||||||
|
|
||||||
class FileBrowser(QtWidgets.QWidget):
|
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)
|
QtWidgets.QWidget.__init__(self)
|
||||||
layout = QtWidgets.QHBoxLayout()
|
layout = QtWidgets.QHBoxLayout()
|
||||||
self.setLayout(layout)
|
self.setLayout(layout)
|
||||||
@@ -57,16 +58,11 @@ class FileBrowser(QtWidgets.QWidget):
|
|||||||
filter=self.filter_name)[0])
|
filter=self.filter_name)[0])
|
||||||
self.setFiles(filepaths)
|
self.setFiles(filepaths)
|
||||||
|
|
||||||
def setFiles(self, paths):
|
def setFiles(self, paths:list):
|
||||||
self.filepaths = paths
|
self.filepaths = [path for path in paths if not is_none_or_empty(path)]
|
||||||
if not self.filepaths or len(self.filepaths) == 0:
|
self.lineEdit.setPlainText("\n".join(self.filepaths))
|
||||||
return
|
|
||||||
elif len(self.filepaths) == 1:
|
|
||||||
self.lineEdit.setPlainText(self.filepaths[0])
|
|
||||||
else:
|
|
||||||
self.lineEdit.setPlainText("\n".join(self.filepaths))
|
|
||||||
|
|
||||||
def getPaths(self):
|
def getPaths(self) -> list:
|
||||||
if self.lineEdit.toPlainText() == '':
|
if self.lineEdit.toPlainText() == '':
|
||||||
return []
|
return []
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -4,9 +4,8 @@ from pathlib import Path
|
|||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
|
||||||
|
|
||||||
# External Packages
|
# External Packages
|
||||||
from PyQt6 import QtWidgets
|
from PyQt6 import QtGui, QtWidgets
|
||||||
from PyQt6.QtCore import Qt, QThread, QObject, pyqtSignal
|
from PyQt6.QtCore import Qt, QThread, QObject, pyqtSignal
|
||||||
|
|
||||||
# Internal Packages
|
# Internal Packages
|
||||||
@@ -49,6 +48,10 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
self.setWindowTitle("Khoj")
|
self.setWindowTitle("Khoj")
|
||||||
self.setFixedWidth(600)
|
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
|
# Initialize Configure Window Layout
|
||||||
self.layout = QtWidgets.QVBoxLayout()
|
self.layout = QtWidgets.QVBoxLayout()
|
||||||
|
|
||||||
@@ -72,7 +75,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||||||
self.config_window = QtWidgets.QWidget()
|
self.config_window = QtWidgets.QWidget()
|
||||||
self.config_window.setLayout(self.layout)
|
self.config_window.setLayout(self.layout)
|
||||||
self.setCentralWidget(self.config_window)
|
self.setCentralWidget(self.config_window)
|
||||||
|
self.position_window()
|
||||||
|
|
||||||
def add_settings_panel(self, current_content_config: dict, search_type: SearchType):
|
def add_settings_panel(self, current_content_config: dict, search_type: SearchType):
|
||||||
"Add Settings Panel for specified Search Type. Toggle Editable Search Types"
|
"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.configure_button.setEnabled(True))
|
||||||
self.thread.finished.connect(lambda: self.search_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):
|
class SettingsLoader(QObject):
|
||||||
"Load Settings Thread"
|
"Load Settings Thread"
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ def create_system_tray(gui: QtWidgets.QApplication, main_window: QtWidgets.QMain
|
|||||||
menu = QtWidgets.QMenu()
|
menu = QtWidgets.QMenu()
|
||||||
menu_actions = [
|
menu_actions = [
|
||||||
('Search', lambda: webbrowser.open(f'http://{state.host}:{state.port}/')),
|
('Search', lambda: webbrowser.open(f'http://{state.host}:{state.port}/')),
|
||||||
('Configure', main_window.show),
|
('Configure', main_window.show_on_top),
|
||||||
('Quit', gui.quit),
|
('Quit', gui.quit),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from os.path import join
|
|||||||
|
|
||||||
|
|
||||||
def is_none_or_empty(item):
|
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):
|
def to_snake_case_from_dash(item: str):
|
||||||
|
|||||||
Reference in New Issue
Block a user