author | mikade <redgrinner@gmail.com> |
Sun, 25 Mar 2012 21:17:01 +0200 | |
changeset 6821 | d4f75843cf5d |
parent 6616 | f77bb02b669f |
child 6930 | d187ea93fc4f |
permissions | -rw-r--r-- |
6477 | 1 |
|
2 |
#include <QEvent> |
|
3 |
#include <QWidget> |
|
4 |
#include <QStackedLayout> |
|
5 |
#include <QLabel> |
|
6584
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
6 |
#include <QLineEdit> |
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
7 |
#include <QCheckBox> |
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
8 |
|
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
9 |
#include "mouseoverfilter.h" |
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
10 |
#include "ui/page/AbstractPage.h" |
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
11 |
#include "ui_hwform.h" |
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
12 |
#include "hwform.h" |
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
13 |
#include "gameuiconfig.h" |
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
14 |
#include "HWDataManager.h" |
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
15 |
#include "SDLInteraction.h" |
6477 | 16 |
|
17 |
MouseOverFilter::MouseOverFilter(QObject *parent) : |
|
18 |
QObject(parent) |
|
19 |
{ |
|
20 |
} |
|
21 |
||
22 |
bool MouseOverFilter::eventFilter( QObject *dist, QEvent *event ) |
|
23 |
{ |
|
24 |
if (event->type() == QEvent::Enter) |
|
25 |
{ |
|
26 |
QWidget * widget = dynamic_cast<QWidget*>(dist); |
|
27 |
||
28 |
abstractpage = qobject_cast<AbstractPage*>(ui->Pages->currentWidget()); |
|
29 |
||
30 |
if (widget->whatsThis() != NULL) |
|
31 |
abstractpage->setButtonDescription(widget->whatsThis()); |
|
32 |
else if (widget->toolTip() != NULL) |
|
33 |
abstractpage->setButtonDescription(widget->toolTip()); |
|
34 |
||
6584
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
35 |
// play a sound when mouse hovers certain ui elements |
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
36 |
QPushButton * button = dynamic_cast<QPushButton*>(dist); |
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
37 |
QLineEdit * textfield = dynamic_cast<QLineEdit*>(dist); |
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
38 |
QCheckBox * checkbox = dynamic_cast<QCheckBox*>(dist); |
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
39 |
QComboBox * droplist = dynamic_cast<QComboBox*>(dist); |
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
40 |
QSlider * slider = dynamic_cast<QSlider*>(dist); |
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
41 |
QTabWidget * tab = dynamic_cast<QTabWidget*>(dist); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6584
diff
changeset
|
42 |
if (HWForm::config->isFrontendSoundEnabled() && (button || textfield || checkbox || droplist || slider || tab)) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6584
diff
changeset
|
43 |
{ |
6584
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
44 |
HWDataManager & dataMgr = HWDataManager::instance(); |
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
45 |
SDLInteraction::instance().playSoundFile(dataMgr.findFileForRead("Sounds/steps.ogg")); |
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
46 |
} |
5bb48450b978
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)
koda
parents:
6477
diff
changeset
|
47 |
|
6477 | 48 |
return true; |
49 |
} |
|
50 |
else if (event->type() == QEvent::Leave) |
|
51 |
{ |
|
52 |
abstractpage = qobject_cast<AbstractPage*>(ui->Pages->currentWidget()); |
|
53 |
||
54 |
if (abstractpage->getDefautDescription() != NULL) |
|
55 |
{ |
|
56 |
abstractpage->setButtonDescription( * abstractpage->getDefautDescription()); |
|
57 |
} |
|
58 |
else |
|
59 |
abstractpage->setButtonDescription(""); |
|
60 |
} |
|
61 |
||
62 |
return false; |
|
63 |
} |
|
64 |
||
65 |
void MouseOverFilter::setUi(Ui_HWForm *uiForm) |
|
66 |
{ |
|
67 |
ui = uiForm; |
|
68 |
} |