eric6/WebBrowser/Download/DownloadAskActionDialog.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2011 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to ask for a download action.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtWidgets import QDialog
13
14 from .Ui_DownloadAskActionDialog import Ui_DownloadAskActionDialog
15
16 import Preferences
17
18
19 class DownloadAskActionDialog(QDialog, Ui_DownloadAskActionDialog):
20 """
21 Class implementing a dialog to ask for a download action.
22 """
23 def __init__(self, fileName, mimeType, baseUrl, parent=None):
24 """
25 Constructor
26
27 @param fileName file name (string)
28 @param mimeType mime type (string)
29 @param baseUrl URL (string)
30 @param parent reference to the parent widget (QWidget)
31 """
32 super(DownloadAskActionDialog, self).__init__(parent)
33 self.setupUi(self)
34
35 self.infoLabel.setText("<b>{0}</b>".format(fileName))
36 self.typeLabel.setText(mimeType)
37 self.siteLabel.setText(baseUrl)
38
39 if not Preferences.getWebBrowser("VirusTotalEnabled") or \
40 Preferences.getWebBrowser("VirusTotalServiceKey") == "":
41 self.scanButton.setHidden(True)
42
43 msh = self.minimumSizeHint()
44 self.resize(max(self.width(), msh.width()), msh.height())
45
46 def getAction(self):
47 """
48 Public method to get the selected action.
49
50 @return selected action ("save", "open", "scan" or "cancel")
51 """
52 if self.openButton.isChecked():
53 return "open"
54 elif self.scanButton.isChecked():
55 return "scan"
56 elif self.saveButton.isChecked():
57 return "save"
58 else:
59 # should not happen, but keep it safe
60 return "cancel"

eric ide

mercurial