Preferences/ConfigurationPages/CooperationPage.py

changeset 945
8cd4d08fa9f6
parent 791
9ec2ac20e54e
child 1131
7781e396c903
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
13 from .ConfigurationPageBase import ConfigurationPageBase 13 from .ConfigurationPageBase import ConfigurationPageBase
14 from .Ui_CooperationPage import Ui_CooperationPage 14 from .Ui_CooperationPage import Ui_CooperationPage
15 15
16 import Preferences 16 import Preferences
17 17
18
18 class CooperationPage(ConfigurationPageBase, Ui_CooperationPage): 19 class CooperationPage(ConfigurationPageBase, Ui_CooperationPage):
19 """ 20 """
20 Class implementing the Cooperation configuration page. 21 Class implementing the Cooperation configuration page.
21 """ 22 """
22 def __init__(self): 23 def __init__(self):
28 self.setObjectName("CooperationPage") 29 self.setObjectName("CooperationPage")
29 30
30 self.__bannedUserValidator = QRegExpValidator( 31 self.__bannedUserValidator = QRegExpValidator(
31 QRegExp("[a-zA-Z0-9.-]+@" 32 QRegExp("[a-zA-Z0-9.-]+@"
32 "(?:(?:2(?:[0-4][0-9]|5[0-5])|[01]?[0-9]{1,2})\.){3}" 33 "(?:(?:2(?:[0-4][0-9]|5[0-5])|[01]?[0-9]{1,2})\.){3}"
33 "(?:2(?:[0-4][0-9]|5[0-5])|[01]?[0-9]{1,2})"), 34 "(?:2(?:[0-4][0-9]|5[0-5])|[01]?[0-9]{1,2})"),
34 self.bannedUserEdit) 35 self.bannedUserEdit)
35 self.bannedUserEdit.setValidator(self.__bannedUserValidator) 36 self.bannedUserEdit.setValidator(self.__bannedUserValidator)
36 37
37 # set initial values 38 # set initial values
38 self.autostartCheckBox.setChecked( 39 self.autostartCheckBox.setChecked(
51 52
52 def save(self): 53 def save(self):
53 """ 54 """
54 Public slot to save the Cooperation configuration. 55 Public slot to save the Cooperation configuration.
55 """ 56 """
56 Preferences.setCooperation("AutoStartServer", 57 Preferences.setCooperation("AutoStartServer",
57 self.autostartCheckBox.isChecked()) 58 self.autostartCheckBox.isChecked())
58 Preferences.setCooperation("TryOtherPorts", 59 Preferences.setCooperation("TryOtherPorts",
59 self.otherPortsCheckBox.isChecked()) 60 self.otherPortsCheckBox.isChecked())
60 Preferences.setCooperation("AutoAcceptConnections", 61 Preferences.setCooperation("AutoAcceptConnections",
61 self.autoAcceptCheckBox.isChecked()) 62 self.autoAcceptCheckBox.isChecked())
62 Preferences.setCooperation("ServerPort", 63 Preferences.setCooperation("ServerPort",
63 self.serverPortSpin.value()) 64 self.serverPortSpin.value())
64 Preferences.setCooperation("MaxPortsToTry", 65 Preferences.setCooperation("MaxPortsToTry",
65 self.portToTrySpin.value()) 66 self.portToTrySpin.value())
66 67
67 bannedUsers = [] 68 bannedUsers = []
68 for row in range(self.bannedUsersList.count()): 69 for row in range(self.bannedUsersList.count()):
69 bannedUsers.append(self.bannedUsersList.item(row).text()) 70 bannedUsers.append(self.bannedUsersList.item(row).text())
89 QValidator.Acceptable) 90 QValidator.Acceptable)
90 91
91 @pyqtSlot() 92 @pyqtSlot()
92 def on_deleteBannedUsersButton_clicked(self): 93 def on_deleteBannedUsersButton_clicked(self):
93 """ 94 """
94 Private slot to remove the selected users from the list of 95 Private slot to remove the selected users from the list of
95 banned users. 96 banned users.
96 """ 97 """
97 for itm in self.bannedUsersList.selectedItems(): 98 for itm in self.bannedUsersList.selectedItems():
98 row = self.bannedUsersList.row(itm) 99 row = self.bannedUsersList.row(itm)
99 itm = self.bannedUsersList.takeItem(row) 100 itm = self.bannedUsersList.takeItem(row)
105 Private slot to add a user to the list of banned users. 106 Private slot to add a user to the list of banned users.
106 """ 107 """
107 self.bannedUsersList.addItem(self.bannedUserEdit.text()) 108 self.bannedUsersList.addItem(self.bannedUserEdit.text())
108 self.bannedUserEdit.clear() 109 self.bannedUserEdit.clear()
109 110
111
110 def create(dlg): 112 def create(dlg):
111 """ 113 """
112 Module function to create the configuration page. 114 Module function to create the configuration page.
113 115
114 @param dlg reference to the configuration dialog 116 @param dlg reference to the configuration dialog

eric ide

mercurial