QTfrontend/ui/widget/qpushbuttonwithsound.cpp
author bovi
Mon, 16 Jan 2012 00:03:13 +0100
changeset 6577 9e49e6a8585b
parent 6572 0d0af531c1c7
child 6584 5bb48450b978
permissions -rw-r--r--
disable the glitchy exit sound
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6572
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
     1
#include "qpushbuttonwithsound.h"
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
     2
#include <QMessageBox>
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
     3
#include <HWDataManager.h>
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
     4
#include <QDir>
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
     5
#include <SDLInteraction.h>
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
     6
#include <hwform.h>
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
     7
#include <QSettings>
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
     8
#include <gameuiconfig.h>
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
     9
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    10
QPushButtonWithSound::QPushButtonWithSound(QWidget *parent) :
6577
9e49e6a8585b disable the glitchy exit sound
bovi
parents: 6572
diff changeset
    11
    QPushButton(parent),
9e49e6a8585b disable the glitchy exit sound
bovi
parents: 6572
diff changeset
    12
    isSoundEnabled(true)
6572
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    13
{
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    14
    connect(this, SIGNAL(clicked()), this, SLOT(buttonClicked()));
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    15
}
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    16
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    17
void QPushButtonWithSound::buttonClicked()
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    18
{
6577
9e49e6a8585b disable the glitchy exit sound
bovi
parents: 6572
diff changeset
    19
    if ( !isSoundEnabled || !HWForm::config->isFrontendSoundEnabled())
6572
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    20
        return;
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    21
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    22
    HWDataManager & dataMgr = HWDataManager::instance();
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    23
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    24
    QString soundsDir = QString("Sounds/");
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    25
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    26
    QStringList list = dataMgr.entryList(
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    27
            soundsDir,
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    28
            QDir::Files,
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    29
            QStringList() <<
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    30
                "shotgunreload.ogg"
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    31
            );
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    32
    if(!list.empty())
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    33
        SDLInteraction::instance().playSoundFile(dataMgr.findFileForRead(soundsDir + "/" + list[0]));
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    34
}