Commit 4ace295a authored by Claudio Valerio's avatar Claudio Valerio

imported some fixes by hand from 2.10.b.04

parent 43929f15
...@@ -597,12 +597,12 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() ...@@ -597,12 +597,12 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
QList<UBGraphicsPolygonItem*> polygonItems QList<UBGraphicsPolygonItem*> polygonItems
= polygonItemsFromPolylineSvg(mScene->isDarkBackground() ? Qt::white : Qt::black); = polygonItemsFromPolylineSvg(mScene->isDarkBackground() ? Qt::white : Qt::black);
QString newParentId = QUuid::createUuid().toString();
foreach(UBGraphicsPolygonItem* polygonItem, polygonItems) foreach(UBGraphicsPolygonItem* polygonItem, polygonItems)
{ {
if (annotationGroup) if (annotationGroup)
{
polygonItem->setStroke(annotationGroup); polygonItem->setStroke(annotationGroup);
}
if(strokesGroup){ if(strokesGroup){
...@@ -614,6 +614,10 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() ...@@ -614,6 +614,10 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic)); polygonItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Graphic));
QString parentId = mXmlReader.attributes().value(mNamespaceUri, "parent").toString(); QString parentId = mXmlReader.attributes().value(mNamespaceUri, "parent").toString();
if(parentId.isEmpty())
parentId = newParentId;
Q_ASSERT(!parentId.isEmpty()); Q_ASSERT(!parentId.isEmpty());
UBGraphicsStrokesGroup* group; UBGraphicsStrokesGroup* group;
if(!mStrokesList.contains(parentId)){ if(!mStrokesList.contains(parentId)){
...@@ -623,8 +627,10 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() ...@@ -623,8 +627,10 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
else else
group = mStrokesList.value(parentId); group = mStrokesList.value(parentId);
group->addToGroup(polygonItem);
polygonItem->show(); polygonItem->show();
} }
} }
else if (mXmlReader.name() == "image") else if (mXmlReader.name() == "image")
{ {
...@@ -984,10 +990,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() ...@@ -984,10 +990,6 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
{ {
if (mXmlReader.name() == "g") if (mXmlReader.name() == "g")
{ {
// if(strokesGroup && mScene){
// mScene->addItem(strokesGroup);
// }
if (annotationGroup) if (annotationGroup)
{ {
if (!annotationGroup->polygons().empty()) if (!annotationGroup->polygons().empty())
...@@ -1010,12 +1012,12 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene() ...@@ -1010,12 +1012,12 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
QMapIterator<QString, UBGraphicsStrokesGroup*> iterator(mStrokesList); QMapIterator<QString, UBGraphicsStrokesGroup*> iterator(mStrokesList);
while (iterator.hasNext()) { while (iterator.hasNext()) {
iterator.next(); iterator.next();
qDebug() << "Number of polygons : " << (int)(((UBGraphicsStrokesGroup*)iterator.value())->childItems().count());
mScene->addItem(iterator.value()); mScene->addItem(iterator.value());
} }
if (mScene) { if (mScene)
mScene->setModified(false); mScene->setModified(false);
}
if (annotationGroup && annotationGroup->polygons().empty()){ if (annotationGroup && annotationGroup->polygons().empty()){
delete annotationGroup; delete annotationGroup;
...@@ -1557,17 +1559,8 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistGroupToDom(QGraphicsItem *gro ...@@ -1557,17 +1559,8 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistGroupToDom(QGraphicsItem *gro
foreach (QGraphicsItem *item, groupItem->childItems()) { foreach (QGraphicsItem *item, groupItem->childItems()) {
QUuid tmpUuid = UBGraphicsScene::getPersonalUuid(item); QUuid tmpUuid = UBGraphicsScene::getPersonalUuid(item);
if (!tmpUuid.isNull()) { if (!tmpUuid.isNull()) {
if (item->type() == UBGraphicsGroupContainerItem::Type && item->childItems().count()) { if (item->type() == UBGraphicsGroupContainerItem::Type && item->childItems().count())
persistGroupToDom(item, curParent, groupDomDocument); persistGroupToDom(item, curParent, groupDomDocument);
}
// else if (item->type() == UBGraphicsStrokesGroup::Type) {
// foreach (QGraphicsItem *polygonItem, item->childItems()) {
// QDomElement curPolygonElement = groupDomDocument->createElement(tElement);
// curPolygonElement.setAttribute(aId, tmpUuid.toString()
// + UBGraphicsItem::getOwnUuid(polygonItem).toString());
// curGroupElement.appendChild(curPolygonElement);
// }
// }
else { else {
QDomElement curSubElement = groupDomDocument->createElement(tElement); QDomElement curSubElement = groupDomDocument->createElement(tElement);
......
...@@ -357,9 +357,7 @@ void UBBoardController::setupToolbar() ...@@ -357,9 +357,7 @@ void UBBoardController::setupToolbar()
void UBBoardController::setToolCursor(int tool) void UBBoardController::setToolCursor(int tool)
{ {
if (mActiveScene) if (mActiveScene)
{
mActiveScene->setToolCursor(tool); mActiveScene->setToolCursor(tool);
}
mControlView->setToolCursor(tool); mControlView->setToolCursor(tool);
} }
...@@ -648,7 +646,7 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item, bool bAsync) ...@@ -648,7 +646,7 @@ UBGraphicsItem *UBBoardController::duplicateItem(UBItem *item, bool bAsync)
QList<QGraphicsItem*> duplicatedItems; QList<QGraphicsItem*> duplicatedItems;
QList<QGraphicsItem*> children = groupItem->childItems(); QList<QGraphicsItem*> children = groupItem->childItems();
mActiveScene->setURStackEnable(false); mActiveScene->setURStackEnable(false);
foreach(QGraphicsItem* pIt, children){ foreach(QGraphicsItem* pIt, children){
UBItem* pItem = dynamic_cast<UBItem*>(pIt); UBItem* pItem = dynamic_cast<UBItem*>(pIt);
......
This diff is collapsed.
...@@ -159,35 +159,23 @@ bool UBDrawingController::isDrawingTool() ...@@ -159,35 +159,23 @@ bool UBDrawingController::isDrawingTool()
int UBDrawingController::currentToolWidthIndex() int UBDrawingController::currentToolWidthIndex()
{ {
if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line) if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line)
{
return UBSettings::settings()->penWidthIndex(); return UBSettings::settings()->penWidthIndex();
}
else if (stylusTool() == UBStylusTool::Marker) else if (stylusTool() == UBStylusTool::Marker)
{
return UBSettings::settings()->markerWidthIndex(); return UBSettings::settings()->markerWidthIndex();
}
else else
{
return -1; return -1;
}
} }
qreal UBDrawingController::currentToolWidth() qreal UBDrawingController::currentToolWidth()
{ {
if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line) if (stylusTool() == UBStylusTool::Pen || stylusTool() == UBStylusTool::Line)
{
return UBSettings::settings()->currentPenWidth(); return UBSettings::settings()->currentPenWidth();
}
else if (stylusTool() == UBStylusTool::Marker) else if (stylusTool() == UBStylusTool::Marker)
{
return UBSettings::settings()->currentMarkerWidth(); return UBSettings::settings()->currentMarkerWidth();
}
else else
{
//failsafe //failsafe
return UBSettings::settings()->currentPenWidth(); return UBSettings::settings()->currentPenWidth();
}
} }
......
...@@ -50,17 +50,17 @@ struct UBStylusTool ...@@ -50,17 +50,17 @@ struct UBStylusTool
{ {
enum Enum enum Enum
{ {
Pen = 0, Pen = 0,
Eraser, Eraser,
Marker, Marker,
Selector, Selector,
Play, Play,
Hand, Hand,
ZoomIn, ZoomIn,
ZoomOut, ZoomOut,
Pointer, Pointer,
Line, Line,
Text, Text,
Capture Capture
}; };
}; };
...@@ -138,17 +138,17 @@ struct UBGraphicsItemType ...@@ -138,17 +138,17 @@ struct UBGraphicsItemType
{ {
enum Enum enum Enum
{ {
PolygonItemType = QGraphicsItem::UserType + 1, PolygonItemType = QGraphicsItem::UserType + 1,
PixmapItemType, PixmapItemType,
SvgItemType, SvgItemType,
DelegateButtonType, DelegateButtonType,
MediaItemType, MediaItemType,
PDFItemType, PDFItemType,
TextItemType, TextItemType,
CurtainItemType, CurtainItemType,
RulerItemType, RulerItemType,
CompassItemType, CompassItemType,
ProtractorItemType, ProtractorItemType,
StrokeItemType, StrokeItemType,
TriangleItemType, TriangleItemType,
MagnifierItemType, MagnifierItemType,
......
This diff is collapsed.
...@@ -104,10 +104,12 @@ public: ...@@ -104,10 +104,12 @@ public:
MediaTimer(QGraphicsItem * parent = 0); MediaTimer(QGraphicsItem * parent = 0);
~MediaTimer(); ~MediaTimer();
void positionHandles();
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget); QWidget *widget);
void display(const QString &str); void display(const QString &str);
void setNumDigits(int nDigits);
private: private:
...@@ -117,7 +119,6 @@ private: ...@@ -117,7 +119,6 @@ private:
void drawSegment(const QPoint &, char, QPainter &, int, bool = false); void drawSegment(const QPoint &, char, QPainter &, int, bool = false);
void addPoint(QPolygon&, const QPoint&); void addPoint(QPolygon&, const QPoint&);
void internalSetString(const QString& s); void internalSetString(const QString& s);
void setNumDigits(int nDigits);
static char segments [][8]; static char segments [][8];
...@@ -128,6 +129,14 @@ private: ...@@ -128,6 +129,14 @@ private:
uint shadow : 1; uint shadow : 1;
uint smallPoint : 1; uint smallPoint : 1;
int digitSpace;
int xSegLen;
int ySegLen;
int segLen;
int xAdvance;
int xOffset;
int yOffset;
}; };
class DelegateMediaControl: public QObject, public QGraphicsRectItem class DelegateMediaControl: public QObject, public QGraphicsRectItem
...@@ -178,6 +187,8 @@ class DelegateMediaControl: public QObject, public QGraphicsRectItem ...@@ -178,6 +187,8 @@ class DelegateMediaControl: public QObject, public QGraphicsRectItem
QRectF mLCDTimerArea; QRectF mLCDTimerArea;
MediaTimer *lcdTimer; MediaTimer *lcdTimer;
QString mDisplayFormat;
}; };
class UBGraphicsToolBarItem : public QGraphicsRectItem, public QObject class UBGraphicsToolBarItem : public QGraphicsRectItem, public QObject
...@@ -189,7 +200,7 @@ class UBGraphicsToolBarItem : public QGraphicsRectItem, public QObject ...@@ -189,7 +200,7 @@ class UBGraphicsToolBarItem : public QGraphicsRectItem, public QObject
bool isVisibleOnBoard() const { return mVisible; } bool isVisibleOnBoard() const { return mVisible; }
void setVisibleOnBoard(bool visible) { mVisible = visible; } void setVisibleOnBoard(bool visible) { mVisible = visible; }
bool isShifting() const { return mShifting; } bool isShifting() const { return mShifting; }
void setShifting(bool shifting) { mShifting = shifting; } void setShifting(bool shifting) { mShifting = shifting; }
QList<QGraphicsItem*> itemsOnToolBar() const { return mItemsOnToolBar; } QList<QGraphicsItem*> itemsOnToolBar() const { return mItemsOnToolBar; }
void setItemsOnToolBar(QList<QGraphicsItem*> itemsOnToolBar) { mItemsOnToolBar = itemsOnToolBar;} void setItemsOnToolBar(QList<QGraphicsItem*> itemsOnToolBar) { mItemsOnToolBar = itemsOnToolBar;}
int minWidth() { return mMinWidth; } int minWidth() { return mMinWidth; }
...@@ -340,6 +351,8 @@ private: ...@@ -340,6 +351,8 @@ private:
bool mToolBarUsed; bool mToolBarUsed;
bool mShowGoContentButton; bool mShowGoContentButton;
bool mMoved;
}; };
......
...@@ -85,7 +85,7 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte ...@@ -85,7 +85,7 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
if ("" == mediaPath) if ("" == mediaPath)
mediaPath = pMediaFileUrl.toLocalFile(); mediaPath = pMediaFileUrl.toLocalFile();
if (mediaPath.toLower().contains("videos")) if (mediaPath.toLower().contains("videos"))
{ {
mMediaType = mediaType_Video; mMediaType = mediaType_Video;
...@@ -102,8 +102,7 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte ...@@ -102,8 +102,7 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
haveLinkedImage = true; haveLinkedImage = true;
} }
else else if (mediaPath.toLower().contains("audios"))
if (mediaPath.toLower().contains("audios"))
{ {
mMediaType = mediaType_Audio; mMediaType = mediaType_Audio;
mAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this); mAudioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
...@@ -117,20 +116,20 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte ...@@ -117,20 +116,20 @@ UBGraphicsMediaItem::UBGraphicsMediaItem(const QUrl& pMediaFileUrl, QGraphicsIte
borderSize = pAudioWidget->borderSize(); borderSize = pAudioWidget->borderSize();
} }
mAudioWidget->resize(320,26+3*borderSize); mAudioWidget->resize(320,26+2*borderSize); //3*border size with enabled title
mAudioWidget->setMinimumSize(150,26+borderSize); mAudioWidget->setMinimumSize(150,26+borderSize);
haveLinkedImage = false; haveLinkedImage = false;
} }
Phonon::createPath(mMediaObject, mAudioOutput); Phonon::createPath(mMediaObject, mAudioOutput);
mSource = Phonon::MediaSource(pMediaFileUrl); mSource = Phonon::MediaSource(pMediaFileUrl);
mMediaObject->setCurrentSource(mSource); mMediaObject->setCurrentSource(mSource);
// we should create delegate after media objects because delegate uses his properties at creation. // we should create delegate after media objects because delegate uses his properties at creation.
setDelegate(new UBGraphicsMediaItemDelegate(this, mMediaObject)); setDelegate(new UBGraphicsMediaItemDelegate(this, mMediaObject));
// delegate should be created earler because we setWidget calls resize event for graphics proxy widgt. // delegate should be created earler because we setWidget calls resize event for graphics proxy widgt.
// resize uses delegate. // resize uses delegate.
if (mediaType_Video == mMediaType) if (mediaType_Video == mMediaType)
...@@ -320,13 +319,13 @@ void UBGraphicsMediaItem::mousePressEvent(QGraphicsSceneMouseEvent *event) ...@@ -320,13 +319,13 @@ void UBGraphicsMediaItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
QGraphicsItem *curItem = group->getCurrentItem(); QGraphicsItem *curItem = group->getCurrentItem();
if (curItem && this != curItem) if (curItem && this != curItem)
{ {
group->deselectCurrentItem(); group->deselectCurrentItem();
} }
group->setCurrentItem(this); group->setCurrentItem(this);
this->setSelected(true); this->setSelected(true);
Delegate()->positionHandles(); Delegate()->positionHandles();
} }
} }
} }
...@@ -339,7 +338,7 @@ void UBGraphicsMediaItem::mousePressEvent(QGraphicsSceneMouseEvent *event) ...@@ -339,7 +338,7 @@ void UBGraphicsMediaItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
event->accept(); event->accept();
} }
} }
else else
{ {
mShouldMove = (event->buttons() & Qt::LeftButton); mShouldMove = (event->buttons() & Qt::LeftButton);
mMousePressPos = event->scenePos(); mMousePressPos = event->scenePos();
......
...@@ -255,6 +255,11 @@ void UBGraphicsMediaItemDelegate::mediaStateChanged ( Phonon::State newstate, Ph ...@@ -255,6 +255,11 @@ void UBGraphicsMediaItemDelegate::mediaStateChanged ( Phonon::State newstate, Ph
{ {
Q_UNUSED(newstate); Q_UNUSED(newstate);
Q_UNUSED(oldstate); Q_UNUSED(oldstate);
if (oldstate == Phonon::LoadingState)
{
mMediaControl->totalTimeChanged(delegated()->mediaObject()->totalTime());
}
updatePlayPauseState(); updatePlayPauseState();
} }
......
...@@ -335,8 +335,8 @@ void UBGraphicsScene::updateGroupButtonState() ...@@ -335,8 +335,8 @@ void UBGraphicsScene::updateGroupButtonState()
{ {
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool(); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
if (UBStylusTool::Selector != currentTool) if (UBStylusTool::Selector != currentTool && UBStylusTool::Play != currentTool)
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); return;
QAction *groupAction = UBApplication::mainWindow->actionGroupItems; QAction *groupAction = UBApplication::mainWindow->actionGroupItems;
QList<QGraphicsItem*> selItems = selectedItems(); QList<QGraphicsItem*> selItems = selectedItems();
...@@ -362,24 +362,18 @@ void UBGraphicsScene::updateGroupButtonState() ...@@ -362,24 +362,18 @@ void UBGraphicsScene::updateGroupButtonState()
bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pressure) bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pressure)
{ {
//mMesure1Ms = 0;
//mMesure2Ms = 0;
bool accepted = false; bool accepted = false;
if (mInputDeviceIsPressed) if (mInputDeviceIsPressed) {
{
qWarning() << "scene received input device pressed, without input device release, muting event as input device move"; qWarning() << "scene received input device pressed, without input device release, muting event as input device move";
accepted = inputDeviceMove(scenePos, pressure); accepted = inputDeviceMove(scenePos, pressure);
} }
else else {
{
mInputDeviceIsPressed = true; mInputDeviceIsPressed = true;
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool(); UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
if (UBDrawingController::drawingController()->isDrawingTool()) if (UBDrawingController::drawingController()->isDrawingTool()) {
{
// ----------------------------------------------------------------- // -----------------------------------------------------------------
// We fall here if we are using the Pen, the Marker or the Line tool // We fall here if we are using the Pen, the Marker or the Line tool
// ----------------------------------------------------------------- // -----------------------------------------------------------------
...@@ -399,7 +393,8 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre ...@@ -399,7 +393,8 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
if (currentTool != UBStylusTool::Line){ if (currentTool != UBStylusTool::Line){
// Handle the pressure // Handle the pressure
width = UBDrawingController::drawingController()->currentToolWidth() * pressure; width = UBDrawingController::drawingController()->currentToolWidth() * pressure;
}else{ }
else{
// Ignore pressure for the line tool // Ignore pressure for the line tool
width = UBDrawingController::drawingController()->currentToolWidth(); width = UBDrawingController::drawingController()->currentToolWidth();
} }
...@@ -411,18 +406,14 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre ...@@ -411,18 +406,14 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
mRemovedItems.clear(); mRemovedItems.clear();
if (UBDrawingController::drawingController()->mActiveRuler) if (UBDrawingController::drawingController()->mActiveRuler)
{
UBDrawingController::drawingController()->mActiveRuler->StartLine(scenePos, width); UBDrawingController::drawingController()->mActiveRuler->StartLine(scenePos, width);
} else {
else
{
moveTo(scenePos); moveTo(scenePos);
drawLineTo(scenePos, width, UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line); drawLineTo(scenePos, width, UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line);
} }
accepted = true; accepted = true;
} }
else if (currentTool == UBStylusTool::Eraser) else if (currentTool == UBStylusTool::Eraser) {
{
mAddedItems.clear(); mAddedItems.clear();
mRemovedItems.clear(); mRemovedItems.clear();
moveTo(scenePos); moveTo(scenePos);
...@@ -436,8 +427,7 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre ...@@ -436,8 +427,7 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
accepted = true; accepted = true;
} }
else if (currentTool == UBStylusTool::Pointer) else if (currentTool == UBStylusTool::Pointer) {
{
drawPointer(scenePos, true); drawPointer(scenePos, true);
accepted = true; accepted = true;
} }
...@@ -516,7 +506,8 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres ...@@ -516,7 +506,8 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
if(dc->mActiveRuler){ if(dc->mActiveRuler){
dc->mActiveRuler->DrawLine(position, width); dc->mActiveRuler->DrawLine(position, width);
}else{ }
else{
drawLineTo(position, width, UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line); drawLineTo(position, width, UBDrawingController::drawingController()->stylusTool() == UBStylusTool::Line);
} }
} }
...@@ -1487,15 +1478,14 @@ UBGraphicsTextItem* UBGraphicsScene::textForObjectName(const QString& pString, c ...@@ -1487,15 +1478,14 @@ UBGraphicsTextItem* UBGraphicsScene::textForObjectName(const QString& pString, c
if(!textItem){ if(!textItem){
textItem = addTextWithFont(pString,QPointF(0,0) ,72,UBSettings::settings()->fontFamily(),true,false); textItem = addTextWithFont(pString,QPointF(0,0) ,72,UBSettings::settings()->fontFamily(),true,false);
textItem->setObjectName(objectName); textItem->setObjectName(objectName);
QSizeF size = textItem->size();
textItem->setPos(QPointF(-size.width()/2.0,-size.height()/2.0));
textItem->setData(UBGraphicsItemData::ItemEditable,QVariant(false)); textItem->setData(UBGraphicsItemData::ItemEditable,QVariant(false));
textItem->adjustSize();
textItem->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
} }
textItem->setPlainText(pString); textItem->setPlainText(pString);
textItem->adjustSize();
textItem->clearFocus(); textItem->clearFocus();
textItem->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
return textItem; return textItem;
} }
...@@ -2286,9 +2276,8 @@ void UBGraphicsScene::createPointer() ...@@ -2286,9 +2276,8 @@ 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();
} }
......
...@@ -609,7 +609,9 @@ void UBGraphicsWidgetItem::mainFrameLoadFinished (bool ok) ...@@ -609,7 +609,9 @@ void UBGraphicsWidgetItem::mainFrameLoadFinished (bool ok)
{ {
mLoadIsErronous = !ok; mLoadIsErronous = !ok;
update(boundingRect()); update(boundingRect());
takeSnapshot();
if (mInitialLoadDone && scene() && scene()->renderingContext() == UBGraphicsScene::Screen)
takeSnapshot();
} }
void UBGraphicsWidgetItem::wheelEvent(QGraphicsSceneWheelEvent *event) void UBGraphicsWidgetItem::wheelEvent(QGraphicsSceneWheelEvent *event)
......
...@@ -40,15 +40,9 @@ UBCoreGraphicsScene::~UBCoreGraphicsScene() ...@@ -40,15 +40,9 @@ UBCoreGraphicsScene::~UBCoreGraphicsScene()
{ {
//we must delete removed items that are no more in any scene //we must delete removed items that are no more in any scene
//at groups deleting some items can be added to mItemsToDelete, so we need to use iterators. //at groups deleting some items can be added to mItemsToDelete, so we need to use iterators.
foreach(QGraphicsItem* item, mItemsToDelete) foreach(QGraphicsItem* item, mItemsToDelete){
{ if (item && item->type() != UBGraphicsItemType::PolygonItemType && item->type() != QGraphicsItem::UserType && item->type() != UBGraphicsItemType::groupContainerType && (item->scene() == NULL || item->scene() == this))
if (item) delete item;
{
if (item->scene() == NULL || item->scene() == this)
{
delete item;
}
}
} }
mItemsToDelete.clear(); mItemsToDelete.clear();
} }
...@@ -62,7 +56,7 @@ void UBCoreGraphicsScene::addItem(QGraphicsItem* item) ...@@ -62,7 +56,7 @@ void UBCoreGraphicsScene::addItem(QGraphicsItem* item)
removeItemFromDeletion(curItem); removeItemFromDeletion(curItem);
} }
} }
if (item->scene() != this) if (item->scene() != this)
QGraphicsScene::addItem(item); QGraphicsScene::addItem(item);
......
...@@ -98,13 +98,13 @@ UBNavigatorPalette::~UBNavigatorPalette() ...@@ -98,13 +98,13 @@ UBNavigatorPalette::~UBNavigatorPalette()
} }
if(NULL != mLayout) if(NULL != mLayout)
{ {
delete mLayout; delete mLayout;
mLayout = NULL; mLayout = NULL;
} }
if(NULL != mNavigator) if(NULL != mNavigator)
{ {
delete mNavigator; delete mNavigator;
mNavigator = NULL; mNavigator = NULL;
} }
} }
......
...@@ -273,8 +273,8 @@ void UBTeacherGuideEditionWidget::onActiveSceneChanged() ...@@ -273,8 +273,8 @@ void UBTeacherGuideEditionWidget::onActiveSceneChanged()
void UBTeacherGuideEditionWidget::cleanData() void UBTeacherGuideEditionWidget::cleanData()
{ {
mpPageTitle->setText(""); mpPageTitle->resetText();
mpComment->setText(""); mpComment->resetText();
QList<QTreeWidgetItem*> children = mpAddAnActionItem->takeChildren(); QList<QTreeWidgetItem*> children = mpAddAnActionItem->takeChildren();
children << mpAddAMediaItem->takeChildren(); children << mpAddAMediaItem->takeChildren();
children << mpAddALinkItem->takeChildren(); children << mpAddALinkItem->takeChildren();
......
...@@ -224,6 +224,19 @@ void UBTGAdaptableText::setInitialText(const QString& text) ...@@ -224,6 +224,19 @@ void UBTGAdaptableText::setInitialText(const QString& text)
onTextChanged(); onTextChanged();
} }
void UBTGAdaptableText::resetText()
{
if(mHasPlaceHolder && !mPlaceHolderText.isEmpty()){
setTextColor(QColor(Qt::lightGray));
setText(mPlaceHolderText);
}
else{
setText("");
setTextColor(QColor(Qt::black));
}
onTextChanged();
}
void UBTGAdaptableText::showText(const QString & text) void UBTGAdaptableText::showText(const QString & text)
{ {
setText(text); setText(text);
...@@ -252,14 +265,40 @@ void UBTGAdaptableText::focusOutEvent(QFocusEvent* e) ...@@ -252,14 +265,40 @@ void UBTGAdaptableText::focusOutEvent(QFocusEvent* e)
QTextEdit::focusOutEvent(e); QTextEdit::focusOutEvent(e);
} }
void UBTGAdaptableText::insertFromMimeData(const QMimeData *source)
{
QMimeData editedMimeData;
QTextDocument textDoc;
QString plainText;
if (source->hasHtml())
{
textDoc.setHtml(source->html());
plainText += textDoc.toPlainText();
}
if (source->hasText())
if (textDoc.toPlainText() != source->text())
plainText += source->text();
if (source->hasUrls())
{
foreach(QUrl url, source->urls())
{
plainText += url.toString();
}
}
editedMimeData.setText(plainText);
QTextEdit::insertFromMimeData(&editedMimeData);
}
void UBTGAdaptableText::managePlaceholder(bool focus) void UBTGAdaptableText::managePlaceholder(bool focus)
{ {
if(focus){ if(focus){
if(toPlainText() == mPlaceHolderText){ if(toPlainText() == mPlaceHolderText){
setTextColor(QColor(Qt::black)); setTextColor(QColor(Qt::black));
setPlainText(""); setPlainText("");
setCursorToTheEnd();
} }
setCursorToTheEnd();
} }
else{ else{
if(toPlainText().isEmpty()){ if(toPlainText().isEmpty()){
...@@ -537,9 +576,9 @@ void UBTGMediaWidget::createWorkWidget(bool forceFlashMediaType) ...@@ -537,9 +576,9 @@ void UBTGMediaWidget::createWorkWidget(bool forceFlashMediaType)
mpMediaLayout = new QHBoxLayout(mpWorkWidget); mpMediaLayout = new QHBoxLayout(mpWorkWidget);
mpWorkWidget->setLayout(mpMediaLayout); mpWorkWidget->setLayout(mpMediaLayout);
} }
mpMediaLayout->addStretch(1); mpMediaLayout->addStretch(1);
if(mpMediaLabelWidget){ if(mpMediaLabelWidget){
mpMediaLabelWidget->setFixedHeight(mMediaWidgetHeight); mpMediaLabelWidget->setFixedHeight(mMediaWidgetHeight);
mpMediaLabelWidget->setParent(mpWorkWidget); mpMediaLabelWidget->setParent(mpWorkWidget);
......
...@@ -103,6 +103,7 @@ class UBTGAdaptableText : public QTextEdit ...@@ -103,6 +103,7 @@ class UBTGAdaptableText : public QTextEdit
public: public:
explicit UBTGAdaptableText(QTreeWidgetItem* widget = 0, QWidget *parent = 0, const char* name = "UBTGAdaptableText"); explicit UBTGAdaptableText(QTreeWidgetItem* widget = 0, QWidget *parent = 0, const char* name = "UBTGAdaptableText");
void showText(const QString & text); void showText(const QString & text);
void resetText();
void bottomMargin(int newValue); void bottomMargin(int newValue);
void setPlaceHolderText(QString text); void setPlaceHolderText(QString text);
QString text(); QString text();
...@@ -118,6 +119,7 @@ protected: ...@@ -118,6 +119,7 @@ protected:
void showEvent(QShowEvent* e); void showEvent(QShowEvent* e);
void focusInEvent(QFocusEvent* e); void focusInEvent(QFocusEvent* e);
void focusOutEvent(QFocusEvent* e); void focusOutEvent(QFocusEvent* e);
virtual void insertFromMimeData(const QMimeData *source);
private: private:
void setCursorToTheEnd(); void setCursorToTheEnd();
......
...@@ -87,6 +87,7 @@ void UBThumbnailWidget::setGraphicsItems(const QList<QGraphicsItem*>& pGraphicsI ...@@ -87,6 +87,7 @@ void UBThumbnailWidget::setGraphicsItems(const QList<QGraphicsItem*>& pGraphicsI
, const QStringList pLabels , const QStringList pLabels
, const QString& pMimeType) , const QString& pMimeType)
{ {
Q_ASSERT(pItemsPaths.count() == pLabels.count());
mGraphicItems = pGraphicsItems; mGraphicItems = pGraphicsItems;
mItemsPaths = pItemsPaths; mItemsPaths = pItemsPaths;
mMimeType = pMimeType; mMimeType = pMimeType;
...@@ -224,13 +225,6 @@ void UBThumbnailWidget::mousePressEvent(QMouseEvent *event) ...@@ -224,13 +225,6 @@ void UBThumbnailWidget::mousePressEvent(QMouseEvent *event)
event->ignore(); event->ignore();
return; return;
} }
//if(sceneItem){
// int pageIndex = UBDocumentContainer::pageFromSceneIndex(sceneItem->sceneIndex());
// if(pageIndex == 0){
// event->ignore();
// return;
// }
//}
mMousePressScenePos = mapToScene(mMousePressPos); mMousePressScenePos = mapToScene(mMousePressPos);
QGraphicsItem* underlyingItem = itemAt(mMousePressPos); QGraphicsItem* underlyingItem = itemAt(mMousePressPos);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment