274 lines
9.1 KiB
Python
274 lines
9.1 KiB
Python
"""
|
|
EU-Utility - Plugin Store UI Plugin
|
|
|
|
Browse and install community plugins.
|
|
"""
|
|
|
|
from PyQt6.QtWidgets import (
|
|
QWidget, QVBoxLayout, QHBoxLayout, QLabel,
|
|
QPushButton, QLineEdit, QListWidget, QListWidgetItem,
|
|
QProgressBar, QFrame, QTextEdit
|
|
)
|
|
from PyQt6.QtCore import Qt, QThread, pyqtSignal
|
|
|
|
from plugins.base_plugin import BasePlugin
|
|
|
|
|
|
class PluginStoreUIPlugin(BasePlugin):
|
|
"""Browse and install community plugins."""
|
|
|
|
name = "Plugin Store"
|
|
version = "1.0.0"
|
|
author = "ImpulsiveFPS"
|
|
description = "Community plugin marketplace"
|
|
hotkey = "ctrl+shift+slash"
|
|
|
|
def initialize(self):
|
|
"""Setup plugin store."""
|
|
self.available_plugins = []
|
|
self.installed_plugins = []
|
|
self.is_loading = False
|
|
|
|
def get_ui(self):
|
|
"""Create plugin store UI."""
|
|
widget = QWidget()
|
|
widget.setStyleSheet("background: transparent;")
|
|
layout = QVBoxLayout(widget)
|
|
layout.setSpacing(15)
|
|
layout.setContentsMargins(0, 0, 0, 0)
|
|
|
|
# Title
|
|
title = QLabel("🛒 Plugin Store")
|
|
title.setStyleSheet("color: white; font-size: 16px; font-weight: bold;")
|
|
layout.addWidget(title)
|
|
|
|
# Search
|
|
search_layout = QHBoxLayout()
|
|
self.search_input = QLineEdit()
|
|
self.search_input.setPlaceholderText("Search plugins...")
|
|
self.search_input.setStyleSheet("""
|
|
QLineEdit {
|
|
background-color: rgba(30, 35, 45, 200);
|
|
color: white;
|
|
border: 1px solid rgba(100, 110, 130, 80);
|
|
border-radius: 4px;
|
|
padding: 8px;
|
|
}
|
|
""")
|
|
search_layout.addWidget(self.search_input)
|
|
|
|
search_btn = QPushButton("🔍")
|
|
search_btn.setFixedSize(32, 32)
|
|
search_btn.setStyleSheet("""
|
|
QPushButton {
|
|
background-color: #ff8c42;
|
|
border: none;
|
|
border-radius: 4px;
|
|
}
|
|
""")
|
|
search_btn.clicked.connect(self._search_plugins)
|
|
search_layout.addWidget(search_btn)
|
|
|
|
layout.addLayout(search_layout)
|
|
|
|
# Categories
|
|
cats_layout = QHBoxLayout()
|
|
for cat in ["All", "Hunting", "Mining", "Crafting", "Tools", "Social"]:
|
|
btn = QPushButton(cat)
|
|
btn.setStyleSheet("""
|
|
QPushButton {
|
|
background-color: rgba(255,255,255,15);
|
|
color: white;
|
|
border: none;
|
|
border-radius: 4px;
|
|
padding: 5px 10px;
|
|
}
|
|
QPushButton:hover {
|
|
background-color: rgba(255,255,255,30);
|
|
}
|
|
""")
|
|
cats_layout.addWidget(btn)
|
|
cats_layout.addStretch()
|
|
layout.addLayout(cats_layout)
|
|
|
|
# Plugins list
|
|
self.plugins_list = QListWidget()
|
|
self.plugins_list.setStyleSheet("""
|
|
QListWidget {
|
|
background-color: rgba(30, 35, 45, 200);
|
|
color: white;
|
|
border: 1px solid rgba(100, 110, 130, 80);
|
|
border-radius: 6px;
|
|
}
|
|
QListWidget::item {
|
|
padding: 12px;
|
|
border-bottom: 1px solid rgba(100, 110, 130, 40);
|
|
}
|
|
QListWidget::item:hover {
|
|
background-color: rgba(255, 255, 255, 10);
|
|
}
|
|
""")
|
|
self.plugins_list.itemClicked.connect(self._show_plugin_details)
|
|
layout.addWidget(self.plugins_list)
|
|
|
|
# Sample plugins
|
|
self._load_sample_plugins()
|
|
|
|
# Details panel
|
|
self.details_panel = QFrame()
|
|
self.details_panel.setStyleSheet("""
|
|
QFrame {
|
|
background-color: rgba(30, 35, 45, 200);
|
|
border: 1px solid rgba(100, 110, 130, 80);
|
|
border-radius: 6px;
|
|
}
|
|
""")
|
|
details_layout = QVBoxLayout(self.details_panel)
|
|
|
|
self.detail_name = QLabel("Select a plugin")
|
|
self.detail_name.setStyleSheet("color: #ff8c42; font-size: 14px; font-weight: bold;")
|
|
details_layout.addWidget(self.detail_name)
|
|
|
|
self.detail_desc = QLabel("")
|
|
self.detail_desc.setStyleSheet("color: rgba(255,255,255,150);")
|
|
self.detail_desc.setWordWrap(True)
|
|
details_layout.addWidget(self.detail_desc)
|
|
|
|
self.detail_author = QLabel("")
|
|
self.detail_author.setStyleSheet("color: rgba(255,255,255,100); font-size: 10px;")
|
|
details_layout.addWidget(self.detail_author)
|
|
|
|
self.install_btn = QPushButton("Install")
|
|
self.install_btn.setStyleSheet("""
|
|
QPushButton {
|
|
background-color: #4caf50;
|
|
color: white;
|
|
padding: 10px;
|
|
border: none;
|
|
border-radius: 4px;
|
|
font-weight: bold;
|
|
}
|
|
""")
|
|
self.install_btn.clicked.connect(self._install_plugin)
|
|
self.install_btn.setEnabled(False)
|
|
details_layout.addWidget(self.install_btn)
|
|
|
|
layout.addWidget(self.details_panel)
|
|
|
|
# Refresh button
|
|
refresh_btn = QPushButton("🔄 Refresh")
|
|
refresh_btn.setStyleSheet("""
|
|
QPushButton {
|
|
background-color: rgba(255,255,255,20);
|
|
color: white;
|
|
padding: 8px;
|
|
border: none;
|
|
border-radius: 4px;
|
|
}
|
|
""")
|
|
refresh_btn.clicked.connect(self._refresh_store)
|
|
layout.addWidget(refresh_btn)
|
|
|
|
layout.addStretch()
|
|
return widget
|
|
|
|
def _load_sample_plugins(self):
|
|
"""Load sample plugin list."""
|
|
sample = [
|
|
{
|
|
'name': 'Crafting Calculator',
|
|
'description': 'Calculate crafting success rates and costs',
|
|
'author': 'EU Community',
|
|
'version': '1.0.0',
|
|
'downloads': 542,
|
|
'rating': 4.5,
|
|
},
|
|
{
|
|
'name': 'Global Tracker',
|
|
'description': 'Track globals and HOFs with notifications',
|
|
'author': 'ImpulsiveFPS',
|
|
'version': '1.2.0',
|
|
'downloads': 1203,
|
|
'rating': 4.8,
|
|
},
|
|
{
|
|
'name': 'Bank Manager',
|
|
'description': 'Manage storage and bank items across planets',
|
|
'author': 'StorageMaster',
|
|
'version': '0.9.0',
|
|
'downloads': 328,
|
|
'rating': 4.2,
|
|
},
|
|
{
|
|
'name': 'Society Tools',
|
|
'description': 'Society management and member tracking',
|
|
'author': 'SocietyDev',
|
|
'version': '1.0.0',
|
|
'downloads': 215,
|
|
'rating': 4.0,
|
|
},
|
|
{
|
|
'name': 'Team Helper',
|
|
'description': 'Team coordination and loot sharing',
|
|
'author': 'TeamPlayer',
|
|
'version': '1.1.0',
|
|
'downloads': 876,
|
|
'rating': 4.6,
|
|
},
|
|
]
|
|
|
|
self.available_plugins = sample
|
|
self._update_list()
|
|
|
|
def _update_list(self):
|
|
"""Update plugins list."""
|
|
self.plugins_list.clear()
|
|
|
|
for plugin in self.available_plugins:
|
|
item = QListWidgetItem(
|
|
f"{plugin['name']} v{plugin['version']}\n"
|
|
f"⭐ {plugin['rating']} | ⬇ {plugin['downloads']}"
|
|
)
|
|
item.setData(Qt.ItemDataRole.UserRole, plugin)
|
|
self.plugins_list.addItem(item)
|
|
|
|
def _show_plugin_details(self, item):
|
|
"""Show plugin details."""
|
|
plugin = item.data(Qt.ItemDataRole.UserRole)
|
|
if plugin:
|
|
self.detail_name.setText(f"{plugin['name']} v{plugin['version']}")
|
|
self.detail_desc.setText(plugin['description'])
|
|
self.detail_author.setText(f"By {plugin['author']} | ⭐ {plugin['rating']}")
|
|
self.install_btn.setEnabled(True)
|
|
self.selected_plugin = plugin
|
|
|
|
def _install_plugin(self):
|
|
"""Install selected plugin."""
|
|
if hasattr(self, 'selected_plugin'):
|
|
print(f"Installing {self.selected_plugin['name']}...")
|
|
self.install_btn.setText("Installing...")
|
|
self.install_btn.setEnabled(False)
|
|
# TODO: Actual install
|
|
|
|
def _search_plugins(self):
|
|
"""Search plugins."""
|
|
query = self.search_input.text().lower()
|
|
|
|
filtered = [
|
|
p for p in self.available_plugins
|
|
if query in p['name'].lower() or query in p['description'].lower()
|
|
]
|
|
|
|
self.plugins_list.clear()
|
|
for plugin in filtered:
|
|
item = QListWidgetItem(
|
|
f"{plugin['name']} v{plugin['version']}\n"
|
|
f"⭐ {plugin['rating']} | ⬇ {plugin['downloads']}"
|
|
)
|
|
item.setData(Qt.ItemDataRole.UserRole, plugin)
|
|
self.plugins_list.addItem(item)
|
|
|
|
def _refresh_store(self):
|
|
"""Refresh plugin list."""
|
|
self._load_sample_plugins()
|