better app search
This commit is contained in:
@@ -3,14 +3,16 @@ import os
|
||||
import configparser
|
||||
|
||||
class App:
|
||||
def __init__(self, name: str, exec: str, icon: str = "", hidden: bool = False):
|
||||
def __init__(self, name: str, exec: str, icon: str = "", hidden: bool = False, generic_name: str = "", comment: str = ""):
|
||||
self.name = name
|
||||
self.exec = exec
|
||||
self.icon = icon
|
||||
self.hidden = hidden
|
||||
self.generic_name = generic_name
|
||||
self.comment = comment
|
||||
|
||||
def __str__(self):
|
||||
return f"App(name={self.name}, exec={self.exec}, icon={self.icon}, hidden={self.hidden})"
|
||||
return f"App(name={self.name}, exec={self.exec}, icon={self.icon}, hidden={self.hidden}, generic_name={self.generic_name}, comment={self.comment})"
|
||||
|
||||
def get_desktop_dirs():
|
||||
dirs = [
|
||||
@@ -53,7 +55,9 @@ def parse_desktop_file(file_path: Path) -> list[App]:
|
||||
name=main_name,
|
||||
exec=main_exec,
|
||||
icon=main_entry.get('Icon', ''),
|
||||
hidden=False
|
||||
hidden=False,
|
||||
generic_name=main_entry.get('GenericName', ''),
|
||||
comment=main_entry.get('Comment', '')
|
||||
))
|
||||
|
||||
if 'Actions' in main_entry:
|
||||
|
||||
@@ -57,6 +57,15 @@ class AppLauncherDialog(QtWidgets.QDialog):
|
||||
item = QtWidgets.QListWidgetItem(app.name)
|
||||
item.setData(QtCore.Qt.UserRole, app) #type: ignore
|
||||
|
||||
# Set tooltip with GenericName and Comment
|
||||
tooltip_parts = []
|
||||
if app.generic_name:
|
||||
tooltip_parts.append(app.generic_name)
|
||||
if app.comment:
|
||||
tooltip_parts.append(app.comment)
|
||||
if tooltip_parts:
|
||||
item.setToolTip("\n".join(tooltip_parts))
|
||||
|
||||
# Try to load the icon
|
||||
if app.icon:
|
||||
icon = QtGui.QIcon.fromTheme(app.icon)
|
||||
@@ -71,7 +80,12 @@ class AppLauncherDialog(QtWidgets.QDialog):
|
||||
return
|
||||
|
||||
text_lower = text.lower()
|
||||
filtered_apps = [app for app in self.apps if text_lower in app.name.lower()]
|
||||
filtered_apps = [
|
||||
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())
|
||||
]
|
||||
self.populate_list(filtered_apps)
|
||||
|
||||
def launch_app(self, item: QtWidgets.QListWidgetItem):
|
||||
|
||||
Reference in New Issue
Block a user