QTfrontend/ui/widget/qpushbuttonwithsound.cpp
author koda
Wed, 18 Jan 2012 01:07:07 +0100
changeset 6584 5bb48450b978
parent 6583 4218782d8ca0
child 6700 e04da46ee43c
permissions -rw-r--r--
simplify qpushbuttonwithsound and add a mouseover sound (I tried selecting the least annoying ones, maybe it'd be better to look for proper button sound effects)

#include <QMessageBox>
#include <QDir>

#include "qpushbuttonwithsound.h"
#include "HWDataManager.h"
#include "SDLInteraction.h"
#include "hwform.h"
#include "gameuiconfig.h"

QPushButtonWithSound::QPushButtonWithSound(QWidget *parent) :
    QPushButton(parent),
    isSoundEnabled(true)
{
    connect(this, SIGNAL(clicked()), this, SLOT(buttonClicked()));
}

void QPushButtonWithSound::buttonClicked()
{
    if ( !isSoundEnabled || !HWForm::config->isFrontendSoundEnabled())
        return;

    HWDataManager & dataMgr = HWDataManager::instance();

    if (this->isEnabled())
        SDLInteraction::instance().playSoundFile(dataMgr.findFileForRead("Sounds/roperelease.ogg"));
}