17 |
17 |
18 class CookiesConfigurationDialog(QDialog, Ui_CookiesConfigurationDialog): |
18 class CookiesConfigurationDialog(QDialog, Ui_CookiesConfigurationDialog): |
19 """ |
19 """ |
20 Class implementing the cookies configuration dialog. |
20 Class implementing the cookies configuration dialog. |
21 """ |
21 """ |
|
22 |
22 def __init__(self, parent): |
23 def __init__(self, parent): |
23 """ |
24 """ |
24 Constructor |
25 Constructor |
25 |
26 |
26 @param parent reference to the parent object (QWidget) |
27 @param parent reference to the parent object (QWidget) |
27 """ |
28 """ |
28 super().__init__(parent) |
29 super().__init__(parent) |
29 self.setupUi(self) |
30 self.setupUi(self) |
30 |
31 |
31 self.__mw = parent |
32 self.__mw = parent |
32 |
33 |
33 jar = self.__mw.cookieJar() |
34 jar = self.__mw.cookieJar() |
34 acceptPolicy = jar.acceptPolicy() |
35 acceptPolicy = jar.acceptPolicy() |
35 if acceptPolicy == CookieJar.AcceptAlways: |
36 if acceptPolicy == CookieJar.AcceptAlways: |
36 self.acceptCombo.setCurrentIndex(0) |
37 self.acceptCombo.setCurrentIndex(0) |
37 elif acceptPolicy == CookieJar.AcceptNever: |
38 elif acceptPolicy == CookieJar.AcceptNever: |
38 self.acceptCombo.setCurrentIndex(1) |
39 self.acceptCombo.setCurrentIndex(1) |
39 elif acceptPolicy == CookieJar.AcceptOnlyFromSitesNavigatedTo: |
40 elif acceptPolicy == CookieJar.AcceptOnlyFromSitesNavigatedTo: |
40 self.acceptCombo.setCurrentIndex(2) |
41 self.acceptCombo.setCurrentIndex(2) |
41 |
42 |
42 keepPolicy = jar.keepPolicy() |
43 keepPolicy = jar.keepPolicy() |
43 if keepPolicy == CookieJar.KeepUntilExpire: |
44 if keepPolicy == CookieJar.KeepUntilExpire: |
44 self.keepUntilCombo.setCurrentIndex(0) |
45 self.keepUntilCombo.setCurrentIndex(0) |
45 elif keepPolicy == CookieJar.KeepUntilExit: |
46 elif keepPolicy == CookieJar.KeepUntilExit: |
46 self.keepUntilCombo.setCurrentIndex(1) |
47 self.keepUntilCombo.setCurrentIndex(1) |
47 |
48 |
48 self.filterTrackingCookiesCheckbox.setChecked( |
49 self.filterTrackingCookiesCheckbox.setChecked(jar.filterTrackingCookies()) |
49 jar.filterTrackingCookies()) |
50 |
50 |
|
51 msh = self.minimumSizeHint() |
51 msh = self.minimumSizeHint() |
52 self.resize(max(self.width(), msh.width()), msh.height()) |
52 self.resize(max(self.width(), msh.width()), msh.height()) |
53 |
53 |
54 def accept(self): |
54 def accept(self): |
55 """ |
55 """ |
56 Public slot to accept the dialog. |
56 Public slot to accept the dialog. |
57 """ |
57 """ |
58 acceptSelection = self.acceptCombo.currentIndex() |
58 acceptSelection = self.acceptCombo.currentIndex() |
60 acceptPolicy = CookieJar.AcceptAlways |
60 acceptPolicy = CookieJar.AcceptAlways |
61 elif acceptSelection == 1: |
61 elif acceptSelection == 1: |
62 acceptPolicy = CookieJar.AcceptNever |
62 acceptPolicy = CookieJar.AcceptNever |
63 elif acceptSelection == 2: |
63 elif acceptSelection == 2: |
64 acceptPolicy = CookieJar.AcceptOnlyFromSitesNavigatedTo |
64 acceptPolicy = CookieJar.AcceptOnlyFromSitesNavigatedTo |
65 |
65 |
66 keepSelection = self.keepUntilCombo.currentIndex() |
66 keepSelection = self.keepUntilCombo.currentIndex() |
67 if keepSelection == 0: |
67 if keepSelection == 0: |
68 keepPolicy = CookieJar.KeepUntilExpire |
68 keepPolicy = CookieJar.KeepUntilExpire |
69 elif keepSelection == 1: |
69 elif keepSelection == 1: |
70 keepPolicy = CookieJar.KeepUntilExit |
70 keepPolicy = CookieJar.KeepUntilExit |
71 |
71 |
72 jar = self.__mw.cookieJar() |
72 jar = self.__mw.cookieJar() |
73 jar.setAcceptPolicy(acceptPolicy) |
73 jar.setAcceptPolicy(acceptPolicy) |
74 jar.setKeepPolicy(keepPolicy) |
74 jar.setKeepPolicy(keepPolicy) |
75 jar.setFilterTrackingCookies( |
75 jar.setFilterTrackingCookies(self.filterTrackingCookiesCheckbox.isChecked()) |
76 self.filterTrackingCookiesCheckbox.isChecked()) |
76 |
77 |
|
78 super().accept() |
77 super().accept() |
79 |
78 |
80 @pyqtSlot() |
79 @pyqtSlot() |
81 def on_exceptionsButton_clicked(self): |
80 def on_exceptionsButton_clicked(self): |
82 """ |
81 """ |
83 Private slot to show the cookies exceptions dialog. |
82 Private slot to show the cookies exceptions dialog. |
84 """ |
83 """ |
85 from .CookiesExceptionsDialog import CookiesExceptionsDialog |
84 from .CookiesExceptionsDialog import CookiesExceptionsDialog |
|
85 |
86 dlg = CookiesExceptionsDialog(self.__mw.cookieJar()) |
86 dlg = CookiesExceptionsDialog(self.__mw.cookieJar()) |
87 dlg.exec() |
87 dlg.exec() |
88 |
88 |
89 @pyqtSlot() |
89 @pyqtSlot() |
90 def on_cookiesButton_clicked(self): |
90 def on_cookiesButton_clicked(self): |
91 """ |
91 """ |
92 Private slot to show the cookies dialog. |
92 Private slot to show the cookies dialog. |
93 """ |
93 """ |
94 from .CookiesDialog import CookiesDialog |
94 from .CookiesDialog import CookiesDialog |
|
95 |
95 dlg = CookiesDialog(self.__mw.cookieJar()) |
96 dlg = CookiesDialog(self.__mw.cookieJar()) |
96 dlg.exec() |
97 dlg.exec() |