Added error message to dialogs

This commit is contained in:
donoban 2020-12-11 23:48:16 +01:00
parent 0cb89e611a
commit b29934b898
No known key found for this signature in database
GPG Key ID: 141310D8E3ED08A5

View File

@ -820,19 +820,19 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
QMessageBox.Yes | QMessageBox.Cancel) QMessageBox.Yes | QMessageBox.Cancel)
if reply == QMessageBox.Yes: if reply == QMessageBox.Yes:
failed = [] errors = []
for info in selected_vms: for info in selected_vms:
try: try:
info.vm.template = template info.vm.template = template
except: except exc.QubesValueError as ex:
failed.append(info.name) errors.append((info.name, ex))
if failed: for error in errors:
info_dialog = QMessageBox(self) info_dialog = QMessageBox(self)
info_dialog.setWindowTitle(self.tr("Warning!")) info_dialog.setWindowTitle(self.tr("Error!"))
info_dialog.setText( info_dialog.setText(
self.tr("Some template change failed: {0} " self.tr("Template change failed for '{0}':<br>{1}"
).format(", ".join(failed))) ).format(error[0], error[1]))
info_dialog.show() info_dialog.show()
def change_network(self, netvm_name): def change_network(self, netvm_name):
@ -847,45 +847,39 @@ class VmManagerWindow(ui_qubemanager.Ui_VmManagerWindow, QMainWindow):
if reply != QMessageBox.Yes: if reply != QMessageBox.Yes:
return return
try: if netvm_name is not None:
if netvm_name is not None: check_power = any(info.state['power'] == 'Running' for info
check_power = any(info.state['power'] == 'Running' for info in self.get_selected_vms())
in self.get_selected_vms()) netvm = self.qubes_cache.get_vm(name=netvm_name)
netvm = self.qubes_cache.get_vm(name=netvm_name) if check_power and netvm.state['power'] != 'Running':
if check_power and netvm.state['power'] != 'Running': reply = QMessageBox.question(
reply = QMessageBox.question( self, self.tr("Qube Start Confirmation"),
self, self.tr("Qube Start Confirmation"), self.tr("<br>Can not change netvm to a halted Qube.<br>"
self.tr("<br>Can not change netvm to a halted Qube.<br>" "Do you want to start the Qube <b>'{0}'</b>?").format(
"Do you want to start the Qube <b>'{0}'</b>?").format( netvm_name),
netvm_name), QMessageBox.Yes | QMessageBox.Cancel)
QMessageBox.Yes | QMessageBox.Cancel)
if reply == QMessageBox.Yes: if reply == QMessageBox.Yes:
with common_threads.busy_cursor(): with common_threads.busy_cursor():
netvm.vm.start() netvm.vm.start()
else: else:
return return
failed = [] errors = []
for info in self.get_selected_vms(): for info in self.get_selected_vms():
try: try:
info.vm.netvm = netvm_name info.vm.netvm = netvm_name
except: except exc.QubesValueError as ex:
failed.append(info.name) errors.append((info.name, ex))
if failed: for error in errors:
info_dialog = QMessageBox(self) info_dialog = QMessageBox(self)
info_dialog.setWindowTitle(self.tr("Warning!")) info_dialog.setWindowTitle(self.tr("Error!"))
info_dialog.setText( info_dialog.setText(
self.tr("Some network change failed: {0} " self.tr("Network change failed for '{0'}:<br>{1]"
).format(", ".join(failed))) ).format(error[0], error[1]))
info_dialog.show() info_dialog.show()
except exc.QubesValueError as ex:
QMessageBox.warning(
self,
self.tr("Change Network Error"),
self.tr((str(ex))))
def __init_context_menu(self): def __init_context_menu(self):
self.context_menu = QMenu(self) self.context_menu = QMenu(self)