WebBrowser/Download/DownloadManager.py

changeset 6224
08875555771a
parent 6222
baffb22b4467
child 6233
a64b986abb54
--- a/WebBrowser/Download/DownloadManager.py	Sun Apr 08 16:37:21 2018 +0200
+++ b/WebBrowser/Download/DownloadManager.py	Sun Apr 08 17:34:59 2018 +0200
@@ -16,6 +16,7 @@
     QApplication, QShortcut
 
 from E5Gui import E5MessageBox
+from E5Gui.E5Application import e5App
 
 from .Ui_DownloadManager import Ui_DownloadManager
 
@@ -265,7 +266,10 @@
                            parent=self)
         self.__addItem(itm)
         
-        self.__startUpdateTimer()
+        if Preferences.getWebBrowser("DownloadManagerAutoOpen"):
+            self.show()
+        else:
+            self.__startUpdateTimer()
     
     def show(self):
         """
@@ -459,14 +463,39 @@
         
         self.downloadsCountChanged.emit()
     
-    def __finished(self):
+    def __finished(self, success):
         """
         Private slot to handle a finished download.
+        
+        @param success flag indicating a successful download
+        @type bool
         """
         if self.isVisible():
             QApplication.alert(self)
         
         self.downloadsCountChanged.emit()
+        
+        if self.activeDownloadsCount() == 0:
+            # all active downloads are done
+            if success and e5App().activeWindow() is not self:
+                if WebBrowserWindow.notificationsEnabled():
+                    WebBrowserWindow.showNotification(
+                        UI.PixmapCache.getPixmap("downloads48.png"),
+                        self.tr("Downloads finished"),
+                        self.tr("All files have been downloaded.")
+                    )
+                if not Preferences.getWebBrowser("DownloadManagerAutoClose"):
+                    self.raise_()
+                    self.activateWindow()
+            
+            self.__stopUpdateTimer()
+            self.infoLabel.clear()
+            self.setWindowTitle(self.tr("Download Manager"))
+            if Globals.isWindowsPlatform():
+                self.__taskbarButton().progress().hide()
+            
+            if Preferences.getWebBrowser("DownloadManagerAutoClose"):
+                self.close()
     
     def setDownloadDirectory(self, directory):
         """

eric ide

mercurial