eric7/WebBrowser/Download/DownloadManager.py

branch
eric7
changeset 8356
68ec9c3d4de5
parent 8322
b422b4e77d19
child 8358
144a6b854f70
equal deleted inserted replaced
8355:8a7677a63c8d 8356:68ec9c3d4de5
13 from PyQt6.QtGui import QCursor, QKeySequence, QShortcut 13 from PyQt6.QtGui import QCursor, QKeySequence, QShortcut
14 from PyQt6.QtWidgets import ( 14 from PyQt6.QtWidgets import (
15 QDialog, QStyle, QFileIconProvider, QMenu, QApplication 15 QDialog, QStyle, QFileIconProvider, QMenu, QApplication
16 ) 16 )
17 17
18 from E5Gui import E5MessageBox 18 from E5Gui import EricMessageBox
19 from E5Gui.E5Application import e5App 19 from E5Gui.EricApplication import ericApp
20 20
21 from .Ui_DownloadManager import Ui_DownloadManager 21 from .Ui_DownloadManager import Ui_DownloadManager
22 22
23 from .DownloadModel import DownloadModel 23 from .DownloadModel import DownloadModel
24 from .DownloadUtilities import speedString, timeString 24 from .DownloadUtilities import speedString, timeString
164 Public method to check, if it is ok to quit. 164 Public method to check, if it is ok to quit.
165 165
166 @return flag indicating allowance to quit (boolean) 166 @return flag indicating allowance to quit (boolean)
167 """ 167 """
168 if self.activeDownloadsCount() > 0: 168 if self.activeDownloadsCount() > 0:
169 res = E5MessageBox.yesNo( 169 res = EricMessageBox.yesNo(
170 self, 170 self,
171 self.tr(""), 171 self.tr(""),
172 self.tr("""There are %n downloads in progress.\n""" 172 self.tr("""There are %n downloads in progress.\n"""
173 """Do you want to quit anyway?""", "", 173 """Do you want to quit anyway?""", "",
174 self.activeDownloadsCount()), 174 self.activeDownloadsCount()),
175 icon=E5MessageBox.Warning) 175 icon=EricMessageBox.Warning)
176 if not res: 176 if not res:
177 self.show() 177 self.show()
178 return False 178 return False
179 179
180 self.close() 180 self.close()
253 if threatLists: 253 if threatLists:
254 threatMessages = ( 254 threatMessages = (
255 WebBrowserWindow.safeBrowsingManager() 255 WebBrowserWindow.safeBrowsingManager()
256 .getThreatMessages(threatLists) 256 .getThreatMessages(threatLists)
257 ) 257 )
258 res = E5MessageBox.warning( 258 res = EricMessageBox.warning(
259 WebBrowserWindow.getWindow(), 259 WebBrowserWindow.getWindow(),
260 self.tr("Suspicuous URL detected"), 260 self.tr("Suspicuous URL detected"),
261 self.tr("<p>The URL <b>{0}</b> was found in the Safe" 261 self.tr("<p>The URL <b>{0}</b> was found in the Safe"
262 " Browsing database.</p>{1}").format( 262 " Browsing database.</p>{1}").format(
263 url.toString(), "".join(threatMessages)), 263 url.toString(), "".join(threatMessages)),
264 E5MessageBox.Abort | E5MessageBox.Ignore, 264 EricMessageBox.Abort | EricMessageBox.Ignore,
265 E5MessageBox.Abort) 265 EricMessageBox.Abort)
266 if res == E5MessageBox.Abort: 266 if res == EricMessageBox.Abort:
267 downloadItem.cancel() 267 downloadItem.cancel()
268 return 268 return
269 269
270 window = WebBrowserWindow.getWindow() 270 window = WebBrowserWindow.getWindow()
271 pageUrl = window.currentBrowser().url() if window else QUrl() 271 pageUrl = window.currentBrowser().url() if window else QUrl()
487 487
488 self.downloadsCountChanged.emit() 488 self.downloadsCountChanged.emit()
489 489
490 if self.activeDownloadsCount() == 0: 490 if self.activeDownloadsCount() == 0:
491 # all active downloads are done 491 # all active downloads are done
492 if success and e5App().activeWindow() is not self: 492 if success and ericApp().activeWindow() is not self:
493 WebBrowserWindow.showNotification( 493 WebBrowserWindow.showNotification(
494 UI.PixmapCache.getPixmap("downloads48"), 494 UI.PixmapCache.getPixmap("downloads48"),
495 self.tr("Downloads finished"), 495 self.tr("Downloads finished"),
496 self.tr("All files have been downloaded.") 496 self.tr("All files have been downloaded.")
497 ) 497 )

eric ide

mercurial