Skip to content

Commit

Permalink
Merge pull request #16 from niklashenning/develop
Browse files Browse the repository at this point in the history
v1.3.1
  • Loading branch information
niklashenning authored Aug 16, 2024
2 parents dd3b27e + 6065407 commit 7c14a50
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 34 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PyQt Toast

[![PyPI](https://img.shields.io/badge/pypi-v1.3.0-blue)](https://pypi.org/project/pyqt-toast-notification/)
[![PyPI](https://img.shields.io/badge/pypi-v1.3.1-blue)](https://pypi.org/project/pyqt-toast-notification/)
[![Python](https://img.shields.io/badge/python-3.7+-blue)](https://github.com/niklashenning/pyqttoast)
[![Build](https://img.shields.io/badge/build-passing-neon)](https://github.com/niklashenning/pyqttoast)
[![Coverage](https://img.shields.io/badge/coverage-95%25-green)](https://github.com/niklashenning/pyqttoast)
Expand Down
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

[options.entry_points]
pyinstaller40 =
hook-dirs = pyqttoast.hooks:get_hook_dirs
13 changes: 7 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@


with open('README.md', 'r') as fh:
readme = "\n" + fh.read()
readme = '\n' + fh.read()

setup(
name='pyqt-toast-notification',
version='1.3.0',
version='1.3.1',
author='Niklas Henning',
author_email='[email protected]',
license='MIT',
packages=find_namespace_packages(where="src"),
package_dir={"": "src"},
packages=find_namespace_packages(where='src'),
package_dir={'': 'src'},
package_data={
"pyqttoast.css": ["*.css"],
"pyqttoast.icons": ["*.png"],
'pyqttoast.css': ['*.css'],
'pyqttoast.icons': ['*.png'],
'pyqttoast.hooks': ['*.py']
},
install_requires=[
'QtPy>=2.4.1'
Expand Down
5 changes: 5 additions & 0 deletions src/pyqttoast/hooks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import os


def get_hook_dirs():
return [os.path.dirname(__file__)]
3 changes: 3 additions & 0 deletions src/pyqttoast/hooks/hook-pyqttoast.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from PyInstaller.utils.hooks import collect_data_files

datas = collect_data_files('pyqttoast', excludes=['hooks'])
54 changes: 27 additions & 27 deletions src/pyqttoast/toast.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,20 +250,20 @@ def show(self):
self.move(x, y + int(self.height() / 1.5) + predecessor_target_difference_y)

# Start fade down / up animation
self.pos_animation = QPropertyAnimation(self, b"pos")
self.pos_animation.setEndValue(QPoint(x, y))
self.pos_animation.setDuration(self.__fade_in_duration)
self.pos_animation.start()
self.__pos_animation = QPropertyAnimation(self, b"pos")
self.__pos_animation.setEndValue(QPoint(x, y))
self.__pos_animation.setDuration(self.__fade_in_duration)
self.__pos_animation.start()
else:
self.move(x, y)

# Fade in
super().show()
self.fade_in_animation = QPropertyAnimation(self.__opacity_effect, b"opacity")
self.fade_in_animation.setDuration(self.__fade_in_duration)
self.fade_in_animation.setStartValue(0)
self.fade_in_animation.setEndValue(1)
self.fade_in_animation.start()
self.__fade_in_animation = QPropertyAnimation(self.__opacity_effect, b"opacity")
self.__fade_in_animation.setDuration(self.__fade_in_duration)
self.__fade_in_animation.setStartValue(0)
self.__fade_in_animation.setEndValue(1)
self.__fade_in_animation.start()

# Update every other currently shown notification
for toast in Toast.__currently_shown:
Expand All @@ -284,12 +284,12 @@ def hide(self):
def __fade_out(self):
"""Start the fade out animation"""

self.fade_out_animation = QPropertyAnimation(self.__opacity_effect, b"opacity")
self.fade_out_animation.setDuration(self.__fade_out_duration)
self.fade_out_animation.setStartValue(1)
self.fade_out_animation.setEndValue(0)
self.fade_out_animation.finished.connect(self.__hide)
self.fade_out_animation.start()
self.__fade_out_animation = QPropertyAnimation(self.__opacity_effect, b"opacity")
self.__fade_out_animation.setDuration(self.__fade_out_duration)
self.__fade_out_animation.setStartValue(1)
self.__fade_out_animation.setEndValue(0)
self.__fade_out_animation.finished.connect(self.__hide)
self.__fade_out_animation.start()

def __hide(self):
"""Hide the toast notification"""
Expand Down Expand Up @@ -338,10 +338,10 @@ def __update_position_xy(self, animate: bool = True):
position = QPoint(x, y)

# Animate position change
self.pos_animation = QPropertyAnimation(self, b"pos")
self.pos_animation.setEndValue(position)
self.pos_animation.setDuration(UPDATE_POSITION_DURATION if animate else 0)
self.pos_animation.start()
self.__pos_animation = QPropertyAnimation(self, b"pos")
self.__pos_animation.setEndValue(position)
self.__pos_animation.setDuration(UPDATE_POSITION_DURATION if animate else 0)
self.__pos_animation.start()

def __update_position_x(self, animate: bool = True):
"""Update the x position of the toast with an optional animation
Expand All @@ -353,10 +353,10 @@ def __update_position_x(self, animate: bool = True):
position = QPoint(x, self.y())

# Animate position change
self.pos_animation = QPropertyAnimation(self, b"pos")
self.pos_animation.setEndValue(position)
self.pos_animation.setDuration(UPDATE_POSITION_DURATION if animate else 0)
self.pos_animation.start()
self.__pos_animation = QPropertyAnimation(self, b"pos")
self.__pos_animation.setEndValue(position)
self.__pos_animation.setDuration(UPDATE_POSITION_DURATION if animate else 0)
self.__pos_animation.start()

def __update_position_y(self, animate: bool = True):
"""Update the y position of the toast with an optional animation
Expand All @@ -368,10 +368,10 @@ def __update_position_y(self, animate: bool = True):
position = QPoint(self.x(), y)

# Animate position change
self.pos_animation = QPropertyAnimation(self, b"pos")
self.pos_animation.setEndValue(position)
self.pos_animation.setDuration(UPDATE_POSITION_DURATION if animate else 0)
self.pos_animation.start()
self.__pos_animation = QPropertyAnimation(self, b"pos")
self.__pos_animation.setEndValue(position)
self.__pos_animation.setDuration(UPDATE_POSITION_DURATION if animate else 0)
self.__pos_animation.start()

def __get_bounds(self) -> QRect:
"""Get the bounds (QRect) of the target screen or widget
Expand Down

0 comments on commit 7c14a50

Please sign in to comment.