Sun, 29 Jun 2014 20:13:56 +0200
Started porting eric5 to PyQt5.
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 | |
3160
209a07d7e401
Updated copyright for 2014.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3035
diff
changeset
|
3 | # Copyright (c) 2011 - 2014 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 | |
3145
a9de05d4a22f
# __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents:
3060
diff
changeset
|
10 | from __future__ import unicode_literals |
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
|
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 | |
3656
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3484
diff
changeset
|
14 | from PyQt5.QtCore import pyqtSlot, QUrl, Qt, QFile, qVersion |
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3484
diff
changeset
|
15 | from PyQt5.QtGui import QPixmap, QCursor |
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3484
diff
changeset
|
16 | from PyQt5.QtWidgets import QDialog, QTreeWidgetItem, QGraphicsScene, QMenu, \ |
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3484
diff
changeset
|
17 | QApplication, QListWidgetItem |
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3484
diff
changeset
|
18 | from PyQt5.QtWebKit import QWebSettings |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | 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
|
21 | |
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
|
22 | try: |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2432
diff
changeset
|
23 | from .Ui_SiteInfoDialog import Ui_SiteInfoDialog # __IGNORE_WARNING__ |
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
|
24 | 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
|
25 | except ImportError: |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2432
diff
changeset
|
26 | from .Ui_SiteInfoNoSslDialog import Ui_SiteInfoDialog # __IGNORE_WARNING__ |
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
|
27 | SSL = False |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | 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
|
30 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | import UI.PixmapCache |
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 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | 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
|
35 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
36 | 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
|
37 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | 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
|
39 | 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
|
40 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
41 | 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
|
42 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | Constructor |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | @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
|
46 | @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
|
47 | """ |
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
|
48 | 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
|
49 | self.setupUi(self) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | # put icons |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2432
diff
changeset
|
52 | self.tabWidget.setTabIcon( |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2432
diff
changeset
|
53 | 0, UI.PixmapCache.getIcon("siteinfo-general.png")) |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2432
diff
changeset
|
54 | self.tabWidget.setTabIcon( |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2432
diff
changeset
|
55 | 1, UI.PixmapCache.getIcon("siteinfo-media.png")) |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2432
diff
changeset
|
56 | self.tabWidget.setTabIcon( |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2432
diff
changeset
|
57 | 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
|
58 | if SSL: |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2432
diff
changeset
|
59 | self.tabWidget.setTabIcon( |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2432
diff
changeset
|
60 | 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
|
61 | |
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
|
62 | 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
|
63 | 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
|
64 | 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
|
65 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | # populate General tab |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | 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
|
68 | 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
|
69 | 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
|
70 | encoding = "" |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | # 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
|
73 | 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
|
74 | 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
|
75 | 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
|
76 | 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
|
77 | if not name: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | 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
|
79 | 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
|
80 | 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
|
81 | 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
|
82 | 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
|
83 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | 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
|
85 | continue |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | 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
|
88 | 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
|
89 | 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
|
90 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | if not encoding: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | 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
|
93 | 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
|
94 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
95 | # 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
|
96 | if sslInfo and \ |
3034
7ce719013078
Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3022
diff
changeset
|
97 | ((qVersion() >= "5.0.0" and not sslInfo[0].isBlacklisted()) or |
3035
36e9f388958b
Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3034
diff
changeset
|
98 | (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
|
99 | 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
|
100 | 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
|
101 | 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
|
102 | 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
|
103 | 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
|
104 | 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
|
105 | 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
|
106 | else: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | 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
|
108 | 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
|
109 | self.securityDetailsButton.setEnabled(False) |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2432
diff
changeset
|
110 | self.tabWidget.setTabEnabled( |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2432
diff
changeset
|
111 | 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
|
112 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | # 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
|
114 | 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
|
115 | 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
|
116 | 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
|
117 | 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
|
118 | 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
|
119 | continue |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | if not alt: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | 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
|
122 | alt = src |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | else: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | pos = src.find("/") |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
125 | 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
|
126 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | 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
|
128 | continue |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | 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
|
131 | 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
|
132 | 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
|
133 | 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
|
134 | 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
|
135 | 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
|
136 | 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
|
137 | 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
|
138 | 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
|
139 | |
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 | # 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
|
141 | 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
|
142 | 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
|
143 | 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
|
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(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
|
146 | 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
|
147 | 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
|
148 | |
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
|
149 | 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
|
150 | itm = QListWidgetItem(self.databasesList) |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
151 | itm.setText(self.tr("No databases are used by this page.")) |
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
|
152 | 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
|
153 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | @pyqtSlot() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
155 | 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
|
156 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | 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
|
158 | """ |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2432
diff
changeset
|
159 | self.tabWidget.setCurrentIndex( |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2432
diff
changeset
|
160 | 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
|
161 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
162 | @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | 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
|
164 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | 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
|
166 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
167 | @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
|
168 | @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
|
169 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
170 | 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
|
171 | return |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
172 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
173 | 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
|
174 | 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
|
175 | 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
|
176 | 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
|
177 | |
2403
e3d7a861547c
Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
178 | 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
|
179 | 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
|
180 | 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
|
181 | 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
|
182 | 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
|
183 | cacheData = None |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | pixmap = QPixmap() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | invalidPixmap = False |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
186 | 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
|
187 | if not cacheData: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | invalidPixmap = True |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | else: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | 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
|
191 | if pixmap.isNull(): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | invalidPixmap = True |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
193 | if invalidPixmap: |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
194 | scene.addText(self.tr("Preview not available.")) |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
195 | else: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | scene.addPixmap(pixmap) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
197 | 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
|
198 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | 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
|
200 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
201 | 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
|
202 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
203 | @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
|
204 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
205 | 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
|
206 | 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
|
207 | return |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
208 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
209 | menu = QMenu() |
3022
57179e4cdadd
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
210 | act = menu.addAction( |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
211 | self.tr("Copy Image Location to Clipboard"), |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | self.__copyAction) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
213 | act.setData(itm.text(1)) |
3022
57179e4cdadd
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3020
diff
changeset
|
214 | act = menu.addAction( |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
215 | self.tr("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
|
216 | self.__copyAction) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
217 | 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
|
218 | menu.addSeparator() |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
219 | act = menu.addAction(self.tr("Save Image"), self.__saveImage) |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
220 | 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
|
221 | 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
|
222 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
223 | def __copyAction(self): |
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 | 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
|
226 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
227 | act = self.sender() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
228 | 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
|
229 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
230 | def __saveImage(self): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
231 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
232 | 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
|
233 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
234 | act = self.sender() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
235 | index = act.data() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
236 | 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
|
237 | 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
|
238 | return |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
239 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
240 | 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
|
241 | 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
|
242 | 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
|
243 | 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
|
244 | |
2403
e3d7a861547c
Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
245 | 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
|
246 | 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
|
247 | 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
|
248 | 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
|
249 | 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
|
250 | cacheData = None |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
251 | if not cacheData: |
3020
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3002
diff
changeset
|
252 | E5MessageBox.critical( |
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3002
diff
changeset
|
253 | self, |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
254 | self.tr("Save Image"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
255 | self.tr("""This image is not available.""")) |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
256 | return |
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 | 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
|
259 | .downloadManager().downloadDirectory() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
260 | 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
|
261 | filename = E5FileDialog.getSaveFileName( |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
262 | self, |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
263 | self.tr("Save Image"), |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
264 | fn, |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
265 | self.tr("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
|
266 | 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
|
267 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
268 | if not filename: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
269 | return |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
270 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
271 | f = QFile(filename) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
272 | if not f.open(QFile.WriteOnly): |
3020
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3002
diff
changeset
|
273 | E5MessageBox.critical( |
542e97d4ecb3
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3002
diff
changeset
|
274 | self, |
3190
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
275 | self.tr("Save Image"), |
a9a94491c4fd
Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
276 | self.tr( |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2432
diff
changeset
|
277 | """<p>Cannot write to file <b>{0}</b>.</p>""") |
3035
36e9f388958b
Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3034
diff
changeset
|
278 | .format(filename)) |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
279 | return |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
280 | 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
|
281 | 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
|
282 | |
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 | @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
|
284 | 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
|
285 | """ |
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 | 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
|
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 | @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
|
289 | @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
|
290 | """ |
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 | 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
|
292 | 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
|
293 | |
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
|
294 | 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
|
295 | 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
|
296 | |
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
|
297 | 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
|
298 | 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
|
299 | |
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
|
300 | db = databases[id] |
3002
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2432
diff
changeset
|
301 | self.databaseName.setText( |
6ffc581f00f1
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2432
diff
changeset
|
302 | "{0} ({1})".format(db.displayName(), db.name())) |
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
|
303 | 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
|
304 | self.databaseSize.setText(dataString(db.size())) |