From a41908f92f90b074c9b5434b3529275f9e2c756d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Tue, 7 Jul 2020 21:02:54 +0200 Subject: [PATCH] Added gui daemon options to VM settings Added allow-fullscreen and allow-utf8-titles as options to VM settings references QubesOS/qubes-issues#2304 --- qubesmanager/settings.py | 43 +++ qubesmanager/utils.py | 33 ++ ui/settingsdlg.ui | 696 ++++++++++++++++++++++----------------- 3 files changed, 473 insertions(+), 299 deletions(-) diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index ef72c81..13262cf 100644 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -775,6 +775,27 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog): except AttributeError: self.run_in_debug_mode.setVisible(False) + utils.prepare_choice_data( + widget=self.allow_fullscreen, + choices=[ + ('(use system default)', None), + ('allow', True), + ('disallow', False) + ], + selected_value=utils.get_boolean_feature(self.vm, + 'gui-allow-fullscreen')) + self.allow_fullscreen_initial = self.allow_fullscreen.currentIndex() + utils.prepare_choice_data( + widget=self.allow_utf8, + choices=[ + ('(use system default)', None), + ('allow', True), + ('disallow', False) + ], + selected_value=utils.get_boolean_feature(self.vm, + 'gui-allow-utf8-titles')) + self.allow_utf8_initial = self.allow_utf8.currentIndex() + def enable_seamless(self): self.vm.run_service_for_stdio("qubes.SetGuiMode", input=b'SEAMLESS') @@ -861,6 +882,28 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog): except qubesadmin.exc.QubesException as ex: msg.append(str(ex)) + if self.allow_fullscreen_initial !=\ + self.allow_fullscreen.currentIndex(): + try: + if self.allow_fullscreen.currentData() is None: + del self.vm.features['gui-allow-fullscreen'] + else: + self.vm.features['gui-allow-fullscreen'] = \ + self.allow_fullscreen.currentData() + except qubesadmin.exc.QubesException as ex: + msg.append(str(ex)) + + if self.allow_utf8_initial !=\ + self.allow_utf8.currentIndex(): + try: + if self.allow_utf8.currentData() is None: + del self.vm.features['gui-allow-utf8-titles'] + else: + self.vm.features['gui-allow-utf8-titles'] = \ + self.allow_utf8.currentData() + except qubesadmin.exc.QubesException as ex: + msg.append(str(ex)) + return msg def include_in_balancing_changed(self, state): diff --git a/qubesmanager/utils.py b/qubesmanager/utils.py index e8d8ea5..b352953 100644 --- a/qubesmanager/utils.py +++ b/qubesmanager/utils.py @@ -68,6 +68,39 @@ class SizeSpinBox(QtWidgets.QSpinBox): return int(float(value) * multiplier) +def get_boolean_feature(vm, feature_name): + result = vm.features.get(feature_name, None) + if result is not None: + try: + result = bool(result) + except ValueError: + result = None + return result + +def prepare_choice_data(widget, + choices, + selected_value=None): + """ + populates widget (ListBox or ComboBox) with items + :param widget: widget to populate + :param choices: list of tuples (text, value) to use to populate widget + :param selected_value: value to populate widget with + :return: + """ + + while widget.count() > 0: + widget.removeItem(0) + + for (name, value) in choices: + widget.addItem(name, value) + + if widget.findData(selected_value) > -1: + widget.setCurrentIndex(widget.findData(selected_value)) + else: + widget.addItem(selected_value, selected_value) + widget.setCurrentIndex(widget.findData(selected_value)) + + def prepare_choice(widget, holder, propname, choice, default, filter_function=None, *, icon_getter=None, allow_internal=None, allow_default=False, diff --git a/ui/settingsdlg.ui b/ui/settingsdlg.ui index e7b288b..778e791 100644 --- a/ui/settingsdlg.ui +++ b/ui/settingsdlg.ui @@ -7,7 +7,7 @@ 0 0 836 - 656 + 665 @@ -29,7 +29,7 @@ - 0 + 1 @@ -444,22 +444,359 @@ border-width: 1px; Advanced - - - + + + + + + + true + + + + 0 + 0 + + + + Memory/CPU + + + + 15 + + + + + true + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 1 + + + + + + + + 0 + 0 + + + + VCPUs no.: + + + vcpus + + + + + + + true + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + MB + + + 0 + + + 10000000 + + + 50 + + + 400 + + + + + + + true + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + MB + + + 0 + + + 1000000 + + + 50 + + + 256 + + + + + + + true + + + Include in memory balancing + + + + + + + + 75 + true + true + + + + color:rgb(255, 0, 0) + + + Dynamic memory balancing can result in some devices not working! + + + true + + + + + + + true + + + + 0 + 0 + + + + Initial memory: + + + init_mem + + + + + + + + 0 + 0 + + + + Max memory: + + + max_mem_size + + + + + + + + + + Other + + + + QFormLayout::AllNonFixedFieldsGrow + + + 15 + + + + + Provides network + + + + + + + <html><head/><body><p>Allows using this qube as a template for DisposableVMs. The DisposableVMs will inherit the VM's state (configuration, installed programs etc.), but their state will not persist between restarts. </p><p>Setting this option will cause this qube to be listed as an option in the &quot;Default DisposableVM Template&quot; dropdown for all other qubes. </p></body></html> + + + Disposable VM Template + + + + + + + Boot qube from CDROM + + + + + + + + + Windows (with Qubes Windows Tools installed) only. +The qube must be running to enable seamless mode; this setting is not persistent. + + + Enable seamless mode + + + + + + + Windows (with Qubes Windows Tools installed) only. +The qube must be running to disable seamless mode; this setting is not persistent. + + + Disable seamless mode + + + + + + + + + + + <html><head/><body><p>Which qube should be used by default as a template for DisposableVMs started from this one? DisposableVMs will inherit their template's configuration and installed programs.<br/>For a qube to to appear in this list, it must have the &quot;DisposableVM Template&quot; checkbox enabled. </p></body></html> + + + Default DisposableVM Template + + + default_dispvm + + + + + + + + 0 + 0 + + + + <html><head/><body><p>Which qube should be used by default as a template for DisposableVMs started from this one? DisposableVMs will inherit their template's configuration and installed programs.<br/>For a qube to to appear in this list, it must have the &quot;DisposableVM Template&quot; checkbox enabled. </p></body></html> + + + + + + + + + Run in debug mode + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + QLayout::SetDefaultConstraint 0 + + + + + 0 + 0 + + + + Window Options + + + + + + <html><head/><body><p>Allow fullscreen<span style=" color:#ef2929;">*</span>:</p></body></html> + + + + + + + + + + <html><head/><body><p>Allow UTF-8 window titles<span style=" color:#ef2929;">*</span>:</p></body></html> + + + + + + + + + + + 0 + 0 + + + + + true + + + + <html><head/><body><p><span style=" color:#ef2929;">*</span><span style=" font-style:normal; color:#000000;"> Requires restart</span></p></body></html> + + + + + + true - + 0 0 @@ -489,6 +826,12 @@ border-width: 1px; + + + 0 + 0 + + 75 @@ -506,6 +849,12 @@ border-width: 1px; + + + 0 + 0 + + Kernel opts: @@ -513,6 +862,12 @@ border-width: 1px; + + + 0 + 0 + + 50 @@ -528,23 +883,13 @@ border-width: 1px; - - - - - - QLayout::SetDefaultConstraint - - - 0 - true - + 0 0 @@ -574,6 +919,12 @@ border-width: 1px; + + + 0 + 0 + + 75 @@ -594,6 +945,12 @@ border-width: 1px; + + + 0 + 0 + + 75 @@ -611,6 +968,12 @@ border-width: 1px; + + + 0 + 0 + + true @@ -627,288 +990,21 @@ border-width: 1px; + + + + Qt::Vertical + + + + 20 + 40 + + + + - - - - true - - - - 0 - 0 - - - - Memory/CPU - - - - 15 - - - - - true - - - - 0 - 0 - - - - Initial memory: - - - init_mem - - - - - - - true - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - MB - - - 0 - - - 1000000 - - - 50 - - - 256 - - - - - - - true - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - MB - - - 0 - - - 10000000 - - - 50 - - - 400 - - - - - - - - 0 - 0 - - - - VCPUs no.: - - - vcpus - - - - - - - true - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 1 - - - - - - - true - - - Include in memory balancing - - - - - - - - 75 - true - true - - - - color:rgb(255, 0, 0) - - - Dynamic memory balancing can result in some devices not working! - - - true - - - - - - - - 0 - 0 - - - - Max memory: - - - max_mem_size - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Other - - - - QFormLayout::AllNonFixedFieldsGrow - - - 15 - - - - - Provides network - - - - - - - <html><head/><body><p>Allows using this qube as a template for DisposableVMs. The DisposableVMs will inherit the VM's state (configuration, installed programs etc.), but their state will not persist between restarts. </p><p>Setting this option will cause this qube to be listed as an option in the &quot;Default DisposableVM Template&quot; dropdown for all other qubes. </p></body></html> - - - Disposable VM Template - - - - - - - Boot qube from CDROM - - - - - - - - - Windows (with Qubes Windows Tools installed) only. -The qube must be running to enable seamless mode; this setting is not persistent. - - - Enable seamless mode - - - - - - - Windows (with Qubes Windows Tools installed) only. -The qube must be running to disable seamless mode; this setting is not persistent. - - - Disable seamless mode - - - - - - - - - - - <html><head/><body><p>Which qube should be used by default as a template for DisposableVMs started from this one? DisposableVMs will inherit their template's configuration and installed programs.<br/>For a qube to to appear in this list, it must have the &quot;DisposableVM Template&quot; checkbox enabled. </p></body></html> - - - Default DisposableVM Template - - - default_dispvm - - - - - - - - 0 - 0 - - - - <html><head/><body><p>Which qube should be used by default as a template for DisposableVMs started from this one? DisposableVMs will inherit their template's configuration and installed programs.<br/>For a qube to to appear in this list, it must have the &quot;DisposableVM Template&quot; checkbox enabled. </p></body></html> - - - - - - - - - Run in debug mode - - - - - - @@ -1600,16 +1696,18 @@ The qube must be running to disable seamless mode; this setting is not persisten boot_from_device_button seamless_on_button seamless_off_button + allow_fullscreen + allow_utf8 kernel virt_mode policy_allow_radio_button policy_deny_radio_button rulesTreeView + temp_full_access + temp_full_access_time new_rule_button edit_rule_button delete_rule_button - temp_full_access - temp_full_access_time no_strict_reset_button refresh_apps_button service_line_edit