Skip to content

Commit

Permalink
Bump to v1.0.4
Browse files Browse the repository at this point in the history
- Hide Notification area when there is nothing to display so it doesn’t
block interaction with other widgets.
  • Loading branch information
dschreij committed May 2, 2016
1 parent e751439 commit ae89a01
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions QNotifications/QNotification.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def category(self, value):
"""
allowed_values = [u'primary',u'success',u'info',u'warning',u'danger']
if not value in allowed_values:
raise ValueError(_(u'{} not a valid value. '
'Should be one of').format(value, allowed_values))
raise ValueError(u'{} not a valid value. '
'Should be one of').format(value, allowed_values)
self._category = value

6 changes: 6 additions & 0 deletions QNotifications/QNotificationArea.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,17 @@ def __init__(self, targetWidget, *args, **kwargs):
# Overwrite resizeEvent function of targetWidget to capture it ourself
# (parent's resizeEvent will be called in our function too)
self.targetWidget.resizeEvent = self.resizeEvent
self.hide()

def __delete_notification(self, notification=None):
""" Close and destroy the supplied notification """
notification.close()
self.layout().removeWidget(notification)
self.adjustSize()
# Hide notification area if it doesn't contain any items
print(self.layout().count())
if self.layout().count() == 0:
self.hide()

# Public functions
def setEntryEffect(self, effect, duration=250):
Expand Down Expand Up @@ -189,6 +194,7 @@ def display(self, message, category, timeout=5000):
The duration for which the notification should be shown. If None then
the notification will be shown indefinitely
"""
self.show()
notification = QNotification(message, category, self)
notification.closeClicked.connect(self.remove)
self.layout().addWidget(notification)
Expand Down
2 changes: 1 addition & 1 deletion QNotifications/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
You should have received a copy of the GPLv3 License
along with this module.>.
"""
__version__ = "1.0.2"
__version__ = "1.0.4"
__author__ = "Daniel Schreij ([email protected])"

# Do some base imports
Expand Down

0 comments on commit ae89a01

Please sign in to comment.