#include "gui/buttoneventlistener.h" #include "soundengine.h" #include #include ButtonEventListener::ButtonEventListener(QObject *parent) : QObject(parent) { } bool ButtonEventListener::eventFilter(QObject * watched, QEvent * event) { QPushButton * button = qobject_cast(watched); if (!button) { return false; } if (event->type() == QEvent::Enter) { button->setStyleSheet("border-image: url(:/assets/common/buttons/" + button->objectName() + "_hover.png);"); SoundEngine::getInstance().playAsync("qrc:/assets/common/buttons/button_hover.mp3"); return false; } if (event->type() == QEvent::Leave){ button->setStyleSheet("border-image: url(:/assets/common/buttons/" + button->objectName() + ".png);"); SoundEngine::getInstance().playAsync("qrc:/assets/common/buttons/button_hover.mp3"); return false; } if (event->type() == QEvent::MouseButtonPress) { SoundEngine::getInstance().playAsync("qrc:/assets/common/buttons/button_click.mp3"); return false; } return false; }