28
28
# Easier function decorating
29
29
from functools import wraps
30
30
# PyQt modules
31
- from qtpy import QtCore , QtNetwork , QtWidgets
31
+ from qtpy import QtCore , QtNetwork , QtWidgets , QtGui
32
32
33
33
# Dummy function later to be replaced for translation
34
34
_ = lambda s : s
@@ -120,6 +120,21 @@ def __init__(self, *args, **kwargs):
120
120
121
121
self .config_mgr = QtNetwork .QNetworkConfigurationManager (self )
122
122
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
+
123
138
### Private functions
124
139
125
140
def __logout_succeeded (self , data , * args ):
@@ -850,6 +865,10 @@ def __create_progress_dialog(self, text, filesize):
850
865
The label to display on the dialog
851
866
filesize : int
852
867
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)
853
872
854
873
Returns
855
874
-------
@@ -860,6 +879,9 @@ def __create_progress_dialog(self, text, filesize):
860
879
progress_dialog .setLabelText (text )
861
880
progress_dialog .setMinimum (0 )
862
881
progress_dialog .setMaximum (filesize )
882
+ if self ._progress_icon :
883
+ progress_dialog .setWindowIcon (windowIcon )
884
+ progress_dialog .setWindowIconText (u"OSF: " + _ (u"Transfer in progress" ))
863
885
return progress_dialog
864
886
865
887
def __transfer_progress (self , transfered , total ):
@@ -881,7 +903,10 @@ def __download(self, reply, download_url, *args, **kwargs):
881
903
size = progressDialog ['filesize' ]
882
904
except KeyError as e :
883
905
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 )
885
910
kwargs ['progressDialog' ] = progress_indicator
886
911
kwargs ['downloadProgress' ] = self .__transfer_progress
887
912
0 commit comments