WebBrowser/Download/DownloadItem.py

changeset 5033
d1c2651060ec
parent 4917
682750cc7bd5
child 5194
4750c83cc718
equal deleted inserted replaced
5032:0b060e23930f 5033:d1c2651060ec
134 self.__saveFileName(downloadDirectory) 134 self.__saveFileName(downloadDirectory)
135 fileName = defaultFileName 135 fileName = defaultFileName
136 self.__originalFileName = originalFileName 136 self.__originalFileName = originalFileName
137 ask = True 137 ask = True
138 self.__autoOpen = False 138 self.__autoOpen = False
139 from .DownloadAskActionDialog import DownloadAskActionDialog 139
140 url = self.__downloadItem.url() 140 if not originalFileName.lower().endswith(".mhtml"):
141 mimetype = Utilities.MimeTypes.mimeType(originalFileName) 141 from .DownloadAskActionDialog import DownloadAskActionDialog
142 dlg = DownloadAskActionDialog( 142 url = self.__downloadItem.url()
143 QFileInfo(originalFileName).fileName(), 143 mimetype = Utilities.MimeTypes.mimeType(originalFileName)
144 mimetype, 144 dlg = DownloadAskActionDialog(
145 "{0}://{1}".format(url.scheme(), url.authority()), 145 QFileInfo(originalFileName).fileName(),
146 self) 146 mimetype,
147 if dlg.exec_() == QDialog.Rejected or dlg.getAction() == "cancel": 147 "{0}://{1}".format(url.scheme(), url.authority()),
148 self.progressBar.setVisible(False) 148 self)
149 self.on_stopButton_clicked()
150 self.filenameLabel.setText(
151 self.tr("Download canceled: {0}").format(
152 QFileInfo(defaultFileName).fileName()))
153 self.__canceledFileSelect = True
154 return
155
156 if dlg.getAction() == "scan":
157 self.__mainWindow.requestVirusTotalScan(url)
158 149
159 self.progressBar.setVisible(False) 150 if dlg.exec_() == QDialog.Rejected or dlg.getAction() == "cancel":
160 self.on_stopButton_clicked() 151 self.progressBar.setVisible(False)
161 self.filenameLabel.setText( 152 self.on_stopButton_clicked()
162 self.tr("VirusTotal scan scheduled: {0}").format( 153 self.filenameLabel.setText(
163 QFileInfo(defaultFileName).fileName())) 154 self.tr("Download canceled: {0}").format(
164 self.__canceledFileSelect = True 155 QFileInfo(defaultFileName).fileName()))
165 return 156 self.__canceledFileSelect = True
166 157 return
167 self.__autoOpen = dlg.getAction() == "open" 158
159 if dlg.getAction() == "scan":
160 self.__mainWindow.requestVirusTotalScan(url)
161
162 self.progressBar.setVisible(False)
163 self.on_stopButton_clicked()
164 self.filenameLabel.setText(
165 self.tr("VirusTotal scan scheduled: {0}").format(
166 QFileInfo(defaultFileName).fileName()))
167 self.__canceledFileSelect = True
168 return
169
170 self.__autoOpen = dlg.getAction() == "open"
171 else:
172 self.__autoOpen = False
173
168 if PYQT_VERSION_STR >= "5.0.0": 174 if PYQT_VERSION_STR >= "5.0.0":
169 from PyQt5.QtCore import QStandardPaths 175 from PyQt5.QtCore import QStandardPaths
170 tempLocation = QStandardPaths.standardLocations( 176 tempLocation = QStandardPaths.standardLocations(
171 QStandardPaths.TempLocation)[0] 177 QStandardPaths.TempLocation)[0]
172 else: 178 else:

eric ide

mercurial