13 pyqtSignal, QObject, QByteArray, QUrl, QCoreApplication, QXmlStreamReader |
13 pyqtSignal, QObject, QByteArray, QUrl, QCoreApplication, QXmlStreamReader |
14 ) |
14 ) |
15 from PyQt6.QtWidgets import QApplication |
15 from PyQt6.QtWidgets import QApplication |
16 from PyQt6.QtWebEngineWidgets import QWebEngineScript |
16 from PyQt6.QtWebEngineWidgets import QWebEngineScript |
17 |
17 |
18 from E5Gui import E5MessageBox |
18 from E5Gui import EricMessageBox |
19 from E5Gui.E5ProgressDialog import E5ProgressDialog |
19 from E5Gui.EricProgressDialog import EricProgressDialog |
20 |
20 |
21 from Utilities.AutoSaver import AutoSaver |
21 from Utilities.AutoSaver import AutoSaver |
22 import Utilities |
22 import Utilities |
23 import Utilities.crypto |
23 import Utilities.crypto |
24 import Preferences |
24 import Preferences |
155 from .PasswordWriter import PasswordWriter |
155 from .PasswordWriter import PasswordWriter |
156 loginFile = self.getFileName() |
156 loginFile = self.getFileName() |
157 writer = PasswordWriter() |
157 writer = PasswordWriter() |
158 if not writer.write( |
158 if not writer.write( |
159 loginFile, self.__logins, self.__loginForms, self.__never): |
159 loginFile, self.__logins, self.__loginForms, self.__never): |
160 E5MessageBox.critical( |
160 EricMessageBox.critical( |
161 None, |
161 None, |
162 self.tr("Saving login data"), |
162 self.tr("Saving login data"), |
163 self.tr( |
163 self.tr( |
164 """<p>Login data could not be saved to""" |
164 """<p>Login data could not be saved to""" |
165 """ <b>{0}</b></p>""" |
165 """ <b>{0}</b></p>""" |
179 from .PasswordReader import PasswordReader |
179 from .PasswordReader import PasswordReader |
180 reader = PasswordReader() |
180 reader = PasswordReader() |
181 self.__logins, self.__loginForms, self.__never = reader.read( |
181 self.__logins, self.__loginForms, self.__never = reader.read( |
182 loginFile) |
182 loginFile) |
183 if reader.error() != QXmlStreamReader.Error.NoError: |
183 if reader.error() != QXmlStreamReader.Error.NoError: |
184 E5MessageBox.warning( |
184 EricMessageBox.warning( |
185 None, |
185 None, |
186 self.tr("Loading login data"), |
186 self.tr("Loading login data"), |
187 self.tr("""Error when loading login data on""" |
187 self.tr("""Error when loading login data on""" |
188 """ line {0}, column {1}:\n{2}""") |
188 """ line {0}, column {1}:\n{2}""") |
189 .format(reader.lineNumber(), |
189 .format(reader.lineNumber(), |
289 if userName and password: |
289 if userName and password: |
290 url = QUrl(urlStr) |
290 url = QUrl(urlStr) |
291 url = self.__stripUrl(url) |
291 url = self.__stripUrl(url) |
292 key = self.__createKey(url, "") |
292 key = self.__createKey(url, "") |
293 if key not in self.__loginForms: |
293 if key not in self.__loginForms: |
294 mb = E5MessageBox.E5MessageBox( |
294 mb = EricMessageBox.EricMessageBox( |
295 E5MessageBox.Question, |
295 EricMessageBox.Question, |
296 self.tr("Save password"), |
296 self.tr("Save password"), |
297 self.tr( |
297 self.tr( |
298 """<b>Would you like to save this password?</b><br/>""" |
298 """<b>Would you like to save this password?</b><br/>""" |
299 """To review passwords you have saved and remove""" |
299 """To review passwords you have saved and remove""" |
300 """ them, use the password management dialog of the""" |
300 """ them, use the password management dialog of the""" |
301 """ Settings menu."""), |
301 """ Settings menu."""), |
302 modal=True, parent=page.view()) |
302 modal=True, parent=page.view()) |
303 neverButton = mb.addButton( |
303 neverButton = mb.addButton( |
304 self.tr("Never for this site"), |
304 self.tr("Never for this site"), |
305 E5MessageBox.DestructiveRole) |
305 EricMessageBox.DestructiveRole) |
306 noButton = mb.addButton( |
306 noButton = mb.addButton( |
307 self.tr("Not now"), E5MessageBox.RejectRole) |
307 self.tr("Not now"), EricMessageBox.RejectRole) |
308 mb.addButton(E5MessageBox.Yes) |
308 mb.addButton(EricMessageBox.Yes) |
309 mb.exec() |
309 mb.exec() |
310 if mb.clickedButton() == neverButton: |
310 if mb.clickedButton() == neverButton: |
311 self.__never.append(url.toString()) |
311 self.__never.append(url.toString()) |
312 return |
312 return |
313 elif mb.clickedButton() == noButton: |
313 elif mb.clickedButton() == noButton: |
383 @param newPassword new master password (string) |
383 @param newPassword new master password (string) |
384 """ |
384 """ |
385 if not self.__loaded: |
385 if not self.__loaded: |
386 self.__load() |
386 self.__load() |
387 |
387 |
388 progress = E5ProgressDialog( |
388 progress = EricProgressDialog( |
389 self.tr("Re-encoding saved passwords..."), |
389 self.tr("Re-encoding saved passwords..."), |
390 None, 0, len(self.__logins) + len(self.__loginForms), |
390 None, 0, len(self.__logins) + len(self.__loginForms), |
391 self.tr("%v/%m Passwords"), |
391 self.tr("%v/%m Passwords"), |
392 QApplication.activeModalWidget()) |
392 QApplication.activeModalWidget()) |
393 progress.setMinimumDuration(0) |
393 progress.setMinimumDuration(0) |