Skip to content

Commit

Permalink
Update to 1.1.3
Browse files Browse the repository at this point in the history
Progress dialog can now be given a custom window icon
  • Loading branch information
dschreij committed Aug 8, 2016
1 parent f8a4d14 commit 0fc458d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion QOpenScienceFramework/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "1.1.2"
__version__ = "1.1.3"
__author__ = "Daniel Schreij"

import os
Expand Down
29 changes: 27 additions & 2 deletions QOpenScienceFramework/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# Easier function decorating
from functools import wraps
# PyQt modules
from qtpy import QtCore, QtNetwork, QtWidgets
from qtpy import QtCore, QtNetwork, QtWidgets, QtGui

# Dummy function later to be replaced for translation
_ = lambda s: s
Expand Down Expand Up @@ -120,6 +120,21 @@ def __init__(self, *args, **kwargs):

self.config_mgr = QtNetwork.QNetworkConfigurationManager(self)

# The icon to show on the progress dialog
self._progress_icon = None

### properties
@property
def progress_icon(self):
return self._progress_icon

@progress_icon.setter
def progress_icon(self, val):
""" The icon to show on the progress dialog. Should be a QIcon. """
if not isinstance(val, QtGui.QIcon):
raise TypeError('progress_icon should be a QIcon')
self._progress_icon = val

### Private functions

def __logout_succeeded(self, data, *args):
Expand Down Expand Up @@ -850,6 +865,10 @@ def __create_progress_dialog(self, text, filesize):
The label to display on the dialog
filesize : int
The size of the file being transfered in bytes
windowIcon : QIcon
The icon which the progress dialog should show
windowTitle : str
The text next to the icon (relevant for Windows only)
Returns
-------
Expand All @@ -860,6 +879,9 @@ def __create_progress_dialog(self, text, filesize):
progress_dialog.setLabelText(text)
progress_dialog.setMinimum(0)
progress_dialog.setMaximum(filesize)
if self._progress_icon:
progress_dialog.setWindowIcon(windowIcon)
progress_dialog.setWindowIconText(u"OSF: " + _(u"Transfer in progress"))
return progress_dialog

def __transfer_progress(self, transfered, total):
Expand All @@ -881,7 +903,10 @@ def __download(self, reply, download_url, *args, **kwargs):
size = progressDialog['filesize']
except KeyError as e:
raise KeyError("progressDialog missing field {}".format(e))
progress_indicator = self.__create_progress_dialog(text, size)
icon = QtGui.QIcon()
title = _("Transfer in progress")
progress_indicator = self.__create_progress_dialog(text, size, icon,
title)
kwargs['progressDialog'] = progress_indicator
kwargs['downloadProgress'] = self.__transfer_progress

Expand Down

0 comments on commit 0fc458d

Please sign in to comment.