7 Module implementing a custom widget indicating the strength of a password. |
7 Module implementing a custom widget indicating the strength of a password. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt6.QtWidgets import QProgressBar |
10 from PyQt6.QtWidgets import QProgressBar |
11 |
11 |
12 from eric7.Utilities.PasswordChecker import PasswordChecker |
12 from eric7.Utilities.PasswordChecker import PasswordChecker, PasswordStrength |
13 |
13 |
14 |
14 |
15 class EricPasswordMeter(QProgressBar): |
15 class EricPasswordMeter(QProgressBar): |
16 """ |
16 """ |
17 Class implementing a custom widget indicating the strength of a password. |
17 Class implementing a custom widget indicating the strength of a password. |
26 """ |
26 """ |
27 super().__init__(parent) |
27 super().__init__(parent) |
28 |
28 |
29 super().setTextVisible(False) |
29 super().setTextVisible(False) |
30 super().setMaximum(100) |
30 super().setMaximum(100) |
31 self.__increment = 100 // (PasswordChecker.Complexity_VeryStrong + 1) |
31 self.__increment = 100 // (PasswordStrength.VeryStrong + 1) |
32 |
32 |
33 self.__indicatorColors = [ |
33 self.__indicatorColors = { |
34 "#ff0000", # red |
34 PasswordStrength.VeryWeak: "#ff0000", # red |
35 "#ff8800", # orange |
35 PasswordStrength.Weak: "#ff8800", # orange |
36 "#ffff00", # yellow |
36 PasswordStrength.Good: "#ffff00", # yellow |
37 "#ccff00", # yellow green |
37 PasswordStrength.Strong: "#ccff00", # yellow green |
38 "#00ff00", # green |
38 PasswordStrength.VeryStrong: "#00ff00", # green |
39 ] |
39 } |
40 self.__noIndicator = "#ffffff" |
40 self.__noIndicator = "#ffffff" |
41 |
41 |
42 self.__styleSheetTemplate = ( |
42 self.__styleSheetTemplate = ( |
43 "QProgressBar {{" |
43 "QProgressBar {{" |
44 " border: 2px solid black;" |
44 " border: 2px solid black;" |