# HG changeset patch # User koda # Date 1326845227 -3600 # Node ID 5bb48450b9782642741c388f43c7759076aab8d7 # Parent 4218782d8ca0ca3cf059f8e85aa7c3dba6b2669b simplify qpushbuttonwithsound and add a mouseover sound (I tried selecting the least annoying ones, maybe it'd be better to look for proper button sound effects) diff -r 4218782d8ca0 -r 5bb48450b978 QTfrontend/ui/mouseoverfilter.cpp --- a/QTfrontend/ui/mouseoverfilter.cpp Tue Jan 17 23:42:30 2012 +0100 +++ b/QTfrontend/ui/mouseoverfilter.cpp Wed Jan 18 01:07:07 2012 +0100 @@ -1,11 +1,18 @@ -#include "mouseoverfilter.h" -#include "ui/page/AbstractPage.h" -#include "ui_hwform.h" #include #include #include #include +#include +#include + +#include "mouseoverfilter.h" +#include "ui/page/AbstractPage.h" +#include "ui_hwform.h" +#include "hwform.h" +#include "gameuiconfig.h" +#include "HWDataManager.h" +#include "SDLInteraction.h" MouseOverFilter::MouseOverFilter(QObject *parent) : QObject(parent) @@ -25,6 +32,18 @@ else if (widget->toolTip() != NULL) abstractpage->setButtonDescription(widget->toolTip()); + // play a sound when mouse hovers certain ui elements + QPushButton * button = dynamic_cast(dist); + QLineEdit * textfield = dynamic_cast(dist); + QCheckBox * checkbox = dynamic_cast(dist); + QComboBox * droplist = dynamic_cast(dist); + QSlider * slider = dynamic_cast(dist); + QTabWidget * tab = dynamic_cast(dist); + if (HWForm::config->isFrontendSoundEnabled() && (button || textfield || checkbox || droplist || slider || tab)) { + HWDataManager & dataMgr = HWDataManager::instance(); + SDLInteraction::instance().playSoundFile(dataMgr.findFileForRead("Sounds/steps.ogg")); + } + return true; } else if (event->type() == QEvent::Leave) diff -r 4218782d8ca0 -r 5bb48450b978 QTfrontend/ui/widget/qpushbuttonwithsound.cpp --- a/QTfrontend/ui/widget/qpushbuttonwithsound.cpp Tue Jan 17 23:42:30 2012 +0100 +++ b/QTfrontend/ui/widget/qpushbuttonwithsound.cpp Wed Jan 18 01:07:07 2012 +0100 @@ -1,11 +1,11 @@ -#include "qpushbuttonwithsound.h" #include -#include #include -#include -#include -#include -#include + +#include "qpushbuttonwithsound.h" +#include "HWDataManager.h" +#include "SDLInteraction.h" +#include "hwform.h" +#include "gameuiconfig.h" QPushButtonWithSound::QPushButtonWithSound(QWidget *parent) : QPushButton(parent), @@ -21,14 +21,6 @@ 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])); + if (this->isEnabled()) + SDLInteraction::instance().playSoundFile(dataMgr.findFileForRead("Sounds/roperelease.ogg")); }