Enter and Leave events for Maxim

preferencesAboutTextFull
Ivan Ilin 13 years ago
parent c4e771c8ad
commit a5bdc4f58a
  1. 10
      src/domain/UBGraphicsProxyWidget.cpp
  2. 2
      src/domain/UBGraphicsProxyWidget.h
  3. 24
      src/domain/UBGraphicsWidgetItem.cpp
  4. 8
      src/domain/UBGraphicsWidgetItem.h

@ -111,6 +111,16 @@ void UBGraphicsProxyWidget::wheelEvent(QGraphicsSceneWheelEvent *event)
}
}
void UBGraphicsProxyWidget::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
// NOOP
}
void UBGraphicsProxyWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
// NOOP
}
void UBGraphicsProxyWidget::setDelegate(UBGraphicsItemDelegate* pDelegate)
{

@ -51,6 +51,8 @@ class UBGraphicsProxyWidget: public QGraphicsProxyWidget, public UBItem, public
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);

@ -78,6 +78,16 @@ void UBGraphicsWidgetItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
UBGraphicsProxyWidget::mouseReleaseEvent(event);
}
void UBGraphicsWidgetItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
sendJSEnterEvent();
UBGraphicsProxyWidget::hoverEnterEvent(event);
}
void UBGraphicsWidgetItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
sendJSLeaveEvent();
UBGraphicsProxyWidget::hoverLeaveEvent(event);
}
bool UBGraphicsWidgetItem::eventFilter(QObject *obj, QEvent *event)
{
@ -247,6 +257,20 @@ void UBGraphicsWidgetItem::removeScript()
mWebKitWidget->page()->mainFrame()->evaluateJavaScript("if(widget && widget.onremove) { widget.onremove();}");
}
}
void UBGraphicsWidgetItem::sendJSEnterEvent()
{
if (mWebKitWidget && mWebKitWidget->page() && mWebKitWidget->page()->mainFrame())
{
mWebKitWidget->page()->mainFrame()->evaluateJavaScript("if(widget && widget.onenter) { widget.onenter();}");
}
}
void UBGraphicsWidgetItem::sendJSLeaveEvent()
{
if (mWebKitWidget && mWebKitWidget->page() && mWebKitWidget->page()->mainFrame())
{
mWebKitWidget->page()->mainFrame()->evaluateJavaScript("if(widget && widget.onleave) { widget.onleave();}");
}
}
void UBGraphicsWidgetItem::clearSource()
{

@ -66,6 +66,7 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
virtual void remove();
void removeScript();
QString downloadUrl(const QString &fileUrl, const QString &extention);
QString downloadWeb(const QString &fileUrl);
void processDropEvent(QDropEvent *event);
@ -77,13 +78,20 @@ class UBGraphicsWidgetItem : public UBGraphicsProxyWidget
virtual void clearSource();
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual bool eventFilter(QObject *obj, QEvent *event);
virtual void sendJSEnterEvent();
virtual void sendJSLeaveEvent();
UBAbstractWidget* mWebKitWidget;
QMap<QString, QString> mPreferences;

Loading…
Cancel
Save