Mon, 25 Mar 2013 03:11:06 +0100
Script changes: Future import added, super calls modified and unicode behavior for str.
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
2302
f29e9405c851
Updated copyright for 2013.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2122
diff
changeset
|
3 | # Copyright (c) 2011 - 2013 Detlev Offenbach <detlev@die-offenbachs.de> |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog to show some information about a site. |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
2525
8b507a9a2d40
Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2432
diff
changeset
|
10 | from __future__ import unicode_literals # __IGNORE_WARNING__ |
8b507a9a2d40
Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2432
diff
changeset
|
11 | |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
12 | import os |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | |
2078
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1857
diff
changeset
|
14 | from PyQt4.QtCore import pyqtSlot, QUrl, Qt, QFile, qVersion |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | from PyQt4.QtGui import QDialog, QTreeWidgetItem, QPixmap, QGraphicsScene, QMenu, \ |
1780
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
16 | QCursor, QApplication, QListWidgetItem |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | from PyQt4.QtWebKit import QWebSettings |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | from E5Gui import E5MessageBox, E5FileDialog |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | |
1857
baf039cc2d9a
Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1780
diff
changeset
|
21 | try: |
baf039cc2d9a
Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1780
diff
changeset
|
22 | from .Ui_SiteInfoDialog import Ui_SiteInfoDialog # __IGNORE_WARNING__ |
baf039cc2d9a
Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1780
diff
changeset
|
23 | SSL = True |
baf039cc2d9a
Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1780
diff
changeset
|
24 | except ImportError: |
baf039cc2d9a
Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1780
diff
changeset
|
25 | from .Ui_SiteInfoNoSslDialog import Ui_SiteInfoDialog # __IGNORE_WARNING__ |
baf039cc2d9a
Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1780
diff
changeset
|
26 | SSL = False |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | from ..Download.DownloadUtilities import dataString |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | import UI.PixmapCache |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | class SiteInfoDialog(QDialog, Ui_SiteInfoDialog): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | Class implementing a dialog to show some information about a site. |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | okStyle = "QLabel { color : white; background-color : green; }" |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | nokStyle = "QLabel { color : white; background-color : red; }" |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | def __init__(self, browser, parent=None): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | Constructor |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | @param browser reference to the browser window (HelpBrowser) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | @param parent reference to the parent widget (QWidget) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | """ |
2525
8b507a9a2d40
Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
2432
diff
changeset
|
47 | super(SiteInfoDialog, self).__init__(parent) |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | self.setupUi(self) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | # put icons |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | self.tabWidget.setTabIcon(0, UI.PixmapCache.getIcon("siteinfo-general.png")) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | self.tabWidget.setTabIcon(1, UI.PixmapCache.getIcon("siteinfo-media.png")) |
1780
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
53 | self.tabWidget.setTabIcon(2, UI.PixmapCache.getIcon("siteinfo-databases.png")) |
1857
baf039cc2d9a
Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1780
diff
changeset
|
54 | if SSL: |
baf039cc2d9a
Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1780
diff
changeset
|
55 | self.tabWidget.setTabIcon(3, UI.PixmapCache.getIcon("siteinfo-security.png")) |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | |
1780
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
57 | self.__mainFrame = browser.page().mainFrame() |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | title = browser.title() |
2432
b1a2f9054b28
Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2403
diff
changeset
|
59 | sslInfo = browser.page().getSslCertificateChain() |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | # populate General tab |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | self.heading.setText("<b>{0}</b>".format(title)) |
1780
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
63 | self.siteAddressLabel.setText(self.__mainFrame.baseUrl().toString()) |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | self.sizeLabel.setText(dataString(browser.page().totalBytes())) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | encoding = "" |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | # populate Meta tags |
1780
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
68 | meta = self.__mainFrame.findAllElements("meta") |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | for element in meta: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | content = element.attribute("content") |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | name = element.attribute("name") |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | if not name: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | name = element.attribute("http-equiv") |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | if element.attribute("charset"): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | encoding = element.attribute("charset") |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | if "charset=" in content: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | encoding = content[content.index("charset=") + 8:] |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | if not content or not name: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | continue |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | QTreeWidgetItem(self.tagsTree, [name, content]) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | for col in range(self.tagsTree.columnCount()): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | self.tagsTree.resizeColumnToContents(col) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | if not encoding: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | encoding = QWebSettings.globalSettings().defaultTextEncoding() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | self.encodingLabel.setText(encoding) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | # populate the Security info and the Security tab |
2432
b1a2f9054b28
Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2403
diff
changeset
|
91 | if sslInfo and \ |
b1a2f9054b28
Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2403
diff
changeset
|
92 | ((qVersion() >= "5.0.0" and not sslInfo[0].isBlacklisted()) or \ |
b1a2f9054b28
Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2403
diff
changeset
|
93 | (qVersion() < "5.0.0" and sslInfo[0].isValid())): |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
94 | self.securityLabel.setStyleSheet(SiteInfoDialog.okStyle) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | self.securityLabel.setText('<b>Connection is encrypted.</b>') |
1857
baf039cc2d9a
Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1780
diff
changeset
|
96 | if SSL: |
2432
b1a2f9054b28
Reworked the various SSL info widgets of the web browser to show more info.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2403
diff
changeset
|
97 | self.sslWidget.showCertificateChain(sslInfo) |
1857
baf039cc2d9a
Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1780
diff
changeset
|
98 | self.securityDetailsButton.setEnabled(True) |
baf039cc2d9a
Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1780
diff
changeset
|
99 | else: |
baf039cc2d9a
Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1780
diff
changeset
|
100 | self.securityDetailsButton.setEnabled(False) |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | else: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | self.securityLabel.setStyleSheet(SiteInfoDialog.nokStyle) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | self.securityLabel.setText('<b>Connection is not encrypted.</b>') |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | self.securityDetailsButton.setEnabled(False) |
2122
fce5f83cb990
Fixed two issues in the SSL Info Dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2078
diff
changeset
|
105 | self.tabWidget.setTabEnabled(self.tabWidget.indexOf(self.securityTab), False) |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | # populate Media tab |
1780
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
108 | images = self.__mainFrame.findAllElements("img") |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | for element in images: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
110 | src = element.attribute("src") |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
111 | alt = element.attribute("alt") |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | if src and src.startswith("data:"): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | continue |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | if not alt: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | if src.find("/") == -1: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | alt = src |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | else: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | pos = src.find("/") |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | alt = src[pos + 1:] |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | if not src or not alt: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | continue |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | QTreeWidgetItem(self.imagesTree, [alt, src]) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | for col in range(self.imagesTree.columnCount()): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
126 | self.imagesTree.resizeColumnToContents(col) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | if self.imagesTree.columnWidth(0) > 300: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | self.imagesTree.setColumnWidth(0, 300) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | self.imagesTree.setCurrentItem(self.imagesTree.topLevelItem(0)) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | self.imagesTree.setContextMenuPolicy(Qt.CustomContextMenu) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
131 | self.imagesTree.customContextMenuRequested.connect( |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | self.__imagesTreeContextMenuRequested) |
1780
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
133 | |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
134 | # populate the Databases tab |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
135 | databases = self.__mainFrame.securityOrigin().databases() |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
136 | counter = 0 |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
137 | for database in databases: |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
138 | itm = QListWidgetItem(self.databasesList) |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
139 | itm.setText(database.displayName()) |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
140 | itm.setData(Qt.UserRole, counter) |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
141 | counter += 1 |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
142 | |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
143 | if counter == 0: |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
144 | itm = QListWidgetItem(self.databasesList) |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
145 | itm.setText(self.trUtf8("No databases are used by this page.")) |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
146 | itm.setFlags(itm.flags() & Qt.ItemIsSelectable) |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
148 | @pyqtSlot() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | def on_securityDetailsButton_clicked(self): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | Private slot to show security details. |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
152 | """ |
2122
fce5f83cb990
Fixed two issues in the SSL Info Dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2078
diff
changeset
|
153 | self.tabWidget.setCurrentIndex(self.tabWidget.indexOf(self.securityTab)) |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | def on_imagesTree_currentItemChanged(self, current, previous): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | Private slot to show a preview of the selected image. |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
159 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
160 | @param current current image entry (QTreeWidgetItem) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | @param previous old current entry (QTreeWidgetItem) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | if current is None: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | return |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
166 | imageUrl = QUrl(current.text(1)) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
167 | if not imageUrl.host(): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
168 | imageUrl.setHost(QUrl(self.siteAddressLabel.text()).host()) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
169 | imageUrl.setScheme(QUrl(self.siteAddressLabel.text()).scheme()) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | |
2403
e3d7a861547c
Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
171 | import Helpviewer.HelpWindow |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | cache = Helpviewer.HelpWindow.HelpWindow.networkAccessManager().cache() |
1433
cb6507f68b16
Fixed an issue in the site info dialog causing it to fail, if no disk cache was enabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1427
diff
changeset
|
173 | if cache: |
cb6507f68b16
Fixed an issue in the site info dialog causing it to fail, if no disk cache was enabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1427
diff
changeset
|
174 | cacheData = cache.data(imageUrl) |
cb6507f68b16
Fixed an issue in the site info dialog causing it to fail, if no disk cache was enabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1427
diff
changeset
|
175 | else: |
cb6507f68b16
Fixed an issue in the site info dialog causing it to fail, if no disk cache was enabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1427
diff
changeset
|
176 | cacheData = None |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | pixmap = QPixmap() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
178 | invalidPixmap = False |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | scene = QGraphicsScene(self.imagePreview) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | if not cacheData: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | invalidPixmap = True |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
182 | else: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | pixmap.loadFromData(cacheData.readAll()) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | if pixmap.isNull(): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | invalidPixmap = True |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | if invalidPixmap: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | scene.addText(self.trUtf8("Preview not available.")) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | else: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | scene.addPixmap(pixmap) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | self.imagePreview.setScene(scene) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
191 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | def __imagesTreeContextMenuRequested(self, pos): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | Private slot to show a context menu for the images list. |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | @param pos position for the menu (QPoint) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
198 | itm = self.imagesTree.itemAt(pos) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | if itm is None: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
200 | return |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
201 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
202 | menu = QMenu() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
203 | act = menu.addAction(self.trUtf8("Copy Image Location to Clipboard"), |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
204 | self.__copyAction) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
205 | act.setData(itm.text(1)) |
1474
1eaec11a0078
Fixed a few PEP-8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1433
diff
changeset
|
206 | act = menu.addAction(self.trUtf8("Copy Image Name to Clipboard"), |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
207 | self.__copyAction) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
208 | act.setData(itm.text(0)) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
209 | menu.addSeparator() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
210 | act = menu.addAction(self.trUtf8("Save Image"), self.__saveImage) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
211 | act.setData(self.imagesTree.indexOfTopLevelItem(itm)) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | menu.exec_(QCursor.pos()) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
213 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
214 | def __copyAction(self): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
215 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
216 | Private slot to copy the image URL or the image name to the clipboard. |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
217 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
218 | act = self.sender() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | QApplication.clipboard().setText(act.data()) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
220 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
221 | def __saveImage(self): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
222 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
223 | Private slot to save the selected image to disk. |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
224 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
225 | act = self.sender() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
226 | index = act.data() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
227 | itm = self.imagesTree.topLevelItem(index) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
228 | if itm is None: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
229 | return |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
230 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
231 | imageUrl = QUrl(itm.text(1)) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
232 | if not imageUrl.host(): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
233 | imageUrl.setHost(QUrl(self.siteAddressLabel.text()).host()) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
234 | imageUrl.setScheme(QUrl(self.siteAddressLabel.text()).scheme()) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
235 | |
2403
e3d7a861547c
Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
236 | import Helpviewer.HelpWindow |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
237 | cache = Helpviewer.HelpWindow.HelpWindow.networkAccessManager().cache() |
1433
cb6507f68b16
Fixed an issue in the site info dialog causing it to fail, if no disk cache was enabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1427
diff
changeset
|
238 | if cache: |
cb6507f68b16
Fixed an issue in the site info dialog causing it to fail, if no disk cache was enabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1427
diff
changeset
|
239 | cacheData = cache.data(imageUrl) |
cb6507f68b16
Fixed an issue in the site info dialog causing it to fail, if no disk cache was enabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1427
diff
changeset
|
240 | else: |
cb6507f68b16
Fixed an issue in the site info dialog causing it to fail, if no disk cache was enabled.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1427
diff
changeset
|
241 | cacheData = None |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
242 | if not cacheData: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
243 | E5MessageBox.critical(self, |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
244 | self.trUtf8("Save Image"), |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
245 | self.trUtf8("""This image is not available.""")) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
246 | return |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
247 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
248 | downloadDirectory = Helpviewer.HelpWindow.HelpWindow\ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
249 | .downloadManager().downloadDirectory() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
250 | fn = os.path.join(downloadDirectory, os.path.basename(itm.text(1))) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
251 | filename = E5FileDialog.getSaveFileName( |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
252 | self, |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
253 | self.trUtf8("Save Image"), |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
254 | fn, |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
255 | self.trUtf8("All Files (*)"), |
1780
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
256 | E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
257 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
258 | if not filename: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
259 | return |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
260 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
261 | f = QFile(filename) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
262 | if not f.open(QFile.WriteOnly): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
263 | E5MessageBox.critical(self, |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
264 | self.trUtf8("Save Image"), |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
265 | self.trUtf8( |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
266 | """<p>Cannot write to file <b>{0}</b>.</p>""".format(filename))) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
267 | return |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
268 | f.write(cacheData.readAll()) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
269 | f.close() |
1780
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
270 | |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
271 | @pyqtSlot(QListWidgetItem, QListWidgetItem) |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
272 | def on_databasesList_currentItemChanged(self, current, previous): |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
273 | """ |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
274 | Private slot to show data about the selected database. |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
275 | |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
276 | @param current current database entry (QTreeWidgetItem) |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
277 | @param previous old current entry (QTreeWidgetItem) |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
278 | """ |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
279 | if current is None: |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
280 | return |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
281 | |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
282 | id = current.data(Qt.UserRole) |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
283 | databases = self.__mainFrame.securityOrigin().databases() |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
284 | |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
285 | if id >= len(databases): |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
286 | return |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
287 | |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
288 | db = databases[id] |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
289 | self.databaseName.setText("{0} ({1})".format(db.displayName(), db.name())) |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
290 | self.databasePath.setText(db.fileName()) |
f42757fd021b
Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1509
diff
changeset
|
291 | self.databaseSize.setText(dataString(db.size())) |