imported some fixes by hand from 2.10.b.04

preferencesAboutTextFull
Claudio Valerio 12 years ago
parent 43929f158d
commit 4ace295a28
  1. 29
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 2
      src/board/UBBoardController.cpp
  3. 49
      src/board/UBBoardView.cpp
  4. 12
      src/board/UBDrawingController.cpp
  5. 120
      src/domain/UBGraphicsItemDelegate.cpp
  6. 15
      src/domain/UBGraphicsItemDelegate.h
  7. 5
      src/domain/UBGraphicsMediaItem.cpp
  8. 5
      src/domain/UBGraphicsMediaItemDelegate.cpp
  9. 43
      src/domain/UBGraphicsScene.cpp
  10. 2
      src/domain/UBGraphicsWidgetItem.cpp
  11. 10
      src/frameworks/UBCoreGraphicsScene.cpp
  12. 4
      src/gui/UBTeacherGuideWidget.cpp
  13. 41
      src/gui/UBTeacherGuideWidgetsTools.cpp
  14. 2
      src/gui/UBTeacherGuideWidgetsTools.h
  15. 8
      src/gui/UBThumbnailWidget.cpp

@ -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()
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()
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()
{ {
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()
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
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()
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);
} }

@ -570,6 +570,8 @@ Here we determines cases when items should to get mouse press event at pressing
case UBGraphicsSvgItem::Type: case UBGraphicsSvgItem::Type:
case UBGraphicsPixmapItem::Type: case UBGraphicsPixmapItem::Type:
case UBGraphicsTextItem::Type: case UBGraphicsTextItem::Type:
if (currentTool == UBStylusTool::Play)
return true;
if ((currentTool == UBStylusTool::Selector) && item->isSelected()) if ((currentTool == UBStylusTool::Selector) && item->isSelected())
return true; return true;
if ((currentTool == UBStylusTool::Selector) && item->parentItem() && item->parentItem()->isSelected()) if ((currentTool == UBStylusTool::Selector) && item->parentItem() && item->parentItem()->isSelected())
@ -577,19 +579,19 @@ Here we determines cases when items should to get mouse press event at pressing
if (currentTool != UBStylusTool::Selector) if (currentTool != UBStylusTool::Selector)
return false; return false;
break; break;
case UBGraphicsItemType::StrokeItemType:
// Groups shouldn't reacts on any presses and moves for Play tool. if (currentTool == UBStylusTool::Play)
return true;
break;
case UBGraphicsGroupContainerItem::Type: case UBGraphicsGroupContainerItem::Type:
// Groups shouldn't reacts on any presses and moves for Play tool.
if(currentTool == UBStylusTool::Play) if(currentTool == UBStylusTool::Play)
{ {
movingItem = NULL; movingItem = NULL;
return true;
} }
return false; return false;
break; break;
//case UBToolWidget::Type:
// return true;
case QGraphicsWebView::Type: case QGraphicsWebView::Type:
return true; return true;
@ -759,12 +761,10 @@ void UBBoardView::handleItemMousePress(QMouseEvent *event)
if (isMultipleSelectionEnabled()) if (isMultipleSelectionEnabled())
return; return;
if (itemShouldReceiveMousePressEvent(movingItem)) if (itemShouldReceiveMousePressEvent(movingItem)) {
{
QGraphicsView::mousePressEvent (event); QGraphicsView::mousePressEvent (event);
} }
else else {
{
if (movingItem) if (movingItem)
{ {
UBGraphicsItem *graphicsItem = dynamic_cast<UBGraphicsItem*>(movingItem); UBGraphicsItem *graphicsItem = dynamic_cast<UBGraphicsItem*>(movingItem);
@ -898,8 +898,7 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
mIsDragInProgress = false; mIsDragInProgress = false;
if (isAbsurdPoint (event->pos ())) if (isAbsurdPoint (event->pos ())) {
{
event->accept (); event->accept ();
return; return;
} }
@ -935,8 +934,7 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
mPreviousPoint = event->posF (); mPreviousPoint = event->posF ();
event->accept (); event->accept ();
} }
else if (currentTool == UBStylusTool::Selector || currentTool == UBStylusTool::Play) else if (currentTool == UBStylusTool::Selector || currentTool == UBStylusTool::Play) {
{
if (bIsDesktop) { if (bIsDesktop) {
event->ignore(); event->ignore();
return; return;
@ -957,8 +955,7 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
mUBRubberBand->setGeometry (QRect (mMouseDownPos, QSize ())); mUBRubberBand->setGeometry (QRect (mMouseDownPos, QSize ()));
mUBRubberBand->show(); mUBRubberBand->show();
} }
else else {
{
if(mUBRubberBand) if(mUBRubberBand)
mUBRubberBand->hide(); mUBRubberBand->hide();
} }
@ -1223,22 +1220,18 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
QGraphicsView::mouseReleaseEvent (event); QGraphicsView::mouseReleaseEvent (event);
} }
} }
else if (currentTool == UBStylusTool::Play) else if (currentTool == UBStylusTool::Play) {
{
if (bIsDesktop) { if (bIsDesktop) {
event->ignore(); event->ignore();
return; return;
} }
if (mWidgetMoved) if (mWidgetMoved) {
{
movingItem = NULL; movingItem = NULL;
mWidgetMoved = false; mWidgetMoved = false;
} }
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;
delete suspendedMousePressEvent; delete suspendedMousePressEvent;
@ -1247,13 +1240,11 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
} }
QGraphicsView::mouseReleaseEvent (event); QGraphicsView::mouseReleaseEvent (event);
} }
else if (currentTool == UBStylusTool::Text) else if (currentTool == UBStylusTool::Text) {
{
if (mRubberBand) if (mRubberBand)
mRubberBand->hide (); mRubberBand->hide ();
if (scene () && mRubberBand && mIsCreatingTextZone) if (scene () && mRubberBand && mIsCreatingTextZone) {
{
QRect rubberRect = mRubberBand->geometry (); QRect rubberRect = mRubberBand->geometry ();
UBGraphicsTextItem* textItem = scene()->addTextHtml ("", mapToScene (rubberRect.topLeft ())); UBGraphicsTextItem* textItem = scene()->addTextHtml ("", mapToScene (rubberRect.topLeft ()));
@ -1265,9 +1256,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
textItem->setFocus(); textItem->setFocus();
} }
else else
{
QGraphicsView::mouseReleaseEvent (event); QGraphicsView::mouseReleaseEvent (event);
}
mIsCreatingTextZone = false; mIsCreatingTextZone = false;
} }

@ -159,36 +159,24 @@ 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();
} }
}
void UBDrawingController::setLineWidthIndex(int index) void UBDrawingController::setLineWidthIndex(int index)

@ -236,9 +236,7 @@ UBGraphicsItemDelegate::~UBGraphicsItemDelegate()
QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{ {
if(change == QGraphicsItem::ItemChildAddedChange){ if (change == QGraphicsItem::ItemSelectedHasChanged) {
}else if (change == QGraphicsItem::ItemSelectedHasChanged) {
bool ok; bool ok;
bool selected = value.toUInt(&ok); bool selected = value.toUInt(&ok);
if (ok) { if (ok) {
@ -286,6 +284,8 @@ bool UBGraphicsItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
mDragStartPosition = event->pos(); mDragStartPosition = event->pos();
mMoved = false;
startUndoStep(); startUndoStep();
if (!delegated()->isSelected()) if (!delegated()->isSelected())
@ -315,6 +315,7 @@ bool UBGraphicsItemDelegate::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
} }
mDrag->exec(); mDrag->exec();
mDragPixmap = QPixmap(); mDragPixmap = QPixmap();
mMoved = true;
return true; return true;
} }
return false; return false;
@ -439,22 +440,9 @@ void UBGraphicsItemDelegate::setZOrderButtonsVisible(bool visible)
void UBGraphicsItemDelegate::remove(bool canUndo) void UBGraphicsItemDelegate::remove(bool canUndo)
{ {
/*UBGraphicsScene* scene = dynamic_cast<UBGraphicsScene*>(mDelegated->scene());
if (scene && canUndo)
{
UBGraphicsItemUndoCommand *uc = new UBGraphicsItemUndoCommand(scene, mDelegated, 0);
UBApplication::undoStack->push(uc);
}
mDelegated->hide(); */
UBGraphicsScene* scene = dynamic_cast<UBGraphicsScene*>(mDelegated->scene()); UBGraphicsScene* scene = dynamic_cast<UBGraphicsScene*>(mDelegated->scene());
if (scene) if (scene)
{ {
// bool shownOnDisplay = mDelegated->data(UBGraphicsItemData::ItemLayerType).toInt() != UBItemLayerType::Control;
// showHide(shownOnDisplay);
// updateFrame();
// updateButtons();
if (mFrame && !mFrame->scene() && mDelegated->scene()) if (mFrame && !mFrame->scene() && mDelegated->scene())
{ {
mDelegated->scene()->addItem(mFrame); mDelegated->scene()->addItem(mFrame);
@ -734,7 +722,7 @@ void UBGraphicsItemDelegate::updateButtons(bool showUpdated)
mDelegated->scene()->addItem(mDeleteButton); mDelegated->scene()->addItem(mDeleteButton);
} }
if (showUpdated /*&& mFrame->isResizing()*/) if (showUpdated)
mDeleteButton->show(); mDeleteButton->show();
int i = 1, j = 0, k = 0; int i = 1, j = 0, k = 0;
@ -785,7 +773,6 @@ UBGraphicsToolBarItem::UBGraphicsToolBarItem(QGraphicsItem * parent) :
rect.setWidth(parent->boundingRect().width()); rect.setWidth(parent->boundingRect().width());
this->setRect(rect); this->setRect(rect);
// setBrush(QColor(UBSettings::paletteColor));
setPen(Qt::NoPen); setPen(Qt::NoPen);
hide(); hide();
@ -826,25 +813,29 @@ MediaTimer::MediaTimer(QGraphicsItem * parent): QGraphicsRectItem(parent)
{ {
val = 0; val = 0;
smallPoint = false; smallPoint = false;
setNumDigits(4); setNumDigits(6);
} }
MediaTimer::~MediaTimer() MediaTimer::~MediaTimer()
{} {}
void MediaTimer::positionHandles()
{
digitSpace = smallPoint ? 2 : 1;
ySegLen = rect().height()*5/12;
xSegLen = ySegLen*2/3;
segLen = xSegLen;
xAdvance = segLen*(5 + digitSpace)/5;
xOffset = (rect().width() - ndigits*xAdvance + segLen/5)/2;
yOffset = rect().height() - ySegLen*2;
setRect(rect().x(), rect().y(), xOffset + xAdvance*ndigits, rect().height());
}
void MediaTimer::drawString(const QString &s, QPainter &p, void MediaTimer::drawString(const QString &s, QPainter &p,
QBitArray *newPoints, bool newString) QBitArray *newPoints, bool newString)
{ {
QPoint pos; QPoint pos;
int digitSpace = smallPoint ? 2 : 1;
int xSegLen = (rect().width()/1)*5/(ndigits*(5 + digitSpace) + digitSpace);
int ySegLen = rect().height()*5/12;
int segLen = ySegLen > xSegLen ? xSegLen : ySegLen;
int xAdvance = segLen*(5 + digitSpace)/5;
int xOffset = rect().x() + (rect().width()/1 - ndigits*xAdvance + segLen/5)/2;
int yOffset = (rect().height() - segLen*2)/2;
for (int i=0; i<ndigits; i++) { for (int i=0; i<ndigits; i++) {
pos = QPoint(xOffset + xAdvance*i, yOffset); pos = QPoint(xOffset + xAdvance*i, yOffset);
if (newString) if (newString)
@ -1090,10 +1081,6 @@ void MediaTimer::paint(QPainter *p,
Q_UNUSED(option); Q_UNUSED(option);
Q_UNUSED(widget); Q_UNUSED(widget);
QFont f = p->font();
f.setPointSizeF(f.pointSizeF());
p->setFont(f);
if (smallPoint) if (smallPoint)
drawString(digitStr, *p, &points, false); drawString(digitStr, *p, &points, false);
else else
@ -1178,7 +1165,7 @@ void MediaTimer::setNumDigits(int numDigits)
numDigits = 0; numDigits = 0;
} }
if (digitStr.isNull()) { // from constructor if (digitStr.isNull()) { // from constructor
ndigits = numDigits; ndigits = numDigits + numDigits/2 - 1;
digitStr.fill(QLatin1Char(' '), ndigits); digitStr.fill(QLatin1Char(' '), ndigits);
points.fill(0, ndigits); points.fill(0, ndigits);
digitStr[ndigits - 1] = QLatin1Char('0'); // "0" is the default number digitStr[ndigits - 1] = QLatin1Char('0'); // "0" is the default number
@ -1208,6 +1195,7 @@ void MediaTimer::setNumDigits(int numDigits)
ndigits = numDigits; ndigits = numDigits;
update(); update();
} }
positionHandles();
} }
DelegateMediaControl::DelegateMediaControl(UBGraphicsMediaItem* pDelegated, QGraphicsItem * parent) DelegateMediaControl::DelegateMediaControl(UBGraphicsMediaItem* pDelegated, QGraphicsItem * parent)
@ -1238,13 +1226,6 @@ void DelegateMediaControl::paint(QPainter *painter,
QPainterPath path; QPainterPath path;
mLCDTimerArea.setHeight(rect().height());
mLCDTimerArea.setWidth(rect().height());
mSeecArea.setWidth(rect().width()-mLCDTimerArea.width()-2);
mSeecArea.setHeight(rect().height()-2*mSeecAreaBorderHeight);
mSeecArea.setY(mSeecAreaBorderHeight);
path.addRoundedRect(mSeecArea, mSeecArea.height()/2, mSeecArea.height()/2); path.addRoundedRect(mSeecArea, mSeecArea.height()/2, mSeecArea.height()/2);
painter->fillPath(path, brush()); painter->fillPath(path, brush());
@ -1274,28 +1255,59 @@ QPainterPath DelegateMediaControl::shape() const
void DelegateMediaControl::positionHandles() void DelegateMediaControl::positionHandles()
{ {
mLCDTimerArea.setWidth(parentItem()->boundingRect().height()); QRectF selfRect = rect();
selfRect.setHeight(parentItem()->boundingRect().height());
setRect(selfRect);
QTime tTotal;
tTotal = tTotal.addMSecs(mTotalTimeInMs);
mLCDTimerArea.setHeight(parentItem()->boundingRect().height()); mLCDTimerArea.setHeight(parentItem()->boundingRect().height());
int digitsCount = 2;
int timerWidth = mLCDTimerArea.height();
mDisplayFormat = "ss";
if (tTotal.minute() > 0)
{
mDisplayFormat = "mm:" + mDisplayFormat;
digitsCount += 3;
timerWidth += mLCDTimerArea.height()*0.5;
}
if (tTotal.hour() > 0)
{
mDisplayFormat = "hh:" + mDisplayFormat;
digitsCount += 3;
timerWidth += mLCDTimerArea.height();
}
lcdTimer->setNumDigits(digitsCount);
mLCDTimerArea.setWidth(timerWidth);
lcdTimer->setRect(mLCDTimerArea); lcdTimer->setRect(mLCDTimerArea);
lcdTimer->setPos(mSeecArea.width()-mLCDTimerArea.width(),0);
// not the best solution, but it works.
lcdTimer->positionHandles();
mLCDTimerArea = lcdTimer->rect();
// -------------------------------------
lcdTimer->setPos(rect().width() - mLCDTimerArea.width(), 0);
mSeecAreaBorderHeight = rect().height()/20; mSeecAreaBorderHeight = rect().height()/20;
mSeecArea.setWidth(rect().width()-mLCDTimerArea.width()-2); mSeecArea.setWidth(rect().width()-mLCDTimerArea.width()-2);
mSeecArea.setHeight(rect().height()-2*mSeecAreaBorderHeight); mSeecArea.setHeight(rect().height()-2*mSeecAreaBorderHeight);
mSeecArea.setY(mSeecAreaBorderHeight); mSeecArea.setY(mSeecAreaBorderHeight);
QRectF selfRect = rect();
selfRect.setHeight(parentItem()->boundingRect().height());
setRect(selfRect);
lcdTimer->setPos(rect().width() - mLCDTimerArea.width(), 0);
} }
void DelegateMediaControl::update() void DelegateMediaControl::update()
{ {
QTime t; QTime tCurrent;
t = t.addMSecs(mCurrentTimeInMs < 0 ? 0 : mCurrentTimeInMs); tCurrent = tCurrent.addMSecs(mCurrentTimeInMs < 0 ? 0 : mCurrentTimeInMs);
lcdTimer->display(t.toString("m:ss"));
lcdTimer->display(tCurrent.toString(mDisplayFormat));
QGraphicsRectItem::update(); QGraphicsRectItem::update();
} }
@ -1308,10 +1320,14 @@ void DelegateMediaControl::updateTicker(qint64 time )
void DelegateMediaControl::totalTimeChanged(qint64 newTotalTime) void DelegateMediaControl::totalTimeChanged(qint64 newTotalTime)
{
if (mTotalTimeInMs != newTotalTime)
{ {
mTotalTimeInMs = newTotalTime; mTotalTimeInMs = newTotalTime;
positionHandles();
update(); update();
} }
}
void DelegateMediaControl::mousePressEvent(QGraphicsSceneMouseEvent *event) void DelegateMediaControl::mousePressEvent(QGraphicsSceneMouseEvent *event)
@ -1347,7 +1363,7 @@ void DelegateMediaControl::seekToMousePos(QPointF mousePos)
qreal frameWidth = rect().height() / 2; qreal frameWidth = rect().height() / 2;
minX = frameWidth; minX = frameWidth;
length = mSeecArea.width() - lcdTimer->rect().width(); length = mSeecArea.width() - mSeecArea.height();
qreal mouseX = mousePos.x(); qreal mouseX = mousePos.x();
if (mouseX >= (mSeecArea.width() - mSeecArea.height()/2)) if (mouseX >= (mSeecArea.width() - mSeecArea.height()/2))

@ -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:
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:
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
QRectF mLCDTimerArea; QRectF mLCDTimerArea;
MediaTimer *lcdTimer; MediaTimer *lcdTimer;
QString mDisplayFormat;
}; };
class UBGraphicsToolBarItem : public QGraphicsRectItem, public QObject class UBGraphicsToolBarItem : public QGraphicsRectItem, public QObject
@ -340,6 +351,8 @@ private:
bool mToolBarUsed; bool mToolBarUsed;
bool mShowGoContentButton; bool mShowGoContentButton;
bool mMoved;
}; };

@ -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,7 +116,7 @@ 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;

@ -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()
{ {
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()
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
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
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
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
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
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;
} }
@ -2287,8 +2277,7 @@ 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,6 +609,8 @@ void UBGraphicsWidgetItem::mainFrameLoadFinished (bool ok)
{ {
mLoadIsErronous = !ok; mLoadIsErronous = !ok;
update(boundingRect()); update(boundingRect());
if (mInitialLoadDone && scene() && scene()->renderingContext() == UBGraphicsScene::Screen)
takeSnapshot(); takeSnapshot();
} }

@ -40,16 +40,10 @@ 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)
{
if (item->scene() == NULL || item->scene() == this)
{
delete item; delete item;
} }
}
}
mItemsToDelete.clear(); mItemsToDelete.clear();
} }

@ -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)
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,15 +265,41 @@ 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()){
setTextColor(QColor(Qt::lightGray)); setTextColor(QColor(Qt::lightGray));

@ -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:
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
, 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)
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);

Loading…
Cancel
Save