author | unc0rr |
Wed, 22 Apr 2015 23:33:16 +0300 | |
branch | qmlfrontend |
changeset 10898 | f373838129c2 |
parent 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 |
{ |
|
10248 | 25 |
AbstractPage* abstractpage; |
26 |
||
8732 | 27 |
if (event->type() == QEvent::Enter) |
6477 | 28 |
{ |
29 |
QWidget * widget = dynamic_cast<QWidget*>(dist); |
|
30 |
||
31 |
abstractpage = qobject_cast<AbstractPage*>(ui->Pages->currentWidget()); |
|
32 |
||
33 |
if (widget->whatsThis() != NULL) |
|
34 |
abstractpage->setButtonDescription(widget->whatsThis()); |
|
35 |
else if (widget->toolTip() != NULL) |
|
36 |
abstractpage->setButtonDescription(widget->toolTip()); |
|
8732 | 37 |
} |
38 |
else if (event->type() == QEvent::FocusIn) |
|
39 |
{ |
|
40 |
abstractpage = qobject_cast<AbstractPage*>(ui->Pages->currentWidget()); |
|
6477 | 41 |
|
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
|
42 |
// 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
|
43 |
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
|
44 |
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
|
45 |
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
|
46 |
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
|
47 |
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
|
48 |
QTabWidget * tab = dynamic_cast<QTabWidget*>(dist); |
8729 | 49 |
QListView * listview = dynamic_cast<QListView*>(dist); |
50 |
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
|
51 |
{ |
8049 | 52 |
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
|
53 |
} |
6477 | 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 |
return false; |
|
67 |
} |
|
68 |
||
69 |
void MouseOverFilter::setUi(Ui_HWForm *uiForm) |
|
70 |
{ |
|
71 |
ui = uiForm; |
|
72 |
} |