Sun, 10 Feb 2013 18:31:31 +0100
Continued implementing the delayed import.
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 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | import os |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
11 | |
2078
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1857
diff
changeset
|
12 | 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
|
13 | 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
|
14 | 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
|
15 | 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
|
16 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | 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
|
18 | |
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
|
19 | 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
|
20 | 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
|
21 | 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
|
22 | 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
|
23 | 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
|
24 | SSL = False |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | 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
|
27 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | import UI.PixmapCache |
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 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | 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
|
32 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | 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
|
34 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | 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
|
36 | 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
|
37 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | 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
|
39 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
40 | Constructor |
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 | @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
|
43 | @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
|
44 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | super().__init__(parent) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | self.setupUi(self) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | # put icons |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | 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
|
50 | 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
|
51 | 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
|
52 | 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
|
53 | 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
|
54 | |
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
|
55 | 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
|
56 | title = browser.title() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | sslInfo = browser.page().getSslInfo() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | # populate General tab |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | 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
|
61 | 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
|
62 | 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
|
63 | encoding = "" |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | # 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
|
66 | 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
|
67 | 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
|
68 | 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
|
69 | 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
|
70 | if not name: |
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("http-equiv") |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | 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
|
73 | 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
|
74 | 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
|
75 | 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
|
76 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | 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
|
78 | continue |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | 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
|
81 | 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
|
82 | 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
|
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 encoding: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | 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
|
86 | 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
|
87 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | # populate the Security info and the Security tab |
2078
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1857
diff
changeset
|
89 | if sslInfo is not None and \ |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1857
diff
changeset
|
90 | ((qVersion() >= "5.0.0" and not sslInfo.isBlacklisted()) or \ |
9f4a45741622
Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1857
diff
changeset
|
91 | (qVersion() < "5.0.0" and sslInfo.isValid())): |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | 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
|
93 | 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
|
94 | 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
|
95 | self.sslWidget.showCertificate(sslInfo) |
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 | 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
|
97 | 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
|
98 | 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
|
99 | else: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | 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
|
101 | 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
|
102 | self.securityDetailsButton.setEnabled(False) |
2122
fce5f83cb990
Fixed two issues in the SSL Info Dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2078
diff
changeset
|
103 | 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
|
104 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | # 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
|
106 | 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
|
107 | 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
|
108 | 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
|
109 | 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
|
110 | 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
|
111 | continue |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | if not alt: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | 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
|
114 | alt = src |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | else: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | pos = src.find("/") |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | 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
|
118 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | 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
|
120 | continue |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | 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
|
123 | 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
|
124 | 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
|
125 | 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
|
126 | 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
|
127 | 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
|
128 | 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
|
129 | 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
|
130 | 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
|
131 | |
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
|
132 | # 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
|
133 | 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
|
134 | 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
|
135 | 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
|
136 | 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
|
137 | 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
|
138 | 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
|
139 | 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
|
140 | |
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 | 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
|
142 | 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
|
143 | 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
|
144 | 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
|
145 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
146 | @pyqtSlot() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
147 | 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
|
148 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | 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
|
150 | """ |
2122
fce5f83cb990
Fixed two issues in the SSL Info Dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2078
diff
changeset
|
151 | 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
|
152 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
153 | @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
154 | 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
|
155 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
156 | 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
|
157 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | @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
|
159 | @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
|
160 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
161 | 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
|
162 | return |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
163 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | 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
|
165 | 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
|
166 | 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
|
167 | 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
|
168 | |
2403
e3d7a861547c
Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
169 | 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
|
170 | 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
|
171 | 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
|
172 | 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
|
173 | 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
|
174 | cacheData = None |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | pixmap = QPixmap() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
176 | invalidPixmap = False |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
177 | 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
|
178 | if not cacheData: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
179 | invalidPixmap = True |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | else: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
181 | 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
|
182 | if pixmap.isNull(): |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | invalidPixmap = True |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
184 | if invalidPixmap: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
185 | 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
|
186 | else: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
187 | scene.addPixmap(pixmap) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | 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
|
189 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
190 | 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
|
191 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
192 | 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
|
193 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
194 | @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
|
195 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
196 | 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
|
197 | 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
|
198 | return |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
200 | menu = QMenu() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
201 | 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
|
202 | self.__copyAction) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
203 | act.setData(itm.text(1)) |
1474
1eaec11a0078
Fixed a few PEP-8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1433
diff
changeset
|
204 | 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
|
205 | self.__copyAction) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
206 | 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
|
207 | menu.addSeparator() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
208 | 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
|
209 | 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
|
210 | 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
|
211 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | def __copyAction(self): |
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 | 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
|
215 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
216 | act = self.sender() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
217 | 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
|
218 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | def __saveImage(self): |
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 | 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
|
222 | """ |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
223 | act = self.sender() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
224 | index = act.data() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
225 | 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
|
226 | 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
|
227 | return |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
228 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
229 | 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
|
230 | 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
|
231 | 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
|
232 | 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
|
233 | |
2403
e3d7a861547c
Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
234 | 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
|
235 | 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
|
236 | 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
|
237 | 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
|
238 | 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
|
239 | cacheData = None |
1427
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
240 | if not cacheData: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
241 | E5MessageBox.critical(self, |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
242 | 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
|
243 | 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
|
244 | return |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
245 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
246 | 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
|
247 | .downloadManager().downloadDirectory() |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
248 | 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
|
249 | filename = E5FileDialog.getSaveFileName( |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
250 | self, |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
251 | 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
|
252 | fn, |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
253 | 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
|
254 | 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
|
255 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
256 | if not filename: |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
257 | return |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
258 | |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
259 | f = QFile(filename) |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
260 | 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
|
261 | E5MessageBox.critical(self, |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
262 | 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
|
263 | self.trUtf8( |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
264 | """<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
|
265 | return |
09d6731b73ad
Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
266 | 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
|
267 | 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
|
268 | |
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
|
269 | @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
|
270 | 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
|
271 | """ |
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 | 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
|
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 | @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
|
275 | @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
|
276 | """ |
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 | 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
|
278 | 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
|
279 | |
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 | 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
|
281 | 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
|
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 | 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
|
284 | 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
|
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 | 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
|
287 | 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
|
288 | 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
|
289 | self.databaseSize.setText(dataString(db.size())) |