From 9a6237071668f0c58c44cd566b7dd3a32cecc23e Mon Sep 17 00:00:00 2001
From: Yimgo <yimgo@yimgo.fr>
Date: Thu, 2 Aug 2012 13:51:23 +0200
Subject: [PATCH] Bug with shortcuts in widget fixed.

Now copy/paste can be performed without being grapped by application's actions.
Another bug when removing object fixed (dynamic_cast instead of static_cast) in DelegateItem.
---
 src/domain/UBGraphicsItemDelegate.cpp |  3 ++-
 src/domain/UBGraphicsWebView.cpp      | 11 +++++++++--
 src/domain/UBGraphicsWebView.h        |  1 +
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/domain/UBGraphicsItemDelegate.cpp b/src/domain/UBGraphicsItemDelegate.cpp
index d785ffa1..66ae6ac6 100644
--- a/src/domain/UBGraphicsItemDelegate.cpp
+++ b/src/domain/UBGraphicsItemDelegate.cpp
@@ -389,9 +389,10 @@ void UBGraphicsItemDelegate::remove(bool canUndo)
         scene->removeItem(mFrame);
 
         /* this is performed because when removing delegated from scene while it contains flash content, segfault happens because of QGraphicsScene::removeItem() */ 
-        UBGraphicsWebView *mDelegated_casted = static_cast<UBGraphicsWebView*>(mDelegated);
+        UBGraphicsWebView *mDelegated_casted = dynamic_cast<UBGraphicsWebView*>(mDelegated);
         if (mDelegated_casted)
             mDelegated_casted->setHtml(QString());
+
         scene->removeItem(mDelegated);
 
         if (canUndo)
diff --git a/src/domain/UBGraphicsWebView.cpp b/src/domain/UBGraphicsWebView.cpp
index d68bd51d..de9da3e7 100644
--- a/src/domain/UBGraphicsWebView.cpp
+++ b/src/domain/UBGraphicsWebView.cpp
@@ -51,10 +51,9 @@ QVariant UBGraphicsWebView::itemChange(GraphicsItemChange change, const QVariant
     if ((change == QGraphicsItem::ItemSelectedHasChanged) &&  scene()) {
         if (isSelected())
             scene()->setActiveWindow(this);
-        else {
+        else
             if(scene()->activeWindow() == this)
                 scene()->setActiveWindow(0);
-        }
     }
 
     QVariant newValue = mDelegate->itemChange(change, value);
@@ -169,3 +168,11 @@ void UBGraphicsWebView::remove()
     if (mDelegate)
         mDelegate->remove(true);
 }
+
+bool UBGraphicsWebView::event(QEvent *event)
+{
+    if (event->type() == QEvent::ShortcutOverride)
+        event->accept();
+
+    return QGraphicsWebView::event(event);
+}
diff --git a/src/domain/UBGraphicsWebView.h b/src/domain/UBGraphicsWebView.h
index a24d3aa6..508f60bb 100644
--- a/src/domain/UBGraphicsWebView.h
+++ b/src/domain/UBGraphicsWebView.h
@@ -55,6 +55,7 @@ class UBGraphicsWebView: public QGraphicsWebView, public UBItem, public UBResiza
         virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
         virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
         virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
+        virtual bool event(QEvent *event);
 
 
         virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);