QTfrontend/ui/widget/qpushbuttonwithsound.cpp
author bovi
Sun, 15 Jan 2012 22:57:49 +0100
changeset 6572 0d0af531c1c7
child 6577 9e49e6a8585b
permissions -rw-r--r--
GCI task: ping
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) :
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    11
    QPushButton(parent)
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    12
{
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    13
    connect(this, SIGNAL(clicked()), this, SLOT(buttonClicked()));
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    14
}
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    15
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    16
void QPushButtonWithSound::buttonClicked()
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    17
{
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    18
    if (!HWForm::config->isFrontendSoundEnabled())
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    19
        return;
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    20
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    21
    HWDataManager & dataMgr = HWDataManager::instance();
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    22
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    23
    QString soundsDir = QString("Sounds/");
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    24
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    25
    QStringList list = dataMgr.entryList(
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    26
            soundsDir,
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    27
            QDir::Files,
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    28
            QStringList() <<
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    29
                "shotgunreload.ogg"
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    30
            );
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    31
    if(!list.empty())
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    32
        SDLInteraction::instance().playSoundFile(dataMgr.findFileForRead(soundsDir + "/" + list[0]));
0d0af531c1c7 GCI task: ping
bovi
parents:
diff changeset
    33
}