even better app search

This commit is contained in:
N0\A
2025-10-29 09:13:10 +01:00
parent 66ac8589b1
commit 775a529c81
2 changed files with 14 additions and 6 deletions

View File

@@ -3,16 +3,17 @@ import os
import configparser
class App:
def __init__(self, name: str, exec: str, icon: str = "", hidden: bool = False, generic_name: str = "", comment: str = ""):
def __init__(self, name: str, exec: str, icon: str = "", hidden: bool = False, generic_name: str = "", comment: str = "", command: str = ""):
self.name = name
self.exec = exec
self.icon = icon
self.hidden = hidden
self.generic_name = generic_name
self.comment = comment
self.command = command
def __str__(self):
return f"App(name={self.name}, exec={self.exec}, icon={self.icon}, hidden={self.hidden}, generic_name={self.generic_name}, comment={self.comment})"
return f"App(name={self.name}, exec={self.exec}, command={self.command}, icon={self.icon}, hidden={self.hidden}, generic_name={self.generic_name}, comment={self.comment})"
def get_desktop_dirs():
dirs = [
@@ -51,13 +52,15 @@ def parse_desktop_file(file_path: Path) -> list[App]:
if main_name and not is_hidden:
main_exec = main_entry.get('Exec')
if main_exec:
command_name = os.path.basename(main_exec.split(' ')[0])
apps.append(App(
name=main_name,
exec=main_exec,
icon=main_entry.get('Icon', ''),
hidden=False,
generic_name=main_entry.get('GenericName', ''),
comment=main_entry.get('Comment', '')
comment=main_entry.get('Comment', ''),
command=command_name
))
if 'Actions' in main_entry:
@@ -70,12 +73,14 @@ def parse_desktop_file(file_path: Path) -> list[App]:
action_exec = action_section.get('Exec')
if action_name and action_exec:
action_command_name = os.path.basename(action_exec.split(' ')[0])
combined_name = f"{main_name} - {action_name}"
apps.append(App(
name=combined_name,
exec=action_exec,
icon=main_entry.get('Icon', ''),
hidden=False
hidden=False,
command=action_command_name
))
return apps

View File

@@ -57,12 +57,14 @@ class AppLauncherDialog(QtWidgets.QDialog):
item = QtWidgets.QListWidgetItem(app.name)
item.setData(QtCore.Qt.UserRole, app) #type: ignore
# Set tooltip with GenericName and Comment
# Set tooltip with GenericName, Comment, and Command
tooltip_parts = []
if app.generic_name:
tooltip_parts.append(app.generic_name)
if app.comment:
tooltip_parts.append(app.comment)
if app.command and app.command.lower() != app.name.lower():
tooltip_parts.append(f"Command: {app.command}")
if tooltip_parts:
item.setToolTip("\n".join(tooltip_parts))
@@ -84,7 +86,8 @@ class AppLauncherDialog(QtWidgets.QDialog):
app for app in self.apps if
text_lower in app.name.lower() or
(app.generic_name and text_lower in app.generic_name.lower()) or
(app.comment and text_lower in app.comment.lower())
(app.comment and text_lower in app.comment.lower()) or
(app.command and text_lower in app.command.lower())
]
self.populate_list(filtered_apps)