QTfrontend/ui/mouseoverfilter.cpp
author unc0rr
Sun, 04 Dec 2011 00:56:07 +0300
changeset 6491 736479f3d348
parent 6477 ad5741c252b9
child 6584 5bb48450b978
permissions -rw-r--r--
Some cleanup here and there
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6477
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
     1
#include "mouseoverfilter.h"
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
     2
#include "ui/page/AbstractPage.h"
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
     3
#include "ui_hwform.h"
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
     4
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
     5
#include <QEvent>
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
     6
#include <QWidget>
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
     7
#include <QStackedLayout>
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
     8
#include <QLabel>
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
     9
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    10
MouseOverFilter::MouseOverFilter(QObject *parent) :
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    11
    QObject(parent)
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    12
{
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    13
}
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    14
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    15
bool MouseOverFilter::eventFilter( QObject *dist, QEvent *event )
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    16
{
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    17
    if (event->type() == QEvent::Enter)
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    18
    {
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    19
        QWidget * widget = dynamic_cast<QWidget*>(dist);
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    20
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    21
        abstractpage = qobject_cast<AbstractPage*>(ui->Pages->currentWidget());
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    22
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    23
        if (widget->whatsThis() != NULL)
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    24
            abstractpage->setButtonDescription(widget->whatsThis());
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    25
        else if (widget->toolTip() != NULL)
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    26
            abstractpage->setButtonDescription(widget->toolTip());
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    27
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    28
        return true;
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    29
    }
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    30
    else if (event->type() == QEvent::Leave)
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    31
    {
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    32
        abstractpage = qobject_cast<AbstractPage*>(ui->Pages->currentWidget());
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    33
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    34
        if (abstractpage->getDefautDescription() != NULL)
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    35
        {
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    36
            abstractpage->setButtonDescription( * abstractpage->getDefautDescription());
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    37
        }
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    38
        else
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    39
            abstractpage->setButtonDescription("");
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    40
    }
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    41
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    42
    return false;
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    43
}
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    44
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    45
void MouseOverFilter::setUi(Ui_HWForm *uiForm)
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    46
{
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    47
    ui = uiForm;
ad5741c252b9 GCI task: describez
Oranger
parents:
diff changeset
    48
}