bug fixes
This commit is contained in:
+16
-13
@@ -1,6 +1,6 @@
|
||||
"""
|
||||
Filename: plugins.py
|
||||
Description: Plugins window with deferred remote fetching and installation state checks.
|
||||
Description: Plugins window
|
||||
|
||||
Author: Tyler de Zeeuw
|
||||
License: GPL-3.0
|
||||
@@ -43,7 +43,7 @@ class PluginsWindow(QWidget):
|
||||
self.main_app_window = parent
|
||||
self.manager: PluginManager = plugin_manager
|
||||
|
||||
self.setWindowTitle(f"Plugins - {APP_NAME.upper()}")
|
||||
self.setWindowTitle(f"{APP_NAME.upper()} - Plugins")
|
||||
self.resize(750, 500)
|
||||
|
||||
self.repository_urls: list[str] = [PLUGINS_URL]
|
||||
@@ -157,7 +157,7 @@ class PluginsWindow(QWidget):
|
||||
def fetch_remote_plugins(self) -> None:
|
||||
"""Asynchronously fetches remote plugins on a background thread."""
|
||||
if self._fetch_worker is not None and self._fetch_worker.isRunning():
|
||||
return # Fetch operation already in progress
|
||||
return
|
||||
|
||||
self.browser_list.clear()
|
||||
self.browser_list.addItem("Fetching remote repositories...")
|
||||
@@ -185,10 +185,9 @@ class PluginsWindow(QWidget):
|
||||
self.browser_list.addItem("No plugins found across configured repositories.")
|
||||
|
||||
def _populate_browser_list(self) -> None:
|
||||
"""Populates the browser tab list and checks if each plugin is already installed."""
|
||||
"""Populates the browser tab list and evaluates compatibility and installation state."""
|
||||
self.browser_list.clear()
|
||||
|
||||
# Gather set of currently installed identifiers (by ID and Name)
|
||||
installed_info = self.manager.get_installed_plugins_info()
|
||||
installed_ids = {p.get("id") for p in installed_info if p.get("id")}
|
||||
installed_names = {p.get("name") for p in installed_info if p.get("name")}
|
||||
@@ -205,14 +204,22 @@ class PluginsWindow(QWidget):
|
||||
is_version_ok = self.manager.current_app_version >= parse_version(min_v_str)
|
||||
is_compatible = is_platform_ok and is_version_ok
|
||||
|
||||
# Check if plugin is already installed locally
|
||||
# Evaluate reasons for incompatibility
|
||||
incompat_reasons: list[str] = []
|
||||
if not is_platform_ok:
|
||||
plat_str = ", ".join(platforms) if isinstance(platforms, list) else str(platforms)
|
||||
incompat_reasons.append(f"Requires platform: {plat_str}")
|
||||
if not is_version_ok:
|
||||
incompat_reasons.append(f"Requires App v{min_v_str}+")
|
||||
|
||||
is_installed = (bool(p_id) and p_id in installed_ids) or (bool(name) and name in installed_names)
|
||||
|
||||
display_text = f"{name} (v{version}) - {desc}"
|
||||
if is_installed:
|
||||
display_text += " [Installed]"
|
||||
elif not is_compatible:
|
||||
display_text += " [Incompatible]"
|
||||
elif incompat_reasons:
|
||||
reason_str = "; ".join(incompat_reasons)
|
||||
display_text += f" [Incompatible: {reason_str}]"
|
||||
|
||||
item = QListWidgetItem(display_text, self.browser_list)
|
||||
item.setData(Qt.ItemDataRole.UserRole, plugin)
|
||||
@@ -250,7 +257,7 @@ class PluginsWindow(QWidget):
|
||||
is_compatible = bool(current.data(Qt.ItemDataRole.UserRole + 1))
|
||||
is_installed = bool(current.data(Qt.ItemDataRole.UserRole + 2))
|
||||
|
||||
# Disable install button if plugin is incompatible OR ALREADY INSTALLED
|
||||
# Button lights up ONLY if plugin is compatible and NOT yet installed
|
||||
self.btn_install.setEnabled(is_compatible and not is_installed)
|
||||
else:
|
||||
self.btn_install.setEnabled(False)
|
||||
@@ -267,7 +274,6 @@ class PluginsWindow(QWidget):
|
||||
tab = QWidget()
|
||||
layout = QVBoxLayout(tab)
|
||||
|
||||
# Header bar with directory path and Open Folder button
|
||||
path_layout = QHBoxLayout()
|
||||
path_label = QLabel(f"<b>Plugins Directory:</b> <code>{self.manager.plugins_dir}</code>", tab)
|
||||
btn_open_folder = QPushButton("Open Folder", tab)
|
||||
@@ -278,13 +284,11 @@ class PluginsWindow(QWidget):
|
||||
path_layout.addStretch()
|
||||
path_layout.addWidget(btn_open_folder)
|
||||
|
||||
# Splitter Layout: Left side List, Right side Detail Panel
|
||||
content_layout = QHBoxLayout()
|
||||
|
||||
self.installed_list = QListWidget(tab)
|
||||
self.installed_list.currentItemChanged.connect(self._on_installed_item_changed)
|
||||
|
||||
# Right-side Details Panel
|
||||
self.details_panel = QWidget(tab)
|
||||
details_layout = QVBoxLayout(self.details_panel)
|
||||
details_layout.setContentsMargins(10, 0, 0, 0)
|
||||
@@ -312,7 +316,6 @@ class PluginsWindow(QWidget):
|
||||
content_layout.addWidget(self.installed_list, stretch=1)
|
||||
content_layout.addWidget(self.details_panel, stretch=1)
|
||||
|
||||
# Bottom Action Buttons
|
||||
btn_layout = QHBoxLayout()
|
||||
btn_refresh = QPushButton("Refresh List", tab)
|
||||
btn_enable = QPushButton("Enable / Disable", tab)
|
||||
|
||||
Reference in New Issue
Block a user