fixed issue 1131 and 1161

preferencesAboutTextFull
Claudio Valerio 12 years ago
parent 3607318f83
commit dc272ce305
  1. 97
      src/board/UBBoardView.cpp
  2. 20
      src/domain/UBGraphicsScene.cpp
  3. 48
      src/domain/UBGraphicsWidgetItem.cpp
  4. 35
      src/domain/UBGraphicsWidgetItem.h

@ -100,7 +100,7 @@ UBBoardView::UBBoardView (UBBoardController* pController, int pStartLayer, int p
mStartLayer = pStartLayer; mStartLayer = pStartLayer;
mEndLayer = pEndLayer; mEndLayer = pEndLayer;
mFilterZIndex = true; mFilterZIndex = true;
mLongPressTimer.setInterval(mLongPressInterval); mLongPressTimer.setInterval(mLongPressInterval);
mLongPressTimer.setSingleShot(true); mLongPressTimer.setSingleShot(true);
@ -288,7 +288,7 @@ UBBoardView::keyPressEvent (QKeyEvent *event)
void UBBoardView::keyReleaseEvent(QKeyEvent *event) void UBBoardView::keyReleaseEvent(QKeyEvent *event)
{ {
// if (!event->isAccepted ()) // if (!event->isAccepted ())
{ {
if (Qt::Key_Shift == event->key() if (Qt::Key_Shift == event->key()
||Qt::Key_Control == event->key()) ||Qt::Key_Control == event->key())
{ {
@ -430,7 +430,7 @@ bool UBBoardView::itemHaveParentWithType(QGraphicsItem *item, int type)
if (type == item->type()) if (type == item->type())
return true; return true;
return itemHaveParentWithType(item->parentItem(), type); return itemHaveParentWithType(item->parentItem(), type);
} }
@ -447,7 +447,7 @@ bool UBBoardView::isUBItem(QGraphicsItem *item)
void UBBoardView::handleItemsSelection(QGraphicsItem *item) void UBBoardView::handleItemsSelection(QGraphicsItem *item)
{ {
// we need to select new pressed itemOnBoard and deselect all other items. // we need to select new pressed itemOnBoard and deselect all other items.
// the trouble is in: // the trouble is in:
// some items can has parents (groupped items or strokes, or strokes in groups). // some items can has parents (groupped items or strokes, or strokes in groups).
// some items is already selected and we don't need to reselect them // some items is already selected and we don't need to reselect them
// //
@ -458,11 +458,11 @@ void UBBoardView::handleItemsSelection(QGraphicsItem *item)
// item has group as first parent - it is any item or UBGraphicsStrokesGroup. // item has group as first parent - it is any item or UBGraphicsStrokesGroup.
if(item->parentItem() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type()) if(item->parentItem() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type())
return; return;
// delegate buttons shouldn't selected // delegate buttons shouldn't selected
if (DelegateButton::Type == item->type()) if (DelegateButton::Type == item->type())
return; return;
// click on svg items (images on Frame) shouldn't change selection. // click on svg items (images on Frame) shouldn't change selection.
if (QGraphicsSvgItem::Type == item->type()) if (QGraphicsSvgItem::Type == item->type())
return; return;
@ -470,8 +470,8 @@ void UBBoardView::handleItemsSelection(QGraphicsItem *item)
// Delegate frame shouldn't selected // Delegate frame shouldn't selected
if (UBGraphicsDelegateFrame::Type == item->type()) if (UBGraphicsDelegateFrame::Type == item->type())
return; return;
// if we need to uwe multiple selection - we shouldn't deselect other items. // if we need to uwe multiple selection - we shouldn't deselect other items.
if (!isMultipleSelectionEnabled()) if (!isMultipleSelectionEnabled())
{ {
@ -495,8 +495,8 @@ void UBBoardView::handleItemsSelection(QGraphicsItem *item)
bool UBBoardView::itemShouldReceiveMousePressEvent(QGraphicsItem *item) bool UBBoardView::itemShouldReceiveMousePressEvent(QGraphicsItem *item)
{ {
/* /*
Some items should receive mouse press events averytime, Some items should receive mouse press events averytime,
some items should receive that events when they are selected, some items should receive that events when they are selected,
some items shouldn't receive mouse press events at mouse press, but should receive them at mouse release (suspended mouse press event) some items shouldn't receive mouse press events at mouse press, but should receive them at mouse release (suspended mouse press event)
Here we determines cases when items should to get mouse press event at pressing on mouse. Here we determines cases when items should to get mouse press event at pressing on mouse.
@ -559,9 +559,9 @@ Here we determines cases when items should to get mouse press event at pressing
return true; return true;
case UBGraphicsWidgetItem::Type: case UBGraphicsWidgetItem::Type:
if (currentTool == UBStylusTool::Selector && item->parentItem() && item->parentItem()->isSelected()) if (currentTool == UBStylusTool::Selector && item->parentItem() && item->parentItem()->isSelected())
return true; return true;
if (currentTool == UBStylusTool::Selector && item->isSelected()) if (currentTool == UBStylusTool::Selector && item->isSelected())
return true; return true;
if (currentTool == UBStylusTool::Play) if (currentTool == UBStylusTool::Play)
return true; return true;
@ -574,7 +574,7 @@ Here we determines cases when items should to get mouse press event at pressing
bool UBBoardView::itemShouldReceiveSuspendedMousePressEvent(QGraphicsItem *item) bool UBBoardView::itemShouldReceiveSuspendedMousePressEvent(QGraphicsItem *item)
{ {
if (!item) if (!item)
return false; return false;
if (item == scene()->backgroundObject()) if (item == scene()->backgroundObject())
@ -594,7 +594,7 @@ bool UBBoardView::itemShouldReceiveSuspendedMousePressEvent(QGraphicsItem *item)
if (currentTool == UBStylusTool::Selector && item->isSelected()) if (currentTool == UBStylusTool::Selector && item->isSelected())
return true; return true;
break; break;
case DelegateButton::Type: case DelegateButton::Type:
case UBGraphicsMediaItem::Type: case UBGraphicsMediaItem::Type:
return true; return true;
@ -606,7 +606,7 @@ bool UBBoardView::itemShouldReceiveSuspendedMousePressEvent(QGraphicsItem *item)
bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item) bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item)
{ {
if (!item) if (!item)
return false; return false;
if (item == scene()->backgroundObject()) if (item == scene()->backgroundObject())
@ -614,15 +614,15 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item)
if (!(mMouseButtonIsPressed || mTabletStylusIsPressed)) if (!(mMouseButtonIsPressed || mTabletStylusIsPressed))
return false; return false;
if (movingItem->data(UBGraphicsItemData::ItemLocked).toBool()) if (movingItem->data(UBGraphicsItemData::ItemLocked).toBool())
return false; return false;
if (movingItem->parentItem() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type() && !movingItem->isSelected() && movingItem->parentItem()->isSelected()) if (movingItem->parentItem() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type() && !movingItem->isSelected() && movingItem->parentItem()->isSelected())
return false; return false;
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool(); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
switch(item->type()) switch(item->type())
{ {
case UBGraphicsCurtainItem::Type: case UBGraphicsCurtainItem::Type:
@ -630,7 +630,7 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item)
return true; return true;
case UBGraphicsWidgetItem::Type: case UBGraphicsWidgetItem::Type:
if(currentTool == UBStylusTool::Selector && item->isSelected()) if(currentTool == UBStylusTool::Selector && item->isSelected())
return false; return false;
if(currentTool == UBStylusTool::Play) if(currentTool == UBStylusTool::Play)
return false; return false;
@ -640,7 +640,7 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item)
if (item->isSelected()) if (item->isSelected())
return false; return false;
case UBGraphicsMediaItem::Type: case UBGraphicsMediaItem::Type:
case UBGraphicsStrokesGroup::Type: case UBGraphicsStrokesGroup::Type:
return true; return true;
case UBGraphicsTextItem::Type: case UBGraphicsTextItem::Type:
return !item->isSelected(); return !item->isSelected();
@ -654,13 +654,13 @@ QGraphicsItem* UBBoardView::determineItemToPress(QGraphicsItem *item)
{ {
if(item) if(item)
{ {
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool(); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
// if item is on group and group is not selected - group should take press. // if item is on group and group is not selected - group should take press.
if (UBStylusTool::Selector == currentTool if (UBStylusTool::Selector == currentTool
&& item->parentItem() && item->parentItem()
&& UBGraphicsGroupContainerItem::Type == item->parentItem()->type() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type()
&& !item->parentItem()->isSelected()) && !item->parentItem()->isSelected())
return item->parentItem(); return item->parentItem();
// items like polygons placed in two groups nested, so we need to recursive call. // items like polygons placed in two groups nested, so we need to recursive call.
@ -676,7 +676,7 @@ QGraphicsItem* UBBoardView::determineItemToMove(QGraphicsItem *item)
{ {
if(item) if(item)
{ {
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool(); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
//W3C widgets should take mouse move events from play tool. //W3C widgets should take mouse move events from play tool.
if ((UBStylusTool::Play == currentTool) && (UBGraphicsWidgetItem::Type == item->type())) if ((UBStylusTool::Play == currentTool) && (UBGraphicsWidgetItem::Type == item->type()))
@ -696,7 +696,7 @@ QGraphicsItem* UBBoardView::determineItemToMove(QGraphicsItem *item)
// selected groups should be moved by moving any element // selected groups should be moved by moving any element
if (item->parentItem()->isSelected()) if (item->parentItem()->isSelected())
return item; return item;
if (item->isSelected()) if (item->isSelected())
return NULL; return NULL;
@ -704,7 +704,7 @@ QGraphicsItem* UBBoardView::determineItemToMove(QGraphicsItem *item)
} }
// items like polygons placed in two groups nested, so we need to recursive call. // items like polygons placed in two groups nested, so we need to recursive call.
if(item->parentItem() && UBGraphicsStrokesGroup::Type == item->parentItem()->type()) if(item->parentItem() && UBGraphicsStrokesGroup::Type == item->parentItem()->type())
return determineItemToMove(item->parentItem()); return determineItemToMove(item->parentItem());
} }
@ -715,7 +715,7 @@ void UBBoardView::handleItemMousePress(QMouseEvent *event)
{ {
mLastPressedMousePos = mapToScene(event->pos()); mLastPressedMousePos = mapToScene(event->pos());
// Determining item who will take mouse press event // Determining item who will take mouse press event
//all other items will be deselected and if all item will be deselected, then //all other items will be deselected and if all item will be deselected, then
// wrong item can catch mouse press. because selected items placed on the top // wrong item can catch mouse press. because selected items placed on the top
movingItem = determineItemToPress(movingItem); movingItem = determineItemToPress(movingItem);
@ -738,7 +738,7 @@ void UBBoardView::handleItemMousePress(QMouseEvent *event)
delete suspendedMousePressEvent; delete suspendedMousePressEvent;
suspendedMousePressEvent = NULL; suspendedMousePressEvent = NULL;
} }
if (itemShouldReceiveSuspendedMousePressEvent(movingItem)) if (itemShouldReceiveSuspendedMousePressEvent(movingItem))
{ {
suspendedMousePressEvent = new QMouseEvent(event->type(), event->pos(), event->button(), event->buttons(), event->modifiers()); suspendedMousePressEvent = new QMouseEvent(event->type(), event->pos(), event->button(), event->buttons(), event->modifiers());
@ -752,7 +752,7 @@ void UBBoardView::handleItemMouseMove(QMouseEvent *event)
movingItem = determineItemToMove(movingItem); movingItem = determineItemToMove(movingItem);
// items should be moved not every mouse move. // items should be moved not every mouse move.
if (movingItem && itemShouldBeMoved(movingItem) && (mMouseButtonIsPressed || mTabletStylusIsPressed)) if (movingItem && itemShouldBeMoved(movingItem) && (mMouseButtonIsPressed || mTabletStylusIsPressed))
{ {
QPointF scenePos = mapToScene(event->pos()); QPointF scenePos = mapToScene(event->pos());
QPointF newPos = movingItem->pos() + scenePos - mLastPressedMousePos; QPointF newPos = movingItem->pos() + scenePos - mLastPressedMousePos;
@ -761,7 +761,7 @@ void UBBoardView::handleItemMouseMove(QMouseEvent *event)
mWidgetMoved = true; mWidgetMoved = true;
event->accept(); event->accept();
} }
else else
{ {
QPointF posBeforeMove; QPointF posBeforeMove;
QPointF posAfterMove; QPointF posAfterMove;
@ -777,11 +777,10 @@ void UBBoardView::handleItemMouseMove(QMouseEvent *event)
mWidgetMoved = ((posAfterMove-posBeforeMove).manhattanLength() != 0); mWidgetMoved = ((posAfterMove-posBeforeMove).manhattanLength() != 0);
// a cludge for terminate moving of w3c widgets. // a cludge for terminate moving of w3c widgets.
// in some cases w3c widgets catches mouse move and doesn't sends that events to web page, // in some cases w3c widgets catches mouse move and doesn't sends that events to web page,
// at simple - in google map widget - mouse move events doesn't comes to web page from rectangle of wearch bar on bottom right corner of widget. // at simple - in google map widget - mouse move events doesn't comes to web page from rectangle of wearch bar on bottom right corner of widget.
if (mWidgetMoved && UBGraphicsW3CWidgetItem::Type == movingItem->type()) if (mWidgetMoved && UBGraphicsW3CWidgetItem::Type == movingItem->type())
movingItem->setPos(posBeforeMove); movingItem->setPos(posBeforeMove);
} }
} }
@ -801,7 +800,7 @@ void UBBoardView::moveRubberedItems(QPointF movingVector)
{ {
QRectF invalidateRect = scene()->itemsBoundingRect(); QRectF invalidateRect = scene()->itemsBoundingRect();
foreach (QGraphicsItem *item, mRubberedItems) foreach (QGraphicsItem *item, mRubberedItems)
{ {
if (item->type() == UBGraphicsW3CWidgetItem::Type if (item->type() == UBGraphicsW3CWidgetItem::Type
@ -810,10 +809,10 @@ void UBBoardView::moveRubberedItems(QPointF movingVector)
|| item->type() == UBGraphicsSvgItem::Type || item->type() == UBGraphicsSvgItem::Type
|| item->type() == UBGraphicsTextItem::Type || item->type() == UBGraphicsTextItem::Type
|| item->type() == UBGraphicsStrokesGroup::Type || item->type() == UBGraphicsStrokesGroup::Type
|| item->type() == UBGraphicsGroupContainerItem::Type) || item->type() == UBGraphicsGroupContainerItem::Type)
{ {
item->setPos(item->pos()+movingVector); item->setPos(item->pos()+movingVector);
} }
} }
scene()->invalidate(invalidateRect); scene()->invalidate(invalidateRect);
@ -829,7 +828,7 @@ void UBBoardView::longPressEvent()
UBDrawingController *drawingController = UBDrawingController::drawingController(); UBDrawingController *drawingController = UBDrawingController::drawingController();
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool (); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController ()->stylusTool ();
disconnect(&mLongPressTimer, SIGNAL(timeout()), this, SLOT(longPressEvent())); disconnect(&mLongPressTimer, SIGNAL(timeout()), this, SLOT(longPressEvent()));
if (UBStylusTool::Selector == currentTool) if (UBStylusTool::Selector == currentTool)
@ -899,7 +898,7 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
connect(&mLongPressTimer, SIGNAL(timeout()), this, SLOT(longPressEvent())); connect(&mLongPressTimer, SIGNAL(timeout()), this, SLOT(longPressEvent()));
if (!movingItem && !mController->cacheIsVisible()) if (!movingItem && !mController->cacheIsVisible())
mLongPressTimer.start(); mLongPressTimer.start();
if (!movingItem) { if (!movingItem) {
// Rubberband selection implementation // Rubberband selection implementation
if (!mUBRubberBand) { if (!mUBRubberBand) {
@ -986,7 +985,7 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
void void
UBBoardView::mouseMoveEvent (QMouseEvent *event) UBBoardView::mouseMoveEvent (QMouseEvent *event)
{ {
if(!mIsDragInProgress && ((mapToScene(event->pos()) - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance())) if(!mIsDragInProgress && ((mapToScene(event->pos()) - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance()))
{ {
return; return;
} }
@ -1077,14 +1076,14 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
else else
{ {
if (!mTabletStylusIsPressed && scene ()) if (!mTabletStylusIsPressed && scene ())
{ {
scene ()->inputDeviceMove (mapToScene (UBGeometryUtils::pointConstrainedInRect (event->pos (), rect ())), mMouseButtonIsPressed); scene ()->inputDeviceMove (mapToScene (UBGeometryUtils::pointConstrainedInRect (event->pos (), rect ())), mMouseButtonIsPressed);
} }
event->accept (); event->accept ();
} }
if((event->pos() - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance()) if((event->pos() - mLastPressedMousePos).manhattanLength() < QApplication::startDragDistance())
mWidgetMoved = true; mWidgetMoved = true;
} }
void void
@ -1105,9 +1104,9 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
mWidgetMoved = false; mWidgetMoved = false;
movingItem = NULL; movingItem = NULL;
} }
else else
if (movingItem) if (movingItem)
{ {
if (suspendedMousePressEvent) if (suspendedMousePressEvent)
{ {
QGraphicsView::mousePressEvent(suspendedMousePressEvent); // suspendedMousePressEvent is deleted by old Qt event loop QGraphicsView::mousePressEvent(suspendedMousePressEvent); // suspendedMousePressEvent is deleted by old Qt event loop
@ -1140,7 +1139,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
movingItem->setSelected(true); movingItem->setSelected(true);
} }
} }
} }
} }
@ -1163,7 +1162,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
} }
else else
{ {
if (suspendedMousePressEvent) if (suspendedMousePressEvent)
{ {
QGraphicsView::mousePressEvent(suspendedMousePressEvent); // suspendedMousePressEvent is deleted by old Qt event loop QGraphicsView::mousePressEvent(suspendedMousePressEvent); // suspendedMousePressEvent is deleted by old Qt event loop
movingItem = NULL; movingItem = NULL;

@ -303,12 +303,10 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent, bool enableUndoRedoSta
UBGraphicsScene::~UBGraphicsScene() UBGraphicsScene::~UBGraphicsScene()
{ {
if (mCurrentStroke) if (mCurrentStroke && mCurrentStroke->polygons().empty()){
if (mCurrentStroke->polygons().empty()) delete mCurrentStroke;
{ mCurrentStroke = NULL;
delete mCurrentStroke; }
mCurrentStroke = NULL;
}
if (mZLayerController) if (mZLayerController)
delete mZLayerController; delete mZLayerController;
@ -437,7 +435,7 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
} }
if (mCurrentStroke && mCurrentStroke->polygons().empty()){ if (mCurrentStroke && mCurrentStroke->polygons().empty()){
delete mCurrentStroke; delete mCurrentStroke;
mCurrentStroke = NULL; mCurrentStroke = NULL;
} }
@ -800,7 +798,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
} }
} }
else if (eraserPath.intersects(itemPainterPath)) else if (eraserPath.intersects(itemPainterPath))
{ {
QPainterPath newPath = itemPainterPath.subtracted(eraserPath); QPainterPath newPath = itemPainterPath.subtracted(eraserPath);
#pragma omp critical #pragma omp critical
@ -820,7 +818,7 @@ void UBGraphicsScene::eraseLineTo(const QPointF &pEndPoint, const qreal &pWidth)
else else
{ {
UBGraphicsPolygonItem *pi = intersectedItems[i]; UBGraphicsPolygonItem *pi = intersectedItems[i];
for(int j = 0; j < intersectedPolygons[i].size(); j++) for(int j = 0; j < intersectedPolygons[i].size(); j++)
{ {
QPolygonF p = intersectedPolygons[i][j]; QPolygonF p = intersectedPolygons[i][j];
@ -2295,7 +2293,7 @@ void UBGraphicsScene::createPointer()
void UBGraphicsScene::setToolCursor(int tool) void UBGraphicsScene::setToolCursor(int tool)
{ {
if (tool == (int)UBStylusTool::Selector || if (tool == (int)UBStylusTool::Selector ||
tool == (int)UBStylusTool::Text || tool == (int)UBStylusTool::Text ||
tool == (int)UBStylusTool::Play) tool == (int)UBStylusTool::Play)
{ {
deselectAllItems(); deselectAllItems();
@ -2310,5 +2308,5 @@ void UBGraphicsScene::setToolCursor(int tool)
void UBGraphicsScene::initStroke() void UBGraphicsScene::initStroke()
{ {
mCurrentStroke = new UBGraphicsStroke(); mCurrentStroke = new UBGraphicsStroke();
} }

@ -48,7 +48,7 @@ UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem
: QGraphicsWebView(parent) : QGraphicsWebView(parent)
, mInitialLoadDone(false) , mInitialLoadDone(false)
, mIsFreezable(true) , mIsFreezable(true)
, mIsResizable(false) , mIsResizable(false)
, mLoadIsErronous(false) , mLoadIsErronous(false)
, mCanBeContent(0) , mCanBeContent(0)
, mCanBeTool(0) , mCanBeTool(0)
@ -56,7 +56,7 @@ UBGraphicsWidgetItem::UBGraphicsWidgetItem(const QUrl &pWidgetUrl, QGraphicsItem
, mIsFrozen(false) , mIsFrozen(false)
, mIsTakingSnapshot(false) , mIsTakingSnapshot(false)
, mShouldMoveWidget(false) , mShouldMoveWidget(false)
, mUniboardAPI(0) , mUniboardAPI(0)
{ {
setData(UBGraphicsItemData::ItemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::ItemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
@ -119,7 +119,8 @@ void UBGraphicsWidgetItem::initialize()
void UBGraphicsWidgetItem::onLinkClicked(const QUrl& url) void UBGraphicsWidgetItem::onLinkClicked(const QUrl& url)
{ {
UBApplication::webController->loadUrl(url); //UBApplication::webController->loadUrl(url);
load(url);
} }
void UBGraphicsWidgetItem::initialLayoutCompleted() void UBGraphicsWidgetItem::initialLayoutCompleted()
@ -147,24 +148,6 @@ QString UBGraphicsWidgetItem::mainHtmlFileName()
return mMainHtmlFileName; return mMainHtmlFileName;
} }
bool UBGraphicsWidgetItem::hasEmbededObjects()
{
if (page()->mainFrame()) {
QList<UBWebKitUtils::HtmlObject> htmlObjects = UBWebKitUtils::objectsInFrame(page()->mainFrame());
return htmlObjects.length() > 0;
}
return false;
}
bool UBGraphicsWidgetItem::hasEmbededFlash()
{
if (hasEmbededObjects())
return page()->mainFrame()->toHtml().contains("application/x-shockwave-flash");
else
return false;
}
bool UBGraphicsWidgetItem::canBeContent() bool UBGraphicsWidgetItem::canBeContent()
{ {
// if we under MAC OS // if we under MAC OS
@ -324,18 +307,18 @@ bool UBGraphicsWidgetItem::hasLoadedSuccessfully() const
return (mInitialLoadDone && !mLoadIsErronous); return (mInitialLoadDone && !mLoadIsErronous);
} }
bool UBGraphicsWidgetItem::freezable() bool UBGraphicsWidgetItem::freezable()
{ {
return mIsFreezable; return mIsFreezable;
} }
bool UBGraphicsWidgetItem::resizable() bool UBGraphicsWidgetItem::resizable()
{ {
return mIsResizable; return mIsResizable;
} }
bool UBGraphicsWidgetItem::isFrozen() bool UBGraphicsWidgetItem::isFrozen()
{ {
return mIsFrozen; return mIsFrozen;
} }
@ -351,7 +334,7 @@ QPixmap UBGraphicsWidgetItem::takeSnapshot()
QPixmap pixmap(size().toSize()); QPixmap pixmap(size().toSize());
pixmap.fill(Qt::transparent); pixmap.fill(Qt::transparent);
QPainter painter(&pixmap); QPainter painter(&pixmap);
QStyleOptionGraphicsItem options; QStyleOptionGraphicsItem options;
paint(&painter, &options); paint(&painter, &options);
@ -497,7 +480,7 @@ bool UBGraphicsWidgetItem::event(QEvent *event)
event->accept(); event->accept();
return true; return true;
} }
} }
else if (event->type() == QEvent::ShortcutOverride) else if (event->type() == QEvent::ShortcutOverride)
event->accept(); event->accept();
@ -813,7 +796,7 @@ UBGraphicsW3CWidgetItem::UBGraphicsW3CWidgetItem(const QUrl& pWidgetUrl, QGraphi
if (roles.contains("tmac")) if (roles.contains("tmac"))
mCanBeTool |= UBGraphicsWidgetItem::type_MAC; mCanBeTool |= UBGraphicsWidgetItem::type_MAC;
if (roles.contains("tunix")) if (roles.contains("tunix"))
mCanBeTool |= UBGraphicsWidgetItem::type_UNIX; mCanBeTool |= UBGraphicsWidgetItem::type_UNIX;
@ -886,9 +869,6 @@ UBGraphicsW3CWidgetItem::UBGraphicsW3CWidgetItem(const QUrl& pWidgetUrl, QGraphi
/* is it a valid local file ? */ /* is it a valid local file ? */
QFile f(mMainHtmlUrl.toLocalFile()); QFile f(mMainHtmlUrl.toLocalFile());
qDebug() << mMainHtmlFileName;
qDebug() << mMainHtmlUrl.toLocalFile();
if(!f.exists()) if(!f.exists())
mMainHtmlUrl = QUrl(mMainHtmlFileName); mMainHtmlUrl = QUrl(mMainHtmlFileName);
@ -1108,11 +1088,11 @@ QString UBGraphicsW3CWidgetItem::freezedWidgetPage()
if (!wrapperFile.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!wrapperFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << "can't open wrapper file " + freezedWidgetDefaultContentFilePath; qDebug() << "can't open wrapper file " + freezedWidgetDefaultContentFilePath;
defaultcontent = ""; defaultcontent = "";
} }
else { else {
QByteArray arr = wrapperFile.readAll(); QByteArray arr = wrapperFile.readAll();
if (!arr.isEmpty()) if (!arr.isEmpty())
defaultcontent = QString(arr); defaultcontent = QString(arr);
else { else {
qDebug() << "content of " + freezedWidgetDefaultContentFilePath + "is empty"; qDebug() << "content of " + freezedWidgetDefaultContentFilePath + "is empty";
defaultcontent = QString(); defaultcontent = QString();

@ -62,14 +62,11 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
QUrl widgetUrl(); QUrl widgetUrl();
QString mainHtmlFileName(); QString mainHtmlFileName();
bool hasEmbededObjects();
bool hasEmbededFlash();
bool canBeContent(); bool canBeContent();
bool canBeTool(); bool canBeTool();
QString preference(const QString& key) const; QString preference(const QString& key) const;
void setPreference(const QString& key, QString value); void setPreference(const QString& key, QString value);
QMap<QString, QString> preferences() const; QMap<QString, QString> preferences() const;
void removePreference(const QString& key); void removePreference(const QString& key);
void removeAllPreferences(); void removeAllPreferences();
@ -94,7 +91,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);
QSize nominalSize() const; QSize nominalSize() const;
bool hasLoadedSuccessfully() const; bool hasLoadedSuccessfully() const;
@ -110,7 +107,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
virtual UBGraphicsScene* scene(); virtual UBGraphicsScene* scene();
static int widgetType(const QUrl& pUrl); static int widgetType(const QUrl& pUrl);
static QString widgetName(const QUrl& pUrl); static QString widgetName(const QUrl& pUrl);
static QString iconFilePath(const QUrl& pUrl); static QString iconFilePath(const QUrl& pUrl);
public slots: public slots:
@ -127,7 +124,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
type_ALL = 7, // 0111 type_ALL = 7, // 0111
}; };
bool mFirstReleaseAfterMove; bool mFirstReleaseAfterMove;
bool mInitialLoadDone; bool mInitialLoadDone;
bool mIsFreezable; bool mIsFreezable;
bool mIsResizable; bool mIsResizable;
@ -137,7 +134,7 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
int mCanBeTool; int mCanBeTool;
QSize mNominalSize; QSize mNominalSize;
QString mMainHtmlFileName; QString mMainHtmlFileName;
QUrl mMainHtmlUrl; QUrl mMainHtmlUrl;
QUrl mWidgetUrl; QUrl mWidgetUrl;
QMap<QString, QString> mDatastore; QMap<QString, QString> mDatastore;
QMap<QString, QString> mPreferences; QMap<QString, QString> mPreferences;
@ -162,21 +159,21 @@ class UBGraphicsWidgetItem : public QGraphicsWebView, public UBItem, public UBRe
void mainFrameLoadFinished(bool ok); void mainFrameLoadFinished(bool ok);
private slots: private slots:
void onLinkClicked(const QUrl& url); void onLinkClicked(const QUrl& url);
void initialLayoutCompleted(); void initialLayoutCompleted();
private: private:
bool mIsFrozen; bool mIsFrozen;
bool mIsTakingSnapshot; bool mIsTakingSnapshot;
bool mShouldMoveWidget; bool mShouldMoveWidget;
UBWidgetUniboardAPI* mUniboardAPI; UBWidgetUniboardAPI* mUniboardAPI;
QPixmap mSnapshot; QPixmap mSnapshot;
QPointF mLastMousePos; QPointF mLastMousePos;
QUrl ownFolder; QUrl ownFolder;
QUrl SnapshotFile; QUrl SnapshotFile;
static bool sInlineJavaScriptLoaded; static bool sInlineJavaScriptLoaded;
static QStringList sInlineJavaScripts; static QStringList sInlineJavaScripts;
}; };
class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem
@ -185,11 +182,11 @@ class UBGraphicsAppleWidgetItem : public UBGraphicsWidgetItem
public: public:
UBGraphicsAppleWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent = 0); UBGraphicsAppleWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent = 0);
~UBGraphicsAppleWidgetItem(); ~UBGraphicsAppleWidgetItem();
virtual void copyItemParameters(UBItem *copy) const; virtual void copyItemParameters(UBItem *copy) const;
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
}; };
class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
@ -205,7 +202,7 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
{ {
/* NOOP */ /* NOOP */
} }
PreferenceValue(const QString& pValue, bool pReadonly) PreferenceValue(const QString& pValue, bool pReadonly)
{ {
@ -230,13 +227,13 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
}; };
UBGraphicsW3CWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent = 0); UBGraphicsW3CWidgetItem(const QUrl& pWidgetUrl, QGraphicsItem *parent = 0);
~UBGraphicsW3CWidgetItem(); ~UBGraphicsW3CWidgetItem();
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const; virtual void copyItemParameters(UBItem *copy) const;
QMap<QString, PreferenceValue> preferences(); QMap<QString, PreferenceValue> preferences();
Metadata metadatas() const; Metadata metadatas() const;
static QString freezedWidgetFilePath(); static QString freezedWidgetFilePath();
static QString createNPAPIWrapper(const QString& url, const QString& pMimeType = QString(), const QSize& sizeHint = QSize(300, 150), const QString& pName = QString()); static QString createNPAPIWrapper(const QString& url, const QString& pMimeType = QString(), const QSize& sizeHint = QSize(300, 150), const QString& pName = QString());
@ -255,11 +252,11 @@ class UBGraphicsW3CWidgetItem : public UBGraphicsWidgetItem
static QString textForSubElementByLocale(QDomElement rootElement, QString subTagName, QLocale locale); static QString textForSubElementByLocale(QDomElement rootElement, QString subTagName, QLocale locale);
UBW3CWidgetAPI* mW3CWidgetAPI; UBW3CWidgetAPI* mW3CWidgetAPI;
QMap<QString, PreferenceValue> mPreferences; QMap<QString, PreferenceValue> mPreferences;
static bool sTemplateLoaded; static bool sTemplateLoaded;
static QString sNPAPIWrappperConfigTemplate; static QString sNPAPIWrappperConfigTemplate;
static QMap<QString, QString> sNPAPIWrapperTemplates; static QMap<QString, QString> sNPAPIWrapperTemplates;
}; };
#endif // UBGRAPHICSWIDGETITEM_H #endif // UBGRAPHICSWIDGETITEM_H

Loading…
Cancel
Save