Merge branch 'develop' of github.com:OpenEducationFoundation/OpenBoard into develop

preferencesAboutTextFull
Ilia Ryabokon 11 years ago
commit 92167aab77
  1. 17
      src/adaptors/UBSvgSubsetAdaptor.cpp
  2. 8
      src/board/UBBoardController.cpp
  3. 2
      src/core/UBSettings.cpp
  4. 2
      src/core/UBSettings.h
  5. 15
      src/domain/UBGraphicsGroupContainerItem.cpp
  6. 9
      src/domain/UBGraphicsItemDelegate.cpp
  7. 1
      src/domain/UBGraphicsItemDelegate.h
  8. 7
      src/domain/UBGraphicsWidgetItem.cpp
  9. 5
      src/domain/UBItem.cpp
  10. 1
      src/domain/UBItem.h

@ -42,6 +42,7 @@
#include "domain/UBGraphicsStroke.h" #include "domain/UBGraphicsStroke.h"
#include "domain/UBGraphicsStrokesGroup.h" #include "domain/UBGraphicsStrokesGroup.h"
#include "domain/UBGraphicsGroupContainerItem.h" #include "domain/UBGraphicsGroupContainerItem.h"
#include "domain/UBGraphicsGroupContainerItemDelegate.h"
#include "domain/UBItem.h" #include "domain/UBItem.h"
#include "tools/UBGraphicsRuler.h" #include "tools/UBGraphicsRuler.h"
@ -924,7 +925,13 @@ void UBSvgSubsetAdaptor::UBSvgSubsetReader::readGroupRoot()
} }
else if (mXmlReader.isStartElement()) { else if (mXmlReader.isStartElement()) {
if (mXmlReader.name() == tGroup) { if (mXmlReader.name() == tGroup) {
QString ubLocked = mXmlReader.attributes().value(UBSettings::uniboardDocumentNamespaceUri, "locked").toString();
UBGraphicsGroupContainerItem *curGroup = readGroup(); UBGraphicsGroupContainerItem *curGroup = readGroup();
if (!ubLocked.isEmpty())
{
bool isLocked = ubLocked.contains(xmlTrue);
curGroup->Delegate()->setLocked(isLocked);
}
if (curGroup) { if (curGroup) {
mScene->addGroup(curGroup); mScene->addGroup(curGroup);
} }
@ -1276,6 +1283,9 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene(int pageIndex)
if (curElement.hasAttribute(aId)) { if (curElement.hasAttribute(aId)) {
mXmlWriter.writeStartElement(curElement.tagName()); mXmlWriter.writeStartElement(curElement.tagName());
mXmlWriter.writeAttribute(aId, curElement.attribute(aId)); mXmlWriter.writeAttribute(aId, curElement.attribute(aId));
if(curElement.hasAttribute("locked")){
mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri,"locked",curElement.attribute("locked"));
}
QDomElement curSubElement = curElement.firstChildElement(); QDomElement curSubElement = curElement.firstChildElement();
while (!curSubElement.isNull()) { while (!curSubElement.isNull()) {
if (curSubElement.hasAttribute(aId)) { if (curSubElement.hasAttribute(aId)) {
@ -1320,6 +1330,13 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistGroupToDom(QGraphicsItem *gro
if (!uuid.isNull()) { if (!uuid.isNull()) {
QDomElement curGroupElement = groupDomDocument->createElement(tGroup); QDomElement curGroupElement = groupDomDocument->createElement(tGroup);
curGroupElement.setAttribute(aId, uuid); curGroupElement.setAttribute(aId, uuid);
UBGraphicsGroupContainerItem* group = dynamic_cast<UBGraphicsGroupContainerItem*>(groupItem);
if(group && group->Delegate()){
if(group->Delegate()->isLocked())
curGroupElement.setAttribute("locked", xmlTrue);
else
curGroupElement.setAttribute("locked", xmlFalse);
}
curParent->appendChild(curGroupElement); curParent->appendChild(curGroupElement);
foreach (QGraphicsItem *item, groupItem->childItems()) { foreach (QGraphicsItem *item, groupItem->childItems()) {
QUuid tmpUuid = UBGraphicsScene::getPersonalUuid(item); QUuid tmpUuid = UBGraphicsScene::getPersonalUuid(item);

@ -1634,7 +1634,7 @@ void UBBoardController::adjustDisplayViews()
int UBBoardController::autosaveTimeoutFromSettings() int UBBoardController::autosaveTimeoutFromSettings()
{ {
int value = UBSettings::settings()->timerInterval->get().toInt(); int value = UBSettings::settings()->autoSaveInterval->get().toInt();
int minute = 60 * 1000; int minute = 60 * 1000;
return value * minute; return value * minute;
@ -1773,8 +1773,8 @@ void UBBoardController::autosaveTimeout()
void UBBoardController::appMainModeChanged(UBApplicationController::MainMode md) void UBBoardController::appMainModeChanged(UBApplicationController::MainMode md)
{ {
int timerInterval = autosaveTimeoutFromSettings(); int autoSaveInterval = autosaveTimeoutFromSettings();
if (!timerInterval) { if (!autoSaveInterval) {
return; return;
} }
@ -1784,7 +1784,7 @@ void UBBoardController::appMainModeChanged(UBApplicationController::MainMode md)
} }
if (md == UBApplicationController::Board) { if (md == UBApplicationController::Board) {
mAutosaveTimer->start(timerInterval); mAutosaveTimer->start(autoSaveInterval);
} else if (mAutosaveTimer->isActive()) { } else if (mAutosaveTimer->isActive()) {
mAutosaveTimer->stop(); mAutosaveTimer->stop();
} }

@ -353,7 +353,7 @@ void UBSettings::init()
boardShowToolsPalette = new UBSetting(this, "Board", "ShowToolsPalette", "false"); boardShowToolsPalette = new UBSetting(this, "Board", "ShowToolsPalette", "false");
magnifierDrawingMode = new UBSetting(this, "Board", "MagnifierDrawingMode", "0"); magnifierDrawingMode = new UBSetting(this, "Board", "MagnifierDrawingMode", "0");
timerInterval = new UBSetting(this, "Board", "Timer interval", "5"); autoSaveInterval = new UBSetting(this, "Board", "AutoSaveIntervalInMinutes", "3");
svgViewBoxMargin = new UBSetting(this, "SVG", "ViewBoxMargin", "50"); svgViewBoxMargin = new UBSetting(this, "SVG", "ViewBoxMargin", "50");

@ -373,7 +373,7 @@ class UBSettings : public QObject
UBSetting* libIconSize; UBSetting* libIconSize;
UBSetting* magnifierDrawingMode; UBSetting* magnifierDrawingMode;
UBSetting* timerInterval; UBSetting* autoSaveInterval;
public slots: public slots:

@ -79,9 +79,14 @@ void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item)
if (UBGraphicsItem::isRotatable(this) && !UBGraphicsItem::isRotatable(item)) { if (UBGraphicsItem::isRotatable(this) && !UBGraphicsItem::isRotatable(item)) {
Delegate()->setUBFlag(GF_REVOLVABLE, false); Delegate()->setUBFlag(GF_REVOLVABLE, false);
} }
} else { if (!UBGraphicsItem::isLocked(this) && UBGraphicsItem::isLocked(item)) {
Delegate()->setLocked(true);
}
}
else {
Delegate()->setUBFlag(GF_FLIPPABLE_ALL_AXIS, UBGraphicsItem::isFlippable(item)); Delegate()->setUBFlag(GF_FLIPPABLE_ALL_AXIS, UBGraphicsItem::isFlippable(item));
Delegate()->setUBFlag(GF_REVOLVABLE, UBGraphicsItem::isRotatable(item)); Delegate()->setUBFlag(GF_REVOLVABLE, UBGraphicsItem::isRotatable(item));
Delegate()->setLocked(UBGraphicsItem::isLocked(item));
} }
// COMBINE // COMBINE
@ -322,6 +327,7 @@ void UBGraphicsGroupContainerItem::pRemoveFromGroup(QGraphicsItem *item)
if (!UBGraphicsItem::isFlippable(item) || !UBGraphicsItem::isRotatable(item)) { if (!UBGraphicsItem::isFlippable(item) || !UBGraphicsItem::isRotatable(item)) {
bool flippableNow = true; bool flippableNow = true;
bool rotatableNow = true; bool rotatableNow = true;
bool lockedNow = false;
foreach (QGraphicsItem *item, childItems()) { foreach (QGraphicsItem *item, childItems()) {
if (!UBGraphicsItem::isFlippable(item)) { if (!UBGraphicsItem::isFlippable(item)) {
@ -330,12 +336,17 @@ void UBGraphicsGroupContainerItem::pRemoveFromGroup(QGraphicsItem *item)
if (!UBGraphicsItem::isRotatable(item)) { if (!UBGraphicsItem::isRotatable(item)) {
rotatableNow = false; rotatableNow = false;
} }
if (!rotatableNow && !flippableNow) { if(UBGraphicsItem::isLocked(item))
lockedNow = true;
if (!rotatableNow && !flippableNow && lockedNow) {
break; break;
} }
} }
Delegate()->setUBFlag(GF_FLIPPABLE_ALL_AXIS, flippableNow); Delegate()->setUBFlag(GF_FLIPPABLE_ALL_AXIS, flippableNow);
Delegate()->setUBFlag(GF_REVOLVABLE, rotatableNow); Delegate()->setUBFlag(GF_REVOLVABLE, rotatableNow);
Delegate()->setLocked(lockedNow);
} }
} }

@ -727,6 +727,15 @@ void UBGraphicsItemDelegate::showMenu()
mMenu->exec(cv->mapToGlobal(pinPos.bottomRight())); mMenu->exec(cv->mapToGlobal(pinPos.bottomRight()));
} }
void UBGraphicsItemDelegate::setLocked(bool pLocked)
{
Q_ASSERT(mDelegated);
if (mDelegated) {
mDelegated->setData(UBGraphicsItemData::ItemLocked, QVariant(pLocked));
}
}
void UBGraphicsItemDelegate::updateFrame() void UBGraphicsItemDelegate::updateFrame()
{ {
if (mFrame && !mFrame->scene() && mDelegated->scene()) if (mFrame && !mFrame->scene() && mDelegated->scene())

@ -282,6 +282,7 @@ class UBGraphicsItemDelegate : public QObject
void setMimeData(QMimeData* mimeData); void setMimeData(QMimeData* mimeData);
void setDragPixmap(const QPixmap &pix) {mDragPixmap = pix;} void setDragPixmap(const QPixmap &pix) {mDragPixmap = pix;}
void setLocked(bool pLocked);
void setButtonsVisible(bool visible); void setButtonsVisible(bool visible);
UBGraphicsToolBarItem* getToolBarItem() const { return mToolBarItem; } UBGraphicsToolBarItem* getToolBarItem() const { return mToolBarItem; }

@ -565,12 +565,9 @@ void UBGraphicsWidgetItem::injectInlineJavaScript()
void UBGraphicsWidgetItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void UBGraphicsWidgetItem::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{ {
if (scene() && scene()->renderingContext() != UBGraphicsScene::Screen) {
painter->drawPixmap(0, 0, snapshot());
}
else {
QGraphicsWebView::paint(painter, option, widget); QGraphicsWebView::paint(painter, option, widget);
}
if (!mInitialLoadDone) { if (!mInitialLoadDone) {
QString message; QString message;

@ -85,6 +85,11 @@ bool UBGraphicsItem::isRotatable(QGraphicsItem *item)
return item->data(UBGraphicsItemData::ItemRotatable).toBool(); return item->data(UBGraphicsItemData::ItemRotatable).toBool();
} }
bool UBGraphicsItem::isLocked(QGraphicsItem *item)
{
return item->data(UBGraphicsItemData::ItemLocked).toBool();
}
QUuid UBGraphicsItem::getOwnUuid(QGraphicsItem *item) QUuid UBGraphicsItem::getOwnUuid(QGraphicsItem *item)
{ {
QString idCandidate = item->data(UBGraphicsItemData::ItemUuid).toString(); QString idCandidate = item->data(UBGraphicsItemData::ItemUuid).toString();

@ -116,6 +116,7 @@ public:
static void assignZValue(QGraphicsItem*, qreal value); static void assignZValue(QGraphicsItem*, qreal value);
static bool isRotatable(QGraphicsItem *item); static bool isRotatable(QGraphicsItem *item);
static bool isFlippable(QGraphicsItem *item); static bool isFlippable(QGraphicsItem *item);
static bool isLocked(QGraphicsItem *item);
static QUuid getOwnUuid(QGraphicsItem *item); static QUuid getOwnUuid(QGraphicsItem *item);
static UBGraphicsItemDelegate *Delegate(QGraphicsItem *pItem); static UBGraphicsItemDelegate *Delegate(QGraphicsItem *pItem);

Loading…
Cancel
Save