Skip to content

Commit

Permalink
add weird animation on start stop button
Browse files Browse the repository at this point in the history
  • Loading branch information
fe-art committed Sep 10, 2024
1 parent 44d5e7b commit c0e6552
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
23 changes: 23 additions & 0 deletions clashroyalebuildabot/gui/animations.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from PyQt6.QtCore import QEasingCurve, QPropertyAnimation, Qt
from PyQt6.QtWidgets import QGraphicsDropShadowEffect


def start_play_button_animation(self):
self.glow_effect = QGraphicsDropShadowEffect(self)
self.glow_effect.setBlurRadius(10) # Initial blur radius for the glow effect
self.glow_effect.setColor(Qt.GlobalColor.cyan)
self.glow_effect.setOffset(0, 0) # Center the shadow to create the glow effect
self.start_stop_button.setGraphicsEffect(self.glow_effect)

_start_glow_animation(self)


def _start_glow_animation(self):
"""Create a glow effect animation."""
self.glow_animation = QPropertyAnimation(self.glow_effect, b"blurRadius")
self.glow_animation.setStartValue(0)
self.glow_animation.setEndValue(25)
self.glow_animation.setDuration(2000)
self.glow_animation.setEasingCurve(QEasingCurve.Type.SineCurve)
self.glow_animation.setLoopCount(-1)
self.glow_animation.start()
8 changes: 4 additions & 4 deletions clashroyalebuildabot/gui/main_window.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from threading import Thread

from PyQt6.QtCore import Qt
from PyQt6.QtWidgets import QMainWindow
from PyQt6.QtWidgets import QTabWidget
from PyQt6.QtWidgets import QVBoxLayout
from PyQt6.QtWidgets import QWidget

from clashroyalebuildabot import Bot
from clashroyalebuildabot.bot.bot import pause_event
from clashroyalebuildabot.gui.animations import start_play_button_animation
from clashroyalebuildabot.gui.layout_setup import setup_tabs
from clashroyalebuildabot.gui.layout_setup import setup_top_bar
from clashroyalebuildabot.gui.styles import set_styles
Expand All @@ -16,8 +15,6 @@
class MainWindow(QMainWindow):
def __init__(self, config, actions):
super().__init__()


self.config = config
self.actions = actions
self.bot = None
Expand All @@ -39,12 +36,15 @@ def __init__(self, config, actions):
main_layout.addWidget(tab_widget)

set_styles(self)
start_play_button_animation(self)

def toggle_start_stop(self):
if self.is_running:
self.stop_bot()
self.glow_animation.start()
else:
self.start_bot()
self.glow_animation.stop()

def toggle_pause_resume_and_display(self):
if not self.bot:
Expand Down

0 comments on commit c0e6552

Please sign in to comment.