QTfrontend/ui/widget/qpushbuttonwithsound.cpp
author bovi
Tue, 17 Jan 2012 23:42:30 +0100
changeset 6583 4218782d8ca0
parent 6572 0d0af531c1c7
child 6584 5bb48450b978
permissions -rw-r--r--
skip button sound when exiting

#include "qpushbuttonwithsound.h"
#include <QMessageBox>
#include <HWDataManager.h>
#include <QDir>
#include <SDLInteraction.h>
#include <hwform.h>
#include <QSettings>
#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();

    QString soundsDir = QString("Sounds/");

    QStringList list = dataMgr.entryList(
            soundsDir,
            QDir::Files,
            QStringList() <<
                "shotgunreload.ogg"
            );
    if(!list.empty())
        SDLInteraction::instance().playSoundFile(dataMgr.findFileForRead(soundsDir + "/" + list[0]));
}