quest-wizard/view/controls/pushbuttonsound.cpp

38 lines
882 B
C++
Raw Normal View History

2023-02-09 14:41:24 +01:00
#include "pushbuttonsound.h"
#include "features/gamefeatures.h"
PushButtonSound::PushButtonSound(const QPixmap &pixmap_off, QGraphicsItem *parent) :
b_on(false),
pix_on(pixmap_off),
pix_off(pixmap_off)
{
setParentItem(parent);
Q_ASSERT(!pixmap_off.isNull());
}
void PushButtonSound::onClick()
{
b_on = !b_on;
emit signalChangeSound(b_on);
}
void PushButtonSound::onConnect(std::unique_ptr<GameFeatures> &game_features)
{
QObject::connect(this, //sender
SIGNAL(signalChangeSound(bool)),
game_features->ptr_sound_player, //receiver
SLOT(setMuteness(bool)));
}
////////////////////////
void PushButtonSound::setPixmapOn(const QPixmap &pixmap_on) noexcept
{
pix_on = pixmap_on;
}
void PushButtonSound::setPixmapOff(const QPixmap &pixmap_off) noexcept
{
pix_off = pixmap_off;
}