Services tab

This commit is contained in:
Agnieszka Kostrzewa 2012-03-14 11:54:50 +01:00
parent 2987320b2f
commit b3dbbe5fa3
2 changed files with 52 additions and 32 deletions

View File

@ -44,6 +44,7 @@ import subprocess
import time
import threading
from operator import itemgetter
from copy import copy
from ui_settingsdlg import *
from multiselectwidget import *
@ -104,6 +105,11 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
####### devices tab
self.__init_devices_tab__()
####### services tab
self.__init_services_tab__()
self.add_srv_button.clicked.connect(self.__add_service__)
self.remove_srv_button.clicked.connect(self.__remove_service__)
####### apps tab
if self.tabWidget.isTabEnabled(self.tabs_indices["applications"]):
self.app_list = MultiSelectWidget(self)
@ -147,6 +153,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
ret = self.__apply_basic_tab__()
self.__apply_advanced_tab__()
self.__apply_devices_tab__()
self.__apply_services_tab__()
if len(ret) > 0 :
thread_monitor.set_error_msg('\n'.join(ret))
@ -402,7 +409,7 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
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.vm.services['meminfo-writer'] = self.include_in_balancing.isChecked()
self.new_srv_dict['meminfo-writer'] = self.include_in_balancing.isChecked()
self.anything_changed = True
#kernel changed
@ -465,7 +472,45 @@ class VMSettingsWindow(Ui_SettingsDialog, QDialog):
self.vm.pcidevs = pcidevs
self.anything_changed = True
######## services tab
def __init_services_tab__(self):
for srv in self.vm.services:
item = QListWidgetItem(srv)
if self.vm.services[srv] == True:
item.setCheckState(QtCore.Qt.Checked)
else:
item.setCheckState(QtCore.Qt.Unchecked)
self.services_list.addItem(item)
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
def __remove_service__(self):
row = self.services_list.currentRow()
if row:
item = self.services_list.takeItem(row)
print item.text()
del self.new_srv_dict[str(item.text())]
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)
if self.new_srv_dict != self.vm.services:
self.vm.services = self.new_srv_dict
self.anything_changed = True
######### firewall tab related
def set_fw_model(self, model):

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">
@ -748,17 +748,17 @@
</widget>
<widget class="QWidget" name="services_tab">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<attribute name="title">
<string>Services</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QLineEdit" name="service_lineEdit"/>
<widget class="QLineEdit" name="service_line_edit"/>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="add_button">
<widget class="QPushButton" name="add_srv_button">
<property name="text">
<string/>
</property>
@ -775,32 +775,7 @@
</widget>
</item>
<item row="4" column="0" rowspan="2">
<widget class="QListWidget" name="services_list">
<item>
<property name="text">
<string>ntpd</string>
</property>
<property name="checkState">
<enum>Checked</enum>
</property>
</item>
<item>
<property name="text">
<string>cupsd</string>
</property>
<property name="checkState">
<enum>Checked</enum>
</property>
</item>
<item>
<property name="text">
<string>meminfo</string>
</property>
<property name="checkState">
<enum>Checked</enum>
</property>
</item>
</widget>
<widget class="QListWidget" name="services_list"/>
</item>
<item row="6" column="0" colspan="2">
<widget class="QLabel" name="label_7">
@ -824,7 +799,7 @@
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="remove_button">
<widget class="QPushButton" name="remove_srv_button">
<property name="text">
<string/>
</property>