author | Xeli |
Sat, 28 Jan 2012 22:19:42 +0100 | |
changeset 6608 | 9305a12f66bf |
parent 6584 | 5bb48450b978 |
child 6616 | f77bb02b669f |
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); |
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 |
if (HWForm::config->isFrontendSoundEnabled() && (button || textfield || checkbox || droplist || slider || tab)) { |
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 |
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
|
44 |
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
|
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 |
} |