QTfrontend/ui/mouseoverfilter.cpp
changeset 6477 ad5741c252b9
child 6584 5bb48450b978
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/QTfrontend/ui/mouseoverfilter.cpp	Sat Dec 03 14:36:36 2011 +0100
@@ -0,0 +1,48 @@
+#include "mouseoverfilter.h"
+#include "ui/page/AbstractPage.h"
+#include "ui_hwform.h"
+
+#include <QEvent>
+#include <QWidget>
+#include <QStackedLayout>
+#include <QLabel>
+
+MouseOverFilter::MouseOverFilter(QObject *parent) :
+    QObject(parent)
+{
+}
+
+bool MouseOverFilter::eventFilter( QObject *dist, QEvent *event )
+{
+    if (event->type() == QEvent::Enter)
+    {
+        QWidget * widget = dynamic_cast<QWidget*>(dist);
+
+        abstractpage = qobject_cast<AbstractPage*>(ui->Pages->currentWidget());
+
+        if (widget->whatsThis() != NULL)
+            abstractpage->setButtonDescription(widget->whatsThis());
+        else if (widget->toolTip() != NULL)
+            abstractpage->setButtonDescription(widget->toolTip());
+
+        return true;
+    }
+    else if (event->type() == QEvent::Leave)
+    {
+        abstractpage = qobject_cast<AbstractPage*>(ui->Pages->currentWidget());
+
+        if (abstractpage->getDefautDescription() != NULL)
+        {
+            abstractpage->setButtonDescription( * abstractpage->getDefautDescription());
+        }
+        else
+            abstractpage->setButtonDescription("");
+    }
+
+    return false;
+}
+
+void MouseOverFilter::setUi(Ui_HWForm *uiForm)
+{
+    ui = uiForm;
+}