eric6/WebBrowser/Download/DownloadAskActionDialog.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8218
7c09585bd960
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

978
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2011 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
978
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to ask for a download action.
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
10 from PyQt5.QtWidgets import QDialog
978
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from .Ui_DownloadAskActionDialog import Ui_DownloadAskActionDialog
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 import Preferences
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
992
566e87428fc8 Fixed a few PEP-8 issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 978
diff changeset
16
978
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 class DownloadAskActionDialog(QDialog, Ui_DownloadAskActionDialog):
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 """
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 Class implementing a dialog to ask for a download action.
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 """
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 def __init__(self, fileName, mimeType, baseUrl, parent=None):
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 Constructor
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
2954
bf0215fe12d1 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
25 @param fileName file name (string)
bf0215fe12d1 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
26 @param mimeType mime type (string)
bf0215fe12d1 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
27 @param baseUrl URL (string)
978
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @param parent reference to the parent widget (QWidget)
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
30 super(DownloadAskActionDialog, self).__init__(parent)
978
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 self.setupUi(self)
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 self.infoLabel.setText("<b>{0}</b>".format(fileName))
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 self.typeLabel.setText(mimeType)
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.siteLabel.setText(baseUrl)
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36
7268
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
37 if (
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
38 not Preferences.getWebBrowser("VirusTotalEnabled") or
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
39 Preferences.getWebBrowser("VirusTotalServiceKey") == ""
a28338eaf694 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
40 ):
978
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.scanButton.setHidden(True)
3366
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
42
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
43 msh = self.minimumSizeHint()
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
44 self.resize(max(self.width(), msh.width()), msh.height())
978
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 def getAction(self):
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 """
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 Public method to get the selected action.
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 @return selected action ("save", "open", "scan" or "cancel")
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 """
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 if self.openButton.isChecked():
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 return "open"
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 elif self.scanButton.isChecked():
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 return "scan"
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 elif self.saveButton.isChecked():
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 return "save"
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 else:
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 # should not happen, but keep it safe
11f8adbcac97 Added an interface to VirusTotal to the web browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 return "cancel"

eric ide

mercurial