Helpviewer/SiteInfo/SiteInfoDialog.py

Wed, 01 Jan 2014 14:39:32 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 01 Jan 2014 14:39:32 +0100
branch
Py2 comp.
changeset 3161
06f57a834adf
parent 3145
a9de05d4a22f
child 3178
f25fc1364c88
permissions
-rw-r--r--

Updated copyright for 2014.

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
3161
06f57a834adf Updated copyright for 2014.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3145
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
2078
9f4a45741622 Made the second set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1857
diff changeset
14 from PyQt4.QtCore import pyqtSlot, QUrl, Qt, QFile, qVersion
3002
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
15 from PyQt4.QtGui import QDialog, QTreeWidgetItem, QPixmap, QGraphicsScene, \
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
16 QMenu, QCursor, QApplication, QListWidgetItem
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 from PyQt4.QtWebKit import QWebSettings
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 from E5Gui import E5MessageBox, E5FileDialog
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
1857
baf039cc2d9a Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1780
diff changeset
21 try:
3002
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
22 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
23 SSL = True
baf039cc2d9a Changed the logic of the site info dialog to be able to cope with Qt installations without SSL support.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1780
diff changeset
24 except ImportError:
3002
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
25 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
26 SSL = False
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 from ..Download.DownloadUtilities import dataString
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 import UI.PixmapCache
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 class SiteInfoDialog(QDialog, Ui_SiteInfoDialog):
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 Class implementing a dialog to show some information about a site.
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 okStyle = "QLabel { color : white; background-color : green; }"
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 nokStyle = "QLabel { color : white; background-color : red; }"
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 def __init__(self, browser, parent=None):
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 Constructor
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 @param browser reference to the browser window (HelpBrowser)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 @param parent reference to the parent widget (QWidget)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2432
diff changeset
47 super(SiteInfoDialog, self).__init__(parent)
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 self.setupUi(self)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 # put icons
3002
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
51 self.tabWidget.setTabIcon(
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
52 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
53 self.tabWidget.setTabIcon(
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
54 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
55 self.tabWidget.setTabIcon(
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
56 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
57 if SSL:
3002
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
58 self.tabWidget.setTabIcon(
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
59 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
60
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.__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
62 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
63 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
64
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 # populate General tab
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 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
67 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
68 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
69 encoding = ""
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 # 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
72 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
73 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
74 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
75 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
76 if not name:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 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
78 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
79 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
80 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
81 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
82
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83 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
84 continue
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 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
87 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
88 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
89
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 if not encoding:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 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
92 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
93
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 # 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
95 if sslInfo and \
3034
7ce719013078 Fixed various coding style issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3022
diff changeset
96 ((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
97 (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
98 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
99 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
100 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
101 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
102 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
103 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
104 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
105 else:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 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
107 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
108 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
109 self.tabWidget.setTabEnabled(
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
110 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
111
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 # 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
113 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
114 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
115 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
116 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
117 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
118 continue
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119 if not alt:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 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
121 alt = src
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 else:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123 pos = src.find("/")
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 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
125
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 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
127 continue
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 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
130 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
131 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
132 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
133 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
134 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
135 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
136 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
137 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
138
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 # 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
140 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
141 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 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
143 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
144 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
145 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
146 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
147
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 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
149 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
150 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
151 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
152
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 @pyqtSlot()
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 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
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 security details.
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 """
3002
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
158 self.tabWidget.setCurrentIndex(
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
159 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
160
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 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
163 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 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
165
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 @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
167 @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
168 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 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
170 return
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 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
173 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
174 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
175 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
176
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
177 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
178 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
179 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
180 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
181 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
182 cacheData = None
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 pixmap = QPixmap()
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 invalidPixmap = False
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 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
186 if not cacheData:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 invalidPixmap = True
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 else:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 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
190 if pixmap.isNull():
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 invalidPixmap = True
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 if invalidPixmap:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 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
194 else:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 scene.addPixmap(pixmap)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 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
197
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 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
199 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 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
201
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 @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
203 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 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
205 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
206 return
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 menu = QMenu()
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
209 act = menu.addAction(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
210 self.trUtf8("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
211 self.__copyAction)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 act.setData(itm.text(1))
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
213 act = menu.addAction(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
214 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
215 self.__copyAction)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 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
217 menu.addSeparator()
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 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
219 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
220 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
221
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 def __copyAction(self):
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 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
225 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 act = self.sender()
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 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
228
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 def __saveImage(self):
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 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
232 """
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 act = self.sender()
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
234 index = act.data()
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235 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
236 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
237 return
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239 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
240 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
241 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
242 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
243
2403
e3d7a861547c Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
244 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
245 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
246 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
247 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
248 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
249 cacheData = None
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 if not cacheData:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3002
diff changeset
251 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3002
diff changeset
252 self,
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 self.trUtf8("Save Image"),
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 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
255 return
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 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
258 .downloadManager().downloadDirectory()
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 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
260 filename = E5FileDialog.getSaveFileName(
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 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 fn,
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 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
265 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
266
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 if not filename:
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 return
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 f = QFile(filename)
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 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
272 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3002
diff changeset
273 self,
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 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
275 self.trUtf8(
3002
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
276 """<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
277 .format(filename))
1427
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 return
09d6731b73ad Added a dialog to show some information about the current site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 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
280 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
281
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
282 @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
283 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
284 """
f42757fd021b Added a page to the site info dialog to show web databases of the site.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
285 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
286
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 @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
288 @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
289 """
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 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
291 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
292
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 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
294 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
295
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 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
297 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
298
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 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
300 self.databaseName.setText(
6ffc581f00f1 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2432
diff changeset
301 "{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
302 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
303 self.databaseSize.setText(dataString(db.size()))

eric ide

mercurial