Fixed according to @marmarek request
This commit is contained in:
parent
f1964f0c5b
commit
1b9737c1a7
@ -300,7 +300,9 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
|
|||||||
self.vm, 'template',
|
self.vm, 'template',
|
||||||
self.vm.app.default_template,
|
self.vm.app.default_template,
|
||||||
(lambda vm: vm.klass == 'TemplateVM'),
|
(lambda vm: vm.klass == 'TemplateVM'),
|
||||||
allow_default=True, allow_none=False)
|
allow_default=False, allow_none=False,
|
||||||
|
transform=(lambda x: x if x != self.vm.app.default_template
|
||||||
|
else x + self.tr(' (default)')))
|
||||||
else:
|
else:
|
||||||
self.template_name.setEnabled(False)
|
self.template_name.setEnabled(False)
|
||||||
self.template_idx = -1
|
self.template_idx = -1
|
||||||
@ -627,8 +629,6 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
|
|||||||
try:
|
try:
|
||||||
if self.virt_mode.currentIndex() != self.virt_mode_idx:
|
if self.virt_mode.currentIndex() != self.virt_mode_idx:
|
||||||
self.vm.virt_mode = self.selected_virt_mode().lower()
|
self.vm.virt_mode = self.selected_virt_mode().lower()
|
||||||
# pylint: disable=attribute-defined-outside-init
|
|
||||||
self.anything_changed = True
|
|
||||||
except Exception as ex: # pylint: disable=broad-except
|
except Exception as ex: # pylint: disable=broad-except
|
||||||
msg.append(str(ex))
|
msg.append(str(ex))
|
||||||
|
|
||||||
@ -674,10 +674,9 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtGui.QDialog):
|
|||||||
|
|
||||||
self.virt_mode.clear()
|
self.virt_mode.clear()
|
||||||
|
|
||||||
# XXX: Hardcoded default value.
|
|
||||||
# pylint: disable=attribute-defined-outside-init
|
# pylint: disable=attribute-defined-outside-init
|
||||||
self.virt_mode_list, self.virt_mode_idx = utils.prepare_choice(
|
self.virt_mode_list, self.virt_mode_idx = utils.prepare_choice(
|
||||||
self.virt_mode, self.vm, 'virt_mode', choices, 'HVM',
|
self.virt_mode, self.vm, 'virt_mode', choices, None,
|
||||||
allow_default=True, transform=(lambda x: str(x).upper()))
|
allow_default=True, transform=(lambda x: str(x).upper()))
|
||||||
|
|
||||||
if old_mode is not None:
|
if old_mode is not None:
|
||||||
|
@ -49,17 +49,19 @@ def prepare_choice(widget, holder, propname, choice, default,
|
|||||||
'allow_default={allow_default!r}, '
|
'allow_default={allow_default!r}, '
|
||||||
'allow_none={allow_none!r})'.format(**locals()))
|
'allow_none={allow_none!r})'.format(**locals()))
|
||||||
|
|
||||||
|
if propname is not None and allow_default:
|
||||||
|
default = holder.property_get_default(propname)
|
||||||
|
|
||||||
if allow_internal is None:
|
if allow_internal is None:
|
||||||
allow_internal = propname is None or not propname.endswith('vm')
|
allow_internal = propname is None or not propname.endswith('vm')
|
||||||
|
|
||||||
if propname is not None:
|
if propname is not None:
|
||||||
oldvalue = getattr(holder, propname)
|
if holder.property_is_default(propname):
|
||||||
if transform is not None:
|
oldvalue = qubesadmin.DEFAULT
|
||||||
oldvalue = transform(oldvalue)
|
else:
|
||||||
is_default = holder.property_is_default(propname)
|
oldvalue = getattr(holder, propname)
|
||||||
else:
|
else:
|
||||||
oldvalue = object() # won't match for identity
|
oldvalue = object() # won't match for identity
|
||||||
is_default = False
|
|
||||||
idx = 0
|
idx = 0
|
||||||
|
|
||||||
choice_list = list(choice)[:]
|
choice_list = list(choice)[:]
|
||||||
@ -78,17 +80,20 @@ def prepare_choice(widget, holder, propname, choice, default,
|
|||||||
debug('i={} item={}'.format(i, item))
|
debug('i={} item={}'.format(i, item))
|
||||||
# 0: default (unset)
|
# 0: default (unset)
|
||||||
if item is qubesadmin.DEFAULT:
|
if item is qubesadmin.DEFAULT:
|
||||||
text = 'default ({})'.format(
|
default_string = str(default) if default is not None else 'none'
|
||||||
str(default) if default is not None else 'none')
|
if transform is not None:
|
||||||
|
default_string = transform(default_string)
|
||||||
|
text = 'default ({})'.format(default_string)
|
||||||
# N+1: explicit None
|
# N+1: explicit None
|
||||||
elif item is None:
|
elif item is None:
|
||||||
text = '(none)'
|
text = '(none)'
|
||||||
# 1..N: choices
|
# 1..N: choices
|
||||||
else:
|
else:
|
||||||
text = str(item)
|
text = str(item)
|
||||||
|
if transform is not None:
|
||||||
|
text = transform(text)
|
||||||
|
|
||||||
if item is qubesadmin.DEFAULT and is_default \
|
if item == oldvalue:
|
||||||
or item is not qubesadmin.DEFAULT and item == oldvalue:
|
|
||||||
text += ' (current)'
|
text += ' (current)'
|
||||||
idx = i
|
idx = i
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ URL: http://fixme
|
|||||||
Requires: python3
|
Requires: python3
|
||||||
Requires: python3-PyQt4
|
Requires: python3-PyQt4
|
||||||
Requires: python3-inotify
|
Requires: python3-inotify
|
||||||
Requires: python3-qubesadmin >= 4.0.7
|
Requires: python3-qubesadmin >= 4.0.13
|
||||||
Requires: qubes-artwork
|
Requires: qubes-artwork
|
||||||
Requires: pmount
|
Requires: pmount
|
||||||
Requires: cryptsetup
|
Requires: cryptsetup
|
||||||
|
Loading…
Reference in New Issue
Block a user