Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
donob4n committed Jan 23, 2020
2 parents 2e2a14b + 8902727 commit 2756864
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 113 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ script:
- ~/qubes-builder/scripts/travis-build
env:
- DIST_DOM0=fc25 USE_QUBES_REPO_VERSION=4.0 USE_QUBES_REPO_TESTING=1
- DIST_DOM0=fc29 USE_QUBES_REPO_VERSION=4.1 USE_QUBES_REPO_TESTING=1
- DIST_DOM0=fc31 USE_QUBES_REPO_VERSION=4.1 USE_QUBES_REPO_TESTING=1
- DISTS_VM=fc30 USE_QUBES_REPO_VERSION=4.1 USE_QUBES_REPO_TESTING=1
- DISTS_VM=fc31 USE_QUBES_REPO_VERSION=4.1 USE_QUBES_REPO_TESTING=1
- DISTS_VM=centos7 USE_QUBES_REPO_VERSION=4.1 USE_QUBES_REPO_TESTING=1
Expand Down
102 changes: 66 additions & 36 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 @@ -272,6 +270,15 @@ def save_changes(self):
def apply(self):
self.save_changes()

# these signals must be disconnected to avoid unintended behavior
# on refreshing the drop-downs
self.netVM.currentIndexChanged.disconnect()
self.kernel.currentIndexChanged.disconnect()
self.default_dispvm.currentIndexChanged.disconnect()

self.__init_basic_tab__()
self.__init_advanced_tab__()

def save_and_apply(self):
self.save_changes()
self.done(0)
Expand Down Expand Up @@ -397,12 +404,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 +480,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 @@ -625,8 +618,17 @@ def remove_vm(self):

if ok and answer == self.vm.name:
thread = common_threads.RemoveVMThread(self.vm)
thread.finished.connect(self.clear_threads)
self.threads_list.append(thread)

self.progress = QtWidgets.QProgressDialog(
self.tr("Deleting Qube..."), "", 0, 0)
self.progress.setCancelButton(None)
self.progress.setModal(True)
self.thread_closes = True
self.progress.show()

thread.start()
self.done(0)

elif ok:
QtWidgets.QMessageBox.warning(
Expand Down Expand Up @@ -734,6 +736,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 +820,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 +1090,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
5 changes: 5 additions & 0 deletions qubesmanager/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ def prepare_choice(widget, holder, propname, choice, default,
allow_none=False, transform=None):
# for newly created vms, set propname to None

# clear the widget, so that prepare_choice functions can be used
# to refresh widget values
while widget.count() > 0:
widget.removeItem(0)

debug(
'prepare_choice(widget={widget!r}, '
'holder={holder!r}, '
Expand Down
48 changes: 32 additions & 16 deletions ui/globalsettingsdlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1047</width>
<height>599</height>
<width>831</width>
<height>517</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -120,10 +120,10 @@
</size>
</property>
<property name="title">
<string>Default memory settings</string>
<string>Memory Balancer Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="enabled">
<bool>true</bool>
Expand All @@ -133,7 +133,7 @@
</property>
</widget>
</item>
<item row="0" column="1">
<item row="2" column="1">
<widget class="QSpinBox" name="min_vm_mem">
<property name="enabled">
<bool>true</bool>
Expand All @@ -149,21 +149,14 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_7">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>dom0 memory boost:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="3" column="1">
<widget class="QSpinBox" name="dom0_mem_boost">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Additional memory allocated to dom0 by Qubes Memory Balancer.</string>
</property>
<property name="suffix">
<string> MiB</string>
</property>
Expand All @@ -175,6 +168,29 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_7">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Additional memory allocated to dom0 by Qubes Memory Balancer.</string>
</property>
<property name="text">
<string>Additional dom0 memory:</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Memory balancing is used for dom0 and all qubes that have memory balancing enabled (by default all qubes, except for those with PCI devices connected, such as sys-net and sys-usb).</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
Loading

0 comments on commit 2756864

Please sign in to comment.