Merge remote-tracking branch 'origin/pr/221'

* origin/pr/221:
  Fixed tab order
  Moved debug mode checkbox to advanced settings
  Added handling for supported services to VM settings
This commit is contained in:
Marek Marczykowski-Górecki 2020-01-16 04:38:08 +01:00
commit acfdca3851
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 133 additions and 97 deletions

View File

@ -209,8 +209,6 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog):
####### services tab
self.__init_services_tab__()
self.service_line_edit.lineEdit().returnPressed.connect(
self.__add_service__)
self.add_srv_button.clicked.connect(self.__add_service__)
self.remove_srv_button.clicked.connect(self.__remove_service__)
@ -397,12 +395,6 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog):
self.include_in_backups.setChecked(self.vm.include_in_backups)
try:
self.run_in_debug_mode.setChecked(self.vm.debug)
self.run_in_debug_mode.setVisible(True)
except AttributeError:
self.run_in_debug_mode.setVisible(False)
try:
self.autostart_vm.setChecked(self.vm.autostart)
self.autostart_vm.setVisible(True)
@ -479,14 +471,6 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog):
except qubesadmin.exc.QubesException as ex:
msg.append(str(ex))
# run_in_debug_mode
try:
if self.run_in_debug_mode.isVisible():
if self.vm.debug != self.run_in_debug_mode.isChecked():
self.vm.debug = self.run_in_debug_mode.isChecked()
except qubesadmin.exc.QubesException as ex:
msg.append(str(ex))
# autostart_vm
try:
if self.autostart_vm.isVisible():
@ -734,6 +718,12 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog):
"NetVM by the following qubes:\n") +
"\n".join(domains_using))
try:
self.run_in_debug_mode.setChecked(self.vm.debug)
self.run_in_debug_mode.setVisible(True)
except AttributeError:
self.run_in_debug_mode.setVisible(False)
def enable_seamless(self):
self.vm.run_service_for_stdio("qubes.SetGuiMode", input=b'SEAMLESS')
@ -812,6 +802,14 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog):
except Exception as ex: # pylint: disable=broad-except
msg.append(str(ex))
# run_in_debug_mode
try:
if self.run_in_debug_mode.isVisible():
if self.vm.debug != self.run_in_debug_mode.isChecked():
self.vm.debug = self.run_in_debug_mode.isChecked()
except qubesadmin.exc.QubesException as ex:
msg.append(str(ex))
return msg
def include_in_balancing_changed(self, state):
@ -1074,35 +1072,49 @@ class VMSettingsWindow(ui_settingsdlg.Ui_SettingsDialog, QtWidgets.QDialog):
self.services_list.addItem(item)
self.new_srv_dict[service] = self.vm.features[feature]
# add suggested services
self.service_line_edit.addItem('clocksync')
self.service_line_edit.addItem('crond')
self.service_line_edit.addItem('cups')
self.service_line_edit.addItem('disable-default-route')
self.service_line_edit.addItem('disable-dns-server')
self.service_line_edit.addItem('network-manager')
self.service_line_edit.addItem('qubes-firewall')
self.service_line_edit.addItem('qubes-network')
self.service_line_edit.addItem('qubes-update-check')
self.service_line_edit.addItem('qubes-updates-proxy')
self.service_line_edit.addItem('qubes-yum-proxy')
self.service_line_edit.addItem('updates-proxy-setup')
self.service_line_edit.addItem('yum-proxy-setup')
self.service_line_edit.addItem("")
supported_services = set()
service_prefix = "supported-service."
for feature in self.vm.features:
if feature.startswith(service_prefix):
supported_services.add(feature[len(service_prefix):])
if getattr(self.vm, "template", None):
for feature in self.vm.template.features:
if feature.startswith(service_prefix):
supported_services.add(feature[len(service_prefix):])
for service in sorted(supported_services):
self.service_line_edit.addItem(service)
self.service_line_edit.addItem(self.tr('(custom...)'))
self.service_line_edit.setEditText("")
def __add_service__(self):
srv = str(self.service_line_edit.currentText()).strip()
if srv != "":
if self.service_line_edit.currentIndex() == \
len(self.service_line_edit) - 1:
(custom_name, ok) = QtWidgets.QInputDialog.getText(
self, self.tr("Custom service name"),
self.tr(
"Name of the service:"))
if ok:
srv = custom_name.strip()
else:
return
if srv in self.new_srv_dict:
QtWidgets.QMessageBox.information(
self,
'',
self.tr('Service already on the list!'))
else:
item = QtWidgets.QListWidgetItem(srv)
item.setCheckState(ui_settingsdlg.QtCore.Qt.Checked)
self.services_list.addItem(item)
self.new_srv_dict[srv] = True
return
item = QtWidgets.QListWidgetItem(srv)
item.setCheckState(ui_settingsdlg.QtCore.Qt.Checked)
self.services_list.addItem(item)
self.new_srv_dict[srv] = True
def __remove_service__(self):
item = self.services_list.currentItem()

View File

@ -29,7 +29,7 @@
<locale language="English" country="UnitedStates"/>
</property>
<property name="currentIndex">
<number>1</number>
<number>5</number>
</property>
<widget class="QWidget" name="basic_tab">
<property name="locale">
@ -373,13 +373,6 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="run_in_debug_mode">
<property name="text">
<string>Run in debug mode</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0" colspan="3">
@ -813,14 +806,14 @@ border-width: 1px;</string>
<property name="topMargin">
<number>15</number>
</property>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QCheckBox" name="provides_network_checkbox">
<property name="text">
<string>Provides network</string>
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QCheckBox" name="dvm_template_checkbox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;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. &lt;/p&gt;&lt;p&gt;Setting this option will cause this qube to be listed as an option in the &amp;quot;Default DisposableVM Template&amp;quot; dropdown for all other qubes. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@ -830,14 +823,14 @@ border-width: 1px;</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<item row="8" column="0" colspan="2">
<widget class="QPushButton" name="boot_from_device_button">
<property name="text">
<string>Boot qube from CDROM</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<item row="9" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QPushButton" name="seamless_on_button">
@ -863,7 +856,7 @@ The qube must be running to disable seamless mode; this setting is not persisten
</item>
</layout>
</item>
<item row="5" column="0" colspan="2">
<item row="6" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_26">
@ -893,6 +886,13 @@ The qube must be running to disable seamless mode; this setting is not persisten
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="run_in_debug_mode">
<property name="text">
<string>Run in debug mode</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -1322,7 +1322,7 @@ The qube must be running to disable seamless mode; this setting is not persisten
<string>This qube has direct network access and Qubes Firewall settings will not be used. Configure other qubes' network access in their network settings or in a dedicated firewall qube.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
<bool>true</bool>
</property>
</widget>
</item>
@ -1433,47 +1433,85 @@ The qube must be running to disable seamless mode; this setting is not persisten
<string>Services</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="6" column="1">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
<item row="8" column="0" rowspan="2">
<widget class="QListWidget" name="services_list">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</widget>
</item>
<item row="5" column="0" rowspan="2">
<widget class="QListWidget" name="services_list"/>
</item>
<item row="7" column="0" colspan="2">
<item row="11" column="0" colspan="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Checked services will be turned on.</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Unchecked services will be turned off.</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<item row="13" column="0" colspan="2">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Unlisted services will follow default settings.</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="12" column="0" colspan="2">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Unchecked services will be turned off.</string>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Select a service:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="service_line_edit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Services listed here are explicitly supported by the qube. Additional services may be added with the '+' button on the right.</string>
</property>
<property name="currentText">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="add_srv_button">
<property name="text">
<string>Add</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/add.png</normaloff>:/add.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item row="10" column="0">
<widget class="QPushButton" name="remove_srv_button">
<property name="text">
<string/>
<string>Remove service</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
@ -1487,32 +1525,18 @@ The qube must be running to disable seamless mode; this setting is not persisten
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QComboBox" name="service_line_edit">
<property name="toolTip">
<string>Services listed here are only base Qubes services - other services may be installed and implemented.</string>
<item row="9" column="1">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="add_srv_button">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/add.png</normaloff>:/add.png</iconset>
</property>
<property name="iconSize">
<property name="sizeHint" stdset="0">
<size>
<width>24</width>
<height>24</height>
<width>20</width>
<height>40</height>
</size>
</property>
</widget>
</spacer>
</item>
</layout>
</widget>
@ -1540,7 +1564,6 @@ The qube must be running to disable seamless mode; this setting is not persisten
<tabstop>template_name</tabstop>
<tabstop>netVM</tabstop>
<tabstop>include_in_backups</tabstop>
<tabstop>run_in_debug_mode</tabstop>
<tabstop>autostart_vm</tabstop>
<tabstop>max_priv_storage</tabstop>
<tabstop>root_resize</tabstop>
@ -1550,6 +1573,7 @@ The qube must be running to disable seamless mode; this setting is not persisten
<tabstop>max_mem_size</tabstop>
<tabstop>vcpus</tabstop>
<tabstop>include_in_balancing</tabstop>
<tabstop>run_in_debug_mode</tabstop>
<tabstop>provides_network_checkbox</tabstop>
<tabstop>dvm_template_checkbox</tabstop>
<tabstop>default_dispvm</tabstop>