QTfrontend/ui/widget/qpushbuttonwithsound.cpp
author valnut
Mon, 16 Jan 2012 10:22:21 +0100
changeset 6579 fc52f7c22c9b
parent 6572 0d0af531c1c7
child 6577 9e49e6a8585b
permissions -rw-r--r--
GCI task: season greetings

#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)
{
    connect(this, SIGNAL(clicked()), this, SLOT(buttonClicked()));
}

void QPushButtonWithSound::buttonClicked()
{
    if (!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]));
}