QTfrontend/ui/widget/qpushbuttonwithsound.cpp
author koda
Thu, 03 May 2012 16:04:38 +0100
changeset 7016 8b34f46e10c1
parent 6930 d187ea93fc4f
child 7793 3c21da93db9f
permissions -rw-r--r--
HAPPY 7000th COMMIT HEDGEWARS - enforce strong typechecking for strings - disable embedded fpc exceptions (binary size savings of ~5k) - add stack check in debug mode

#include <QMessageBox>
#include <QDir>

#include "qpushbuttonwithsound.h"
#include "DataManager.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;

    DataManager & dataMgr = DataManager::instance();

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