You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
979 B
C++

#ifndef PUSHBUTTONSOUND_H
#define PUSHBUTTONSOUND_H
#include <QPainter>
#include "qw_abstractscenecontrol.h"
/* PushButtonSound
* Switches current sound state. */
class PushButtonSound : public QWAbstractSceneControl
{
Q_OBJECT
private:
bool b_on;
QPixmap pix_on;
QPixmap pix_off;
protected:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *,
QWidget *) override
{
painter->fillRect(rect(), QBrush(b_on ? pix_on : pix_off));
}
public:
explicit PushButtonSound(const QPixmap &pixmap_off, QGraphicsItem *parent = nullptr);
virtual ~PushButtonSound() override {}
void onClick() override;
void onConnect(std::unique_ptr<GameFeatures> &game_features) override;
////////////////////////
inline void setPixmapOn(const QPixmap &pixmap_on) noexcept;
inline void setPixmapOff(const QPixmap &pixmap_off) noexcept;
signals:
void signalChangeSound(bool);
};
#endif // PUSHBUTTONSOUND_H