author | unc0rr |
Sun, 13 Jan 2013 11:14:50 +0400 | |
changeset 8375 | af2d2f56bc45 |
parent 8326 | 023a71940f26 |
child 8729 | b19be476a2fa |
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" |
6930 | 14 |
#include "DataManager.h" |
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
|
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); |
8326
023a71940f26
Don't play sounds in chat if sound is disabled, try to prevent sound crashes by checking for audio init failure.
nemo
parents:
8049
diff
changeset
|
42 |
if (button || textfield || checkbox || droplist || slider || tab) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6584
diff
changeset
|
43 |
{ |
8049 | 44 |
SDLInteraction::instance().playSoundFile("/Sounds/steps.ogg"); |
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
|
45 |
} |
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 |
|
6477 | 47 |
return true; |
48 |
} |
|
49 |
else if (event->type() == QEvent::Leave) |
|
50 |
{ |
|
51 |
abstractpage = qobject_cast<AbstractPage*>(ui->Pages->currentWidget()); |
|
52 |
||
53 |
if (abstractpage->getDefautDescription() != NULL) |
|
54 |
{ |
|
55 |
abstractpage->setButtonDescription( * abstractpage->getDefautDescription()); |
|
56 |
} |
|
57 |
else |
|
58 |
abstractpage->setButtonDescription(""); |
|
59 |
} |
|
60 |
||
61 |
return false; |
|
62 |
} |
|
63 |
||
64 |
void MouseOverFilter::setUi(Ui_HWForm *uiForm) |
|
65 |
{ |
|
66 |
ui = uiForm; |
|
67 |
} |