QTfrontend/ui/mouseoverfilter.cpp
author dag10
Mon, 21 Jan 2013 00:30:18 -0500
changeset 8415 02acf6b92f52
parent 8326 023a71940f26
child 8729 b19be476a2fa
permissions -rw-r--r--
Moved room name edit box from footer to top of page. Also shows room name when in slave mode. Temporarily increased HWForm's min height from 580 to 610.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6477
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
     1
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
     2
#include <QEvent>
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
     3
#include <QWidget>
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
     4
#include <QStackedLayout>
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
     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
d187ea93fc4f renaming HWDataManager -> DataManager
sheepluva
parents: 6616
diff changeset
    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
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    16
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    17
MouseOverFilter::MouseOverFilter(QObject *parent) :
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    18
    QObject(parent)
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    19
{
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    20
}
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    21
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    22
bool MouseOverFilter::eventFilter( QObject *dist, QEvent *event )
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    23
{
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    24
    if (event->type() == QEvent::Enter)
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    25
    {
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    26
        QWidget * widget = dynamic_cast<QWidget*>(dist);
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    27
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    28
        abstractpage = qobject_cast<AbstractPage*>(ui->Pages->currentWidget());
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    29
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    30
        if (widget->whatsThis() != NULL)
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    31
            abstractpage->setButtonDescription(widget->whatsThis());
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    32
        else if (widget->toolTip() != NULL)
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    33
            abstractpage->setButtonDescription(widget->toolTip());
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    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
133e22b5c410 Get rid of DataManager::findFileForRead
unc0rr
parents: 6930
diff changeset
    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
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    47
        return true;
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    48
    }
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    49
    else if (event->type() == QEvent::Leave)
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    50
    {
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    51
        abstractpage = qobject_cast<AbstractPage*>(ui->Pages->currentWidget());
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    52
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    53
        if (abstractpage->getDefautDescription() != NULL)
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    54
        {
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    55
            abstractpage->setButtonDescription( * abstractpage->getDefautDescription());
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    56
        }
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    57
        else
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    58
            abstractpage->setButtonDescription("");
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    59
    }
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    60
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    61
    return false;
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    62
}
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    63
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    64
void MouseOverFilter::setUi(Ui_HWForm *uiForm)
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    65
{
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    66
    ui = uiForm;
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    67
}