2828# Easier function decorating
2929from functools import wraps
3030# PyQt modules
31- from qtpy import QtCore , QtNetwork , QtWidgets
31+ from qtpy import QtCore , QtNetwork , QtWidgets , QtGui
3232
3333# Dummy function later to be replaced for translation
3434_ = lambda s : s
@@ -120,6 +120,21 @@ def __init__(self, *args, **kwargs):
120120
121121 self .config_mgr = QtNetwork .QNetworkConfigurationManager (self )
122122
123+ # The icon to show on the progress dialog
124+ self ._progress_icon = None
125+
126+ ### properties
127+ @property
128+ def progress_icon (self ):
129+ return self ._progress_icon
130+
131+ @progress_icon .setter
132+ def progress_icon (self , val ):
133+ """ The icon to show on the progress dialog. Should be a QIcon. """
134+ if not isinstance (val , QtGui .QIcon ):
135+ raise TypeError ('progress_icon should be a QIcon' )
136+ self ._progress_icon = val
137+
123138 ### Private functions
124139
125140 def __logout_succeeded (self , data , * args ):
@@ -850,6 +865,10 @@ def __create_progress_dialog(self, text, filesize):
850865 The label to display on the dialog
851866 filesize : int
852867 The size of the file being transfered in bytes
868+ windowIcon : QIcon
869+ The icon which the progress dialog should show
870+ windowTitle : str
871+ The text next to the icon (relevant for Windows only)
853872
854873 Returns
855874 -------
@@ -860,6 +879,9 @@ def __create_progress_dialog(self, text, filesize):
860879 progress_dialog .setLabelText (text )
861880 progress_dialog .setMinimum (0 )
862881 progress_dialog .setMaximum (filesize )
882+ if self ._progress_icon :
883+ progress_dialog .setWindowIcon (windowIcon )
884+ progress_dialog .setWindowIconText (u"OSF: " + _ (u"Transfer in progress" ))
863885 return progress_dialog
864886
865887 def __transfer_progress (self , transfered , total ):
@@ -881,7 +903,10 @@ def __download(self, reply, download_url, *args, **kwargs):
881903 size = progressDialog ['filesize' ]
882904 except KeyError as e :
883905 raise KeyError ("progressDialog missing field {}" .format (e ))
884- progress_indicator = self .__create_progress_dialog (text , size )
906+ icon = QtGui .QIcon ()
907+ title = _ ("Transfer in progress" )
908+ progress_indicator = self .__create_progress_dialog (text , size , icon ,
909+ title )
885910 kwargs ['progressDialog' ] = progress_indicator
886911 kwargs ['downloadProgress' ] = self .__transfer_progress
887912
0 commit comments