|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2009 - 2016 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to select which private data to clear. |
|
8 """ |
|
9 |
|
10 from __future__ import unicode_literals |
|
11 |
|
12 from PyQt5.QtWidgets import QDialog |
|
13 |
|
14 from .Ui_WebBrowserClearPrivateDataDialog import \ |
|
15 Ui_WebBrowserClearPrivateDataDialog |
|
16 |
|
17 |
|
18 class WebBrowserClearPrivateDataDialog(QDialog, |
|
19 Ui_WebBrowserClearPrivateDataDialog): |
|
20 """ |
|
21 Class implementing a dialog to select which private data to clear. |
|
22 """ |
|
23 def __init__(self, parent=None): |
|
24 """ |
|
25 Constructor |
|
26 |
|
27 @param parent reference to the parent widget (QWidget) |
|
28 """ |
|
29 super(WebBrowserClearPrivateDataDialog, self).__init__(parent) |
|
30 self.setupUi(self) |
|
31 |
|
32 msh = self.minimumSizeHint() |
|
33 self.resize(max(self.width(), msh.width()), msh.height()) |
|
34 |
|
35 def getData(self): |
|
36 """ |
|
37 Public method to get the data from the dialog. |
|
38 |
|
39 @return tuple with flags indicating which data to clear |
|
40 (browsing history, search history, favicons, disk cache, cookies, |
|
41 passwords, web databases, downloads, flash, zoom values) and the |
|
42 selected history period in milliseconds (tuple of booleans and |
|
43 integer) |
|
44 """ |
|
45 index = self.historyCombo.currentIndex() |
|
46 if index == 0: |
|
47 # last hour |
|
48 historyPeriod = 60 * 60 * 1000 |
|
49 elif index == 1: |
|
50 # last day |
|
51 historyPeriod = 24 * 60 * 60 * 1000 |
|
52 elif index == 2: |
|
53 # last week |
|
54 historyPeriod = 7 * 24 * 60 * 60 * 1000 |
|
55 elif index == 3: |
|
56 # last four weeks |
|
57 historyPeriod = 4 * 7 * 24 * 60 * 60 * 1000 |
|
58 elif index == 4: |
|
59 # clear all |
|
60 historyPeriod = 0 |
|
61 |
|
62 return (self.historyCheckBox.isChecked(), |
|
63 self.searchCheckBox.isChecked(), |
|
64 self.iconsCheckBox.isChecked(), |
|
65 self.cacheCheckBox.isChecked(), |
|
66 self.cookiesCheckBox.isChecked(), |
|
67 self.passwordsCheckBox.isChecked(), |
|
68 self.databasesCheckBox.isChecked(), |
|
69 self.downloadsCheckBox.isChecked(), |
|
70 self.flashCookiesCheckBox.isChecked(), |
|
71 self.zoomCheckBox.isChecked(), |
|
72 historyPeriod) |