10 from __future__ import unicode_literals # __IGNORE_WARNING__ |
10 from __future__ import unicode_literals # __IGNORE_WARNING__ |
11 |
11 |
12 import os |
12 import os |
13 |
13 |
14 from PyQt4.QtCore import pyqtSlot, QUrl, Qt, QFile, qVersion |
14 from PyQt4.QtCore import pyqtSlot, QUrl, Qt, QFile, qVersion |
15 from PyQt4.QtGui import QDialog, QTreeWidgetItem, QPixmap, QGraphicsScene, QMenu, \ |
15 from PyQt4.QtGui import QDialog, QTreeWidgetItem, QPixmap, QGraphicsScene, \ |
16 QCursor, QApplication, QListWidgetItem |
16 QMenu, QCursor, QApplication, QListWidgetItem |
17 from PyQt4.QtWebKit import QWebSettings |
17 from PyQt4.QtWebKit import QWebSettings |
18 |
18 |
19 from E5Gui import E5MessageBox, E5FileDialog |
19 from E5Gui import E5MessageBox, E5FileDialog |
20 |
20 |
21 try: |
21 try: |
22 from .Ui_SiteInfoDialog import Ui_SiteInfoDialog # __IGNORE_WARNING__ |
22 from .Ui_SiteInfoDialog import Ui_SiteInfoDialog # __IGNORE_WARNING__ |
23 SSL = True |
23 SSL = True |
24 except ImportError: |
24 except ImportError: |
25 from .Ui_SiteInfoNoSslDialog import Ui_SiteInfoDialog # __IGNORE_WARNING__ |
25 from .Ui_SiteInfoNoSslDialog import Ui_SiteInfoDialog # __IGNORE_WARNING__ |
26 SSL = False |
26 SSL = False |
27 |
27 |
28 from ..Download.DownloadUtilities import dataString |
28 from ..Download.DownloadUtilities import dataString |
29 |
29 |
30 import UI.PixmapCache |
30 import UI.PixmapCache |
46 """ |
46 """ |
47 super(SiteInfoDialog, self).__init__(parent) |
47 super(SiteInfoDialog, self).__init__(parent) |
48 self.setupUi(self) |
48 self.setupUi(self) |
49 |
49 |
50 # put icons |
50 # put icons |
51 self.tabWidget.setTabIcon(0, UI.PixmapCache.getIcon("siteinfo-general.png")) |
51 self.tabWidget.setTabIcon( |
52 self.tabWidget.setTabIcon(1, UI.PixmapCache.getIcon("siteinfo-media.png")) |
52 0, UI.PixmapCache.getIcon("siteinfo-general.png")) |
53 self.tabWidget.setTabIcon(2, UI.PixmapCache.getIcon("siteinfo-databases.png")) |
53 self.tabWidget.setTabIcon( |
|
54 1, UI.PixmapCache.getIcon("siteinfo-media.png")) |
|
55 self.tabWidget.setTabIcon( |
|
56 2, UI.PixmapCache.getIcon("siteinfo-databases.png")) |
54 if SSL: |
57 if SSL: |
55 self.tabWidget.setTabIcon(3, UI.PixmapCache.getIcon("siteinfo-security.png")) |
58 self.tabWidget.setTabIcon( |
|
59 3, UI.PixmapCache.getIcon("siteinfo-security.png")) |
56 |
60 |
57 self.__mainFrame = browser.page().mainFrame() |
61 self.__mainFrame = browser.page().mainFrame() |
58 title = browser.title() |
62 title = browser.title() |
59 sslInfo = browser.page().getSslCertificateChain() |
63 sslInfo = browser.page().getSslCertificateChain() |
60 |
64 |
100 self.securityDetailsButton.setEnabled(False) |
104 self.securityDetailsButton.setEnabled(False) |
101 else: |
105 else: |
102 self.securityLabel.setStyleSheet(SiteInfoDialog.nokStyle) |
106 self.securityLabel.setStyleSheet(SiteInfoDialog.nokStyle) |
103 self.securityLabel.setText('<b>Connection is not encrypted.</b>') |
107 self.securityLabel.setText('<b>Connection is not encrypted.</b>') |
104 self.securityDetailsButton.setEnabled(False) |
108 self.securityDetailsButton.setEnabled(False) |
105 self.tabWidget.setTabEnabled(self.tabWidget.indexOf(self.securityTab), False) |
109 self.tabWidget.setTabEnabled( |
|
110 self.tabWidget.indexOf(self.securityTab), False) |
106 |
111 |
107 # populate Media tab |
112 # populate Media tab |
108 images = self.__mainFrame.findAllElements("img") |
113 images = self.__mainFrame.findAllElements("img") |
109 for element in images: |
114 for element in images: |
110 src = element.attribute("src") |
115 src = element.attribute("src") |
148 @pyqtSlot() |
153 @pyqtSlot() |
149 def on_securityDetailsButton_clicked(self): |
154 def on_securityDetailsButton_clicked(self): |
150 """ |
155 """ |
151 Private slot to show security details. |
156 Private slot to show security details. |
152 """ |
157 """ |
153 self.tabWidget.setCurrentIndex(self.tabWidget.indexOf(self.securityTab)) |
158 self.tabWidget.setCurrentIndex( |
|
159 self.tabWidget.indexOf(self.securityTab)) |
154 |
160 |
155 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem) |
161 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem) |
156 def on_imagesTree_currentItemChanged(self, current, previous): |
162 def on_imagesTree_currentItemChanged(self, current, previous): |
157 """ |
163 """ |
158 Private slot to show a preview of the selected image. |
164 Private slot to show a preview of the selected image. |
261 f = QFile(filename) |
267 f = QFile(filename) |
262 if not f.open(QFile.WriteOnly): |
268 if not f.open(QFile.WriteOnly): |
263 E5MessageBox.critical(self, |
269 E5MessageBox.critical(self, |
264 self.trUtf8("Save Image"), |
270 self.trUtf8("Save Image"), |
265 self.trUtf8( |
271 self.trUtf8( |
266 """<p>Cannot write to file <b>{0}</b>.</p>""".format(filename))) |
272 """<p>Cannot write to file <b>{0}</b>.</p>""") |
|
273 .format(filename)) |
267 return |
274 return |
268 f.write(cacheData.readAll()) |
275 f.write(cacheData.readAll()) |
269 f.close() |
276 f.close() |
270 |
277 |
271 @pyqtSlot(QListWidgetItem, QListWidgetItem) |
278 @pyqtSlot(QListWidgetItem, QListWidgetItem) |
284 |
291 |
285 if id >= len(databases): |
292 if id >= len(databases): |
286 return |
293 return |
287 |
294 |
288 db = databases[id] |
295 db = databases[id] |
289 self.databaseName.setText("{0} ({1})".format(db.displayName(), db.name())) |
296 self.databaseName.setText( |
|
297 "{0} ({1})".format(db.displayName(), db.name())) |
290 self.databasePath.setText(db.fileName()) |
298 self.databasePath.setText(db.fileName()) |
291 self.databaseSize.setText(dataString(db.size())) |
299 self.databaseSize.setText(dataString(db.size())) |