Fixed translation for application names

This commit is contained in:
Marta Marczykowska-Górecka 2019-11-08 23:35:26 +01:00
parent 46952ebad2
commit b4cb9303bc
No known key found for this signature in database
GPG Key ID: 9A752C30B26FD04B
12 changed files with 583 additions and 558 deletions

View File

@ -85,7 +85,8 @@ class AppmenuSelectManager:
p.communicate('\n'.join(new_whitelisted).encode())
if p.returncode != 0:
exception_text = QtCore.QCoreApplication.translate(
"exception", 'qvm-appmenus --set-whitelist failed')
"Command {command} failed", "exception").format(
command='qvm-appmenus --set-whitelist')
raise RuntimeError(exception_text)
return True

View File

@ -24,7 +24,7 @@ import signal
from qubesadmin import exc
from qubesadmin import utils as admin_utils
from PyQt5 import QtCore, QtWidgets # pylint: disable=import-error
from PyQt5 import QtCore, QtWidgets, QtGui # pylint: disable=import-error
from . import ui_backupdlg # pylint: disable=no-name-in-module
from . import multiselectwidget
@ -121,6 +121,10 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, QtWidgets.QWizard):
self.dispatcher = dispatcher
dispatcher.add_handler('backup-progress', self.on_backup_progress)
def setup_application(self):
self.qt_app.setApplicationName(self.tr("Qubes Backup VMs"))
self.qt_app.setWindowIcon(QtGui.QIcon.fromTheme("qubes-manager"))
def on_backup_progress(self, __submitter, _event, **kwargs):
self.progress_bar.setValue(int(float(kwargs['progress'])))
@ -391,10 +395,7 @@ class BackupVMsWindow(ui_backupdlg.Ui_Backup, QtWidgets.QWizard):
def main():
utils.run_asynchronous(
QtCore.QCoreApplication.translate("appname", "Qubes Backup VMs"),
"qubes-manager",
BackupVMsWindow)
utils.run_asynchronous(BackupVMsWindow)
if __name__ == "__main__":

View File

@ -21,7 +21,7 @@ import functools
import subprocess
from . import utils
from . import ui_bootfromdevice # pylint: disable=no-name-in-module
from PyQt5 import QtWidgets, QtCore # pylint: disable=import-error
from PyQt5 import QtWidgets, QtGui # pylint: disable=import-error
from qubesadmin import tools
from qubesadmin.tools import qvm_start
@ -47,6 +47,10 @@ class VMBootFromDeviceWindow(ui_bootfromdevice.Ui_BootDialog,
# warn user if the VM is currently running
self.__warn_if_running__()
def setup_application(self):
self.qapp.setApplicationName(self.tr("Boot Qube From Device"))
self.qapp.setWindowIcon(QtGui.QIcon.fromTheme("qubes-manager"))
def reject(self):
self.done(0)
@ -148,9 +152,7 @@ def main(args=None):
args = parser.parse_args(args)
vm = args.domains.pop()
utils.run_synchronous(
QtCore.QCoreApplication.translate("appname", "Boot Qube From Device"),
functools.partial(VMBootFromDeviceWindow, vm))
utils.run_synchronous(functools.partial(VMBootFromDeviceWindow, vm))
if __name__ == "__main__":

View File

@ -275,6 +275,7 @@ def main(args=None):
'i18n')
translator.load("qubesmanager_{!s}.qm".format(locale), i18n_dir)
qtapp.installTranslator(translator)
QtCore.QCoreApplication.installTranslator(translator)
qtapp.setOrganizationName('Invisible Things Lab')
qtapp.setOrganizationDomain('https://www.qubes-os.org/')

View File

@ -21,7 +21,7 @@
#
import subprocess
from PyQt5 import QtWidgets, QtCore # pylint: disable=import-error
from PyQt5 import QtWidgets, QtCore, QtGui # pylint: disable=import-error
from qubesadmin.utils import parse_size
@ -75,6 +75,10 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings,
self.__init_mem_defaults__()
self.__init_updates__()
def setup_application(self):
self.qt_app.setApplicationName(self.tr("Qubes Global Settings"))
self.qt_app.setWindowIcon(QtGui.QIcon.fromTheme("qubes-manager"))
def __init_system_defaults__(self):
# set up updatevm choice
self.update_vm_vmlist, self.update_vm_idx = utils.prepare_vm_choice(
@ -408,9 +412,7 @@ class GlobalSettingsWindow(ui_globalsettingsdlg.Ui_GlobalSettings,
def main():
utils.run_synchronous(
QtCore.QCoreApplication.translate("appname", "Qubes Global Settings"),
GlobalSettingsWindow)
utils.run_synchronous(GlobalSettingsWindow)
if __name__ == "__main__":

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -520,6 +520,11 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtWidgets.QMainWindow):
# correctly initialized
self.table.selectRow(0)
def setup_application(self):
self.qt_app.setApplicationName(self.tr("Qube Manager"))
self.qt_app.setWindowIcon(QtGui.QIcon.fromTheme("qubes-manager"))
def keyPressEvent(self, event): # pylint: disable=invalid-name
if event.key() == QtCore.Qt.Key_Escape:
self.searchbox.clear()
@ -1300,10 +1305,7 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QtWidgets.QMainWindow):
def main():
manager_utils.run_asynchronous(
QtCore.QCoreApplication.translate("appname", "Qube Manager"),
"qubes-manager",
VmManagerWindow)
manager_utils.run_asynchronous(VmManagerWindow)
if __name__ == "__main__":

View File

@ -20,7 +20,7 @@
#
#
from PyQt5 import QtCore, QtWidgets # pylint: disable=import-error
from PyQt5 import QtCore, QtWidgets, QtGui # pylint: disable=import-error
import os
import os.path
import logging
@ -110,6 +110,10 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtWidgets.QWizard):
backup_utils.fill_appvms_list(self)
def setup_application(self):
self.qt_app.setApplicationName(self.tr("Qubes Restore VMs"))
self.qt_app.setWindowIcon(QtGui.QIcon.fromTheme("qubes-manager"))
@QtCore.pyqtSlot(name='on_select_path_button_clicked')
def select_path_button_clicked(self):
backup_utils.select_path_button_clicked(self, True)
@ -290,9 +294,7 @@ class RestoreVMsWindow(ui_restoredlg.Ui_Restore, QtWidgets.QWizard):
def main():
utils.run_synchronous(
QtCore.QCoreApplication.translate("appname", "Qubes Restore VMs"),
RestoreVMsWindow)
utils.run_synchronous(RestoreVMsWindow)
if __name__ == "__main__":

View File

@ -222,6 +222,10 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog):
self.refresh_apps_button.clicked.connect(
self.refresh_apps_button_pressed)
def setup_application(self):
self.qt_app.setApplicationName(self.tr("Qube Settings"))
self.qt_app.setWindowIcon(QtGui.QIcon.fromTheme("qubes-manager"))
def clear_threads(self):
for thread in self.threads_list:
if thread.isFinished():
@ -1211,9 +1215,7 @@ def main(args=None):
args = parser.parse_args(args)
vm = args.domains.pop()
utils.run_synchronous(
QtCore.QCoreApplication.translate("appname", "Qube Settings"),
functools.partial(VMSettingsWindow, vm, args.tab))
utils.run_synchronous(functools.partial(VMSettingsWindow, vm, args.tab))
if __name__ == "__main__":

View File

@ -62,6 +62,10 @@ class TemplateManagerWindow(
self.vm_list.show()
def setup_application(self):
self.qt_app.setApplicationName(self.tr("Template Manager"))
self.qt_app.setWindowIcon(QtGui.QIcon.fromTheme("qubes-manager"))
def prepare_lists(self):
self.templates = [vm.name for vm in self.qubes_app.domains
if vm.klass == 'TemplateVM']
@ -259,7 +263,8 @@ class StatusItem(QtWidgets.QTableWidgetItem):
if self.state:
self.setIcon(QtGui.QIcon.fromTheme('dialog-warning'))
self.setToolTip(self.tr("Cannot change template on a running VM."))
self.setToolTip(QtCore.QCoreApplication.translate(
"template-manager", "Cannot change template on a running VM."))
else:
self.setIcon(QtGui.QIcon())
self.setToolTip("")
@ -381,10 +386,7 @@ class VMRow:
def main():
utils.run_asynchronous(
QtCore.QCoreApplication.translate("appname", "Template Manager"),
"qubes-manager",
TemplateManagerWindow)
utils.run_asynchronous(TemplateManagerWindow)
if __name__ == "__main__":

View File

@ -268,7 +268,7 @@ def handle_exception(exc_type, exc_value, exc_traceback):
msg_box.exec_()
def run_asynchronous(app_name, icon_name, window_class):
def run_asynchronous(window_class):
qt_app = QtWidgets.QApplication(sys.argv)
translator = QtCore.QTranslator(qt_app)
@ -278,11 +278,10 @@ def run_asynchronous(app_name, icon_name, window_class):
'i18n')
translator.load("qubesmanager_{!s}.qm".format(locale), i18n_dir)
qt_app.installTranslator(translator)
QtCore.QCoreApplication.installTranslator(translator)
qt_app.setOrganizationName("The Qubes Project")
qt_app.setOrganizationDomain("http://qubes-os.org")
qt_app.setApplicationName(app_name)
qt_app.setWindowIcon(QIcon.fromTheme(icon_name))
qt_app.lastWindowClosed.connect(loop_shutdown)
qubes_app = qubesadmin.Qubes()
@ -292,6 +291,10 @@ def run_asynchronous(app_name, icon_name, window_class):
dispatcher = events.EventsDispatcher(qubes_app)
window = window_class(qt_app, qubes_app, dispatcher)
if hasattr(window, "setup_application"):
window.setup_application()
window.show()
try:
@ -305,7 +308,7 @@ def run_asynchronous(app_name, icon_name, window_class):
handle_exception(exc_type, exc_value, exc_traceback)
def run_synchronous(app_name, window_class):
def run_synchronous(window_class):
qt_app = QtWidgets.QApplication(sys.argv)
translator = QtCore.QTranslator(qt_app)
@ -315,10 +318,10 @@ def run_synchronous(app_name, window_class):
'i18n')
translator.load("qubesmanager_{!s}.qm".format(locale), i18n_dir)
qt_app.installTranslator(translator)
QtCore.QCoreApplication.installTranslator(translator)
qt_app.setOrganizationName("The Qubes Project")
qt_app.setOrganizationDomain("http://qubes-os.org")
qt_app.setApplicationName(app_name)
sys.excepthook = handle_exception
@ -326,6 +329,9 @@ def run_synchronous(app_name, window_class):
window = window_class(qt_app, qubes_app)
if hasattr(window, "setup_application"):
window.setup_application()
window.show()
qt_app.exec_()