QTfrontend/ui/mouseoverfilter.cpp
author Wuzzy <Wuzzy2@mail.ru>
Sat, 21 Oct 2017 23:03:52 +0200
changeset 12733 353cb2ce6f9c
parent 10248 7b9b44a051f8
permissions -rw-r--r--
Fix AddAmmo setting ammo to 99 when trying to add infinite ammo This affected the portal mission, the crate only gave you 99 portal guns instead of infinite.
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>
8729
b19be476a2fa Call steps on focus instead. fix typo
nemo
parents: 8326
diff changeset
     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
d187ea93fc4f renaming HWDataManager -> DataManager
sheepluva
parents: 6616
diff changeset
    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
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    17
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    18
MouseOverFilter::MouseOverFilter(QObject *parent) :
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    19
    QObject(parent)
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
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    23
bool MouseOverFilter::eventFilter( QObject *dist, QEvent *event )
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    24
{
10248
7b9b44a051f8 Fix some of issues found by coverity
unc0rr
parents: 9577
diff changeset
    25
    AbstractPage* abstractpage;
7b9b44a051f8 Fix some of issues found by coverity
unc0rr
parents: 9577
diff changeset
    26
8732
nemo
parents: 8729
diff changeset
    27
    if (event->type() == QEvent::Enter)
6477
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    28
    {
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    29
        QWidget * widget = dynamic_cast<QWidget*>(dist);
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    30
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    31
        abstractpage = qobject_cast<AbstractPage*>(ui->Pages->currentWidget());
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    32
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    33
        if (widget->whatsThis() != NULL)
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    34
            abstractpage->setButtonDescription(widget->whatsThis());
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    35
        else if (widget->toolTip() != NULL)
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    36
            abstractpage->setButtonDescription(widget->toolTip());
8732
nemo
parents: 8729
diff changeset
    37
    }
nemo
parents: 8729
diff changeset
    38
    else if (event->type() == QEvent::FocusIn)
nemo
parents: 8729
diff changeset
    39
    {
nemo
parents: 8729
diff changeset
    40
        abstractpage = qobject_cast<AbstractPage*>(ui->Pages->currentWidget());
6477
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    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
b19be476a2fa Call steps on focus instead. fix typo
nemo
parents: 8326
diff changeset
    49
        QListView * listview = dynamic_cast<QListView*>(dist);
b19be476a2fa Call steps on focus instead. fix typo
nemo
parents: 8326
diff changeset
    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
133e22b5c410 Get rid of DataManager::findFileForRead
unc0rr
parents: 6930
diff changeset
    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
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    54
    }
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    55
    else if (event->type() == QEvent::Leave)
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    56
    {
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    57
        abstractpage = qobject_cast<AbstractPage*>(ui->Pages->currentWidget());
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    58
8729
b19be476a2fa Call steps on focus instead. fix typo
nemo
parents: 8326
diff changeset
    59
        if (abstractpage->getDefaultDescription() != NULL)
6477
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    60
        {
8729
b19be476a2fa Call steps on focus instead. fix typo
nemo
parents: 8326
diff changeset
    61
            abstractpage->setButtonDescription( * abstractpage->getDefaultDescription());
6477
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    62
        }
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    63
        else
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    64
            abstractpage->setButtonDescription("");
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    65
    }
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    66
    return false;
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    67
}
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    68
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    69
void MouseOverFilter::setUi(Ui_HWForm *uiForm)
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    70
{
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    71
    ui = uiForm;
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    72
}