src/eric7/Preferences/ConfigurationPages/SecurityPage.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
18 18
19 class SecurityPage(ConfigurationPageBase, Ui_SecurityPage): 19 class SecurityPage(ConfigurationPageBase, Ui_SecurityPage):
20 """ 20 """
21 Class implementing the Security configuration page. 21 Class implementing the Security configuration page.
22 """ 22 """
23
23 def __init__(self, configDialog): 24 def __init__(self, configDialog):
24 """ 25 """
25 Constructor 26 Constructor
26 27
27 @param configDialog reference to the configuration dialog 28 @param configDialog reference to the configuration dialog
28 (ConfigurationDialog) 29 (ConfigurationDialog)
29 """ 30 """
30 super().__init__() 31 super().__init__()
31 self.setupUi(self) 32 self.setupUi(self)
32 self.setObjectName("SecurityPage") 33 self.setObjectName("SecurityPage")
33 34
34 self.__configDlg = configDialog 35 self.__configDlg = configDialog
35 self.__displayMode = None 36 self.__displayMode = None
36 37
37 # set initial values 38 # set initial values
38 self.savePasswordsCheckBox.setChecked( 39 self.savePasswordsCheckBox.setChecked(Preferences.getUser("SavePasswords"))
39 Preferences.getUser("SavePasswords")) 40 self.masterPasswordCheckBox.setChecked(Preferences.getUser("UseMasterPassword"))
40 self.masterPasswordCheckBox.setChecked( 41 self.masterPasswordButton.setEnabled(Preferences.getUser("UseMasterPassword"))
41 Preferences.getUser("UseMasterPassword")) 42
42 self.masterPasswordButton.setEnabled(
43 Preferences.getUser("UseMasterPassword"))
44
45 self.__newPassword = "" 43 self.__newPassword = ""
46 self.__oldUseMasterPassword = Preferences.getUser("UseMasterPassword") 44 self.__oldUseMasterPassword = Preferences.getUser("UseMasterPassword")
47 45
48 self.alwaysRejectCheckBox.setChecked( 46 self.alwaysRejectCheckBox.setChecked(
49 Preferences.getWebBrowser("AlwaysRejectFaultyCertificates")) 47 Preferences.getWebBrowser("AlwaysRejectFaultyCertificates")
50 48 )
49
51 def setMode(self, displayMode): 50 def setMode(self, displayMode):
52 """ 51 """
53 Public method to perform mode dependent setups. 52 Public method to perform mode dependent setups.
54 53
55 @param displayMode mode of the configuration dialog 54 @param displayMode mode of the configuration dialog
56 (ConfigurationMode.DEFAULTMODE, 55 (ConfigurationMode.DEFAULTMODE,
57 ConfigurationMode.WEBBROWSERMODE) 56 ConfigurationMode.WEBBROWSERMODE)
58 """ 57 """
59 from ..ConfigurationDialog import ConfigurationMode 58 from ..ConfigurationDialog import ConfigurationMode
59
60 if displayMode in ( 60 if displayMode in (
61 ConfigurationMode.DEFAULTMODE, 61 ConfigurationMode.DEFAULTMODE,
62 ConfigurationMode.WEBBROWSERMODE 62 ConfigurationMode.WEBBROWSERMODE,
63 ): 63 ):
64 self.__displayMode = displayMode 64 self.__displayMode = displayMode
65 65
66 self.certificateErrorsGroup.setVisible( 66 self.certificateErrorsGroup.setVisible(
67 displayMode == ConfigurationMode.WEBBROWSERMODE 67 displayMode == ConfigurationMode.WEBBROWSERMODE
68 ) 68 )
69 69
70 def save(self): 70 def save(self):
71 """ 71 """
72 Public slot to save the Help Viewers configuration. 72 Public slot to save the Help Viewers configuration.
73 """ 73 """
74 Preferences.setUser("SavePasswords", self.savePasswordsCheckBox.isChecked())
74 Preferences.setUser( 75 Preferences.setUser(
75 "SavePasswords", 76 "UseMasterPassword", self.masterPasswordCheckBox.isChecked()
76 self.savePasswordsCheckBox.isChecked()) 77 )
77 Preferences.setUser( 78
78 "UseMasterPassword", 79 if self.__oldUseMasterPassword != self.masterPasswordCheckBox.isChecked():
79 self.masterPasswordCheckBox.isChecked())
80
81 if (
82 self.__oldUseMasterPassword !=
83 self.masterPasswordCheckBox.isChecked()
84 ):
85 self.__configDlg.masterPasswordChanged.emit("", self.__newPassword) 80 self.__configDlg.masterPasswordChanged.emit("", self.__newPassword)
86 81
87 Preferences.setWebBrowser( 82 Preferences.setWebBrowser(
88 "AlwaysRejectFaultyCertificates", 83 "AlwaysRejectFaultyCertificates", self.alwaysRejectCheckBox.isChecked()
89 self.alwaysRejectCheckBox.isChecked()) 84 )
90 85
91 @pyqtSlot(bool) 86 @pyqtSlot(bool)
92 def on_masterPasswordCheckBox_clicked(self, checked): 87 def on_masterPasswordCheckBox_clicked(self, checked):
93 """ 88 """
94 Private slot to handle the use of a master password. 89 Private slot to handle the use of a master password.
95 90
96 @param checked flag indicating the state of the check box (boolean) 91 @param checked flag indicating the state of the check box (boolean)
97 """ 92 """
98 if checked: 93 if checked:
99 from .MasterPasswordEntryDialog import MasterPasswordEntryDialog 94 from .MasterPasswordEntryDialog import MasterPasswordEntryDialog
95
100 dlg = MasterPasswordEntryDialog("", self) 96 dlg = MasterPasswordEntryDialog("", self)
101 if dlg.exec() == QDialog.DialogCode.Accepted: 97 if dlg.exec() == QDialog.DialogCode.Accepted:
102 Preferences.setUser( 98 Preferences.setUser("MasterPassword", dlg.getMasterPassword())
103 "MasterPassword",
104 dlg.getMasterPassword())
105 self.masterPasswordButton.setEnabled(True) 99 self.masterPasswordButton.setEnabled(True)
106 self.__newPassword = dlg.getMasterPassword() 100 self.__newPassword = dlg.getMasterPassword()
107 else: 101 else:
108 self.masterPasswordCheckBox.setChecked(False) 102 self.masterPasswordCheckBox.setChecked(False)
109 else: 103 else:
110 self.masterPasswordButton.setEnabled(False) 104 self.masterPasswordButton.setEnabled(False)
111 self.__newPassword = "" 105 self.__newPassword = ""
112 106
113 @pyqtSlot() 107 @pyqtSlot()
114 def on_masterPasswordButton_clicked(self): 108 def on_masterPasswordButton_clicked(self):
115 """ 109 """
116 Private slot to change the master password. 110 Private slot to change the master password.
117 """ 111 """
118 from .MasterPasswordEntryDialog import MasterPasswordEntryDialog 112 from .MasterPasswordEntryDialog import MasterPasswordEntryDialog
119 dlg = MasterPasswordEntryDialog( 113
120 Preferences.getUser("MasterPassword"), self) 114 dlg = MasterPasswordEntryDialog(Preferences.getUser("MasterPassword"), self)
121 if dlg.exec() == QDialog.DialogCode.Accepted: 115 if dlg.exec() == QDialog.DialogCode.Accepted:
122 Preferences.setUser( 116 Preferences.setUser("MasterPassword", dlg.getMasterPassword())
123 "MasterPassword", 117
124 dlg.getMasterPassword()) 118 if self.__oldUseMasterPassword != self.masterPasswordCheckBox.isChecked():
125
126 if (
127 self.__oldUseMasterPassword !=
128 self.masterPasswordCheckBox.isChecked()
129 ):
130 # the user is about to change the use of a master password 119 # the user is about to change the use of a master password
131 # just save the changed password 120 # just save the changed password
132 self.__newPassword = dlg.getMasterPassword() 121 self.__newPassword = dlg.getMasterPassword()
133 else: 122 else:
134 self.__configDlg.masterPasswordChanged.emit( 123 self.__configDlg.masterPasswordChanged.emit(
135 dlg.getCurrentPassword(), dlg.getMasterPassword()) 124 dlg.getCurrentPassword(), dlg.getMasterPassword()
125 )
136 126
137 127
138 def create(dlg): 128 def create(dlg):
139 """ 129 """
140 Module function to create the configuration page. 130 Module function to create the configuration page.
141 131
142 @param dlg reference to the configuration dialog 132 @param dlg reference to the configuration dialog
143 @return reference to the instantiated page (ConfigurationPageBase) 133 @return reference to the instantiated page (ConfigurationPageBase)
144 """ 134 """
145 page = SecurityPage(dlg) 135 page = SecurityPage(dlg)
146 return page 136 return page

eric ide

mercurial