Merge branch 'master' of github.com:Sankore/Sankore-3.1

preferencesAboutTextFull
Aleksei Kanash 13 years ago
commit c29832a58c
  1. 22
      resources/library/interactivities/Choisir.wgt/scripts/languages.js
  2. 2
      resources/library/interactivities/associer_images.wgt/js/script.js
  3. 2
      resources/library/interactivities/categoriser_images.wgt/js/script.js
  4. 4
      resources/library/interactivities/categoriser_text.wgt/js/script.js
  5. 4
      resources/library/interactivities/etudier.wgt/js/script.js
  6. 2
      resources/library/interactivities/ord-words.wgt/locales/fr/scripts/template2.js
  7. 6
      resources/library/interactivities/ordonner_des_images.wgt/locales/fr/js/script.js
  8. 6
      resources/library/interactivities/ordonner_des_letters.wgt/locales/fr/js/script.js
  9. 4
      resources/library/interactivities/selectionner.wgt/locales/fr/js/script.js
  10. 4
      resources/library/interactivities/spl-phrase.wgt/locales/fr/scripts/wcontainer.js
  11. 2
      resources/library/interactivities/spl-text.wgt/locales/fr/scripts/wcontainer.js
  12. 2
      resources/library/interactivities/spl-word.wgt/locales/fr/scripts/wcontainer.js
  13. 3
      src/board/UBBoardView.cpp
  14. 3
      src/core/UBSettings.cpp
  15. 3
      src/core/UBSettings.h
  16. 164
      src/domain/UBGraphicsDelegateFrame.cpp
  17. 17
      src/domain/UBGraphicsDelegateFrame.h
  18. 19
      src/domain/UBGraphicsItemDelegate.cpp
  19. 2
      src/domain/UBGraphicsItemDelegate.h
  20. 2
      src/domain/UBGraphicsPixmapItem.cpp
  21. 6
      src/domain/domain.pri

@ -6,20 +6,20 @@ var sankoreLang = {
"example_question":"This is an example of the question", "example_question":"This is an example of the question",
"answer":"This is an example of the answer", "answer":"This is an example of the answer",
"q":"Q", "q":"Q",
"add_new_question":"Add new question ...", "add_new_question":"Add a new question ...",
"options":"Options", "options":"Options",
"close":"Close", "close":"Close",
"delete_question":"Delete question", "delete_question":"Delete the question",
"delete_answer":"Delete answer", "delete_answer":"Delete a possibility",
"right_answer":"Right answer", "right_answer":"Right answer",
"template_question":"Enter your question here ...", "template_question":"Enter a question here ...",
"template_answer":"Enter the answer here ...", "template_answer":"Enter a possibility here ...",
"add_answer":"Add answer", "add_answer":"Add a possibility",
"select_text":"Choose the right answer", "select_text":"Choose the right answer",
"options_desc":"You can choose any of these three options of displaying your answers. See a short their description.", "options_desc":"Types of question",
"radio_desc":"This option allow to choose one answer only and the answers are displayed as radio buttons.", "radio_desc":"Option 1 : one right answer, possibilities are displayed as radio buttons.",
"checkbox_desc":"This option allow to choose several answers and the answers are displayed as checkboxes.", "checkbox_desc":"Option 2 : several right answers, possibilities are displayed as checkboxes.",
"select_desc":"This option allow to chose one answer only and the answers are displayed as pull-down menu.", "select_desc":"Option 3 : one right answer, possibilities are displayed as pull-down menu.",
"a":"A" "a":"A"
}, },
"ru":{ "ru":{
@ -59,7 +59,7 @@ var sankoreLang = {
"delete_answer":"Supprimer la possibilité", "delete_answer":"Supprimer la possibilité",
"right_answer":"Bonne réponse", "right_answer":"Bonne réponse",
"template_question":"Saisir la question ici ...", "template_question":"Saisir la question ici ...",
"template_answer":"Saisir la réponse ici ...", "template_answer":"Saisir une possibilité ici ...",
"add_answer":"Ajouter une possibilité", "add_answer":"Ajouter une possibilité",
"select_text":"Choisir la bonne réponse", "select_text":"Choisir la bonne réponse",
"options_desc":"Types de questions", "options_desc":"Types de questions",

@ -3,7 +3,7 @@ var sankoreLang = {
edit: "Edit", edit: "Edit",
short_desc: "Select the number \"three\".", short_desc: "Select the number \"three\".",
add: "Add new block", add: "Add new block",
enter: "Enter your condition here ..." enter: "Enter what to do here ..."
}; };
//main function //main function

@ -3,7 +3,7 @@ var sankoreLang = {
edit: "Edit", edit: "Edit",
first_desc: "Odd numbers", first_desc: "Odd numbers",
second_desc: "Even numbers", second_desc: "Even numbers",
enter: "Enter your category name here ...", enter: "Enter a category name here ...",
add: "Add new block" add: "Add new block"
}; };

@ -3,12 +3,12 @@ var sankoreLang = {
edit: "Edit", edit: "Edit",
first_desc: "Fruits", first_desc: "Fruits",
second_desc: "Vegetables", second_desc: "Vegetables",
potatoes: "Potatoes", potatoes: "Potato",
carrot: "Carrot", carrot: "Carrot",
onion: "Onion", onion: "Onion",
apple: "Apple", apple: "Apple",
pear: "Pear", pear: "Pear",
enter: "Enter your category name here ...", enter: "Enter a category name here ...",
add: "Add new block", add: "Add new block",
text: "Some text" text: "Some text"
}; };

@ -1,9 +1,9 @@
var sankoreLang = { var sankoreLang = {
display: "Display", display: "Display",
edit: "Edit", edit: "Edit",
text_content: "This is an example. Instead of this text you can put your own content.", text_content: "This is an example. Instead of this text you can put your own content or drag an drop a picture or an audio file",
new_txt: "New text block", new_txt: "New text block",
new_slide: "This is new slide." new_slide: "This is a new slide."
}; };
//some flags //some flags

@ -29,7 +29,7 @@ function checkResponse()
var sankoreLang = { var sankoreLang = {
view: "Afficher", view: "Afficher",
edit: "Modifier", edit: "Modifier",
example: "Il*y*a*longtemps*,*nous*Žtions*ˆ*la*mer*." example: "Il*était*une*fois*..."
}; };
var word = ""; var word = "";

@ -1,10 +1,10 @@
var sankoreLang = { var sankoreLang = {
display: "Affichage", display: "Afficher",
edit: "Modifier", edit: "Modifier",
short_desc: "Placez les photos dans l'ordre croissant.", short_desc: "Placer les photos dans l'ordre croissant.",
add: "Nouveau bloc", add: "Nouveau bloc",
enter: "Saisissez votre texte ici ..." enter: "Saisir votre texte ici ..."
}; };
//main function //main function

@ -1,9 +1,9 @@
var sankoreLang = { var sankoreLang = {
display: "D'affichage", display: "Afficher",
edit: "Modifier", edit: "Modifier",
short_desc: "Ecoutez le son et faire le bon mot.", short_desc: "Ecouter le son et replacer les lettres dans l'ordre.",
add: "Nouveau bloc", add: "Nouveau bloc",
enter: "Entrez votre description ici ...", enter: "Saisir la consigne ici ...",
example: "exemple" example: "exemple"
}; };

@ -1,9 +1,9 @@
var sankoreLang = { var sankoreLang = {
display: "Affichage", display: "Affichage",
edit: "Modifier", edit: "Modifier",
short_desc: "Sélectionnez les animaux de la liste suivante:", short_desc: "Sélectionner les animaux dans la liste suivante :",
add: "Nouveau bloc", add: "Nouveau bloc",
enter: "Saisissez votre texte ici ...", enter: "Saisir le texte ici ...",
cat: "chat", cat: "chat",
ball: "balle", ball: "balle",
shovel: "pelle", shovel: "pelle",

@ -1,7 +1,7 @@
var sankoreLang = { var sankoreLang = {
view: "D'affichage", view: "Afficher",
edit: "Modifier", edit: "Modifier",
example: "c'est un tas de mots qui ne devraient être répartis à part" example: "Ceci est une série de mots à séparer correctement"
}; };
// if use the "view/edit" button or rely on the api instead // if use the "view/edit" button or rely on the api instead

@ -1,5 +1,5 @@
var sankoreLang = { var sankoreLang = {
view: "D'affichage", view: "Afficher",
edit: "Modifier", edit: "Modifier",
example: "bonjour, ceci est la première phrase. salut, c'est la deuxième phrase. bonjour à nouveau, c'est la troisième phrase. bonjour, c'est la quatrième phrase. salut, désolé, je suis en retard, je suis la cinquième phrase." example: "bonjour, ceci est la première phrase. salut, c'est la deuxième phrase. bonjour à nouveau, c'est la troisième phrase. bonjour, c'est la quatrième phrase. salut, désolé, je suis en retard, je suis la cinquième phrase."
}; };

@ -1,5 +1,5 @@
var sankoreLang = { var sankoreLang = {
view: "D'affichage", view: "Afficher",
edit: "Modifier", edit: "Modifier",
example: "so*phis*ti*qué" example: "so*phis*ti*qué"
}; };

@ -427,7 +427,8 @@ UBBoardView::mousePressEvent (QMouseEvent *event)
|| movingItem->type() == UBGraphicsPDFItem::Type || movingItem->type() == UBGraphicsPDFItem::Type
|| movingItem->type() == UBGraphicsPolygonItem::Type || movingItem->type() == UBGraphicsPolygonItem::Type
|| movingItem->type() == UBGraphicsCache::Type || movingItem->type() == UBGraphicsCache::Type
|| movingItem->type() == UBGraphicsTriangle::Type) || movingItem->type() == UBGraphicsTriangle::Type
|| movingItem == this->scene()->backgroundObject())
{ {
movingItem = NULL; movingItem = NULL;
QGraphicsView::mousePressEvent (event); QGraphicsView::mousePressEvent (event);

@ -377,6 +377,8 @@ void UBSettings::init()
KeyboardLocale = new UBSetting(this, "Board", "StartupKeyboardLocale", 0); KeyboardLocale = new UBSetting(this, "Board", "StartupKeyboardLocale", 0);
swapControlAndDisplayScreens = new UBSetting(this, "App", "SwapControlAndDisplayScreens", false); swapControlAndDisplayScreens = new UBSetting(this, "App", "SwapControlAndDisplayScreens", false);
angleTolerance = new UBSetting(this, "App", "AngleTolerance", 4);
} }
@ -1139,3 +1141,4 @@ QString UBSettings::replaceWildcard(QString& path)
return result; return result;
} }

@ -98,7 +98,6 @@ class UBSettings : public QObject
void init(); void init();
//user directories //user directories
static QString userDataDirectory(); static QString userDataDirectory();
static QString userDocumentDirectory(); static QString userDocumentDirectory();
@ -326,6 +325,8 @@ class UBSettings : public QObject
UBSetting* KeyboardLocale; UBSetting* KeyboardLocale;
UBSetting* swapControlAndDisplayScreens; UBSetting* swapControlAndDisplayScreens;
UBSetting* angleTolerance;
public slots: public slots:
void setPenWidthIndex(int index); void setPenWidthIndex(int index);

@ -29,8 +29,6 @@
#include "core/memcheck.h" #include "core/memcheck.h"
qreal const UBGraphicsDelegateFrame::mAngleTolerance = 6;
UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelegate, QRectF pRect, qreal pFrameWidth, bool respectRatio) UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelegate, QRectF pRect, qreal pFrameWidth, bool respectRatio)
: QGraphicsRectItem(), QObject(pDelegate) : QGraphicsRectItem(), QObject(pDelegate)
, mCurrentTool(None) , mCurrentTool(None)
@ -48,7 +46,11 @@ UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelega
, mTotalTranslateX(0) , mTotalTranslateX(0)
, mTotalTranslateY(0) , mTotalTranslateY(0)
, mOperationMode(Scaling) , mOperationMode(Scaling)
, mMirrorX(false)
, mMirrorY(false)
{ {
mAngleTolerance = UBSettings::settings()->angleTolerance->get().toReal();
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
setAcceptedMouseButtons(Qt::LeftButton); setAcceptedMouseButtons(Qt::LeftButton);
@ -69,9 +71,11 @@ UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelega
mBottomResizeGrip = new QGraphicsRectItem(this); mBottomResizeGrip = new QGraphicsRectItem(this);
mBottomResizeGrip->setPen(Qt::NoPen); mBottomResizeGrip->setPen(Qt::NoPen);
mLeftResizeGrip = new QGraphicsRectItem(this); mLeftResizeGrip = new QGraphicsRectItem(this);
mLeftResizeGrip->setToolTip("left");
mLeftResizeGrip->setPen(Qt::NoPen); mLeftResizeGrip->setPen(Qt::NoPen);
mRightResizeGrip = new QGraphicsRectItem(this); mRightResizeGrip = new QGraphicsRectItem(this);
mRightResizeGrip->setPen(Qt::NoPen); mRightResizeGrip->setPen(Qt::NoPen);
mRightResizeGrip->setToolTip("Right");
mTopResizeGrip = new QGraphicsRectItem(this); mTopResizeGrip = new QGraphicsRectItem(this);
mTopResizeGrip->setPen(Qt::NoPen); mTopResizeGrip->setPen(Qt::NoPen);
@ -86,11 +90,14 @@ UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelega
positionHandles(); positionHandles();
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
angleWidget = new UBAngleWidget();
} }
UBGraphicsDelegateFrame::~UBGraphicsDelegateFrame() UBGraphicsDelegateFrame::~UBGraphicsDelegateFrame()
{ {
delete angleWidget;
// NOOP // NOOP
} }
@ -156,14 +163,39 @@ void UBGraphicsDelegateFrame::initializeTransform()
QPointF topRight = itemTransform.map(itemRect.topRight()); QPointF topRight = itemTransform.map(itemRect.topRight());
QPointF bottomLeft = itemTransform.map(itemRect.bottomLeft()); QPointF bottomLeft = itemTransform.map(itemRect.bottomLeft());
qreal horizontalFlip = (topLeft.x() > topRight.x()) ? -1 : 1;
mMirrorX = horizontalFlip < 0 ;
if(horizontalFlip < 0){
// why this is because of the way of calculating the translations that checks which side is the most is the
// nearest instead of checking which one is the left side.
QPointF tmp = topLeft;
topLeft = topRight;
topRight = tmp;
// because of the calculation of the height is done by lenght and not deltaY
bottomLeft = itemTransform.map(itemRect.bottomRight());
}
qreal verticalFlip = (bottomLeft.y() < topLeft.y()) ? -1 : 1;
// not sure that is usefull
mMirrorY = verticalFlip < 0;
if(verticalFlip < 0 && !mMirrorX){
topLeft = itemTransform.map(itemRect.bottomLeft());
topRight = itemTransform.map(itemRect.bottomRight());
bottomLeft = itemTransform.map(itemRect.topLeft());
}
QLineF topLine(topLeft, topRight); QLineF topLine(topLeft, topRight);
QLineF leftLine(topLeft, bottomLeft); QLineF leftLine(topLeft, bottomLeft);
qreal width = topLine.length(); qreal width = topLine.length();
qreal height = leftLine.length(); qreal height = leftLine.length();
mAngle = topLine.angle(); mAngle = topLine.angle();
mTotalScaleX = width / itemRect.width();
mTotalScaleY = height / itemRect.height(); //the fact the the lenght is used we loose the horizontalFlip information
// a better way to do this is using DeltaX that preserve the direction information.
mTotalScaleX = (width / itemRect.width()) * horizontalFlip;
mTotalScaleY = height / itemRect.height() * verticalFlip;
QTransform tr; QTransform tr;
QPointF center = delegated()->boundingRect().center(); QPointF center = delegated()->boundingRect().center();
@ -192,6 +224,7 @@ void UBGraphicsDelegateFrame::mousePressEvent(QGraphicsSceneMouseEvent *event)
mAngleOffset = 0; mAngleOffset = 0;
mInitialTransform = buildTransform(); mInitialTransform = buildTransform();
mCurrentTool = toolFromPos(event->pos()); mCurrentTool = toolFromPos(event->pos());
event->accept(); event->accept();
@ -205,9 +238,16 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
qreal moveY = -move.length() * sin((move.angle() - mAngle) * PI / 180); qreal moveY = -move.length() * sin((move.angle() - mAngle) * PI / 180);
qreal width = delegated()->boundingRect().width() * mTotalScaleX; qreal width = delegated()->boundingRect().width() * mTotalScaleX;
qreal height = delegated()->boundingRect().height() * mTotalScaleY; qreal height = delegated()->boundingRect().height() * mTotalScaleY;
mTranslateX = moveX;
if(mOperationMode == Scaling) if(mOperationMode == Scaling)
{ {
// // Hide the buttons
// mDelegate->setButtonsVisible(false);
// mResizing = true;
// Perform the resize
if (resizingBottomRight()) if (resizingBottomRight())
{ {
// ----------------------------------------------------- // -----------------------------------------------------
@ -243,8 +283,9 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
scaleX = (width + moveX) / width; scaleX = (width + moveX) / width;
} }
if(mDelegate->isFlippable() && qAbs(scaleX) != 0){ if(mDelegate->isFlippable() && qAbs(scaleX) != 0){
if((width * qAbs(scaleX)) < 2*mFrameWidth){ if((qAbs(width * scaleX)) < 2*mFrameWidth){
bool negative = (scaleX < 0)?true:false; bool negative = (scaleX < 0)?true:false;
//mMirrorX = (negative?mMirrorX:!mMirrorX);
if(negative){ if(negative){
scaleX = -2*mFrameWidth/width; scaleX = -2*mFrameWidth/width;
}else{ }else{
@ -269,8 +310,9 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
} }
if(mDelegate->isFlippable() && qAbs(scaleY) != 0){ if(mDelegate->isFlippable() && qAbs(scaleY) != 0){
if((height * qAbs(scaleY)) < 2*mFrameWidth){ if((qAbs(height * scaleY)) < 2*mFrameWidth){
bool negative = (scaleY < 0)?true:false; bool negative = (scaleY < 0)?true:false;
//mMirrorY = (negative?mMirrorY:!mMirrorY);
if(negative){ if(negative){
scaleY = -2*mFrameWidth/width; scaleY = -2*mFrameWidth/width;
}else{ }else{
@ -281,7 +323,9 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
}else if (scaleY > 1 || (height * scaleY) > 2 * mFrameWidth) }else if (scaleY > 1 || (height * scaleY) > 2 * mFrameWidth)
{ {
mScaleY = scaleY; mScaleY = scaleY;
mTranslateY = moveY; if(resizingTop()){
mTranslateY = moveY;
}
} }
} }
} }
@ -331,7 +375,9 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QLineF startLine(sceneBoundingRect().center(), event->lastScenePos()); QLineF startLine(sceneBoundingRect().center(), event->lastScenePos());
QLineF currentLine(sceneBoundingRect().center(), event->scenePos()); QLineF currentLine(sceneBoundingRect().center(), event->scenePos());
mAngle += startLine.angleTo(currentLine); mAngle += startLine.angleTo(currentLine);
if ((int)mAngle % 45 >= 45 - mAngleTolerance || (int)mAngle % 45 <= mAngleTolerance)
if ((int)mAngle % 45 >= 45 - mAngleTolerance
|| (int)mAngle % 45 <= mAngleTolerance)
{ {
mAngle = qRound(mAngle / 45) * 45; mAngle = qRound(mAngle / 45) * 45;
mAngleOffset += startLine.angleTo(currentLine); mAngleOffset += startLine.angleTo(currentLine);
@ -341,6 +387,23 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
mAngleOffset = 0; mAngleOffset = 0;
} }
} }
else if ((int)mAngle % 30 >= 30 - mAngleTolerance
|| (int)mAngle % 30 <= mAngleTolerance)
{
mAngle = qRound(mAngle / 30) * 30;
mAngleOffset += startLine.angleTo(currentLine);
if ((int)mAngleOffset % 360 > mAngleTolerance && (int)mAngleOffset % 360 < 360 - mAngleTolerance)
{
mAngle += mAngleOffset;
mAngleOffset = 0;
}
}
if (!angleWidget->isVisible())
angleWidget->show();
angleWidget->setText(QString::number((int)mAngle % 360));
angleWidget->update();
} }
else if (moving()) else if (moving())
@ -410,6 +473,9 @@ QTransform UBGraphicsDelegateFrame::buildTransform()
void UBGraphicsDelegateFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsDelegateFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
if (angleWidget->isVisible())
angleWidget->hide();
updateResizeCursors(); updateResizeCursors();
mDelegate->commitUndoStep(); mDelegate->commitUndoStep();
@ -421,6 +487,12 @@ void UBGraphicsDelegateFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
mCurrentTool = None; mCurrentTool = None;
QGraphicsRectItem::mouseReleaseEvent(event); QGraphicsRectItem::mouseReleaseEvent(event);
// Show the buttons
if(isResizing()){
mResizing = false;
}
mDelegate->setButtonsVisible(true);
} }
@ -464,6 +536,14 @@ void UBGraphicsDelegateFrame::positionHandles()
QPointF bottomLeft = itemTransform.map(itemRect.bottomLeft()); QPointF bottomLeft = itemTransform.map(itemRect.bottomLeft());
QPointF center = itemTransform.map(itemRect.center()); QPointF center = itemTransform.map(itemRect.center());
// Handle the mirroring
if(topLeft.x() > topRight.x()){
QPointF tmp = topRight;
topRight = topLeft;
topLeft = tmp;
bottomLeft.setX(topLeft.x());
}
QLineF topLine(topLeft, topRight); QLineF topLine(topLeft, topRight);
qreal angle = topLine.angle(); qreal angle = topLine.angle();
qreal width = topLine.length(); qreal width = topLine.length();
@ -507,17 +587,8 @@ void UBGraphicsDelegateFrame::positionHandles()
mBottomRightResizeGripSvgItem->setPos(rect().right() - brRect.width(), rect().bottom() - brRect.height()); mBottomRightResizeGripSvgItem->setPos(rect().right() - brRect.width(), rect().bottom() - brRect.height());
mBottomResizeGripSvgItem->setPos(rect().center().x() - bRect.width() / 2, rect().bottom() - bRect.height()); mBottomResizeGripSvgItem->setPos(rect().center().x() - bRect.width() / 2, rect().bottom() - bRect.height());
if(0 <= mScaleX){ mLeftResizeGripSvgItem->setPos(rect().left(), rect().center().y() - lRect.height() / 2);
mLeftResizeGripSvgItem->setPos(rect().left(), rect().center().y() - lRect.height() / 2); mRightResizeGripSvgItem->setPos(rect().right() - rRect.width(), rect().center().y() - rRect.height() / 2);
mRightResizeGripSvgItem->setPos(rect().right() - rRect.width(), rect().center().y() - rRect.height() / 2);
}else{
mLeftResizeGripSvgItem->setPos(rect().right() - rRect.width(), rect().center().y() - lRect.height() / 2);
mRightResizeGripSvgItem->setPos(rect().left() , rect().center().y() - rRect.height() / 2);
}
if(0 < mScaleY){
}
mTopResizeGripSvgItem->setPos(rect().center().x() - trRect.width() / 2, rect().y()); mTopResizeGripSvgItem->setPos(rect().center().x() - trRect.width() / 2, rect().y());
mRotateButton->setPos(rect().right() - mFrameWidth - 5, rect().top() + 5); mRotateButton->setPos(rect().right() - mFrameWidth - 5, rect().top() + 5);
@ -571,14 +642,35 @@ UBGraphicsDelegateFrame::FrameTool UBGraphicsDelegateFrame::toolFromPos(QPointF
return None; return None;
else if (bottomRightResizeGripRect().contains(pos)) else if (bottomRightResizeGripRect().contains(pos))
return ResizeBottomRight; return ResizeBottomRight;
else if (bottomResizeGripRect().contains(pos)) else if (bottomResizeGripRect().contains(pos)){
return ResizeBottom; if(mMirrorY){
else if (leftResizeGripRect().contains(pos)) return ResizeTop;
return ResizeLeft; }else{
else if (rightResizeGripRect().contains(pos)) return ResizeBottom;
return ResizeRight; }
else if (topResizeGripRect().contains(pos)) }
return ResizeTop; else if (leftResizeGripRect().contains(pos)){
if(mMirrorX){
return ResizeRight;
}else{
return ResizeLeft;
}
return ResizeLeft;
}
else if (rightResizeGripRect().contains(pos)){
if(mMirrorX){
return ResizeLeft;
}else{
return ResizeRight;
}
}
else if (topResizeGripRect().contains(pos)){
if(mMirrorY){
return ResizeBottom;
}else{
return ResizeTop;
}
}
else if (rotateButtonBounds().contains(pos) && mDelegate && mDelegate->canRotate()) else if (rotateButtonBounds().contains(pos) && mDelegate && mDelegate->canRotate())
return Rotate; return Rotate;
else else
@ -621,3 +713,21 @@ QRectF UBGraphicsDelegateFrame::rotateButtonBounds() const
return QRectF(rect().right()- mFrameWidth, rect().top(), mFrameWidth, mFrameWidth); return QRectF(rect().right()- mFrameWidth, rect().top(), mFrameWidth, mFrameWidth);
} }
void UBGraphicsDelegateFrame::refreshGeometry()
{
// Here we want to have the left on the left, the right on the right, the top on the top and the bottom on the bottom!
QRectF itemRect = delegated()->boundingRect();
QTransform itemTransform = delegated()->sceneTransform();
QPointF topLeft = itemTransform.map(itemRect.topLeft());
QPointF topRight = itemTransform.map(itemRect.topRight());
QPointF bottomLeft = itemTransform.map(itemRect.bottomLeft());
QPointF center = itemTransform.map(itemRect.center());
QLineF topLine(topLeft, topRight);
qreal angle = topLine.angle();
qreal width = topLine.length();
QLineF leftLine(topLeft, bottomLeft);
qreal height = leftLine.length();
setRect(topRight.x() - mFrameWidth, topLeft.y() - mFrameWidth, width + 2*mFrameWidth, height + 2*mFrameWidth);
}

@ -18,6 +18,7 @@
#include <QtGui> #include <QtGui>
#include "core/UB.h" #include "core/UB.h"
#include "domain/UBAngleWidget.h"
class QGraphicsSceneMouseEvent; class QGraphicsSceneMouseEvent;
class UBGraphicsItemDelegate; class UBGraphicsItemDelegate;
@ -47,6 +48,7 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
enum OperationMode {Scaling, Resizing}; enum OperationMode {Scaling, Resizing};
void setOperationMode(OperationMode pMode) {mOperationMode = pMode;} void setOperationMode(OperationMode pMode) {mOperationMode = pMode;}
bool isResizing(){return mResizing;}
private: private:
QRectF bottomRightResizeGripRect() const; QRectF bottomRightResizeGripRect() const;
@ -69,8 +71,8 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
void initializeTransform (); void initializeTransform ();
enum FrameTool {None, Move, Rotate, ResizeBottomRight, ResizeTop, ResizeRight, ResizeBottom, ResizeLeft}; enum FrameTool {None, Move, Rotate, ResizeBottomRight, ResizeTop, ResizeRight, ResizeBottom, ResizeLeft};
FrameTool toolFromPos (QPointF pos);
FrameTool toolFromPos (QPointF pos); void refreshGeometry();
FrameTool mCurrentTool; FrameTool mCurrentTool;
UBGraphicsItemDelegate* mDelegate; UBGraphicsItemDelegate* mDelegate;
@ -90,7 +92,8 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
qreal mTranslateY; qreal mTranslateY;
qreal mTotalTranslateX; qreal mTotalTranslateX;
qreal mTotalTranslateY; qreal mTotalTranslateY;
static const qreal mAngleTolerance; qreal mAngleTolerance;
QRect mAngleRect;
QPointF mStartingPoint; QPointF mStartingPoint;
QTransform mInitialTransform; QTransform mInitialTransform;
@ -111,5 +114,13 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
OperationMode mOperationMode; OperationMode mOperationMode;
QGraphicsItem* delegated(); QGraphicsItem* delegated();
bool mMirrorX;
bool mMirrorY;
bool mResizing;
bool mMirroredXAtStart;
bool mMirroredYAtStart;
UBAngleWidget *angleWidget;
}; };
#endif /* UBGRAPHICSDELEGATEFRAME_H_ */ #endif /* UBGRAPHICSDELEGATEFRAME_H_ */

@ -249,7 +249,9 @@ void UBGraphicsItemDelegate::positionHandles()
mDelegated->scene()->addItem(mDeleteButton); mDelegated->scene()->addItem(mDeleteButton);
} }
mDeleteButton->show(); if(!mFrame->isResizing()){
mDeleteButton->show();
}
bool shownOnDisplay = mDelegated->data(UBGraphicsItemData::ItemLayerType).toInt() != UBItemLayerType::Control; bool shownOnDisplay = mDelegated->data(UBGraphicsItemData::ItemLayerType).toInt() != UBItemLayerType::Control;
showHide(shownOnDisplay); showHide(shownOnDisplay);
@ -274,9 +276,11 @@ void UBGraphicsItemDelegate::positionHandles()
if (mDelegated->scene()) if (mDelegated->scene())
mDelegated->scene()->addItem(button); mDelegated->scene()->addItem(button);
} }
button->show(); if(!mFrame->isResizing()){
button->setZValue(delegated()->zValue()); button->show();
} button->setZValue(delegated()->zValue());
}
}
} else { } else {
foreach(DelegateButton* button, mButtons) foreach(DelegateButton* button, mButtons)
button->hide(); button->hide();
@ -484,3 +488,10 @@ bool UBGraphicsItemDelegate::isFlippable()
{ {
return mFlippable; return mFlippable;
} }
void UBGraphicsItemDelegate::setButtonsVisible(bool visible)
{
foreach(DelegateButton* pButton, mButtons){
pButton->setVisible(visible);
}
}

@ -139,6 +139,8 @@ class UBGraphicsItemDelegate : public QObject
void setFlippable(bool flippable); void setFlippable(bool flippable);
bool isFlippable(); bool isFlippable();
void setButtonsVisible(bool visible);
signals: signals:
void showOnDisplayChanged(bool shown); void showOnDisplayChanged(bool shown);
void lockChanged(bool locked); void lockChanged(bool locked);

@ -32,7 +32,7 @@ UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent)
mDelegate->init(); mDelegate->init();
// NOTE: Do not remove this code, I'm just doing a backup of my changes! thx.. // NOTE: Do not remove this code, I'm just doing a backup of my changes! thx..
//mDelegate->setFlippable(true); mDelegate->setFlippable(true);
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
setTransformationMode(Qt::SmoothTransformation); setTransformationMode(Qt::SmoothTransformation);

@ -22,7 +22,8 @@ HEADERS += src/domain/UBGraphicsScene.h \
src/domain/UBGraphicsMediaItem.h \ src/domain/UBGraphicsMediaItem.h \
src/domain/UBGraphicsAudioItem.h \ src/domain/UBGraphicsAudioItem.h \
src/domain/UBGraphicsAudioItemDelegate.h \ src/domain/UBGraphicsAudioItemDelegate.h \
src/domain/UBAbstractUndoCommand.h src/domain/UBAbstractUndoCommand.h\
src/domain/UBAngleWidget.h
HEADERS += src/domain/UBGraphicsItemDelegate.h \ HEADERS += src/domain/UBGraphicsItemDelegate.h \
src/domain/UBGraphicsVideoItemDelegate.h \ src/domain/UBGraphicsVideoItemDelegate.h \
@ -54,7 +55,8 @@ SOURCES += src/domain/UBGraphicsScene.cpp \
src/domain/UBGraphicsMediaItem.cpp \ src/domain/UBGraphicsMediaItem.cpp \
src/domain/UBGraphicsAudioItem.cpp \ src/domain/UBGraphicsAudioItem.cpp \
src/domain/UBGraphicsAudioItemDelegate.cpp \ src/domain/UBGraphicsAudioItemDelegate.cpp \
src/domain/UBAbstractUndoCommand.cpp src/domain/UBAbstractUndoCommand.cpp \
src/domain/UBAngleWidget.cpp
SOURCES += src/domain/UBGraphicsItemDelegate.cpp \ SOURCES += src/domain/UBGraphicsItemDelegate.cpp \
src/domain/UBGraphicsVideoItemDelegate.cpp \ src/domain/UBGraphicsVideoItemDelegate.cpp \

Loading…
Cancel
Save