pylance fixes and terminal plugin launching
This commit is contained in:
+32
-16
@@ -1,13 +1,15 @@
|
||||
"""
|
||||
Filename: plugins.py
|
||||
Description: Plugins window
|
||||
Note: Compliant with pylance strict type checking
|
||||
|
||||
Author: Tyler de Zeeuw
|
||||
License: GPL-3.0
|
||||
"""
|
||||
|
||||
# Built-in imports
|
||||
from typing import Any
|
||||
from pathlib import Path
|
||||
from typing import Any, cast
|
||||
|
||||
# External library imports
|
||||
from PySide6.QtCore import Qt, QThread, Signal
|
||||
@@ -104,12 +106,14 @@ class PluginsWindow(QWidget):
|
||||
self._clear_details_panel()
|
||||
return
|
||||
|
||||
name = info.get("name", "Unknown")
|
||||
version = info.get("version", "1.0.0")
|
||||
author = info.get("author", "Unknown")
|
||||
desc = info.get("description", "No description provided.")
|
||||
is_disabled = info.get("is_disabled", False)
|
||||
path = info.get("path", "")
|
||||
plugin_info = cast(dict[str, Any], info)
|
||||
|
||||
name = str(plugin_info.get("name", "Unknown"))
|
||||
version = str(plugin_info.get("version", "1.0.0"))
|
||||
author = str(plugin_info.get("author", "Unknown"))
|
||||
desc = str(plugin_info.get("description", "No description provided."))
|
||||
is_disabled = bool(plugin_info.get("is_disabled", False))
|
||||
path = str(plugin_info.get("path", ""))
|
||||
|
||||
self.lbl_plugin_title.setText(name)
|
||||
self.lbl_plugin_meta.setText(f"<b>Version:</b> {version} | <b>Author:</b> {author}")
|
||||
@@ -134,25 +138,37 @@ class PluginsWindow(QWidget):
|
||||
selected = self.installed_list.currentItem()
|
||||
if not selected:
|
||||
return
|
||||
info = selected.data(Qt.ItemDataRole.UserRole)
|
||||
if isinstance(info, dict) and "path" in info:
|
||||
self.manager.toggle_plugin_state(info["path"])
|
||||
raw_info = selected.data(Qt.ItemDataRole.UserRole)
|
||||
if isinstance(raw_info, dict):
|
||||
info = cast(dict[str, Any], raw_info)
|
||||
plugin_path = info.get("path")
|
||||
if isinstance(plugin_path, str) and plugin_path:
|
||||
self.manager.toggle_plugin_state(Path(plugin_path))
|
||||
|
||||
def uninstall_plugin(self) -> None:
|
||||
selected = self.installed_list.currentItem()
|
||||
if not selected:
|
||||
return
|
||||
info = selected.data(Qt.ItemDataRole.UserRole)
|
||||
if not isinstance(info, dict) or "path" not in info:
|
||||
|
||||
raw_info = selected.data(Qt.ItemDataRole.UserRole)
|
||||
if not isinstance(raw_info, dict):
|
||||
return
|
||||
|
||||
info = cast(dict[str, Any], raw_info)
|
||||
plugin_path = info.get("path")
|
||||
plugin_name = info.get("name", "this plugin")
|
||||
|
||||
if not isinstance(plugin_path, str) or not plugin_path:
|
||||
return
|
||||
|
||||
reply = QMessageBox.question(
|
||||
self, "Confirm Uninstall",
|
||||
f"Are you sure you want to delete '{info['name']}'?",
|
||||
self,
|
||||
"Confirm Uninstall",
|
||||
f"Are you sure you want to delete '{plugin_name}'?",
|
||||
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
|
||||
)
|
||||
if reply == QMessageBox.StandardButton.Yes:
|
||||
self.manager.uninstall_plugin(info["path"])
|
||||
self.manager.uninstall_plugin(Path(plugin_path))
|
||||
|
||||
def fetch_remote_plugins(self) -> None:
|
||||
"""Asynchronously fetches remote plugins on a background thread."""
|
||||
@@ -197,7 +213,7 @@ class PluginsWindow(QWidget):
|
||||
p_id = plugin.get("id", "")
|
||||
version = plugin.get("version", "v0.0")
|
||||
desc = plugin.get("description", "")
|
||||
platforms = plugin.get("platforms", [])
|
||||
platforms = str(plugin.get("platforms", []))
|
||||
min_v_str = plugin.get("min_app_version", "0.0.0")
|
||||
|
||||
is_platform_ok = not platforms or self.manager.current_platform in platforms
|
||||
|
||||
Reference in New Issue
Block a user