Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news.d/feature/1825.ui.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add missing translations.
57 changes: 40 additions & 17 deletions plover/gui_qt/plugins_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
QInputDialog,
)

from plover import log
from plover import _, log
from plover.gui_qt.tool import Tool
from plover.gui_qt.info_browser import InfoBrowser
from plover.gui_qt.plugins_manager_ui import Ui_PluginsManager
Expand All @@ -23,7 +23,7 @@


class PluginsManager(Tool, Ui_PluginsManager):
TITLE = "Plugins Manager"
TITLE = _("Plugins Manager")
ROLE = "plugins_manager"
ICON = ":/resources/plugins_manager.svg"

Expand Down Expand Up @@ -67,7 +67,13 @@ def _update_table(self):
self.table.setRowCount(len(self._packages))
for row, state in enumerate(self._packages):
for column, attr in enumerate("status name version summary".split()):
item = QTableWidgetItem(getattr(state, attr, "N/A"))
value = getattr(state, attr, "N/A")
if attr == "status":
if value:
value = _(value)
elif value == "N/A":
value = _("N/A")
item = QTableWidgetItem(value)
item.setFlags(item.flags() & ~Qt.ItemFlag.ItemIsEditable)
self.table.setItem(row, column, item)
self.table.resizeColumnsToContents()
Expand Down Expand Up @@ -117,12 +123,14 @@ def handle_selection_change(self):
html.escape(metadata.version),
)
if metadata.author and metadata.author_email:
prologue += '<p><b>Author: </b><a href="mailto:%s">%s</a></p>' % (
# i18n: Metadata field.
prologue += _('<p><b>Author: </b><a href="mailto:%s">%s</a></p>') % (
html.escape(metadata.author_email),
html.escape(metadata.author),
)
if metadata.home_page:
prologue += '<p><b>Home page: </b><a href="%s">%s</a></p>' % (
# i18n: Metadata field.
prologue += _('<p><b>Home page: </b><a href="%s">%s</a></p>') % (
metadata.home_page,
html.escape(metadata.home_page),
)
Expand Down Expand Up @@ -169,13 +177,15 @@ def refresh(self):
def install_from_git(self):
url, ok = QInputDialog.getText(
self,
"Install from Git repo",
"<b>WARNING: Installing plugins is a security risk.<br>"
"A plugin from a Git repo can contain malicious code.<br>"
"Only install it if you got it from a trusted source.</b><br><br>"
"Enter repository link for plugin<br>"
"(will look similar to "
"https://github.com/user/repository.git): <br>",
_("Install from Git repo"),
_(
"<b>WARNING: Installing plugins is a security risk.<br>"
"A plugin from a Git repo can contain malicious code.<br>"
"Only install it if you got it from a trusted source.</b><br><br>"
"Enter repository link for plugin<br>"
"(will look similar to "
"https://github.com/user/repository.git): <br>"
),
)
if not ok or not url:
return
Expand All @@ -191,11 +201,13 @@ def install_selected_package(self):
if (
QMessageBox.warning(
self,
"Install " + ", ".join(packages),
"Installing plugins is a <b>security risk</b>. "
"A plugin can contain virus/malware. "
"Only install it if you got it from a trusted source."
" Are you sure you want to proceed?",
_("Install {packages}").format(packages=", ".join(packages)),
_(
"Installing plugins is a <b>security risk</b>. "
"A plugin can contain virus/malware. "
"Only install it if you got it from a trusted source."
" Are you sure you want to proceed?"
),
buttons=QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
defaultButton=QMessageBox.StandardButton.No,
)
Expand All @@ -215,6 +227,17 @@ def install_selected_package(self):
@Slot()
def uninstall_selected_package(self):
packages = self._get_selection()[1]
if (
QMessageBox.warning(
self,
_("Uninstall {packages}").format(packages=", ".join(packages)),
_("Are you sure you want to proceed?"),
buttons=QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
defaultButton=QMessageBox.StandardButton.No,
)
!= QMessageBox.StandardButton.Yes
):
return
code = self._run(["uninstall", "-y"] + packages)
if code == QDialog.DialogCode.Accepted:
for name in packages:
Expand Down
Loading
Loading