author | nemo |
Sun, 24 Nov 2013 14:00:24 -0500 | |
changeset 9712 | 5f983813fae7 |
parent 9577 | 9577634bd284 |
child 10248 | 7b9b44a051f8 |
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 |
} |
6477 | 52 |
} |
53 |
else if (event->type() == QEvent::Leave) |
|
54 |
{ |
|
55 |
abstractpage = qobject_cast<AbstractPage*>(ui->Pages->currentWidget()); |
|
56 |
||
8729 | 57 |
if (abstractpage->getDefaultDescription() != NULL) |
6477 | 58 |
{ |
8729 | 59 |
abstractpage->setButtonDescription( * abstractpage->getDefaultDescription()); |
6477 | 60 |
} |
61 |
else |
|
62 |
abstractpage->setButtonDescription(""); |
|
63 |
} |
|
64 |
return false; |
|
65 |
} |
|
66 |
||
67 |
void MouseOverFilter::setUi(Ui_HWForm *uiForm) |
|
68 |
{ |
|
69 |
ui = uiForm; |
|
70 |
} |