eric6/Helpviewer/Download/DownloadAskActionDialog.py

branch
maintenance
changeset 7286
7eb04391adf7
parent 7226
babe80d84a3e
parent 7285
1ff497f33f31
child 7287
1c17f2191bdd
equal deleted inserted replaced
7226:babe80d84a3e 7286:7eb04391adf7
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.getHelp("VirusTotalEnabled") or \
40 Preferences.getHelp("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