Merge branch 'develop' into Ilia_dev

preferencesAboutTextFull
Ilia Ryabokon 12 years ago
commit 4406082dc8
  1. 4
      resources/library/applications/Grapheur.wgt/Grapheur.xhtml
  2. 29
      resources/library/interactivities/Contraste.wgt/locales/fr/scripts/blackYellow.js
  3. 29
      resources/library/interactivities/Contraste.wgt/locales/ru/scripts/blackYellow.js
  4. 29
      resources/library/interactivities/Contraste.wgt/scripts/blackYellow.js
  5. 1
      resources/library/interactivities/Ordre phrase.wgt/styles/of_puppets.css
  6. 8
      src/adaptors/UBCFFSubsetAdaptor.cpp
  7. 16
      src/board/UBBoardController.cpp
  8. 4
      src/board/UBBoardPaletteManager.cpp
  9. 3
      src/board/UBBoardView.cpp
  10. 70
      src/core/UBApplication.cpp
  11. 4
      src/core/UBApplication.h
  12. 20
      src/desktop/UBDesktopAnnotationController.cpp
  13. 152
      src/document/UBDocumentController.cpp
  14. 3
      src/document/UBDocumentController.h
  15. 50
      src/domain/UBGraphicsGroupContainerItem.cpp
  16. 5
      src/domain/UBGraphicsGroupContainerItem.h
  17. 3
      src/domain/UBGraphicsItemDelegate.cpp
  18. 18
      src/domain/UBGraphicsPolygonItem.cpp
  19. 78
      src/domain/UBGraphicsScene.cpp
  20. 12
      src/domain/UBGraphicsScene.h
  21. 7
      src/domain/UBGraphicsStrokesGroup.cpp
  22. 39
      src/frameworks/UBCoreGraphicsScene.cpp
  23. 13
      src/frameworks/UBCoreGraphicsScene.h
  24. 2
      src/gui/UBPropertyPalette.cpp
  25. 2
      src/gui/UBPropertyPalette.h
  26. 4
      src/gui/UBThumbnailWidget.cpp

@ -218,7 +218,6 @@
return true; return true;
}); });
$("label[for*='checkAire']").text(sankoreLang[lang].draw); $("label[for*='checkAire']").text(sankoreLang[lang].draw);
$("label[for*='checkMaJ']").text(sankoreLang[lang].auto_update);
$("#menuOptions td").eq(0).html(sankoreLang[lang].widget); $("#menuOptions td").eq(0).html(sankoreLang[lang].widget);
$("#menuOptions h3").eq(0).text(sankoreLang[lang].widget_options); $("#menuOptions h3").eq(0).text(sankoreLang[lang].widget_options);
$("#menuOptions2D h3").eq(0).text(sankoreLang[lang].options + " 2D"); $("#menuOptions2D h3").eq(0).text(sankoreLang[lang].options + " 2D");
@ -1033,13 +1032,10 @@
<span class="gras">Control options:</span><br/> <span class="gras">Control options:</span><br/>
<input type="button" class="boutonSauvegarde" onclick="saveOptions()" value="Save"/><input type="button" class="boutonSauvegarde" onclick="loadOptions()" value="Load"/> <input class="boutonSauvegarde2" type="button" onclick="delOptions()" value="Delete"/><input class="boutonSauvegarde2" type="button" onclick="alertOptions()" value="Display"/><br/> <input type="button" class="boutonSauvegarde" onclick="saveOptions()" value="Save"/><input type="button" class="boutonSauvegarde" onclick="loadOptions()" value="Load"/> <input class="boutonSauvegarde2" type="button" onclick="delOptions()" value="Delete"/><input class="boutonSauvegarde2" type="button" onclick="alertOptions()" value="Display"/><br/>
<span class="texteSecondaire">Save a widget options in cookies or load an options from cookies or delete a registered options.</span> <span class="texteSecondaire">Save a widget options in cookies or load an options from cookies or delete a registered options.</span>
<br/><br/>
<label for="checkMaJ">Automatically update when a widget opening.</label> <input type="checkbox" id="checkMaJ" onclick="checkboxMaJ()"/>
<br/> <br/>
<div id="cacheCookies"><br/><br/><h1>Cookies are disabled. You cannot save an options...</h1></div> <div id="cacheCookies"><br/><br/><h1>Cookies are disabled. You cannot save an options...</h1></div>
<div id="cacheMaJ">You are using the last version of this widget.</div> <div id="cacheMaJ">You are using the last version of this widget.</div>
<input type="button" onclick='reset()' value="Reload widget" style="position:absolute; bottom:20px; width:140px; height:32px;"/> <input type="button" onclick='reset()' value="Reload widget" style="position:absolute; bottom:20px; width:140px; height:32px;"/>
<input type="button" onclick='miseAjour()' value="Updated" style="position:absolute; bottom:20px; left:160px; width:140px; height:32px;"/>
</div> </div>
<div class="barreBasMenu"><input type="button" onclick="cacherMenu(); actualiserGraph()" value="Check"/></div> <div class="barreBasMenu"><input type="button" onclick="cacherMenu(); actualiserGraph()" value="Check"/></div>
</div> </div>

@ -326,6 +326,15 @@ function init(){
$(".closeItem").live("click", function(){ $(".closeItem").live("click", function(){
if(!shadowOver){ if(!shadowOver){
$(this).parent().remove(); $(this).parent().remove();
if($(".editContainer").size() > 0){
var prev = $(".editContainer:first");
if((prev.position().left == 54) && (prev.position().top != 60))
prev.css("top", "60px");
var prevBottom = prev.position().top + prev.height(),
prevLeft = prev.position().left;
if(prev.next().length)
recursionCall(prevBottom, prevLeft, prev.next());
}
} }
}); });
@ -339,8 +348,7 @@ function init(){
}) })
function recursionCall(prevBottom, prevLeft, curr){ function recursionCall(prevBottom, prevLeft, curr){
var curTop = curr.position().top, var curHeight = curr.height(),
curHeight = curr.height(),
curLeft = curr.position().left; curLeft = curr.position().left;
if(prevLeft == curLeft){ if(prevLeft == curLeft){
if((prevBottom + 15 + curHeight) < ($(window).height() - 54)) if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
@ -351,7 +359,7 @@ function init(){
if((prevBottom + 15 + curHeight) < ($(window).height() - 54)) if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
curr.css("top", prevBottom + 15 + "px").css("left", prevLeft + "px"); curr.css("top", prevBottom + 15 + "px").css("left", prevLeft + "px");
else else
curr.css("top", "60px"); curr.css("top", "60px").css("left", prevLeft + 255 + "px");
} }
prevBottom = curr.position().top + curr.height(), prevBottom = curr.position().top + curr.height(),
prevLeft = curr.position().left; prevLeft = curr.position().left;
@ -364,7 +372,20 @@ function init(){
popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%"); popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%");
$(window).resize(function(){ $(window).resize(function(){
//$("#leftDiv,#rightDiv,#shadowDiv").css("height", $(window).height()); if($("#wgt_edit").hasClass("selected")){
if($(".editContainer").size() > 1){
var prev = $(".editContainer:first"),
prevBottom = prev.position().top + prev.height(),
prevLeft = prev.position().left;
recursionCall(prevBottom, prevLeft, prev.next());
}
} else {
var tmp_array = [];
$(".readyTask").each(function(){
tmp_array.push($(this));
});
orderItems(tmp_array);
}
popupBack.css("top", ($(window).height() - 138)*50/$(window).height() + "%"); popupBack.css("top", ($(window).height() - 138)*50/$(window).height() + "%");
popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%"); popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%");
}); });

@ -326,6 +326,15 @@ function init(){
$(".closeItem").live("click", function(){ $(".closeItem").live("click", function(){
if(!shadowOver){ if(!shadowOver){
$(this).parent().remove(); $(this).parent().remove();
if($(".editContainer").size() > 0){
var prev = $(".editContainer:first");
if((prev.position().left == 54) && (prev.position().top != 60))
prev.css("top", "60px");
var prevBottom = prev.position().top + prev.height(),
prevLeft = prev.position().left;
if(prev.next().length)
recursionCall(prevBottom, prevLeft, prev.next());
}
} }
}); });
@ -339,8 +348,7 @@ function init(){
}) })
function recursionCall(prevBottom, prevLeft, curr){ function recursionCall(prevBottom, prevLeft, curr){
var curTop = curr.position().top, var curHeight = curr.height(),
curHeight = curr.height(),
curLeft = curr.position().left; curLeft = curr.position().left;
if(prevLeft == curLeft){ if(prevLeft == curLeft){
if((prevBottom + 15 + curHeight) < ($(window).height() - 54)) if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
@ -351,7 +359,7 @@ function init(){
if((prevBottom + 15 + curHeight) < ($(window).height() - 54)) if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
curr.css("top", prevBottom + 15 + "px").css("left", prevLeft + "px"); curr.css("top", prevBottom + 15 + "px").css("left", prevLeft + "px");
else else
curr.css("top", "60px"); curr.css("top", "60px").css("left", prevLeft + 255 + "px");
} }
prevBottom = curr.position().top + curr.height(), prevBottom = curr.position().top + curr.height(),
prevLeft = curr.position().left; prevLeft = curr.position().left;
@ -364,7 +372,20 @@ function init(){
popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%"); popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%");
$(window).resize(function(){ $(window).resize(function(){
//$("#leftDiv,#rightDiv,#shadowDiv").css("height", $(window).height()); if($("#wgt_edit").hasClass("selected")){
if($(".editContainer").size() > 1){
var prev = $(".editContainer:first"),
prevBottom = prev.position().top + prev.height(),
prevLeft = prev.position().left;
recursionCall(prevBottom, prevLeft, prev.next());
}
} else {
var tmp_array = [];
$(".readyTask").each(function(){
tmp_array.push($(this));
});
orderItems(tmp_array);
}
popupBack.css("top", ($(window).height() - 138)*50/$(window).height() + "%"); popupBack.css("top", ($(window).height() - 138)*50/$(window).height() + "%");
popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%"); popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%");
}); });

@ -326,6 +326,15 @@ function init(){
$(".closeItem").live("click", function(){ $(".closeItem").live("click", function(){
if(!shadowOver){ if(!shadowOver){
$(this).parent().remove(); $(this).parent().remove();
if($(".editContainer").size() > 0){
var prev = $(".editContainer:first");
if((prev.position().left == 54) && (prev.position().top != 60))
prev.css("top", "60px");
var prevBottom = prev.position().top + prev.height(),
prevLeft = prev.position().left;
if(prev.next().length)
recursionCall(prevBottom, prevLeft, prev.next());
}
} }
}); });
@ -339,8 +348,7 @@ function init(){
}) })
function recursionCall(prevBottom, prevLeft, curr){ function recursionCall(prevBottom, prevLeft, curr){
var curTop = curr.position().top, var curHeight = curr.height(),
curHeight = curr.height(),
curLeft = curr.position().left; curLeft = curr.position().left;
if(prevLeft == curLeft){ if(prevLeft == curLeft){
if((prevBottom + 15 + curHeight) < ($(window).height() - 54)) if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
@ -351,7 +359,7 @@ function init(){
if((prevBottom + 15 + curHeight) < ($(window).height() - 54)) if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
curr.css("top", prevBottom + 15 + "px").css("left", prevLeft + "px"); curr.css("top", prevBottom + 15 + "px").css("left", prevLeft + "px");
else else
curr.css("top", "60px"); curr.css("top", "60px").css("left", prevLeft + 255 + "px");
} }
prevBottom = curr.position().top + curr.height(), prevBottom = curr.position().top + curr.height(),
prevLeft = curr.position().left; prevLeft = curr.position().left;
@ -364,7 +372,20 @@ function init(){
popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%"); popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%");
$(window).resize(function(){ $(window).resize(function(){
//$("#leftDiv,#rightDiv,#shadowDiv").css("height", $(window).height()); if($("#wgt_edit").hasClass("selected")){
if($(".editContainer").size() > 1){
var prev = $(".editContainer:first"),
prevBottom = prev.position().top + prev.height(),
prevLeft = prev.position().left;
recursionCall(prevBottom, prevLeft, prev.next());
}
} else {
var tmp_array = [];
$(".readyTask").each(function(){
tmp_array.push($(this));
});
orderItems(tmp_array);
}
popupBack.css("top", ($(window).height() - 138)*50/$(window).height() + "%"); popupBack.css("top", ($(window).height() - 138)*50/$(window).height() + "%");
popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%"); popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%");
}); });

@ -33,7 +33,6 @@ body{
font: 28px tahoma; font: 28px tahoma;
text-align: center; text-align: center;
cursor: pointer; cursor: pointer;
text-transform: uppercase;
overflow: hidden; overflow: hidden;
} }

@ -174,9 +174,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseGSection(const QDomElement &ele
QDomElement currentSvgElement = element.firstChildElement(); QDomElement currentSvgElement = element.firstChildElement();
while (!currentSvgElement.isNull()) { while (!currentSvgElement.isNull()) {
if (!parseSvgElement(currentSvgElement)) parseSvgElement(currentSvgElement);
return false;
currentSvgElement = currentSvgElement.nextSiblingElement(); currentSvgElement = currentSvgElement.nextSiblingElement();
} }
@ -187,8 +185,8 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseGSection(const QDomElement &ele
else else
{ {
delete mGSectionContainer; delete mGSectionContainer;
mGSectionContainer = NULL;
} }
mGSectionContainer = NULL;
return true; return true;
} }
@ -1189,8 +1187,6 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::persistScenes()
UBGraphicsScene *tmpScene = UBSvgSubsetAdaptor::loadScene(mProxy, i); UBGraphicsScene *tmpScene = UBSvgSubsetAdaptor::loadScene(mProxy, i);
tmpScene->setModified(true); tmpScene->setModified(true);
UBThumbnailAdaptor::persistScene(mProxy, tmpScene, i); UBThumbnailAdaptor::persistScene(mProxy, tmpScene, i);
delete tmpScene;
mCurrentScene->setModified(false); mCurrentScene->setModified(false);
} }

@ -553,15 +553,15 @@ void UBBoardController::duplicateItem(UBItem *item)
qreal shifting = UBSettings::settings()->objectFrameWidth; qreal shifting = UBSettings::settings()->objectFrameWidth;
itemPos = commonItem->pos() + QPointF(shifting,shifting); itemPos = commonItem->pos() + QPointF(shifting,shifting);
itemSize = commonItem->boundingRect().size(); itemSize = commonItem->boundingRect().size();
commonItem->setSelected(false);
} }
UBMimeType::Enum itemMimeType; UBMimeType::Enum itemMimeType;
QString contentTypeHeader = UBFileSystemUtils::mimeTypeFromFileName(item->sourceUrl().toLocalFile()); QString contentTypeHeader = UBFileSystemUtils::mimeTypeFromFileName(item->sourceUrl().toLocalFile());
if(NULL != qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(commonItem)){ if(NULL != qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(commonItem))
itemMimeType = UBMimeType::Group; itemMimeType = UBMimeType::Group;
}else{ else
itemMimeType = UBFileSystemUtils::mimeTypeFromString(contentTypeHeader); itemMimeType = UBFileSystemUtils::mimeTypeFromString(contentTypeHeader);
}
switch(static_cast<int>(itemMimeType)) switch(static_cast<int>(itemMimeType))
{ {
@ -633,10 +633,10 @@ void UBBoardController::duplicateItem(UBItem *item)
QGraphicsItem *gitem = dynamic_cast<QGraphicsItem*>(item->deepCopy()); QGraphicsItem *gitem = dynamic_cast<QGraphicsItem*>(item->deepCopy());
if (gitem) if (gitem)
{ {
qDebug() << "Adding a stroke: " << gitem;
mActiveScene->addItem(gitem); mActiveScene->addItem(gitem);
gitem->setPos(itemPos); gitem->setPos(itemPos);
mLastCreatedItem = gitem; mLastCreatedItem = gitem;
gitem->setSelected(true);
} }
return; return;
}break; }break;
@ -1482,11 +1482,12 @@ void UBBoardController::ClearUndoStack()
UBGraphicsItemUndoCommand *cmd = (UBGraphicsItemUndoCommand*)UBApplication::undoStack->command(i); UBGraphicsItemUndoCommand *cmd = (UBGraphicsItemUndoCommand*)UBApplication::undoStack->command(i);
// go through all added and removed objects, for create list of unique objects // go through all added and removed objects, for create list of unique objects
// grouped items will be deleted by groups, so we don't need do delete that items.
QSetIterator<QGraphicsItem*> itAdded(cmd->GetAddedList()); QSetIterator<QGraphicsItem*> itAdded(cmd->GetAddedList());
while (itAdded.hasNext()) while (itAdded.hasNext())
{ {
QGraphicsItem* item = itAdded.next(); QGraphicsItem* item = itAdded.next();
if( !uniqueItems.contains(item) ) if( !uniqueItems.contains(item) && !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type()))
uniqueItems.insert(item); uniqueItems.insert(item);
} }
@ -1494,7 +1495,7 @@ void UBBoardController::ClearUndoStack()
while (itRemoved.hasNext()) while (itRemoved.hasNext())
{ {
QGraphicsItem* item = itRemoved.next(); QGraphicsItem* item = itRemoved.next();
if( !uniqueItems.contains(item) ) if( !uniqueItems.contains(item) && !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type()))
uniqueItems.insert(item); uniqueItems.insert(item);
} }
} }
@ -1515,7 +1516,8 @@ void UBBoardController::ClearUndoStack()
} }
if(!scene) if(!scene)
{ {
mActiveScene->deleteItem(item); if (!mActiveScene->deleteItem(item))
delete item;
} }
} }

@ -710,9 +710,7 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
mLeftPalette->assignParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView()); mLeftPalette->assignParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView());
mRightPalette->assignParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView()); mRightPalette->assignParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView());
mStylusPalette->raise(); mStylusPalette->raise();
// Maybe threre is a reason to keep that functions but with them right palette in desktop mode is not interactable
// mRightPalette->lower();
// mLeftPalette->lower();
if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL) if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL)
{ {

@ -528,6 +528,8 @@ Here we determines cases when items should to get mouse press event at pressing
return true; return true;
case DelegateButton::Type: case DelegateButton::Type:
return true;
case UBGraphicsMediaItem::Type: case UBGraphicsMediaItem::Type:
return false; return false;
@ -1123,6 +1125,7 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
else else
{ {
if (isUBItem(movingItem) && if (isUBItem(movingItem) &&
DelegateButton::Type != movingItem->type() &&
QGraphicsSvgItem::Type != movingItem->type() && QGraphicsSvgItem::Type != movingItem->type() &&
UBGraphicsDelegateFrame::Type != movingItem->type() && UBGraphicsDelegateFrame::Type != movingItem->type() &&
UBToolWidget::Type != movingItem->type() && UBToolWidget::Type != movingItem->type() &&

@ -139,15 +139,7 @@ UBApplication::UBApplication(const QString &id, int &argc, char **argv) : QtSing
UBSettings *settings = UBSettings::settings(); UBSettings *settings = UBSettings::settings();
QString forcedLanguage(""); setupTranslators(args);
if(args.contains("-lang"))
forcedLanguage=args.at(args.indexOf("-lang") + 1);
else{
QString setLanguage = settings->appPreferredLanguage->get().toString();
if(!setLanguage.isEmpty())
forcedLanguage = setLanguage;
}
setupTranslator(forcedLanguage);
connect(settings->appToolBarPositionedAtTop, SIGNAL(changed(QVariant)), this, SLOT(toolBarPositionChanged(QVariant))); connect(settings->appToolBarPositionedAtTop, SIGNAL(changed(QVariant)), this, SLOT(toolBarPositionChanged(QVariant)));
connect(settings->appToolBarDisplayText, SIGNAL(changed(QVariant)), this, SLOT(toolBarDisplayTextChanged(QVariant))); connect(settings->appToolBarDisplayText, SIGNAL(changed(QVariant)), this, SLOT(toolBarDisplayTextChanged(QVariant)));
@ -207,22 +199,41 @@ UBApplication::~UBApplication()
staticMemoryCleaner = 0; staticMemoryCleaner = 0;
} }
void UBApplication::setupTranslator(QString forcedLanguage) QString UBApplication::checkLanguageAvailabilityForSankore(QString &language)
{ {
QStringList availablesTranslations = UBPlatformUtils::availableTranslations(); QStringList availableTranslations = UBPlatformUtils::availableTranslations();
QString language(""); if(availableTranslations.contains(language,Qt::CaseInsensitive))
if(!forcedLanguage.isEmpty()){ return language;
if(availablesTranslations.contains(forcedLanguage,Qt::CaseInsensitive)) else{
language = forcedLanguage; if(language.length() > 2){
else QString shortLanguageCode = language.left(2);
qDebug() << "forced language " << forcedLanguage << " not available"; if(availableTranslations.contains(shortLanguageCode,Qt::CaseInsensitive))
return shortLanguageCode;
}
}
return QString("");
} }
void UBApplication::setupTranslators(QStringList args)
{
QString forcedLanguage;
if(args.contains("-lang"))
forcedLanguage=args.at(args.indexOf("-lang") + 1);
else{ else{
QString setLanguage = UBSettings::settings()->appPreferredLanguage->get().toString();
if(!setLanguage.isEmpty())
forcedLanguage = setLanguage;
}
QStringList availablesTranslations = UBPlatformUtils::availableTranslations();
QString language("");
if(!forcedLanguage.isEmpty())
language = checkLanguageAvailabilityForSankore(forcedLanguage);
if(language.isEmpty()){
QString systemLanguage = UBPlatformUtils::systemLanguage(); QString systemLanguage = UBPlatformUtils::systemLanguage();
if(availablesTranslations.contains(systemLanguage,Qt::CaseInsensitive)) language = checkLanguageAvailabilityForSankore(systemLanguage);
language = systemLanguage;
else
qDebug() << "translation for system language " << systemLanguage << " not found";
} }
if(language.isEmpty()){ if(language.isEmpty()){
@ -236,17 +247,24 @@ void UBApplication::setupTranslator(QString forcedLanguage)
mApplicationTranslator->load(UBPlatformUtils::translationPath(QString("sankore_"),language)); mApplicationTranslator->load(UBPlatformUtils::translationPath(QString("sankore_"),language));
installTranslator(mApplicationTranslator); installTranslator(mApplicationTranslator);
QString qtGuiTranslationPath = UBPlatformUtils::translationPath("qt_", language);
mQtGuiTranslator->load(UBPlatformUtils::translationPath(QString("qt_"),language)); if(!QFile(qtGuiTranslationPath).exists()){
if(!mQtGuiTranslator->isEmpty()){ qtGuiTranslationPath = UBPlatformUtils::translationPath("qt_", language.left(2));
// checked because this translation could be not available if(!QFile(qtGuiTranslationPath).exists())
qtGuiTranslationPath = "";
}
if(!qtGuiTranslationPath.isEmpty()){
qDebug() << "qtGuiTranslationPath " << qtGuiTranslationPath;
mQtGuiTranslator->load(qtGuiTranslationPath);
installTranslator(mQtGuiTranslator); installTranslator(mQtGuiTranslator);
} }
else else
qDebug() << "Qt gui translation in " << language << " are not available"; qDebug() << "Qt gui translation in " << language << " is not available";
} }
QLocale::setDefault(QLocale(language)); QLocale::setDefault(QLocale(language));
qDebug() << "Running application in:" << language; qDebug() << "Running application in:" << language;
} }

@ -119,10 +119,10 @@ class UBApplication : public QtSingleApplication
private: private:
void updateProtoActionsState(); void updateProtoActionsState();
void setupTranslator(QString forcedLanguage); void setupTranslators(QStringList args);
QList<QMenu*> mProtoMenus; QList<QMenu*> mProtoMenus;
bool mIsVerbose; bool mIsVerbose;
QString checkLanguageAvailabilityForSankore(QString& language);
protected: protected:
#if defined(Q_WS_MACX) && !defined(QT_MAC_USE_COCOA) #if defined(Q_WS_MACX) && !defined(QT_MAC_USE_COCOA)

@ -86,7 +86,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
mTransparentDrawingView->setScene(mTransparentDrawingScene); mTransparentDrawingView->setScene(mTransparentDrawingScene);
mTransparentDrawingScene->setDrawingMode(true); mTransparentDrawingScene->setDrawingMode(true);
mDesktopPalette = new UBDesktopPalette(mTransparentDrawingView); mDesktopPalette = new UBDesktopPalette(NULL); // FIX #633: The palette must be 'floating' in order to stay on top of the library palette
if (UBPlatformUtils::hasVirtualKeyboard()) if (UBPlatformUtils::hasVirtualKeyboard())
{ {
@ -119,13 +119,13 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
connect(UBDrawingController::drawingController(), SIGNAL(stylusToolChanged(int)), this, SLOT(stylusToolChanged(int))); connect(UBDrawingController::drawingController(), SIGNAL(stylusToolChanged(int)), this, SLOT(stylusToolChanged(int)));
// Add the desktop associated palettes // Add the desktop associated palettes
mDesktopPenPalette = new UBDesktopPenPalette(mTransparentDrawingView); mDesktopPenPalette = new UBDesktopPenPalette(NULL); // FIX #633: The palette must be 'floating' in order to stay on top of the library palette
connect(mDesktopPalette, SIGNAL(maximized()), mDesktopPenPalette, SLOT(onParentMaximized())); connect(mDesktopPalette, SIGNAL(maximized()), mDesktopPenPalette, SLOT(onParentMaximized()));
connect(mDesktopPalette, SIGNAL(minimizeStart(eMinimizedLocation)), mDesktopPenPalette, SLOT(onParentMinimized())); connect(mDesktopPalette, SIGNAL(minimizeStart(eMinimizedLocation)), mDesktopPenPalette, SLOT(onParentMinimized()));
mDesktopMarkerPalette = new UBDesktopMarkerPalette(mTransparentDrawingView); mDesktopMarkerPalette = new UBDesktopMarkerPalette(NULL); // FIX #633: The palette must be 'floating' in order to stay on top of the library palette
mDesktopEraserPalette = new UBDesktopEraserPalette(mTransparentDrawingView); mDesktopEraserPalette = new UBDesktopEraserPalette(NULL); // FIX #633: The palette must be 'floating' in order to stay on top of the library palette
mDesktopPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); mDesktopPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor);
mDesktopPenPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor); mDesktopPenPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor);
@ -154,6 +154,12 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
connect(UBApplication::boardController->paletteManager()->rightPalette(), SIGNAL(resized()), this, SLOT(refreshMask())); connect(UBApplication::boardController->paletteManager()->rightPalette(), SIGNAL(resized()), this, SLOT(refreshMask()));
#endif #endif
onDesktopPaletteMaximized(); onDesktopPaletteMaximized();
// FIX #633: Ensure that these palettes stay on top of the other elements
mDesktopEraserPalette->raise();
mDesktopMarkerPalette->raise();
mDesktopPenPalette->raise();
mDesktopPalette->raise();
} }
UBDesktopAnnotationController::~UBDesktopAnnotationController() UBDesktopAnnotationController::~UBDesktopAnnotationController()
@ -243,11 +249,7 @@ void UBDesktopAnnotationController::setAssociatedPalettePosition(UBActionPalette
if(act->objectName() == actionName) if(act->objectName() == actionName)
{ {
int iAction = actions.indexOf(act); int iAction = actions.indexOf(act);
yPen = iAction * mDesktopPalette->buttonSize().height(); yPen = iAction * (mDesktopPalette->buttonSize().height() + 2 * mDesktopPalette->border() +6); // This is the mysterious value (6)
// Add the borders
yPen += (iAction) * (mDesktopPalette->border() + 4); // 4 has been set after some experiment. We must determine why this value is good
break; break;
} }
} }

@ -117,8 +117,11 @@ UBDocumentProxyTreeItem* UBDocumentController::findDocument(UBDocumentProxy* pro
void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurrentDocument) void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurrentDocument)
{ {
if (!proxy) if (proxy==NULL)
{
setDocument(NULL);
return; return;
}
QTreeWidgetItemIterator it(mDocumentUI->documentTreeWidget); QTreeWidgetItemIterator it(mDocumentUI->documentTreeWidget);
@ -531,31 +534,8 @@ void UBDocumentController::duplicateSelectedItem()
} }
} }
void UBDocumentController::moveDocumentToTrash(UBDocumentGroupTreeItem* groupTi, UBDocumentProxyTreeItem *proxyTi)
void UBDocumentController::deleteSelectedItem()
{
if (mSelectionType == Page)
{
QList<QGraphicsItem*> selectedItems = mDocumentUI->thumbnailWidget->selectedItems();
deletePages(selectedItems);
}
else
{
UBDocumentProxyTreeItem *proxyTi = selectedDocumentProxyTreeItem();
UBDocumentGroupTreeItem* groupTi = selectedDocumentGroupTreeItem();
if (proxyTi && proxyTi->proxy() && proxyTi->parent())
{ {
if(UBApplication::mainWindow->yesNoQuestion(tr("Remove Document"), tr("Are you sure you want to remove the document '%1'?").arg(proxyTi->proxy()->metaData(UBSettings::documentName).toString())))
{
if (proxyTi->parent() != mTrashTi)
{
// We have to move document into Trash
// Select another document for processing
// This is for Board, where this document can be selected
int index = proxyTi->parent()->indexOfChild(proxyTi); int index = proxyTi->parent()->indexOfChild(proxyTi);
index --; index --;
@ -619,54 +599,9 @@ void UBDocumentController::deleteSelectedItem()
mTrashTi->addChild(proxyTi); mTrashTi->addChild(proxyTi);
proxyTi->setFlags(proxyTi->flags() ^ Qt::ItemIsEditable); proxyTi->setFlags(proxyTi->flags() ^ Qt::ItemIsEditable);
} }
else
{
// We have to physical delete document
// No action with selection required - document from Trash cant be selected in Board
proxyTi->parent()->removeChild(proxyTi);
UBPersistenceManager::persistenceManager()->deleteDocument(proxyTi->proxy());
}
}
}
else if (groupTi)
{
if (groupTi == mTrashTi)
{
if(UBApplication::mainWindow->yesNoQuestion(tr("Empty Trash"), tr("Are you sure you want to empty trash?")))
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
QList<UBDocumentProxyTreeItem*> toBeDeleted;
for (int i = 0; i < groupTi->childCount(); i++)
{
UBDocumentProxyTreeItem* proxyTi = dynamic_cast<UBDocumentProxyTreeItem*>(groupTi->child(i));
if (proxyTi && proxyTi->proxy())
toBeDeleted << proxyTi;
}
showMessage(tr("Emptying trash"));
for (int i = 0; i < toBeDeleted.count(); i++)
{
UBDocumentProxyTreeItem* proxyTi = toBeDeleted.at(i);
proxyTi->parent()->removeChild(proxyTi);
UBPersistenceManager::persistenceManager()->deleteDocument(proxyTi->proxy());
}
showMessage(tr("Emptied trash")); void UBDocumentController::moveFolderToTrash(UBDocumentGroupTreeItem* groupTi)
QApplication::restoreOverrideCursor();
mMainWindow->actionDelete->setEnabled(false);
}
}
else
{
if(UBApplication::mainWindow->yesNoQuestion(tr("Remove Folder"), tr("Are you sure you want to remove the folder '%1' and all its content?").arg(groupTi->groupName())))
{ {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
bool changeCurrentDocument = false; bool changeCurrentDocument = false;
for (int i = 0; i < groupTi->childCount(); i++) for (int i = 0; i < groupTi->childCount(); i++)
{ {
@ -744,9 +679,84 @@ void UBDocumentController::deleteSelectedItem()
} }
} }
reloadThumbnails();
}
void UBDocumentController::deleteSelectedItem()
{
if (mSelectionType == Page)
{
QList<QGraphicsItem*> selectedItems = mDocumentUI->thumbnailWidget->selectedItems();
deletePages(selectedItems);
}
else
{
UBDocumentProxyTreeItem *proxyTi = selectedDocumentProxyTreeItem();
UBDocumentGroupTreeItem* groupTi = selectedDocumentGroupTreeItem();
if (proxyTi && proxyTi->proxy() && proxyTi->parent())
{
if(UBApplication::mainWindow->yesNoQuestion(tr("Remove Document"), tr("Are you sure you want to remove the document '%1'?").arg(proxyTi->proxy()->metaData(UBSettings::documentName).toString())))
{
if (proxyTi->parent() != mTrashTi)
{
moveDocumentToTrash(groupTi, proxyTi);
}
else
{
// We have to physically delete document
proxyTi->parent()->removeChild(proxyTi);
UBPersistenceManager::persistenceManager()->deleteDocument(proxyTi->proxy());
if (mTrashTi->childCount()==0)
selectDocument(NULL);
else
selectDocument(((UBDocumentProxyTreeItem*)mTrashTi->child(0))->proxy());
reloadThumbnails(); reloadThumbnails();
}
}
}
else if (groupTi)
{
if (groupTi == mTrashTi)
{
if(UBApplication::mainWindow->yesNoQuestion(tr("Empty Trash"), tr("Are you sure you want to empty trash?")))
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
QList<UBDocumentProxyTreeItem*> toBeDeleted;
for (int i = 0; i < groupTi->childCount(); i++)
{
UBDocumentProxyTreeItem* proxyTi = dynamic_cast<UBDocumentProxyTreeItem*>(groupTi->child(i));
if (proxyTi && proxyTi->proxy())
toBeDeleted << proxyTi;
}
showMessage(tr("Emptying trash"));
for (int i = 0; i < toBeDeleted.count(); i++)
{
UBDocumentProxyTreeItem* proxyTi = toBeDeleted.at(i);
proxyTi->parent()->removeChild(proxyTi);
UBPersistenceManager::persistenceManager()->deleteDocument(proxyTi->proxy());
}
showMessage(tr("Emptied trash"));
QApplication::restoreOverrideCursor();
mMainWindow->actionDelete->setEnabled(false);
}
}
else
{
if(UBApplication::mainWindow->yesNoQuestion(tr("Remove Folder"), tr("Are you sure you want to remove the folder '%1' and all its content?").arg(groupTi->groupName())))
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
moveFolderToTrash(groupTi);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
} }

@ -111,6 +111,9 @@ class UBDocumentController : public UBDocumentContainer
bool mToolsPalettePositionned; bool mToolsPalettePositionned;
UBDocumentGroupTreeItem* mTrashTi; UBDocumentGroupTreeItem* mTrashTi;
void moveDocumentToTrash(UBDocumentGroupTreeItem* groupTi, UBDocumentProxyTreeItem *proxyTi);
void moveFolderToTrash(UBDocumentGroupTreeItem* groupTi);
private slots: private slots:
void documentZoomSliderValueChanged (int value); void documentZoomSliderValueChanged (int value);
void loadDocumentProxies(); void loadDocumentProxies();

@ -28,18 +28,12 @@ UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent
setUuid(QUuid::createUuid()); setUuid(QUuid::createUuid());
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
} }
UBGraphicsGroupContainerItem::~UBGraphicsGroupContainerItem() UBGraphicsGroupContainerItem::~UBGraphicsGroupContainerItem()
{ {
foreach (QGraphicsItem *item, childItems()) if (mDelegate)
{ delete mDelegate;
removeFromGroup(item);
if (item && item->scene())
item->scene()->removeItem(item);
}
} }
void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item) void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item)
@ -83,6 +77,10 @@ void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item)
QTransform newItemTransform(itemTransform); QTransform newItemTransform(itemTransform);
item->setPos(mapFromItem(item, 0, 0)); item->setPos(mapFromItem(item, 0, 0));
item->scene()->removeItem(item);
if (corescene())
corescene()->removeItemFromDeletion(item);
item->setParentItem(this); item->setParentItem(this);
// removing position from translation component of the new transform // removing position from translation component of the new transform
@ -113,10 +111,12 @@ void UBGraphicsGroupContainerItem::removeFromGroup(QGraphicsItem *item)
{ {
if (!item) { if (!item) {
qDebug() << "can't specify the item because of the null pointer"; qDebug() << "can't specify the item because of the null pointer";
return;
} }
UBGraphicsScene *groupScene = scene(); UBCoreGraphicsScene *groupScene = corescene();
if (groupScene) { if (groupScene)
{
groupScene->addItemToDeletion(item); groupScene->addItemToDeletion(item);
} }
@ -170,9 +170,9 @@ void UBGraphicsGroupContainerItem::paint(QPainter *painter, const QStyleOptionGr
// } // }
} }
UBGraphicsScene *UBGraphicsGroupContainerItem::scene() UBCoreGraphicsScene *UBGraphicsGroupContainerItem::corescene()
{ {
UBGraphicsScene *castScene = dynamic_cast<UBGraphicsScene*>(QGraphicsItem::scene()); UBCoreGraphicsScene *castScene = dynamic_cast<UBCoreGraphicsScene*>(QGraphicsItem::scene());
return castScene; return castScene;
} }
@ -218,15 +218,7 @@ void UBGraphicsGroupContainerItem::setUuid(const QUuid &pUuid)
void UBGraphicsGroupContainerItem::destroy() { void UBGraphicsGroupContainerItem::destroy() {
UBGraphicsScene *groupScene = scene();
foreach (QGraphicsItem *item, childItems()) { foreach (QGraphicsItem *item, childItems()) {
if (groupScene) {
groupScene->addItemToDeletion(item);
}
pRemoveFromGroup(item); pRemoveFromGroup(item);
item->setFlag(QGraphicsItem::ItemIsSelectable, true); item->setFlag(QGraphicsItem::ItemIsSelectable, true);
item->setFlag(QGraphicsItem::ItemIsFocusable, true); item->setFlag(QGraphicsItem::ItemIsFocusable, true);
@ -235,6 +227,18 @@ void UBGraphicsGroupContainerItem::destroy() {
remove(); remove();
} }
void UBGraphicsGroupContainerItem::clearSource()
{
foreach(QGraphicsItem *child, childItems())
{
UBGraphicsItem *item = dynamic_cast<UBGraphicsItem *>(child);
if (item)
{
item->clearSource();
}
}
}
void UBGraphicsGroupContainerItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsGroupContainerItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if (mDelegate->mousePressEvent(event)) { if (mDelegate->mousePressEvent(event)) {
@ -327,6 +331,12 @@ void UBGraphicsGroupContainerItem::pRemoveFromGroup(QGraphicsItem *item)
item->setParentItem(newParent); item->setParentItem(newParent);
item->setPos(oldPos); item->setPos(oldPos);
UBGraphicsScene *Scene = dynamic_cast<UBGraphicsScene *>(item->scene());
if (Scene)
{
Scene->addItem(item);
}
// removing position from translation component of the new transform // removing position from translation component of the new transform
if (!item->pos().isNull()) if (!item->pos().isNull())
itemTransform *= QTransform::fromTranslate(-item->x(), -item->y()); itemTransform *= QTransform::fromTranslate(-item->x(), -item->y());

@ -4,6 +4,7 @@
#include <QGraphicsItem> #include <QGraphicsItem>
#include "domain/UBItem.h" #include "domain/UBItem.h"
#include "frameworks/UBCoreGraphicsScene.h"
class UBGraphicsGroupContainerItem : public QGraphicsItem, public UBItem, public UBGraphicsItem class UBGraphicsGroupContainerItem : public QGraphicsItem, public UBItem, public UBGraphicsItem
{ {
@ -23,7 +24,7 @@ public:
virtual UBGraphicsItemDelegate* Delegate() const { return mDelegate;} virtual UBGraphicsItemDelegate* Delegate() const { return mDelegate;}
virtual UBGraphicsScene* scene(); virtual UBCoreGraphicsScene *corescene();
virtual UBGraphicsGroupContainerItem *deepCopy() const; virtual UBGraphicsGroupContainerItem *deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const; virtual void copyItemParameters(UBItem *copy) const;
@ -38,6 +39,8 @@ public:
virtual void setUuid(const QUuid &pUuid); virtual void setUuid(const QUuid &pUuid);
void destroy(); void destroy();
virtual void clearSource();
protected: protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);

@ -113,7 +113,6 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec
, mFlippable(false) , mFlippable(false)
, mToolBarUsed(useToolBar) , mToolBarUsed(useToolBar)
{ {
// NOOP
connect(UBApplication::boardController, SIGNAL(zoomChanged(qreal)), this, SLOT(onZoomChanged())); connect(UBApplication::boardController, SIGNAL(zoomChanged(qreal)), this, SLOT(onZoomChanged()));
} }
@ -167,7 +166,7 @@ void UBGraphicsItemDelegate::init()
UBGraphicsItemDelegate::~UBGraphicsItemDelegate() UBGraphicsItemDelegate::~UBGraphicsItemDelegate()
{ {
qDeleteAll(mButtons); disconnect(UBApplication::boardController, SIGNAL(zoomChanged(qreal)), this, SLOT(onZoomChanged()));
// do not release mMimeData. // do not release mMimeData.
// the mMimeData is owned by QDrag since the setMimeData call as specified in the documentation // the mMimeData is owned by QDrag since the setMimeData call as specified in the documentation
} }

@ -143,13 +143,13 @@ QColor UBGraphicsPolygonItem::color() const
UBItem* UBGraphicsPolygonItem::deepCopy() const UBItem* UBGraphicsPolygonItem::deepCopy() const
{ {
UBGraphicsPolygonItem* copy = new UBGraphicsPolygonItem(polygon(), parentItem()); UBGraphicsPolygonItem* copy = new UBGraphicsPolygonItem(polygon(), 0);
UBGraphicsStroke *stroke = new UBGraphicsStroke();
copyItemParameters(copy); copyItemParameters(copy);
copy->mOriginalLine = this->mOriginalLine; copy->setStroke(stroke);
copy->mOriginalWidth = this->mOriginalWidth;
copy->mIsNominalLine = this->mIsNominalLine;
return copy; return copy;
} }
@ -160,17 +160,15 @@ void UBGraphicsPolygonItem::copyItemParameters(UBItem *copy) const
UBGraphicsPolygonItem *cp = dynamic_cast<UBGraphicsPolygonItem*>(copy); UBGraphicsPolygonItem *cp = dynamic_cast<UBGraphicsPolygonItem*>(copy);
if (cp) if (cp)
{ {
cp->mOriginalLine = QLineF(); cp->mOriginalLine = this->mOriginalLine;
cp->mOriginalWidth = -1; cp->mOriginalWidth = this->mOriginalWidth;
cp->mIsNominalLine = false; cp->mIsNominalLine = this->mIsNominalLine;
cp->setStroke(this->stroke()); cp->setTransform(transform());
cp->setStrokesGroup(this->strokesGroup());
cp->setBrush(this->brush()); cp->setBrush(this->brush());
cp->setPen(this->pen()); cp->setPen(this->pen());
cp->mHasAlpha = this->mHasAlpha; cp->mHasAlpha = this->mHasAlpha;
cp->setColorOnDarkBackground(this->colorOnDarkBackground()); cp->setColorOnDarkBackground(this->colorOnDarkBackground());
cp->setColorOnLightBackground(this->colorOnLightBackground()); cp->setColorOnLightBackground(this->colorOnLightBackground());

@ -263,7 +263,6 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
, mCrossedBackground(false) , mCrossedBackground(false)
, mIsDesktopMode(false) , mIsDesktopMode(false)
, mZoomFactor(1) , mZoomFactor(1)
, mIsModified(true)
, mBackgroundObject(0) , mBackgroundObject(0)
, mPreviousWidth(0) , mPreviousWidth(0)
, mInputDeviceIsPressed(false) , mInputDeviceIsPressed(false)
@ -305,7 +304,10 @@ UBGraphicsScene::~UBGraphicsScene()
{ {
if (mCurrentStroke) if (mCurrentStroke)
if (mCurrentStroke->polygons().empty()) if (mCurrentStroke->polygons().empty())
{
delete mCurrentStroke; delete mCurrentStroke;
mCurrentStroke = NULL;
}
if (mZLayerController) if (mZLayerController)
delete mZLayerController; delete mZLayerController;
@ -433,6 +435,11 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
} }
} }
if (mCurrentStroke && mCurrentStroke->polygons().empty()){
delete mCurrentStroke;
mCurrentStroke = NULL;
}
return accepted; return accepted;
} }
@ -474,6 +481,10 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
UBCoreGraphicsScene::removeItemFromDeletion(mpLastPolygon); UBCoreGraphicsScene::removeItemFromDeletion(mpLastPolygon);
mAddedItems.remove(mpLastPolygon); mAddedItems.remove(mpLastPolygon);
mCurrentStroke->remove(mpLastPolygon); mCurrentStroke->remove(mpLastPolygon);
if (mCurrentStroke->polygons().empty()){
delete mCurrentStroke;
mCurrentStroke = NULL;
}
removeItem(mpLastPolygon); removeItem(mpLastPolygon);
mPreviousPolygonItems.removeAll(mpLastPolygon); mPreviousPolygonItems.removeAll(mpLastPolygon);
} }
@ -1060,12 +1071,9 @@ void UBGraphicsScene::clearItemsAndAnnotations()
QSet<QGraphicsItem*> emptyList; QSet<QGraphicsItem*> emptyList;
QSet<QGraphicsItem*> removedItems; QSet<QGraphicsItem*> removedItems;
QListIterator<QGraphicsItem*> itItems(mFastAccessItems); QList<QGraphicsItem*> sceneItems = items();
foreach(QGraphicsItem* item, sceneItems)
while (itItems.hasNext())
{ {
QGraphicsItem* item = itItems.next();
if(!mTools.contains(item) && !isBackgroundObject(item)) if(!mTools.contains(item) && !isBackgroundObject(item))
{ {
removeItem(item); removeItem(item);
@ -1091,23 +1099,19 @@ void UBGraphicsScene::clearItems()
QSet<QGraphicsItem*> emptyList; QSet<QGraphicsItem*> emptyList;
QSet<QGraphicsItem*> removedItems; QSet<QGraphicsItem*> removedItems;
QListIterator<QGraphicsItem*> itItems(mFastAccessItems); QList<QGraphicsItem*> sceneItems = items();
foreach(QGraphicsItem* item, sceneItems)
while (itItems.hasNext())
{
QGraphicsItem* item = itItems.next();
if (!item->parentItem())
{ {
UBGraphicsPolygonItem* pi = qgraphicsitem_cast<UBGraphicsPolygonItem*>(item); bool isGroup = qgraphicsitem_cast<UBGraphicsGroupContainerItem*>(item) != NULL;
bool isPolygon = qgraphicsitem_cast<UBGraphicsPolygonItem*>(item) != NULL;
bool isStrokesGroup = qgraphicsitem_cast<UBGraphicsStrokesGroup*>(item) != NULL;
if(!pi && !mTools.contains(item) && !isBackgroundObject(item)) if(!isGroup && !isPolygon && !isStrokesGroup && !mTools.contains(item) && !isBackgroundObject(item))
{ {
removeItem(item); removeItem(item);
removedItems << item; removedItems << item;
} }
} }
}
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint // force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
update(sceneRect()); update(sceneRect());
@ -1126,11 +1130,9 @@ void UBGraphicsScene::clearAnnotations()
QSet<QGraphicsItem*> emptyList; QSet<QGraphicsItem*> emptyList;
QSet<QGraphicsItem*> removedItems; QSet<QGraphicsItem*> removedItems;
QListIterator<QGraphicsItem*> itItems(mFastAccessItems); QList<QGraphicsItem*> sceneItems = items();
foreach(QGraphicsItem* item, sceneItems)
while (itItems.hasNext())
{ {
QGraphicsItem* item = itItems.next();
UBGraphicsStrokesGroup* pi = qgraphicsitem_cast<UBGraphicsStrokesGroup*>(item); UBGraphicsStrokesGroup* pi = qgraphicsitem_cast<UBGraphicsStrokesGroup*>(item);
if (pi) if (pi)
{ {
@ -1142,7 +1144,6 @@ void UBGraphicsScene::clearAnnotations()
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint // force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
update(sceneRect()); update(sceneRect());
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, emptyList); UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, emptyList);
UBApplication::undoStack->push(uc); UBApplication::undoStack->push(uc);
@ -1356,6 +1357,7 @@ UBGraphicsW3CWidgetItem* UBGraphicsScene::addOEmbed(const QUrl& pContentUrl, con
UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QList<QGraphicsItem *> items) UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QList<QGraphicsItem *> items)
{ {
UBGraphicsGroupContainerItem *groupItem = new UBGraphicsGroupContainerItem(); UBGraphicsGroupContainerItem *groupItem = new UBGraphicsGroupContainerItem();
addItem(groupItem);
foreach (QGraphicsItem *item, items) { foreach (QGraphicsItem *item, items) {
if (item->type() == UBGraphicsGroupContainerItem::Type) { if (item->type() == UBGraphicsGroupContainerItem::Type) {
@ -1366,13 +1368,14 @@ UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QList<QGraphicsItem *
} }
foreach (QGraphicsItem *chItem, childItems) { foreach (QGraphicsItem *chItem, childItems) {
groupItem->addToGroup(chItem); groupItem->addToGroup(chItem);
mFastAccessItems.removeAll(chItem);
} }
} else { } else {
groupItem->addToGroup(item); groupItem->addToGroup(item);
mFastAccessItems.removeAll(item);
} }
} }
addItem(groupItem);
groupItem->setVisible(true); groupItem->setVisible(true);
groupItem->setFocus(); groupItem->setFocus();
@ -1389,6 +1392,15 @@ UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QList<QGraphicsItem *
void UBGraphicsScene::addGroup(UBGraphicsGroupContainerItem *groupItem) void UBGraphicsScene::addGroup(UBGraphicsGroupContainerItem *groupItem)
{ {
addItem(groupItem); addItem(groupItem);
for (int i = 0; i < groupItem->childItems().count(); i++)
{
QGraphicsItem *it = qgraphicsitem_cast<QGraphicsItem *>(groupItem->childItems().at(i));
if (it)
{
mFastAccessItems.removeAll(it);
}
}
groupItem->setVisible(true); groupItem->setVisible(true);
groupItem->setFocus(); groupItem->setFocus();
@ -1557,7 +1569,6 @@ UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString, const Q
void UBGraphicsScene::addItem(QGraphicsItem* item) void UBGraphicsScene::addItem(QGraphicsItem* item)
{ {
setModified(true);
UBCoreGraphicsScene::addItem(item); UBCoreGraphicsScene::addItem(item);
UBGraphicsItem::assignZValue(item, mZLayerController->generateZLevel(item)); UBGraphicsItem::assignZValue(item, mZLayerController->generateZLevel(item));
@ -1570,8 +1581,6 @@ void UBGraphicsScene::addItem(QGraphicsItem* item)
void UBGraphicsScene::addItems(const QSet<QGraphicsItem*>& items) void UBGraphicsScene::addItems(const QSet<QGraphicsItem*>& items)
{ {
setModified(true);
foreach(QGraphicsItem* item, items) { foreach(QGraphicsItem* item, items) {
UBCoreGraphicsScene::addItem(item); UBCoreGraphicsScene::addItem(item);
UBGraphicsItem::assignZValue(item, mZLayerController->generateZLevel(item)); UBGraphicsItem::assignZValue(item, mZLayerController->generateZLevel(item));
@ -1584,7 +1593,7 @@ void UBGraphicsScene::addItems(const QSet<QGraphicsItem*>& items)
void UBGraphicsScene::removeItem(QGraphicsItem* item) void UBGraphicsScene::removeItem(QGraphicsItem* item)
{ {
setModified(true); item->setSelected(false);
UBCoreGraphicsScene::removeItem(item); UBCoreGraphicsScene::removeItem(item);
UBApplication::boardController->freezeW3CWidget(item, true); UBApplication::boardController->freezeW3CWidget(item, true);
@ -1596,8 +1605,6 @@ void UBGraphicsScene::removeItem(QGraphicsItem* item)
void UBGraphicsScene::removeItems(const QSet<QGraphicsItem*>& items) void UBGraphicsScene::removeItems(const QSet<QGraphicsItem*>& items)
{ {
setModified(true);
foreach(QGraphicsItem* item, items) foreach(QGraphicsItem* item, items)
UBCoreGraphicsScene::removeItem(item); UBCoreGraphicsScene::removeItem(item);
@ -1755,7 +1762,6 @@ void UBGraphicsScene::addRuler(QPointF center)
addItem(ruler); addItem(ruler);
ruler->setVisible(true); ruler->setVisible(true);
setModified(true);
} }
void UBGraphicsScene::addProtractor(QPointF center) void UBGraphicsScene::addProtractor(QPointF center)
@ -1773,7 +1779,6 @@ void UBGraphicsScene::addProtractor(QPointF center)
protractor->moveBy(center.x() - itemSceneCenter.x(), center.y() - itemSceneCenter.y()); protractor->moveBy(center.x() - itemSceneCenter.x(), center.y() - itemSceneCenter.y());
protractor->setVisible(true); protractor->setVisible(true);
setModified(true);
} }
void UBGraphicsScene::addTriangle(QPointF center) void UBGraphicsScene::addTriangle(QPointF center)
@ -1791,7 +1796,6 @@ void UBGraphicsScene::addTriangle(QPointF center)
triangle->moveBy(center.x() - itemSceneCenter.x(), center.y() - itemSceneCenter.y()); triangle->moveBy(center.x() - itemSceneCenter.x(), center.y() - itemSceneCenter.y());
triangle->setVisible(true); triangle->setVisible(true);
setModified(true);
} }
void UBGraphicsScene::addMagnifier(UBMagnifierParams params) void UBGraphicsScene::addMagnifier(UBMagnifierParams params)
@ -1850,6 +1854,7 @@ void UBGraphicsScene::moveMagnifier()
{ {
QPoint magnifierPos = QPoint(magniferControlViewWidget->pos().x() + magniferControlViewWidget->size().width() / 2, magniferControlViewWidget->pos().y() + magniferControlViewWidget->size().height() / 2 ); QPoint magnifierPos = QPoint(magniferControlViewWidget->pos().x() + magniferControlViewWidget->size().width() / 2, magniferControlViewWidget->pos().y() + magniferControlViewWidget->size().height() / 2 );
moveMagnifier(magnifierPos, true); moveMagnifier(magnifierPos, true);
setModified(true);
} }
} }
@ -1882,6 +1887,7 @@ void UBGraphicsScene::moveMagnifier(QPoint newPos, bool forceGrab)
void UBGraphicsScene::closeMagnifier() void UBGraphicsScene::closeMagnifier()
{ {
DisposeMagnifierQWidgets(); DisposeMagnifierQWidgets();
setModified(true);
} }
void UBGraphicsScene::zoomInMagnifier() void UBGraphicsScene::zoomInMagnifier()
@ -1899,6 +1905,7 @@ void UBGraphicsScene::zoomOutMagnifier()
{ {
magniferControlViewWidget->setZoom(magniferControlViewWidget->params.zoom - 0.5); magniferControlViewWidget->setZoom(magniferControlViewWidget->params.zoom - 0.5);
magniferDisplayViewWidget->setZoom(magniferDisplayViewWidget->params.zoom - 0.5); magniferDisplayViewWidget->setZoom(magniferDisplayViewWidget->params.zoom - 0.5);
setModified(true);
} }
} }
@ -1910,6 +1917,7 @@ void UBGraphicsScene::resizedMagnifier(qreal newPercent)
magniferControlViewWidget->grabPoint(); magniferControlViewWidget->grabPoint();
magniferDisplayViewWidget->setSize(newPercent); magniferDisplayViewWidget->setSize(newPercent);
magniferDisplayViewWidget->grabPoint(); magniferDisplayViewWidget->grabPoint();
setModified(true);
} }
} }
@ -1925,7 +1933,6 @@ void UBGraphicsScene::addCompass(QPointF center)
compass->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); compass->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
compass->setVisible(true); compass->setVisible(true);
setModified(true);
} }
void UBGraphicsScene::addCache() void UBGraphicsScene::addCache()
@ -1955,7 +1962,6 @@ void UBGraphicsScene::addMask(const QPointF &center)
curtain->setRect(rect); curtain->setRect(rect);
curtain->setVisible(true); curtain->setVisible(true);
curtain->setSelected(true); curtain->setSelected(true);
setModified(true);
} }
void UBGraphicsScene::setRenderingQuality(UBItem::RenderingQuality pRenderingQuality) void UBGraphicsScene::setRenderingQuality(UBItem::RenderingQuality pRenderingQuality)
@ -2205,7 +2211,6 @@ void UBGraphicsScene::keyReleaseEvent(QKeyEvent * keyEvent)
default: default:
{ {
item->setSelected(false);
UBGraphicsItem *ubgi = dynamic_cast<UBGraphicsItem*>(item); UBGraphicsItem *ubgi = dynamic_cast<UBGraphicsItem*>(item);
if (0 != ubgi) if (0 != ubgi)
ubgi->remove(); ubgi->remove();
@ -2267,6 +2272,11 @@ void UBGraphicsScene::setToolCursor(int tool)
{ {
deselectAllItems(); deselectAllItems();
} }
if (mCurrentStroke && mCurrentStroke->polygons().empty()){
delete mCurrentStroke;
}
mCurrentStroke = NULL;
} }
void UBGraphicsScene::initStroke(){ void UBGraphicsScene::initStroke(){

@ -179,16 +179,6 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
bool isEmpty() const; bool isEmpty() const;
bool isModified() const
{
return mIsModified;
}
void setModified(bool pModified)
{
mIsModified = pModified;
}
void setDocument(UBDocumentProxy* pDocument); void setDocument(UBDocumentProxy* pDocument);
UBDocumentProxy* document() const UBDocumentProxy* document() const
@ -380,8 +370,6 @@ public slots:
bool mIsDesktopMode; bool mIsDesktopMode;
qreal mZoomFactor; qreal mZoomFactor;
bool mIsModified;
QGraphicsItem* mBackgroundObject; QGraphicsItem* mBackgroundObject;
QPointF mPreviousPoint; QPointF mPreviousPoint;

@ -115,14 +115,16 @@ UBItem* UBGraphicsStrokesGroup::deepCopy() const
{ {
UBGraphicsStrokesGroup* copy = new UBGraphicsStrokesGroup(); UBGraphicsStrokesGroup* copy = new UBGraphicsStrokesGroup();
QList<QGraphicsItem*> chl = childItems(); QList<QGraphicsItem*> chl = childItems();
foreach(QGraphicsItem *child, chl) foreach(QGraphicsItem *child, chl)
{ {
UBGraphicsPolygonItem *polygon = dynamic_cast<UBGraphicsPolygonItem*>(child); UBGraphicsPolygonItem *polygon = dynamic_cast<UBGraphicsPolygonItem*>(child);
if (polygon) if (polygon)
{
copy->addToGroup(dynamic_cast<QGraphicsItem*>(polygon->deepCopy())); copy->addToGroup(dynamic_cast<QGraphicsItem*>(polygon->deepCopy()));
polygon->setStrokesGroup(copy);
}
} }
copyItemParameters(copy); copyItemParameters(copy);
@ -133,9 +135,8 @@ void UBGraphicsStrokesGroup::copyItemParameters(UBItem *copy) const
{ {
UBGraphicsStrokesGroup *cp = dynamic_cast<UBGraphicsStrokesGroup*>(copy); UBGraphicsStrokesGroup *cp = dynamic_cast<UBGraphicsStrokesGroup*>(copy);
{ {
cp->setPos(this->pos()); cp->setTransform(transform());
cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true); cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true); cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType)); cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));

@ -23,6 +23,7 @@
UBCoreGraphicsScene::UBCoreGraphicsScene(QObject * parent) UBCoreGraphicsScene::UBCoreGraphicsScene(QObject * parent)
: QGraphicsScene ( parent ) : QGraphicsScene ( parent )
, mIsModified(true)
{ {
//NOOP //NOOP
} }
@ -30,27 +31,40 @@ UBCoreGraphicsScene::UBCoreGraphicsScene(QObject * parent)
UBCoreGraphicsScene::~UBCoreGraphicsScene() 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
foreach (const QGraphicsItem* item, mItemsToDelete) //at groups deleting some items can be added to mItemsToDelete, so we need to use iterators.
if (mItemsToDelete.count())
{ {
if (item->scene() == NULL || item->scene() == this) QSet<QGraphicsItem *>::iterator it = mItemsToDelete.begin();
QGraphicsItem* item = *it;
do
{ {
item = *it;
if (item && (item->scene() == NULL || item->scene() == this))
{
mItemsToDelete.remove(*it);
delete item; delete item;
} }
it = mItemsToDelete.begin();
}while(mItemsToDelete.count());
} }
} }
void UBCoreGraphicsScene::addItem(QGraphicsItem* item) void UBCoreGraphicsScene::addItem(QGraphicsItem* item)
{ {
addItemToDeletion(item);
if (item->type() == UBGraphicsGroupContainerItem::Type && item->childItems().count()) { if (item->type() == UBGraphicsGroupContainerItem::Type && item->childItems().count()) {
foreach (QGraphicsItem *curItem, item->childItems()) { foreach (QGraphicsItem *curItem, item->childItems()) {
removeItemFromDeletion(curItem); removeItemFromDeletion(curItem);
} }
} }
mItemsToDelete << item;
if (item->scene() != this) if (item->scene() != this)
QGraphicsScene::addItem(item); QGraphicsScene::addItem(item);
setModified(true);
} }
@ -59,27 +73,16 @@ void UBCoreGraphicsScene::removeItem(QGraphicsItem* item, bool forceDelete)
QGraphicsScene::removeItem(item); QGraphicsScene::removeItem(item);
if (forceDelete) if (forceDelete)
{ {
mItemsToDelete.remove(item); deleteItem(item);
delete item;
item = 0;
} }
setModified(true);
} }
bool UBCoreGraphicsScene::deleteItem(QGraphicsItem* item) bool UBCoreGraphicsScene::deleteItem(QGraphicsItem* item)
{ {
if(mItemsToDelete.contains(item)) if(mItemsToDelete.contains(item))
{ {
UBGraphicsItem* item_casted = 0; UBGraphicsItem *item_casted = dynamic_cast<UBGraphicsItem *>(item);
switch (item->type())
{
case UBGraphicsMediaItem::Type:
item_casted = dynamic_cast<UBGraphicsMediaItem*>(item);
break;
case UBGraphicsW3CWidgetItem::Type:
item_casted = dynamic_cast<UBGraphicsWidgetItem*>(item);
break;
}
if (0 != item_casted) if (0 != item_casted)
item_casted->clearSource(); item_casted->clearSource();

@ -33,8 +33,21 @@ class UBCoreGraphicsScene : public QGraphicsScene
void removeItemFromDeletion(QGraphicsItem* item); void removeItemFromDeletion(QGraphicsItem* item);
void addItemToDeletion(QGraphicsItem *item); void addItemToDeletion(QGraphicsItem *item);
bool isModified() const
{
return mIsModified;
}
void setModified(bool pModified)
{
mIsModified = pModified;
}
private: private:
QSet<QGraphicsItem*> mItemsToDelete; QSet<QGraphicsItem*> mItemsToDelete;
bool mIsModified;
}; };
#endif /* UBCOREGRAPHICSSCENE_H_ */ #endif /* UBCOREGRAPHICSSCENE_H_ */

@ -25,6 +25,7 @@ UBPropertyPalette::UBPropertyPalette(QWidget *parent, const char *name):UBAction
{ {
setObjectName(name); setObjectName(name);
mbGrip = false; mbGrip = false;
setMaximumHeight(MAX_HEIGHT);
} }
/** /**
@ -35,6 +36,7 @@ UBPropertyPalette::UBPropertyPalette(QWidget *parent, const char *name):UBAction
UBPropertyPalette::UBPropertyPalette(Qt::Orientation orientation, QWidget *parent):UBActionPalette(orientation, parent) UBPropertyPalette::UBPropertyPalette(Qt::Orientation orientation, QWidget *parent):UBActionPalette(orientation, parent)
{ {
mbGrip = false; mbGrip = false;
setMaximumHeight(MAX_HEIGHT);
} }
/** /**

@ -20,6 +20,8 @@
#include "UBActionPalette.h" #include "UBActionPalette.h"
#define MAX_HEIGHT 20
class UBPropertyPalette : public UBActionPalette class UBPropertyPalette : public UBActionPalette
{ {
Q_OBJECT Q_OBJECT

@ -12,11 +12,13 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <QObject>
#include <QString> #include <QString>
#include <QCursor> #include <QCursor>
#include "UBThumbnailWidget.h" #include "UBThumbnailWidget.h"
#include "UBRubberBand.h" #include "UBRubberBand.h"
#include "UBMainWindow.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
@ -858,8 +860,10 @@ void UBSceneThumbnailNavigPixmap::updateButtonsState()
void UBSceneThumbnailNavigPixmap::deletePage() void UBSceneThumbnailNavigPixmap::deletePage()
{ {
if(UBApplication::mainWindow->yesNoQuestion(QObject::tr("Remove Page"), QObject::tr("Are you sure you want to remove 1 page from the selected document '%0'?").arg(UBApplication::documentController->selectedDocument()->metaData(UBSettings::documentName).toString()))){
UBApplication::boardController->deleteScene(sceneIndex()); UBApplication::boardController->deleteScene(sceneIndex());
} }
}
void UBSceneThumbnailNavigPixmap::duplicatePage() void UBSceneThumbnailNavigPixmap::duplicatePage()
{ {

Loading…
Cancel
Save