Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/pr/221'
Browse files Browse the repository at this point in the history
* origin/pr/221:
  Fixed tab order
  Moved debug mode checkbox to advanced settings
  Added handling for supported services to VM settings
  • Loading branch information
marmarek committed Jan 16, 2020
2 parents 85f5f81 + 6a5b0a3 commit acfdca3
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 95 deletions.
82 changes: 47 additions & 35 deletions qubesmanager/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,6 @@ def __init__(self, vm, init_page="basic", qapp=None, qubesapp=None,

####### 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__)

Expand Down Expand Up @@ -397,12 +395,6 @@ def __init_basic_tab__(self):

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)
Expand Down Expand Up @@ -479,14 +471,6 @@ def __apply_basic_tab__(self):
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():
Expand Down Expand Up @@ -734,6 +718,12 @@ def __init_advanced_tab__(self):
"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')

Expand Down Expand Up @@ -812,6 +802,14 @@ def __apply_advanced_tab__(self):
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):
Expand Down Expand Up @@ -1074,35 +1072,49 @@ def __init_services_tab__(self):
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()
Expand Down
144 changes: 84 additions & 60 deletions ui/settingsdlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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>
Expand All @@ -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">
Expand All @@ -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">
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
<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>
</spacer>
</item>
<item row="5" column="0" rowspan="2">
<widget class="QListWidget" name="services_list"/>
</widget>
</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">
<item row="13" column="0" colspan="2">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Unchecked services will be turned off.</string>
<string>Unlisted services will follow default settings.</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<widget class="QLabel" name="label_9">
<item row="12" column="0" colspan="2">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Unlisted services will follow default settings.</string>
<string>Unchecked services will be turned off.</string>
</property>
</widget>
</item>
<item row="5" column="1">
<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">
Expand All @@ -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>
</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>
<item row="9" column="1">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</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>
Expand Down Expand Up @@ -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>
Expand All @@ -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>
Expand Down

0 comments on commit acfdca3

Please sign in to comment.