From 2ab9570045a6d54985dcdad6ca14e3b2f1b1a10c Mon Sep 17 00:00:00 2001 From: Agnieszka Kostrzewa Date: Fri, 30 Mar 2012 21:46:23 +0200 Subject: [PATCH] 'Include in memory balancing' heckbox issue fixed (#498). --- qubesmanager/settings.py | 57 +++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/qubesmanager/settings.py b/qubesmanager/settings.py index 483a750..69bf3e8 100644 --- a/qubesmanager/settings.py +++ b/qubesmanager/settings.py @@ -358,7 +358,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog): self.vcpus.setMaximum(QubesHost().no_cpus) self.vcpus.setValue(int(self.vm.vcpus)) - self.include_in_balancing.setChecked('meminfo-writer' in self.vm.services and self.vm.services['meminfo-writer']==True) + self.include_in_balancing.setChecked(self.vm.services['meminfo-writer']==True) #kernel if self.vm.template is not None: @@ -415,10 +415,8 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog): self.vm.vcpus = self.vcpus.value() self.anything_changed = True - balancing_was_checked = ('meminfo-writer' in self.vm.services and self.vm.services['meminfo-writer']==True) - if self.include_in_balancing.isChecked() != balancing_was_checked: - self.new_srv_dict['meminfo-writer'] = self.include_in_balancing.isChecked() - self.anything_changed = True + #include_in_memory_balancing applied in services tab + #kernel changed if self.kernel.currentIndex() != self.kernel_idx: @@ -489,6 +487,12 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog): self.anything_changed = True def include_in_balancing_state_changed(self, state): + for r in range (self.services_list.count()): + item = self.services_list.item(r) + if str(item.text()) == 'meminfo-writer': + item.setCheckState(state) + break; + if self.dev_list.selected_list.count() > 0: if state == QtCore.Qt.Checked: self.dmm_warning_adv.show() @@ -496,6 +500,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog): else: self.dmm_warning_adv.hide() self.dmm_warning_dev.hide() + def devices_selection_changed(self): if self.include_in_balancing.isChecked(): if self.dev_list.selected_list.count() > 0 : @@ -515,28 +520,54 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog): else: item.setCheckState(QtCore.Qt.Unchecked) self.services_list.addItem(item) + + self.connect(self.services_list, SIGNAL("itemClicked(QListWidgetItem *)"), self.services_item_clicked) self.new_srv_dict = copy(self.vm.services) def __add_service__(self): srv = str(self.service_line_edit.text()).strip() - if srv != "" and srv not in self.new_srv_dict: - item = QListWidgetItem(srv) - item.setCheckState(QtCore.Qt.Checked) - self.services_list.addItem(item) - self.new_srv_dict[srv] = True + if srv != "": + if srv in self.new_srv_dict: + QMessageBox.information(None, "", "Service already on the list!") + else: + item = QListWidgetItem(srv) + item.setCheckState(QtCore.Qt.Checked) + self.services_list.addItem(item) + self.new_srv_dict[srv] = True def __remove_service__(self): - row = self.services_list.currentRow() - if row: + item = self.services_list.currentItem() + if str(item.text()) == 'meminfo-writer': + QMessageBox.information(None, "Service can not be removed", "Service meminfo-writer can not be removed from the list.") + else: + row = self.services_list.currentRow() item = self.services_list.takeItem(row) del self.new_srv_dict[str(item.text())] + + def services_item_clicked(self, item): + if str(item.text()) == 'meminfo-writer': + if item.checkState() == QtCore.Qt.Checked: + if not self.include_in_balancing.isChecked(): + self.include_in_balancing.setChecked(True) + elif item.checkState() == QtCore.Qt.Unchecked: + if self.include_in_balancing.isChecked(): + self.include_in_balancing.setChecked(False) + + def __apply_services_tab__(self): - new_dict = {} for r in range (self.services_list.count()): item = self.services_list.item(r) self.new_srv_dict[str(item.text())] = (item.checkState() == QtCore.Qt.Checked) + balancing_was_checked = (self.vm.services['meminfo-writer']==True) + balancing_is_checked = self.include_in_balancing.isChecked() + meminfo_writer_checked = (self.new_srv_dict['meminfo-writer'] == True) + + if balancing_is_checked != meminfo_writer_checked: + if balancing_is_checked != balancing_was_checked: + self.new_srv_dict['meminfo-writer'] = balancing_is_checked + if self.new_srv_dict != self.vm.services: self.vm.services = self.new_srv_dict self.anything_changed = True