author | koda |
Tue, 02 Apr 2013 21:00:57 +0200 | |
branch | webgl |
changeset 8833 | c13ebed437cb |
parent 8801 | c38ce9cf4c3a |
child 9577 | 9577634bd284 |
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> |
8729 | 8 |
#include <QListView> |
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
|
9 |
|
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 "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
|
11 |
#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
|
12 |
#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
|
13 |
#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
|
14 |
#include "gameuiconfig.h" |
6930 | 15 |
#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
|
16 |
#include "SDLInteraction.h" |
6477 | 17 |
|
18 |
MouseOverFilter::MouseOverFilter(QObject *parent) : |
|
19 |
QObject(parent) |
|
20 |
{ |
|
21 |
} |
|
22 |
||
23 |
bool MouseOverFilter::eventFilter( QObject *dist, QEvent *event ) |
|
24 |
{ |
|
8732 | 25 |
if (event->type() == QEvent::Enter) |
6477 | 26 |
{ |
27 |
QWidget * widget = dynamic_cast<QWidget*>(dist); |
|
28 |
||
29 |
abstractpage = qobject_cast<AbstractPage*>(ui->Pages->currentWidget()); |
|
30 |
||
31 |
if (widget->whatsThis() != NULL) |
|
32 |
abstractpage->setButtonDescription(widget->whatsThis()); |
|
33 |
else if (widget->toolTip() != NULL) |
|
34 |
abstractpage->setButtonDescription(widget->toolTip()); |
|
8732 | 35 |
} |
36 |
else if (event->type() == QEvent::FocusIn) |
|
37 |
{ |
|
38 |
abstractpage = qobject_cast<AbstractPage*>(ui->Pages->currentWidget()); |
|
6477 | 39 |
|
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
|
40 |
// 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
|
41 |
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
|
42 |
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
|
43 |
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
|
44 |
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
|
45 |
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
|
46 |
QTabWidget * tab = dynamic_cast<QTabWidget*>(dist); |
8729 | 47 |
QListView * listview = dynamic_cast<QListView*>(dist); |
48 |
if (button || textfield || checkbox || droplist || slider || tab || listview) |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6584
diff
changeset
|
49 |
{ |
8049 | 50 |
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
|
51 |
} |
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
|
52 |
|
6477 | 53 |
return true; |
54 |
} |
|
55 |
else if (event->type() == QEvent::Leave) |
|
56 |
{ |
|
57 |
abstractpage = qobject_cast<AbstractPage*>(ui->Pages->currentWidget()); |
|
58 |
||
8729 | 59 |
if (abstractpage->getDefaultDescription() != NULL) |
6477 | 60 |
{ |
8729 | 61 |
abstractpage->setButtonDescription( * abstractpage->getDefaultDescription()); |
6477 | 62 |
} |
63 |
else |
|
64 |
abstractpage->setButtonDescription(""); |
|
65 |
} |
|
66 |
||
67 |
return false; |
|
68 |
} |
|
69 |
||
70 |
void MouseOverFilter::setUi(Ui_HWForm *uiForm) |
|
71 |
{ |
|
72 |
ui = uiForm; |
|
73 |
} |