diff --git a/JournalDesModifications.pdf b/JournalDesModifications.pdf
index 577818a4..79f01f9d 100644
Binary files a/JournalDesModifications.pdf and b/JournalDesModifications.pdf differ
diff --git a/ReleaseNotes.pdf b/ReleaseNotes.pdf
index 0f4885f3..220a99a7 100644
Binary files a/ReleaseNotes.pdf and b/ReleaseNotes.pdf differ
diff --git a/Sankore_3.1.pro b/Sankore_3.1.pro
index c08d5dec..ce2ac094 100644
--- a/Sankore_3.1.pro
+++ b/Sankore_3.1.pro
@@ -11,7 +11,7 @@ CONFIG += debug_and_release \
VERSION_MAJ = 2
VERSION_MIN = 00
VERSION_TYPE = b # a = alpha, b = beta, r = release, other => error
-VERSION_PATCH = 05
+VERSION_PATCH = 06
VERSION = "$${VERSION_MAJ}.$${VERSION_MIN}.$${VERSION_TYPE}.$${VERSION_PATCH}"
VERSION = $$replace(VERSION, "\\.r", "")
diff --git a/plugins/cffadaptor/src/UBCFFAdaptor.cpp b/plugins/cffadaptor/src/UBCFFAdaptor.cpp
index 68ec3ff9..10a8aca5 100644
--- a/plugins/cffadaptor/src/UBCFFAdaptor.cpp
+++ b/plugins/cffadaptor/src/UBCFFAdaptor.cpp
@@ -858,7 +858,7 @@ bool UBCFFAdaptor::UBToCFFConverter::itIsSupportedFormat(const QString &format)
QStringList tsl = format.split(".", QString::SkipEmptyParts);
if (0 < tsl.count())
- bRet = cffSupportedFileFormats.contains(tsl.at(tsl.count()-1));
+ bRet = cffSupportedFileFormats.contains(tsl.at(tsl.count()-1).toLower());
else
bRet = false;
diff --git a/resources/library/applications/Grapheur.wgt/Grapheur.xhtml b/resources/library/applications/Grapheur.wgt/Grapheur.xhtml
index 3a94a9d3..bfca757c 100644
--- a/resources/library/applications/Grapheur.wgt/Grapheur.xhtml
+++ b/resources/library/applications/Grapheur.wgt/Grapheur.xhtml
@@ -218,7 +218,6 @@
return true;
});
$("label[for*='checkAire']").text(sankoreLang[lang].draw);
- $("label[for*='checkMaJ']").text(sankoreLang[lang].auto_update);
$("#menuOptions td").eq(0).html(sankoreLang[lang].widget);
$("#menuOptions h3").eq(0).text(sankoreLang[lang].widget_options);
$("#menuOptions2D h3").eq(0).text(sankoreLang[lang].options + " 2D");
@@ -1033,13 +1032,10 @@
Control options:
Save a widget options in cookies or load an options from cookies or delete a registered options.
-
-
Cookies are disabled. You cannot save an options...
You are using the last version of this widget.
-
diff --git a/resources/library/applications/Sel video.wgt/css/main.css b/resources/library/applications/Sel video.wgt/css/main.css
index 63b2c7b5..43d6ee71 100644
--- a/resources/library/applications/Sel video.wgt/css/main.css
+++ b/resources/library/applications/Sel video.wgt/css/main.css
@@ -1,7 +1,6 @@
body{
- margin-top:10px;
- margin-left:10px;
+ margin: 0;
font-family:Arial, Sans-serif;
font-size:15px;
color:#444;
@@ -104,7 +103,6 @@ body{
}
#embeded-content{
- border:1px solid rgb(230,230,230);
position:relative;
z-index:3;
float:left;
diff --git a/resources/library/applications/Sel video.wgt/index.html b/resources/library/applications/Sel video.wgt/index.html
index e7a51830..752b7f58 100644
--- a/resources/library/applications/Sel video.wgt/index.html
+++ b/resources/library/applications/Sel video.wgt/index.html
@@ -143,7 +143,7 @@
top:($("#embeded-content").children(":first").height()-35)/2
});
- adaptWidgetSize(5, 13);
+ adaptWidgetSize(3, 0);
return false;
};
diff --git a/resources/library/interactivities/Calcul.wgt/i18n/Messages_fr.properties b/resources/library/interactivities/Calcul.wgt/i18n/Messages_fr.properties
index 42cae735..f89c9066 100644
--- a/resources/library/interactivities/Calcul.wgt/i18n/Messages_fr.properties
+++ b/resources/library/interactivities/Calcul.wgt/i18n/Messages_fr.properties
@@ -1,11 +1,11 @@
fr.njin.i18n.document.title = Calcul rapide
-fr.njin.i18n.toolbar.edit = Editer
-fr.njin.i18n.toolbar.view = Fermer
+fr.njin.i18n.toolbar.edit = Modifier
+fr.njin.i18n.toolbar.view = Editer
fr.njin.i18n.toolbar.reload = Recharger
fr.njin.i18n.toolbar.help = Aide
-fr.njin.i18n.parameters.label.themes = Thème
+fr.njin.i18n.parameters.label.themes = Thèmes
fr.njin.i18n.parameters.label.slate.themes = ardoise
fr.njin.i18n.parameters.label.pad.themes = tablette
fr.njin.i18n.parameters.label.none.themes = aucun
diff --git a/resources/library/interactivities/Contraste.wgt/locales/fr/scripts/blackYellow.js b/resources/library/interactivities/Contraste.wgt/locales/fr/scripts/blackYellow.js
index 34de0859..3fbfd9aa 100644
--- a/resources/library/interactivities/Contraste.wgt/locales/fr/scripts/blackYellow.js
+++ b/resources/library/interactivities/Contraste.wgt/locales/fr/scripts/blackYellow.js
@@ -326,6 +326,15 @@ function init(){
$(".closeItem").live("click", function(){
if(!shadowOver){
$(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){
- var curTop = curr.position().top,
- curHeight = curr.height(),
+ var curHeight = curr.height(),
curLeft = curr.position().left;
if(prevLeft == curLeft){
if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
@@ -351,7 +359,7 @@ function init(){
if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
curr.css("top", prevBottom + 15 + "px").css("left", prevLeft + "px");
else
- curr.css("top", "60px");
+ curr.css("top", "60px").css("left", prevLeft + 255 + "px");
}
prevBottom = curr.position().top + curr.height(),
prevLeft = curr.position().left;
@@ -364,7 +372,20 @@ function init(){
popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%");
$(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("left", ($(window).width() - 360)*50/$(window).width() + "%");
});
@@ -564,4 +585,4 @@ function changeStyle(val){
}
if($("#wgt_edit").hasClass("selected"))
$(document).enableTextSelect();
-}
\ No newline at end of file
+}
diff --git a/resources/library/interactivities/Contraste.wgt/locales/ru/scripts/blackYellow.js b/resources/library/interactivities/Contraste.wgt/locales/ru/scripts/blackYellow.js
index fce0a9af..fc0eb152 100644
--- a/resources/library/interactivities/Contraste.wgt/locales/ru/scripts/blackYellow.js
+++ b/resources/library/interactivities/Contraste.wgt/locales/ru/scripts/blackYellow.js
@@ -326,6 +326,15 @@ function init(){
$(".closeItem").live("click", function(){
if(!shadowOver){
$(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){
- var curTop = curr.position().top,
- curHeight = curr.height(),
+ var curHeight = curr.height(),
curLeft = curr.position().left;
if(prevLeft == curLeft){
if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
@@ -351,7 +359,7 @@ function init(){
if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
curr.css("top", prevBottom + 15 + "px").css("left", prevLeft + "px");
else
- curr.css("top", "60px");
+ curr.css("top", "60px").css("left", prevLeft + 255 + "px");
}
prevBottom = curr.position().top + curr.height(),
prevLeft = curr.position().left;
@@ -364,7 +372,20 @@ function init(){
popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%");
$(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("left", ($(window).width() - 360)*50/$(window).width() + "%");
});
@@ -564,4 +585,4 @@ function changeStyle(val){
}
if($("#wgt_edit").hasClass("selected"))
$(document).enableTextSelect();
-}
\ No newline at end of file
+}
diff --git a/resources/library/interactivities/Contraste.wgt/scripts/blackYellow.js b/resources/library/interactivities/Contraste.wgt/scripts/blackYellow.js
index 27035aaf..89e6df3f 100644
--- a/resources/library/interactivities/Contraste.wgt/scripts/blackYellow.js
+++ b/resources/library/interactivities/Contraste.wgt/scripts/blackYellow.js
@@ -326,6 +326,15 @@ function init(){
$(".closeItem").live("click", function(){
if(!shadowOver){
$(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){
- var curTop = curr.position().top,
- curHeight = curr.height(),
+ var curHeight = curr.height(),
curLeft = curr.position().left;
if(prevLeft == curLeft){
if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
@@ -351,7 +359,7 @@ function init(){
if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
curr.css("top", prevBottom + 15 + "px").css("left", prevLeft + "px");
else
- curr.css("top", "60px");
+ curr.css("top", "60px").css("left", prevLeft + 255 + "px");
}
prevBottom = curr.position().top + curr.height(),
prevLeft = curr.position().left;
@@ -364,7 +372,20 @@ function init(){
popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%");
$(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("left", ($(window).width() - 360)*50/$(window).width() + "%");
});
diff --git a/resources/library/interactivities/Des.wgt/i18n/Messages_fr.properties b/resources/library/interactivities/Des.wgt/i18n/Messages_fr.properties
index 02bef45e..cdc4fe70 100644
--- a/resources/library/interactivities/Des.wgt/i18n/Messages_fr.properties
+++ b/resources/library/interactivities/Des.wgt/i18n/Messages_fr.properties
@@ -1,11 +1,11 @@
fr.njin.i18n.document.title = Dés
-fr.njin.i18n.toolbar.edit = Editer
-fr.njin.i18n.toolbar.view = Fermer
+fr.njin.i18n.toolbar.edit = Modifier
+fr.njin.i18n.toolbar.view = Afficher
fr.njin.i18n.toolbar.reload = Recharger
fr.njin.i18n.toolbar.help = Aide
-fr.njin.i18n.parameters.label.themes = Thème
+fr.njin.i18n.parameters.label.themes = Thèmes
fr.njin.i18n.parameters.label.slate.themes = ardoise
fr.njin.i18n.parameters.label.pad.themes = tablette
fr.njin.i18n.parameters.label.none.themes = aucun
diff --git a/resources/library/interactivities/Enveloppe.wgt/i18n/Messages_fr.properties b/resources/library/interactivities/Enveloppe.wgt/i18n/Messages_fr.properties
index 085ce522..131cc892 100644
--- a/resources/library/interactivities/Enveloppe.wgt/i18n/Messages_fr.properties
+++ b/resources/library/interactivities/Enveloppe.wgt/i18n/Messages_fr.properties
@@ -1,11 +1,11 @@
fr.njin.i18n.document.title = Enveloppe
-fr.njin.i18n.toolbar.edit = Editer
-fr.njin.i18n.toolbar.view = Fermer
+fr.njin.i18n.toolbar.edit = Modifier
+fr.njin.i18n.toolbar.view = Afficher
fr.njin.i18n.toolbar.reload = Recharger
fr.njin.i18n.toolbar.help = Aide
-fr.njin.i18n.parameters.label.themes = Thème
+fr.njin.i18n.parameters.label.themes = Thèmes
fr.njin.i18n.parameters.label.slate.themes = ardoise
fr.njin.i18n.parameters.label.pad.themes = tablette
fr.njin.i18n.parameters.label.none.themes = aucun
diff --git a/resources/library/interactivities/Memory.wgt/i18n/Messages_fr.properties b/resources/library/interactivities/Memory.wgt/i18n/Messages_fr.properties
index 8054dd1c..3b35c9c6 100644
--- a/resources/library/interactivities/Memory.wgt/i18n/Messages_fr.properties
+++ b/resources/library/interactivities/Memory.wgt/i18n/Messages_fr.properties
@@ -1,11 +1,11 @@
fr.njin.i18n.document.title = Memory
-fr.njin.i18n.toolbar.edit = Editer
-fr.njin.i18n.toolbar.view = Fermer
+fr.njin.i18n.toolbar.edit = Modifier
+fr.njin.i18n.toolbar.view = Afficher
fr.njin.i18n.toolbar.reload = Recharger
fr.njin.i18n.toolbar.help = Aide
-fr.njin.i18n.parameters.label.themes = Thème
+fr.njin.i18n.parameters.label.themes = Thèmes
fr.njin.i18n.parameters.label.slate.themes = ardoise
fr.njin.i18n.parameters.label.pad.themes = tablette
fr.njin.i18n.parameters.label.none.themes = aucun
diff --git a/resources/library/interactivities/Ordre phrase.wgt/styles/of_puppets.css b/resources/library/interactivities/Ordre phrase.wgt/styles/of_puppets.css
index 6589dcef..401a2bea 100644
--- a/resources/library/interactivities/Ordre phrase.wgt/styles/of_puppets.css
+++ b/resources/library/interactivities/Ordre phrase.wgt/styles/of_puppets.css
@@ -33,7 +33,6 @@ body{
font: 28px tahoma;
text-align: center;
cursor: pointer;
- text-transform: uppercase;
overflow: hidden;
}
diff --git a/resources/library/interactivities/Selectionner.wgt/locales/fr/js/script.js b/resources/library/interactivities/Selectionner.wgt/locales/fr/js/script.js
index 465f601e..b37fdee6 100644
--- a/resources/library/interactivities/Selectionner.wgt/locales/fr/js/script.js
+++ b/resources/library/interactivities/Selectionner.wgt/locales/fr/js/script.js
@@ -3,7 +3,7 @@ var sankoreLang = {
edit: "Modifier",
short_desc: "Sélectionner les animaux dans la liste suivante :",
add: "Nouveau bloc",
- enter: "Saisir votre consigne ici ...",
+ enter: "Texte",
cat: "chat",
ball: "balle",
shovel: "pelle",
diff --git a/resources/library/interactivities/Tables.wgt/i18n/Messages_fr.properties b/resources/library/interactivities/Tables.wgt/i18n/Messages_fr.properties
index 27f9bd5d..9019424a 100644
--- a/resources/library/interactivities/Tables.wgt/i18n/Messages_fr.properties
+++ b/resources/library/interactivities/Tables.wgt/i18n/Messages_fr.properties
@@ -1,11 +1,11 @@
fr.njin.i18n.document.title = Tables
-fr.njin.i18n.toolbar.edit = Editer
-fr.njin.i18n.toolbar.view = Fermer
+fr.njin.i18n.toolbar.edit = Modifier
+fr.njin.i18n.toolbar.view = Afficher
fr.njin.i18n.toolbar.reload = Recharger
fr.njin.i18n.toolbar.help = Aide
-fr.njin.i18n.parameters.label.themes = Thème
+fr.njin.i18n.parameters.label.themes = Thèmes
fr.njin.i18n.parameters.label.slate.themes = ardoise
fr.njin.i18n.parameters.label.pad.themes = tablette
fr.njin.i18n.parameters.label.none.themes = aucun
diff --git a/resources/library/interactivities/Train.wgt/i18n/Messages_fr.properties b/resources/library/interactivities/Train.wgt/i18n/Messages_fr.properties
index 4f34d08f..f9046ee8 100644
--- a/resources/library/interactivities/Train.wgt/i18n/Messages_fr.properties
+++ b/resources/library/interactivities/Train.wgt/i18n/Messages_fr.properties
@@ -1,11 +1,11 @@
fr.njin.i18n.document.title = Le train
-fr.njin.i18n.toolbar.edit = Editer
-fr.njin.i18n.toolbar.view = Fermer
+fr.njin.i18n.toolbar.edit = Modifier
+fr.njin.i18n.toolbar.view = Afficher
fr.njin.i18n.toolbar.reload = Recharger
fr.njin.i18n.toolbar.help = Aide
-fr.njin.i18n.parameters.label.themes = Thème
+fr.njin.i18n.parameters.label.themes = Thèmes
fr.njin.i18n.parameters.label.slate.themes = ardoise
fr.njin.i18n.parameters.label.pad.themes = tablette
fr.njin.i18n.parameters.label.none.themes = aucun
diff --git a/resources/library/interactivities/Transformation.wgt/i18n/Messages_fr.properties b/resources/library/interactivities/Transformation.wgt/i18n/Messages_fr.properties
index a1de3815..19e73785 100644
--- a/resources/library/interactivities/Transformation.wgt/i18n/Messages_fr.properties
+++ b/resources/library/interactivities/Transformation.wgt/i18n/Messages_fr.properties
@@ -1,11 +1,11 @@
fr.njin.i18n.document.title = Boîte à transformation
-fr.njin.i18n.toolbar.edit = Editer
-fr.njin.i18n.toolbar.view = Fermer
+fr.njin.i18n.toolbar.edit = Modifier
+fr.njin.i18n.toolbar.view = Afficher
fr.njin.i18n.toolbar.reload = Recharger
fr.njin.i18n.toolbar.help = Aide
-fr.njin.i18n.parameters.label.themes = Thème
+fr.njin.i18n.parameters.label.themes = Thèmes
fr.njin.i18n.parameters.label.slate.themes = ardoise
fr.njin.i18n.parameters.label.pad.themes = tablette
fr.njin.i18n.parameters.label.none.themes = aucun
diff --git a/src/adaptors/UBCFFSubsetAdaptor.cpp b/src/adaptors/UBCFFSubsetAdaptor.cpp
index 7eb667b5..87c83cc4 100644
--- a/src/adaptors/UBCFFSubsetAdaptor.cpp
+++ b/src/adaptors/UBCFFSubsetAdaptor.cpp
@@ -174,9 +174,7 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseGSection(const QDomElement &ele
QDomElement currentSvgElement = element.firstChildElement();
while (!currentSvgElement.isNull()) {
- if (!parseSvgElement(currentSvgElement))
- return false;
-
+ parseSvgElement(currentSvgElement);
currentSvgElement = currentSvgElement.nextSiblingElement();
}
@@ -187,8 +185,8 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::parseGSection(const QDomElement &ele
else
{
delete mGSectionContainer;
- mGSectionContainer = NULL;
}
+ mGSectionContainer = NULL;
return true;
}
@@ -1189,8 +1187,6 @@ bool UBCFFSubsetAdaptor::UBCFFSubsetReader::persistScenes()
UBGraphicsScene *tmpScene = UBSvgSubsetAdaptor::loadScene(mProxy, i);
tmpScene->setModified(true);
UBThumbnailAdaptor::persistScene(mProxy, tmpScene, i);
- delete tmpScene;
-
mCurrentScene->setModified(false);
}
diff --git a/src/api/UBWidgetUniboardAPI.cpp b/src/api/UBWidgetUniboardAPI.cpp
index 0e2a54f1..b86e7aa1 100644
--- a/src/api/UBWidgetUniboardAPI.cpp
+++ b/src/api/UBWidgetUniboardAPI.cpp
@@ -250,7 +250,7 @@ void UBWidgetUniboardAPI::eraseLineTo(const qreal x, const qreal y, const qreal
void UBWidgetUniboardAPI::clear()
{
if (mScene)
- mScene->clearItemsAndAnnotations();
+ mScene->clearContent(UBGraphicsScene::clearItemsAndAnnotations);
}
diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp
index 10681926..f3b8b0a8 100644
--- a/src/board/UBBoardController.cpp
+++ b/src/board/UBBoardController.cpp
@@ -553,15 +553,15 @@ void UBBoardController::duplicateItem(UBItem *item)
qreal shifting = UBSettings::settings()->objectFrameWidth;
itemPos = commonItem->pos() + QPointF(shifting,shifting);
itemSize = commonItem->boundingRect().size();
+ commonItem->setSelected(false);
}
UBMimeType::Enum itemMimeType;
QString contentTypeHeader = UBFileSystemUtils::mimeTypeFromFileName(item->sourceUrl().toLocalFile());
- if(NULL != qgraphicsitem_cast(commonItem)){
- itemMimeType = UBMimeType::Group;
- }else{
- itemMimeType = UBFileSystemUtils::mimeTypeFromString(contentTypeHeader);
- }
+ if(NULL != qgraphicsitem_cast(commonItem))
+ itemMimeType = UBMimeType::Group;
+ else
+ itemMimeType = UBFileSystemUtils::mimeTypeFromString(contentTypeHeader);
switch(static_cast(itemMimeType))
{
@@ -633,10 +633,10 @@ void UBBoardController::duplicateItem(UBItem *item)
QGraphicsItem *gitem = dynamic_cast(item->deepCopy());
if (gitem)
{
- qDebug() << "Adding a stroke: " << gitem;
mActiveScene->addItem(gitem);
gitem->setPos(itemPos);
mLastCreatedItem = gitem;
+ gitem->setSelected(true);
}
return;
}break;
@@ -683,7 +683,7 @@ void UBBoardController::clearScene()
if (mActiveScene)
{
freezeW3CWidgets(true);
- mActiveScene->clearItemsAndAnnotations();
+ mActiveScene->clearContent(UBGraphicsScene::clearItemsAndAnnotations);
updateActionStates();
}
}
@@ -694,7 +694,7 @@ void UBBoardController::clearSceneItems()
if (mActiveScene)
{
freezeW3CWidgets(true);
- mActiveScene->clearItems();
+ mActiveScene->clearContent(UBGraphicsScene::clearItems);
updateActionStates();
}
}
@@ -704,7 +704,7 @@ void UBBoardController::clearSceneAnnotation()
{
if (mActiveScene)
{
- mActiveScene->clearAnnotations();
+ mActiveScene->clearContent(UBGraphicsScene::clearAnnotations);
updateActionStates();
}
}
@@ -713,7 +713,7 @@ void UBBoardController::clearSceneBackground()
{
if (mActiveScene)
{
- mActiveScene->clearBackground();
+ mActiveScene->clearContent(UBGraphicsScene::clearBackground);
updateActionStates();
}
}
@@ -1487,11 +1487,12 @@ void UBBoardController::ClearUndoStack()
UBGraphicsItemUndoCommand *cmd = (UBGraphicsItemUndoCommand*)UBApplication::undoStack->command(i);
// 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 itAdded(cmd->GetAddedList());
while (itAdded.hasNext())
{
QGraphicsItem* item = itAdded.next();
- if( !uniqueItems.contains(item) )
+ if( !uniqueItems.contains(item) && !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type()))
uniqueItems.insert(item);
}
@@ -1499,7 +1500,7 @@ void UBBoardController::ClearUndoStack()
while (itRemoved.hasNext())
{
QGraphicsItem* item = itRemoved.next();
- if( !uniqueItems.contains(item) )
+ if( !uniqueItems.contains(item) && !(item->parentItem() && UBGraphicsGroupContainerItem::Type == item->parentItem()->type()))
uniqueItems.insert(item);
}
}
@@ -1520,7 +1521,8 @@ void UBBoardController::ClearUndoStack()
}
if(!scene)
{
- mActiveScene->deleteItem(item);
+ if (!mActiveScene->deleteItem(item))
+ delete item;
}
}
@@ -1554,7 +1556,6 @@ void UBBoardController::changeBackground(bool isDark, bool isCrossed)
}
}
-
void UBBoardController::boardViewResized(QResizeEvent* event)
{
Q_UNUSED(event);
diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp
index 5c55521c..2652bb15 100644
--- a/src/board/UBBoardPaletteManager.cpp
+++ b/src/board/UBBoardPaletteManager.cpp
@@ -710,9 +710,7 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
mLeftPalette->assignParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView());
mRightPalette->assignParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView());
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)
{
diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp
index 1fac93eb..d4570d9e 100644
--- a/src/board/UBBoardView.cpp
+++ b/src/board/UBBoardView.cpp
@@ -55,6 +55,8 @@
#include "document/UBDocumentProxy.h"
+#include "tools/UBGraphicsRuler.h"
+#include "tools/UBGraphicsCurtainItem.h"
#include "tools/UBGraphicsCompass.h"
#include "tools/UBGraphicsCache.h"
#include "tools/UBGraphicsTriangle.h"
@@ -74,6 +76,7 @@ UBBoardView::UBBoardView (UBBoardController* pController, QWidget* pParent, bool
, mIsDragInProgress(false)
, mMultipleSelectionIsEnabled(false)
, isControl(pIsControl)
+, mRubberBandInPlayMode(false) //enables rubberband with play tool
{
init ();
@@ -434,6 +437,15 @@ bool UBBoardView::itemHaveParentWithType(QGraphicsItem *item, int type)
return itemHaveParentWithType(item->parentItem(), type);
}
+bool UBBoardView::isUBItem(QGraphicsItem *item)
+{
+ if ((UBGraphicsItemType::UserTypesCount > item->type()) && (item->type() > QGraphicsItem::UserType))
+ return true;
+ else
+ {
+ return false;
+ }
+}
void UBBoardView::handleItemsSelection(QGraphicsItem *item)
{
@@ -505,11 +517,20 @@ Here we determines cases when items should to get mouse press event at pressing
switch(item->type())
{
+ case UBGraphicsProtractor::Type:
+ case UBGraphicsRuler::Type:
+ case UBGraphicsTriangle::Type:
+ case UBGraphicsCompass::Type:
+ case UBGraphicsCache::Type:
+ return true;
+
case UBGraphicsDelegateFrame::Type:
case QGraphicsSvgItem::Type:
return true;
case DelegateButton::Type:
+ return true;
+
case UBGraphicsMediaItem::Type:
return false;
@@ -534,7 +555,12 @@ Here we determines cases when items should to get mouse press event at pressing
return false;
break;
+ case UBToolWidget::Type:
+ return true;
+
case QGraphicsWebView::Type:
+ return true;
+
case UBGraphicsWidgetItem::Type:
if (currentTool == UBStylusTool::Selector && item->parentItem() && item->parentItem()->isSelected())
return true;
@@ -542,10 +568,11 @@ Here we determines cases when items should to get mouse press event at pressing
return true;
if (currentTool == UBStylusTool::Play)
return true;
+ return false;
break;
}
- return false;
+ return !isUBItem(item); // standard behavior of QGraphicsScene for not UB items. UB items should be managed upper.
}
bool UBBoardView::itemShouldReceiveSuspendedMousePressEvent(QGraphicsItem *item)
@@ -557,9 +584,11 @@ bool UBBoardView::itemShouldReceiveSuspendedMousePressEvent(QGraphicsItem *item)
return false;
UBStylusTool::Enum currentTool = (UBStylusTool::Enum)UBDrawingController::drawingController()->stylusTool();
-
+
switch(item->type())
{
+ case QGraphicsWebView::Type:
+ return false;
case UBGraphicsPixmapItem::Type:
case UBGraphicsTextItem::Type:
case UBGraphicsWidgetItem::Type:
@@ -599,6 +628,7 @@ bool UBBoardView::itemShouldBeMoved(QGraphicsItem *item)
switch(item->type())
{
+ case UBGraphicsCurtainItem::Type:
case UBGraphicsGroupContainerItem::Type:
return true;
@@ -994,38 +1024,41 @@ UBBoardView::mouseMoveEvent (QMouseEvent *event)
return;
}
- if (!movingItem && (mMouseButtonIsPressed || mTabletStylusIsPressed) && mUBRubberBand && mUBRubberBand->isVisible()) {
+ if (currentTool != UBStylusTool::Play || mRubberBandInPlayMode) {
- QRect bandRect(mMouseDownPos, event->pos());
+ if (!movingItem && (mMouseButtonIsPressed || mTabletStylusIsPressed) && mUBRubberBand && mUBRubberBand->isVisible()) {
- bandRect = bandRect.normalized();
+ QRect bandRect(mMouseDownPos, event->pos());
- mUBRubberBand->setGeometry(bandRect);
+ bandRect = bandRect.normalized();
- QList rubberItems = items(bandRect);
- foreach (QGraphicsItem *item, mJustSelectedItems) {
- if (!rubberItems.contains(item)) {
- item->setSelected(false);
- mJustSelectedItems.remove(item);
- }
- }
-
- if (currentTool == UBStylusTool::Selector)
- foreach (QGraphicsItem *item, items(bandRect)) {
+ mUBRubberBand->setGeometry(bandRect);
- if (item->type() == UBGraphicsW3CWidgetItem::Type
- || item->type() == UBGraphicsPixmapItem::Type
- || item->type() == UBGraphicsMediaItem::Type
- || item->type() == UBGraphicsSvgItem::Type
- || item->type() == UBGraphicsTextItem::Type
- || item->type() == UBGraphicsStrokesGroup::Type
- || item->type() == UBGraphicsGroupContainerItem::Type) {
-
- if (!mJustSelectedItems.contains(item)) {
- item->setSelected(true);
- mJustSelectedItems.insert(item);
+ QList rubberItems = items(bandRect);
+ foreach (QGraphicsItem *item, mJustSelectedItems) {
+ if (!rubberItems.contains(item)) {
+ item->setSelected(false);
+ mJustSelectedItems.remove(item);
}
}
+
+ if (currentTool == UBStylusTool::Selector)
+ foreach (QGraphicsItem *item, items(bandRect)) {
+
+ if (item->type() == UBGraphicsW3CWidgetItem::Type
+ || item->type() == UBGraphicsPixmapItem::Type
+ || item->type() == UBGraphicsMediaItem::Type
+ || item->type() == UBGraphicsSvgItem::Type
+ || item->type() == UBGraphicsTextItem::Type
+ || item->type() == UBGraphicsStrokesGroup::Type
+ || item->type() == UBGraphicsGroupContainerItem::Type) {
+
+ if (!mJustSelectedItems.contains(item)) {
+ item->setSelected(true);
+ mJustSelectedItems.insert(item);
+ }
+ }
+ }
}
}
@@ -1092,9 +1125,12 @@ UBBoardView::mouseReleaseEvent (QMouseEvent *event)
}
else
{
- if (QGraphicsSvgItem::Type != movingItem->type() &&
+ if (isUBItem(movingItem) &&
+ DelegateButton::Type != movingItem->type() &&
+ QGraphicsSvgItem::Type != movingItem->type() &&
UBGraphicsDelegateFrame::Type != movingItem->type() &&
UBToolWidget::Type != movingItem->type() &&
+ UBGraphicsCache::Type != movingItem->type() &&
QGraphicsWebView::Type != movingItem->type() && // for W3C widgets as Tools.
!(!isMultipleSelectionEnabled() && movingItem->parentItem() && UBGraphicsWidgetItem::Type == movingItem->type() && UBGraphicsGroupContainerItem::Type == movingItem->parentItem()->type()))
{
diff --git a/src/board/UBBoardView.h b/src/board/UBBoardView.h
index 1aae71ba..5c486a30 100644
--- a/src/board/UBBoardView.h
+++ b/src/board/UBBoardView.h
@@ -57,6 +57,7 @@ class UBBoardView : public QGraphicsView
protected:
bool itemIsLocked(QGraphicsItem *item);
+ bool isUBItem(QGraphicsItem *item); // we should to determine items who is not UB and use general scene behavior for them.
void handleItemsSelection(QGraphicsItem *item);
bool itemShouldReceiveMousePressEvent(QGraphicsItem *item);
bool itemShouldReceiveSuspendedMousePressEvent(QGraphicsItem *item);
@@ -153,6 +154,7 @@ class UBBoardView : public QGraphicsView
bool mIsDragInProgress;
bool mMultipleSelectionIsEnabled;
bool isControl;
+ bool mRubberBandInPlayMode;
static bool hasSelectedParents(QGraphicsItem * item);
diff --git a/src/board/UBFeaturesController.cpp b/src/board/UBFeaturesController.cpp
index b13b7312..6c777e73 100644
--- a/src/board/UBFeaturesController.cpp
+++ b/src/board/UBFeaturesController.cpp
@@ -20,10 +20,22 @@
#include "gui/UBFeaturesWidget.h"
const QString UBFeaturesController::virtualRootName = "root";
+const QString UBFeaturesController::rootPath = "/" + virtualRootName;
+
+const QString UBFeaturesController::appPath = rootPath + "/Applications";
+const QString UBFeaturesController::audiosPath = rootPath + "/Audios";
+const QString UBFeaturesController::moviesPath = rootPath + "/Movies";
+const QString UBFeaturesController::picturesPath = rootPath + "/Pictures";
+const QString UBFeaturesController::flashPath = rootPath + "/Animations";
+const QString UBFeaturesController::interactPath = rootPath + "/Interactivities";
+const QString UBFeaturesController::shapesPath = rootPath + "/Shapes";
+const QString UBFeaturesController::trashPath = rootPath + "/Trash";
+const QString UBFeaturesController::favoritePath = rootPath + "/Favorites";
+const QString UBFeaturesController::webSearchPath = rootPath + "/Web search";
+
void UBFeaturesComputingThread::scanFS(const QUrl & currentPath, const QString & currVirtualPath, const QSet &pFavoriteSet)
{
-
Q_ASSERT(QFileInfo(currentPath.toLocalFile()).exists());
QFileInfoList fileInfoList = UBFileSystemUtils::allElementsInDirectory(currentPath.toLocalFile());
@@ -43,7 +55,7 @@ void UBFeaturesComputingThread::scanFS(const QUrl & currentPath, const QString &
if ( fullFileName.contains(".thumbnail."))
continue;
- UBFeature testFeature(currVirtualPath, icon, fileName, QUrl::fromLocalFile(fullFileName), featureType);
+ UBFeature testFeature(currVirtualPath + "/" + fileName, icon, fileName, QUrl::fromLocalFile(fullFileName), featureType);
emit sendFeature(testFeature);
emit featureSent();
@@ -51,7 +63,7 @@ void UBFeaturesComputingThread::scanFS(const QUrl & currentPath, const QString &
if ( pFavoriteSet.find(QUrl::fromLocalFile(fullFileName)) != pFavoriteSet.end()) {
//TODO send favoritePath from the controller or make favoritePath public and static
- emit sendFeature(UBFeature( "/root/Favorites", icon, fileName, QUrl::fromLocalFile(fullFileName), featureType));
+ emit sendFeature(UBFeature( UBFeaturesController::favoritePath + "/" + fileName, icon, fileName, QUrl::fromLocalFile(fullFileName), featureType));
}
if (featureType == FEATURE_FOLDER) {
@@ -60,16 +72,16 @@ void UBFeaturesComputingThread::scanFS(const QUrl & currentPath, const QString &
}
}
-void UBFeaturesComputingThread::scanAll(QList > pScanningData, const QSet &pFavoriteSet)
+void UBFeaturesComputingThread::scanAll(QList > pScanningData, const QSet &pFavoriteSet)
{
for (int i = 0; i < pScanningData.count(); i++) {
if (abort) {
return;
}
- QPair curPair = pScanningData.at(i);
+ QPair curPair = pScanningData.at(i);
- emit scanCategory(UBFeaturesController::categoryNameForVirtualPath(curPair.second));
- scanFS(curPair.first, curPair.second, pFavoriteSet);
+ emit scanCategory(curPair.second.getDisplayName());
+ scanFS(curPair.first, curPair.second.getFullVirtualPath(), pFavoriteSet);
}
}
@@ -96,11 +108,11 @@ int UBFeaturesComputingThread::featuresCount(const QUrl &pPath)
return noItems;
}
-int UBFeaturesComputingThread::featuresCountAll(QList > pScanningData)
+int UBFeaturesComputingThread::featuresCountAll(QList > pScanningData)
{
int noItems = 0;
for (int i = 0; i < pScanningData.count(); i++) {
- QPair curPair = pScanningData.at(i);
+ QPair curPair = pScanningData.at(i);
noItems += featuresCount(curPair.first);
}
@@ -114,7 +126,7 @@ QThread(parent)
abort = false;
}
-void UBFeaturesComputingThread::compute(const QList > &pScanningData, QSet *pFavoritesSet)
+void UBFeaturesComputingThread::compute(const QList > &pScanningData, QSet *pFavoritesSet)
{
QMutexLocker curLocker(&mMutex);
@@ -135,7 +147,7 @@ void UBFeaturesComputingThread::run()
qDebug() << "Custom thread started execution";
mMutex.lock();
- QList > searchData = mScanningData;
+ QList > searchData = mScanningData;
QSet favoriteSet = mFavoriteSet;
mMutex.unlock();
@@ -182,14 +194,42 @@ UBFeaturesComputingThread::~UBFeaturesComputingThread()
}
UBFeature::UBFeature(const QString &url, const QImage &icon, const QString &name, const QUrl &realPath, UBFeatureElementType type)
-: virtualDir(url), mThumbnail(icon), mName(name), mPath(realPath), elementType(type)
+ : mThumbnail(icon), mDisplayName(name), mPath(realPath), elementType(type)
{
+ mName = getNameFromVirtualPath(url);
+ virtualDir = getVirtualDirFromVirtualPath(url);
}
UBFeature::~UBFeature()
{
}
+QString UBFeature::getNameFromVirtualPath(const QString &pVirtPath)
+{
+ QString result;
+ int slashPos = pVirtPath.lastIndexOf("/");
+ if (slashPos != -1) {
+ result = pVirtPath.right(pVirtPath.count() - slashPos - 1);
+ } else {
+ qDebug() << "UBFeature: incorrect virtual path parameter specified";
+ }
+
+ return result;
+}
+
+QString UBFeature::getVirtualDirFromVirtualPath(const QString &pVirtPath)
+{
+ QString result;
+ int slashPos = pVirtPath.lastIndexOf("/");
+ if (slashPos != -1) {
+ result = pVirtPath.left(slashPos);
+ } else {
+ qDebug() << "UBFeature: incorrect virtual path parameter specified";
+ }
+
+ return result;
+}
+
QString UBFeature::getUrl() const
{
if ( elementType == FEATURE_INTERNAL )
@@ -233,20 +273,6 @@ UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) :
,featuresList(0)
,mLastItemOffsetIndex(0)
{
- //Initializing virtual structure of the list
- rootPath = "/" + virtualRootName;
-
- appPath = rootPath + "/Applications";
- audiosPath = rootPath + "/Audios";
- moviesPath = rootPath + "/Movies";
- picturesPath = rootPath + "/Pictures";
- flashPath = rootPath + "/Animations";
- interactPath = rootPath + "/Interactivities";
- shapesPath = rootPath + "/Shapes";
- trashPath = rootPath + "/Trash";
- favoritePath = rootPath + "/Favorites";
- webSearchPath = rootPath + "/Web search";
-
//Initializing physical directories from UBSettings
mUserAudioDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->userAudioDirectory());
mUserVideoDirectoryPath = QUrl::fromLocalFile(UBSettings::settings()->userVideoDirectory());
@@ -264,18 +290,18 @@ UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) :
mLibSearchDirectoryPath =QUrl::fromLocalFile(UBSettings::settings()->userSearchDirectory());
trashDirectoryPath = QUrl::fromLocalFile(UBSettings::userTrashDirPath());
- rootElement = UBFeature(QString(), QImage( ":images/libpalette/home.png" ), "root", QUrl());
- audiosElement = UBFeature( rootPath, QImage(":images/libpalette/AudiosCategory.svg"), tr("Audios") , mUserAudioDirectoryPath, FEATURE_CATEGORY);
- moviesElement = UBFeature( rootPath, QImage(":images/libpalette/MoviesCategory.svg"), tr("Movies") , mUserVideoDirectoryPath, FEATURE_CATEGORY);
- picturesElement = UBFeature( rootPath, QImage(":images/libpalette/PicturesCategory.svg"), tr("Pictures") , mUserPicturesDirectoryPath, FEATURE_CATEGORY);
- flashElement = UBFeature( rootPath, QImage(":images/libpalette/FlashCategory.svg"), tr("Animations") , mUserAnimationDirectoryPath, FEATURE_CATEGORY);
- interactElement = UBFeature( rootPath, QImage(":images/libpalette/InteractivesCategory.svg"), tr("Interactivities") , mLibInteractiveDirectoryPath, FEATURE_CATEGORY);
- applicationsElement = UBFeature( rootPath, QImage(":images/libpalette/ApplicationsCategory.svg"), tr("Applications") , mUserInteractiveDirectoryPath, FEATURE_CATEGORY);
- shapesElement = UBFeature( rootPath, QImage(":images/libpalette/ShapesCategory.svg"), tr("Shapes") , mLibShapesDirectoryPath, FEATURE_CATEGORY );
- favoriteElement = UBFeature( rootPath, QImage(":images/libpalette/FavoritesCategory.svg"), tr("Favorites"), QUrl("favorites"), FEATURE_FAVORITE );
- webSearchElement = UBFeature( rootPath, QImage(":images/libpalette/WebSearchCategory.svg"), tr("Web search"), mLibSearchDirectoryPath, FEATURE_CATEGORY);
+ rootElement = UBFeature(rootPath, QImage( ":images/libpalette/home.png" ), "root", QUrl());
+ audiosElement = UBFeature( audiosPath, QImage(":images/libpalette/AudiosCategory.svg"), tr("Audios") , mUserAudioDirectoryPath, FEATURE_CATEGORY);
+ moviesElement = UBFeature( moviesPath, QImage(":images/libpalette/MoviesCategory.svg"), tr("Movies") , mUserVideoDirectoryPath, FEATURE_CATEGORY);
+ picturesElement = UBFeature( picturesPath, QImage(":images/libpalette/PicturesCategory.svg"), tr("Pictures") , mUserPicturesDirectoryPath, FEATURE_CATEGORY);
+ flashElement = UBFeature( flashPath, QImage(":images/libpalette/FlashCategory.svg"), tr("Animations") , mUserAnimationDirectoryPath, FEATURE_CATEGORY);
+ interactElement = UBFeature( interactPath, QImage(":images/libpalette/InteractivesCategory.svg"), tr("Interactivities") , mLibInteractiveDirectoryPath, FEATURE_CATEGORY);
+ applicationsElement = UBFeature( appPath, QImage(":images/libpalette/ApplicationsCategory.svg"), tr("Applications") , mUserInteractiveDirectoryPath, FEATURE_CATEGORY);
+ shapesElement = UBFeature( shapesPath, QImage(":images/libpalette/ShapesCategory.svg"), tr("Shapes") , mLibShapesDirectoryPath, FEATURE_CATEGORY );
+ favoriteElement = UBFeature( favoritePath, QImage(":images/libpalette/FavoritesCategory.svg"), tr("Favorites"), QUrl("favorites"), FEATURE_FAVORITE );
+ webSearchElement = UBFeature( webSearchPath, QImage(":images/libpalette/WebSearchCategory.svg"), tr("Web search"), mLibSearchDirectoryPath, FEATURE_CATEGORY);
- trashElement = UBFeature( rootPath, QImage(":images/libpalette/TrashCategory.svg"), tr("Trash"), trashDirectoryPath, FEATURE_TRASH );
+ trashElement = UBFeature( trashPath, QImage(":images/libpalette/TrashCategory.svg"), tr("Trash"), trashDirectoryPath, FEATURE_TRASH);
featuresList = new QList ();
@@ -312,24 +338,24 @@ UBFeaturesController::UBFeaturesController(QWidget *pParentWidget) :
void UBFeaturesController::startThread()
{
- QList > computingData;
+ QList > computingData;
- computingData << QPair(mLibAudiosDirectoryPath, audiosPath)
- << QPair(mLibVideosDirectoryPath, moviesPath)
- << QPair(mLibAnimationsDirectoryPath, flashPath)
- << QPair(mLibPicturesDirectoryPath, picturesPath)
+ computingData << QPair(mLibAudiosDirectoryPath, audiosElement)
+ << QPair(mLibVideosDirectoryPath, moviesElement)
+ << QPair(mLibAnimationsDirectoryPath, flashElement)
+ << QPair(mLibPicturesDirectoryPath, picturesElement)
- << QPair(mUserInteractiveDirectoryPath, appPath)
- << QPair(mUserAudioDirectoryPath, audiosPath)
- << QPair(mUserPicturesDirectoryPath, picturesPath)
- << QPair(mUserVideoDirectoryPath, moviesPath)
- << QPair(mUserAnimationDirectoryPath, flashPath)
+ << QPair(mUserInteractiveDirectoryPath, applicationsElement)
+ << QPair(mUserAudioDirectoryPath, audiosElement)
+ << QPair(mUserPicturesDirectoryPath, picturesElement)
+ << QPair(mUserVideoDirectoryPath, moviesElement)
+ << QPair(mUserAnimationDirectoryPath, flashElement)
- << QPair(mLibApplicationsDirectoryPath, appPath)
- << QPair(mLibShapesDirectoryPath, shapesPath)
- << QPair(mLibInteractiveDirectoryPath, interactPath)
- << QPair(trashDirectoryPath, trashPath)
- << QPair(mLibSearchDirectoryPath, rootPath + "/" + "Web search");
+ << QPair(mLibApplicationsDirectoryPath, applicationsElement)
+ << QPair(mLibShapesDirectoryPath, shapesElement)
+ << QPair(mLibInteractiveDirectoryPath, interactElement)
+ << QPair(trashDirectoryPath, trashElement)
+ << QPair(mLibSearchDirectoryPath, webSearchElement);
mCThread.compute(computingData, favoriteSet);
}
@@ -340,7 +366,7 @@ void UBFeaturesController::createNpApiFeature(const QString &str)
QString widgetName = QFileInfo(str).fileName();
- featuresModel->addItem(UBFeature(QString(appPath+"/Web"), QImage(UBGraphicsWidgetItem::iconFilePath(QUrl::fromLocalFile(str))), widgetName, QUrl::fromLocalFile(str), FEATURE_INTERACTIVE));
+ featuresModel->addItem(UBFeature(QString(appPath + "/Web/" + widgetName), QImage(UBGraphicsWidgetItem::iconFilePath(QUrl::fromLocalFile(str))), widgetName, QUrl::fromLocalFile(str), FEATURE_INTERACTIVE));
}
void UBFeaturesController::scanFS()
@@ -365,9 +391,9 @@ void UBFeaturesController::scanFS()
QList tools = UBToolsManager::manager()->allTools();
foreach (UBToolsManager::UBToolDescriptor tool, tools) {
- featuresList->append(UBFeature(appPath, tool.icon.toImage(), tool.label, QUrl(tool.id), FEATURE_INTERNAL));
+ featuresList->append(UBFeature(appPath + "/" + tool.label, tool.icon.toImage(), tool.label, QUrl(tool.id), FEATURE_INTERNAL));
if (favoriteSet->find(QUrl(tool.id)) != favoriteSet->end()) {
- featuresList->append(UBFeature(favoritePath, tool.icon.toImage(), tool.label, QUrl(tool.id), FEATURE_INTERNAL));
+ featuresList->append(UBFeature(favoritePath + "/" + tool.label, tool.icon.toImage(), tool.label, QUrl(tool.id), FEATURE_INTERNAL));
}
}
}
@@ -386,12 +412,12 @@ void UBFeaturesController::fileSystemScan(const QUrl & currentPath, const QStrin
if ( fullFileName.contains(".thumbnail."))
continue;
- UBFeature testFeature(currVirtualPath, icon, fileName, QUrl::fromLocalFile(fullFileName), featureType);
+ UBFeature testFeature(currVirtualPath + "/" + fileName, icon, fileName, QUrl::fromLocalFile(fullFileName), featureType);
featuresList->append(testFeature);
if ( favoriteSet->find( QUrl::fromLocalFile( fullFileName ) ) != favoriteSet->end() ) {
- featuresList->append( UBFeature( favoritePath, icon, fileName, QUrl::fromLocalFile( fullFileName ), featureType ) );
+ featuresList->append( UBFeature( favoritePath + "/" + fileName, icon, fileName, QUrl::fromLocalFile( fullFileName ), featureType ) );
}
if (featureType == FEATURE_FOLDER) {
@@ -466,7 +492,7 @@ void UBFeaturesController::addToFavorite( const QUrl &path )
QFileInfo fileInfo( filePath );
QString fileName = fileInfo.fileName();
UBFeatureElementType type = fileTypeFromUrl(fileInfo.absoluteFilePath());
- UBFeature elem(favoritePath, getIcon(filePath, type), fileName, path, fileTypeFromUrl(filePath) );
+ UBFeature elem(favoritePath + "/" + fileName, getIcon(filePath, type), fileName, path, fileTypeFromUrl(filePath) );
favoriteSet->insert( path );
saveFavoriteList();
@@ -631,7 +657,7 @@ void UBFeaturesController::importImage( const QImage &image, const UBFeature &de
image.save(filePath);
QImage thumb = createThumbnail( filePath );
- UBFeature resultItem = UBFeature( dest.getFullVirtualPath(), thumb, mFileName,
+ UBFeature resultItem = UBFeature( dest.getFullVirtualPath() + "/" + mFileName, thumb, mFileName,
QUrl::fromLocalFile( filePath ), FEATURE_ITEM );
featuresModel->addItem(resultItem);
@@ -671,10 +697,10 @@ void UBFeaturesController::addNewFolder(QString name)
if(!QFileInfo(path).exists()) {
QDir().mkpath(path);
}
- UBFeature newFeatureFolder = UBFeature( currentElement.getFullVirtualPath(), QImage(":images/libpalette/folder.svg"),
+ UBFeature newFeatureFolder = UBFeature( currentElement.getFullVirtualPath() + "/" + name, QImage(":images/libpalette/folder.svg"),
name, QUrl::fromLocalFile( path ), FEATURE_FOLDER );
- featuresModel->addItem( newFeatureFolder );
+ featuresModel->addItem(newFeatureFolder);
featuresProxyModel->invalidate();
}
@@ -710,9 +736,9 @@ UBFeature UBFeaturesController::getDestinationFeatureForUrl( const QUrl &url )
void UBFeaturesController::addDownloadedFile(const QUrl &sourceUrl, const QByteArray &pData)
{
- UBFeature dest = getDestinationFeatureForUrl( sourceUrl );
+ UBFeature dest = getDestinationFeatureForUrl(sourceUrl);
- if ( dest == UBFeature() )
+ if (dest == UBFeature())
return;
QString fileName = QFileInfo( sourceUrl.toString() ).fileName();
@@ -724,7 +750,7 @@ void UBFeaturesController::addDownloadedFile(const QUrl &sourceUrl, const QByteA
file.write(pData);
file.close();
- UBFeature downloadedFeature = UBFeature( dest.getFullVirtualPath(), getIcon( filePath ),
+ UBFeature downloadedFeature = UBFeature(dest.getFullVirtualPath() + "/" + fileName, getIcon( filePath ),
fileName, QUrl::fromLocalFile(filePath), FEATURE_ITEM);
if (downloadedFeature != UBFeature()) {
featuresModel->addItem(downloadedFeature);
@@ -742,7 +768,7 @@ UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeatu
Q_ASSERT( QFileInfo( sourcePath ).exists() );
- UBFeature possibleDest = getDestinationFeatureForUrl( url );
+ UBFeature possibleDest = getDestinationFeatureForUrl(url);
UBFeature dest = destination;
@@ -767,7 +793,7 @@ UBFeature UBFeaturesController::moveItemToFolder( const QUrl &url, const UBFeatu
UBFeatureElementType type = FEATURE_ITEM;
if ( UBFileSystemUtils::mimeTypeFromFileName( newFullPath ).contains("application") )
type = FEATURE_INTERACTIVE;
- UBFeature newElement( destVirtualPath, thumb, name, QUrl::fromLocalFile( newFullPath ), type );
+ UBFeature newElement( destVirtualPath + "/" + name, thumb, name, QUrl::fromLocalFile( newFullPath ), type );
return newElement;
}
@@ -861,7 +887,7 @@ UBFeature UBFeaturesController::copyItemToFolder( const QUrl &url, const UBFeatu
UBFeatureElementType type = FEATURE_ITEM;
if (UBFileSystemUtils::mimeTypeFromFileName(newFullPath).contains("application"))
type = FEATURE_INTERACTIVE;
- UBFeature newElement( destVirtualPath, thumb, name, QUrl::fromLocalFile( newFullPath ), type );
+ UBFeature newElement( destVirtualPath + "/" + name, thumb, name, QUrl::fromLocalFile( newFullPath ), type );
return newElement;
}
@@ -899,7 +925,7 @@ void UBFeaturesController::moveExternalData(const QUrl &url, const UBFeature &de
Q_ASSERT(QFileInfo(newFullPath).exists());
QImage thumb = getIcon(newFullPath, type);
- UBFeature newElement(destVirtualPath, thumb, name, QUrl::fromLocalFile(newFullPath), type);
+ UBFeature newElement(destVirtualPath + "/" + name, thumb, name, QUrl::fromLocalFile(newFullPath), type);
featuresModel->addItem(newElement);
}
diff --git a/src/board/UBFeaturesController.h b/src/board/UBFeaturesController.h
index 6d57e5d4..b48f3d62 100644
--- a/src/board/UBFeaturesController.h
+++ b/src/board/UBFeaturesController.h
@@ -33,7 +33,7 @@ class UBFeaturesComputingThread : public QThread
public:
explicit UBFeaturesComputingThread(QObject *parent = 0);
virtual ~UBFeaturesComputingThread();
- void compute(const QList > &pScanningData, QSet *pFavoritesSet);
+ void compute(const QList > &pScanningData, QSet *pFavoritesSet);
protected:
void run();
@@ -51,16 +51,16 @@ public slots:
private:
void scanFS(const QUrl & currentPath, const QString & currVirtualPath, const QSet &pFavoriteSet);
- void scanAll(QList > pScanningData, const QSet &pFavoriteSet);
+ void scanAll(QList > pScanningData, const QSet &pFavoriteSet);
int featuresCount(const QUrl &pPath);
- int featuresCountAll(QList > pScanningData);
+ int featuresCountAll(QList > pScanningData);
private:
QMutex mMutex;
QWaitCondition mWaitCondition;
QUrl mScanningPath;
QString mScanningVirtualPath;
- QList > mScanningData;
+ QList > mScanningData;
QSet mFavoriteSet;
bool restart;
bool abort;
@@ -94,6 +94,7 @@ public:
// UBFeature();
virtual ~UBFeature();
QString getName() const { return mName; }
+ QString getDisplayName() const {return mDisplayName;}
QImage getThumbnail() const {return mThumbnail;}
QString getVirtualPath() const { return virtualDir; }
//QString getPath() const { return mPath; };
@@ -112,11 +113,17 @@ public:
const QMap & getMetadata() const { return metadata; }
void setMetadata( const QMap &data ) { metadata = data; }
+
+private:
+ QString getNameFromVirtualPath(const QString &pVirtPath);
+ QString getVirtualDirFromVirtualPath(const QString &pVirtPath);
+
private:
QString virtualDir;
QString virtualPath;
QImage mThumbnail;
QString mName;
+ QString mDisplayName;
QUrl mPath;
UBFeatureElementType elementType;
QMap metadata;
@@ -182,6 +189,19 @@ public:
void assignFeaturesListVeiw(UBFeaturesListView *pList);
void assignPathListView(UBFeaturesListView *pList);
+public:
+ static const QString rootPath;
+ static const QString audiosPath;
+ static const QString moviesPath;
+ static const QString picturesPath;
+ static const QString appPath;
+ static const QString flashPath;
+ static const QString shapesPath;
+ static const QString interactPath;
+ static const QString trashPath;
+ static const QString favoritePath;
+ static const QString webSearchPath;
+
signals:
void maxFilesCountEvaluated(int pLimit);
void scanStarted();
@@ -235,17 +255,7 @@ private:
QUrl trashDirectoryPath;
QUrl mLibSearchDirectoryPath;
- QString rootPath;
- QString audiosPath;
- QString moviesPath;
- QString picturesPath;
- QString appPath;
- QString flashPath;
- QString shapesPath;
- QString interactPath;
- QString trashPath;
- QString favoritePath;
- QString webSearchPath;
+
int mLastItemOffsetIndex;
UBFeature currentElement;
diff --git a/src/core/UBApplication.cpp b/src/core/UBApplication.cpp
index 75591e73..94f0710e 100644
--- a/src/core/UBApplication.cpp
+++ b/src/core/UBApplication.cpp
@@ -139,15 +139,7 @@ UBApplication::UBApplication(const QString &id, int &argc, char **argv) : QtSing
UBSettings *settings = UBSettings::settings();
- QString forcedLanguage("");
- 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);
+ setupTranslators(args);
connect(settings->appToolBarPositionedAtTop, SIGNAL(changed(QVariant)), this, SLOT(toolBarPositionChanged(QVariant)));
connect(settings->appToolBarDisplayText, SIGNAL(changed(QVariant)), this, SLOT(toolBarDisplayTextChanged(QVariant)));
@@ -207,45 +199,71 @@ UBApplication::~UBApplication()
staticMemoryCleaner = 0;
}
-void UBApplication::setupTranslator(QString forcedLanguage)
+QString UBApplication::checkLanguageAvailabilityForSankore(QString &language)
{
- QStringList availablesTranslations = UBPlatformUtils::availableTranslations();
- QString language("");
- if(!forcedLanguage.isEmpty()){
- if(availablesTranslations.contains(forcedLanguage,Qt::CaseInsensitive))
- language = forcedLanguage;
- else
- qDebug() << "forced language " << forcedLanguage << " not available";
- }
- else{
- QString systemLanguage = UBPlatformUtils::systemLanguage();
- if(availablesTranslations.contains(systemLanguage,Qt::CaseInsensitive))
- language = systemLanguage;
- else
- qDebug() << "translation for system language " << systemLanguage << " not found";
- }
-
- if(language.isEmpty()){
- language = "en_US";
- //fallback if no translation are available
- }
- else{
- mApplicationTranslator = new QTranslator(this);
- mQtGuiTranslator = new QTranslator(this);
-
- mApplicationTranslator->load(UBPlatformUtils::translationPath(QString("sankore_"),language));
- installTranslator(mApplicationTranslator);
-
-
- mQtGuiTranslator->load(UBPlatformUtils::translationPath(QString("qt_"),language));
- if(!mQtGuiTranslator->isEmpty()){
- // checked because this translation could be not available
- installTranslator(mQtGuiTranslator);
- }
- else
- qDebug() << "Qt gui translation in " << language << " are not available";
- }
+ QStringList availableTranslations = UBPlatformUtils::availableTranslations();
+ if(availableTranslations.contains(language,Qt::CaseInsensitive))
+ return language;
+ else{
+ if(language.length() > 2){
+ QString shortLanguageCode = language.left(2);
+ 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{
+ 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();
+ language = checkLanguageAvailabilityForSankore(systemLanguage);
+ }
+
+ if(language.isEmpty()){
+ language = "en_US";
+ //fallback if no translation are available
+ }
+ else{
+ mApplicationTranslator = new QTranslator(this);
+ mQtGuiTranslator = new QTranslator(this);
+
+ mApplicationTranslator->load(UBPlatformUtils::translationPath(QString("sankore_"),language));
+ installTranslator(mApplicationTranslator);
+
+ QString qtGuiTranslationPath = UBPlatformUtils::translationPath("qt_", language);
+
+
+ if(!QFile(qtGuiTranslationPath).exists()){
+ qtGuiTranslationPath = UBPlatformUtils::translationPath("qt_", language.left(2));
+ if(!QFile(qtGuiTranslationPath).exists())
+ qtGuiTranslationPath = "";
+ }
+
+ if(!qtGuiTranslationPath.isEmpty()){
+ qDebug() << "qtGuiTranslationPath " << qtGuiTranslationPath;
+ mQtGuiTranslator->load(qtGuiTranslationPath);
+ installTranslator(mQtGuiTranslator);
+ }
+ else
+ qDebug() << "Qt gui translation in " << language << " is not available";
+ }
QLocale::setDefault(QLocale(language));
qDebug() << "Running application in:" << language;
diff --git a/src/core/UBApplication.h b/src/core/UBApplication.h
index b4060d54..b08fdcee 100644
--- a/src/core/UBApplication.h
+++ b/src/core/UBApplication.h
@@ -119,10 +119,10 @@ class UBApplication : public QtSingleApplication
private:
void updateProtoActionsState();
- void setupTranslator(QString forcedLanguage);
+ void setupTranslators(QStringList args);
QList mProtoMenus;
bool mIsVerbose;
-
+ QString checkLanguageAvailabilityForSankore(QString& language);
protected:
#if defined(Q_WS_MACX) && !defined(QT_MAC_USE_COCOA)
diff --git a/src/desktop/UBDesktopAnnotationController.cpp b/src/desktop/UBDesktopAnnotationController.cpp
index 6aaa2812..b95b433d 100644
--- a/src/desktop/UBDesktopAnnotationController.cpp
+++ b/src/desktop/UBDesktopAnnotationController.cpp
@@ -66,8 +66,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
, mDesktopStylusTool(UBDrawingController::drawingController()->stylusTool())
{
- mTransparentDrawingView = new UBBoardView(UBApplication::boardController, NULL, true); // deleted in UBDesktopAnnotationController::destructor
-
+ mTransparentDrawingView = new UBBoardView(UBApplication::boardController, static_cast(0), true); // deleted in UBDesktopAnnotationController::destructor
mTransparentDrawingView->setAttribute(Qt::WA_TranslucentBackground, true);
#ifdef Q_WS_MAC
mTransparentDrawingView->setAttribute(Qt::WA_MacNoShadow, true);
@@ -87,7 +86,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
mTransparentDrawingView->setScene(mTransparentDrawingScene);
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())
{
@@ -102,9 +101,15 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
}
connect(mDesktopPalette, SIGNAL(uniboardClick()), this, SLOT(goToUniboard()));
+ connect(mDesktopPalette, SIGNAL(uniboardClick()), this, SLOT(onToolClicked()));
connect(mDesktopPalette, SIGNAL(customClick()), this, SLOT(customCapture()));
+ connect(mDesktopPalette, SIGNAL(customClick()), this, SLOT(onToolClicked()));
connect(mDesktopPalette, SIGNAL(windowClick()), this, SLOT(windowCapture()));
+ connect(mDesktopPalette, SIGNAL(windowClick()), this, SLOT(onToolClicked()));
connect(mDesktopPalette, SIGNAL(screenClick()), this, SLOT(screenCapture()));
+ connect(mDesktopPalette, SIGNAL(screenClick()), this, SLOT(onToolClicked()));
+ connect(UBApplication::mainWindow->actionPointer, SIGNAL(triggered()), this, SLOT(onToolClicked()));
+ connect(UBApplication::mainWindow->actionSelector, SIGNAL(triggered()), this, SLOT(onToolClicked()));
connect(mDesktopPalette, SIGNAL(maximized()), this, SLOT(onDesktopPaletteMaximized()));
connect(mDesktopPalette, SIGNAL(minimizeStart(eMinimizedLocation)), this, SLOT(onDesktopPaletteMinimize()));
@@ -114,13 +119,13 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
connect(UBDrawingController::drawingController(), SIGNAL(stylusToolChanged(int)), this, SLOT(stylusToolChanged(int)));
// 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(minimizeStart(eMinimizedLocation)), mDesktopPenPalette, SLOT(onParentMinimized()));
- mDesktopMarkerPalette = new UBDesktopMarkerPalette(mTransparentDrawingView);
- mDesktopEraserPalette = new UBDesktopEraserPalette(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(NULL); // FIX #633: The palette must be 'floating' in order to stay on top of the library palette
mDesktopPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor);
mDesktopPenPalette->setBackgroundBrush(UBSettings::settings()->opaquePaletteColor);
@@ -149,6 +154,12 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
connect(UBApplication::boardController->paletteManager()->rightPalette(), SIGNAL(resized()), this, SLOT(refreshMask()));
#endif
onDesktopPaletteMaximized();
+
+ // FIX #633: Ensure that these palettes stay on top of the other elements
+ mDesktopEraserPalette->raise();
+ mDesktopMarkerPalette->raise();
+ mDesktopPenPalette->raise();
+ mDesktopPalette->raise();
}
UBDesktopAnnotationController::~UBDesktopAnnotationController()
@@ -238,11 +249,7 @@ void UBDesktopAnnotationController::setAssociatedPalettePosition(UBActionPalette
if(act->objectName() == actionName)
{
int iAction = actions.indexOf(act);
- yPen = iAction * mDesktopPalette->buttonSize().height();
-
- // Add the borders
- yPen += (iAction) * (mDesktopPalette->border() + 4); // 4 has been set after some experiment. We must determine why this value is good
-
+ yPen = iAction * (mDesktopPalette->buttonSize().height() + 2 * mDesktopPalette->border() +6); // This is the mysterious value (6)
break;
}
}
@@ -267,7 +274,7 @@ void UBDesktopAnnotationController::eraseDesktopAnnotations()
{
if (mTransparentDrawingScene)
{
- mTransparentDrawingScene->clearAnnotations();
+ mTransparentDrawingScene->clearContent(UBGraphicsScene::clearAnnotations);
}
}
@@ -382,6 +389,7 @@ void UBDesktopAnnotationController::hideWindow()
void UBDesktopAnnotationController::goToUniboard()
{
+ onToolClicked();
hideWindow();
UBPlatformUtils::setDesktopMode(false);
@@ -397,6 +405,7 @@ void UBDesktopAnnotationController::goToUniboard()
void UBDesktopAnnotationController::customCapture()
{
+ onToolClicked();
mIsFullyTransparent = true;
updateBackground();
@@ -424,6 +433,7 @@ void UBDesktopAnnotationController::customCapture()
void UBDesktopAnnotationController::windowCapture()
{
+ onToolClicked();
mIsFullyTransparent = true;
updateBackground();
@@ -453,6 +463,7 @@ void UBDesktopAnnotationController::windowCapture()
void UBDesktopAnnotationController::screenCapture()
{
+ onToolClicked();
mIsFullyTransparent = true;
updateBackground();
@@ -539,7 +550,6 @@ void UBDesktopAnnotationController::penActionPressed()
*/
void UBDesktopAnnotationController::penActionReleased()
{
- qDebug() << "penActionReleased()";
mHoldTimerPen.stop();
if(mPendingPenButtonPressed)
{
@@ -594,7 +604,6 @@ void UBDesktopAnnotationController::eraserActionPressed()
*/
void UBDesktopAnnotationController::eraserActionReleased()
{
- qDebug() << "eraserActionReleased()";
mHoldTimerEraser.stop();
if(mPendingEraserButtonPressed)
{
@@ -651,7 +660,6 @@ void UBDesktopAnnotationController::markerActionPressed()
*/
void UBDesktopAnnotationController::markerActionReleased()
{
- qDebug() << "markerActionReleased()";
mHoldTimerMarker.stop();
if(mPendingMarkerButtonPressed)
{
@@ -930,3 +938,9 @@ void UBDesktopAnnotationController::refreshMask()
updateMask(true);
}
}
+
+void UBDesktopAnnotationController::onToolClicked(){
+ mDesktopEraserPalette->hide();
+ mDesktopMarkerPalette->hide();
+ mDesktopPenPalette->hide();
+}
diff --git a/src/desktop/UBDesktopAnnotationController.h b/src/desktop/UBDesktopAnnotationController.h
index 207db94b..c98b2466 100644
--- a/src/desktop/UBDesktopAnnotationController.h
+++ b/src/desktop/UBDesktopAnnotationController.h
@@ -111,6 +111,7 @@ class UBDesktopAnnotationController : public QObject
void onDesktopPaletteMinimize();
void onTransparentWidgetResized();
void refreshMask();
+ void onToolClicked();
private:
void setAssociatedPalettePosition(UBActionPalette* palette, const QString& actionName);
diff --git a/src/document/UBDocumentController.cpp b/src/document/UBDocumentController.cpp
index dbe0707b..af8734e6 100755
--- a/src/document/UBDocumentController.cpp
+++ b/src/document/UBDocumentController.cpp
@@ -117,8 +117,11 @@ UBDocumentProxyTreeItem* UBDocumentController::findDocument(UBDocumentProxy* pro
void UBDocumentController::selectDocument(UBDocumentProxy* proxy, bool setAsCurrentDocument)
{
- if (!proxy)
+ if (proxy==NULL)
+ {
+ setDocument(NULL);
return;
+ }
QTreeWidgetItemIterator it(mDocumentUI->documentTreeWidget);
@@ -531,6 +534,153 @@ void UBDocumentController::duplicateSelectedItem()
}
}
+void UBDocumentController::moveDocumentToTrash(UBDocumentGroupTreeItem* groupTi, UBDocumentProxyTreeItem *proxyTi)
+{
+ int index = proxyTi->parent()->indexOfChild(proxyTi);
+ index --;
+
+ if (index >= 0)
+ {
+ if (proxyTi->proxy() == mBoardController->selectedDocument())
+ {
+ selectDocument(((UBDocumentProxyTreeItem*)proxyTi->parent()->child(index))->proxy(), true);
+ }
+ else
+ proxyTi->parent()->child(index)->setSelected(true);
+ }
+ else if (proxyTi->parent()->childCount() > 1)
+ {
+ if (proxyTi->proxy() == mBoardController->selectedDocument())
+ {
+ selectDocument(((UBDocumentProxyTreeItem*)proxyTi->parent()->child(1))->proxy(), true);
+ }
+ else
+ proxyTi->parent()->child(1)->setSelected(true);
+ }
+ else
+ {
+ if (proxyTi->proxy() == mBoardController->selectedDocument())
+ {
+ bool documentFound = false;
+ for (int i = 0; i < mDocumentUI->documentTreeWidget->topLevelItemCount(); i++)
+ {
+ QTreeWidgetItem* item = mDocumentUI->documentTreeWidget->topLevelItem(i);
+ UBDocumentGroupTreeItem* groupItem = dynamic_cast(item);
+ if (!groupItem->isTrashFolder())
+ {
+ for(int j=0; jchildCount(); j++)
+ {
+ if (((UBDocumentProxyTreeItem*)groupItem->child(j))->proxy() != mBoardController->selectedDocument())
+ {
+ selectDocument(((UBDocumentProxyTreeItem*)groupItem->child(0))->proxy(), true);
+ documentFound = true;
+ break;
+ }
+ }
+ }
+ if (documentFound)
+ break;
+ }
+ if (!documentFound)
+ {
+ UBDocumentProxy *document = UBPersistenceManager::persistenceManager()->createDocument(groupTi->groupName());
+ selectDocument(document, true);
+ }
+ }
+ else
+ proxyTi->parent()->setSelected(true);
+ }
+
+ QString oldGroupName = proxyTi->proxy()->metaData(UBSettings::documentGroupName).toString();
+ proxyTi->proxy()->setMetaData(UBSettings::documentGroupName, UBSettings::trashedDocumentGroupNamePrefix + oldGroupName);
+ UBPersistenceManager::persistenceManager()->persistDocumentMetadata(proxyTi->proxy());
+
+ proxyTi->parent()->removeChild(proxyTi);
+ mTrashTi->addChild(proxyTi);
+ proxyTi->setFlags(proxyTi->flags() ^ Qt::ItemIsEditable);
+}
+
+void UBDocumentController::moveFolderToTrash(UBDocumentGroupTreeItem* groupTi)
+{
+ bool changeCurrentDocument = false;
+ for (int i = 0; i < groupTi->childCount(); i++)
+ {
+ UBDocumentProxyTreeItem* proxyTi = dynamic_cast(groupTi->child(i));
+ if (proxyTi && proxyTi->proxy() && proxyTi->proxy() == mBoardController->selectedDocument())
+ {
+ changeCurrentDocument = true;
+ break;
+ }
+ }
+
+ QList toBeDeleted;
+
+ for (int i = 0; i < groupTi->childCount(); i++)
+ {
+ UBDocumentProxyTreeItem* proxyTi = dynamic_cast(groupTi->child(i));
+ if (proxyTi && proxyTi->proxy())
+ toBeDeleted << proxyTi;
+ }
+
+ for (int i = 0; i < toBeDeleted.count(); i++)
+ {
+ UBDocumentProxyTreeItem* proxyTi = toBeDeleted.at(i);
+
+ showMessage(QString("Deleting %1").arg(proxyTi->proxy()->metaData(UBSettings::documentName).toString()));
+ // Move document to trash
+ QString oldGroupName = proxyTi->proxy()->metaData(UBSettings::documentGroupName).toString();
+ proxyTi->proxy()->setMetaData(UBSettings::documentGroupName, UBSettings::trashedDocumentGroupNamePrefix + oldGroupName);
+ UBPersistenceManager::persistenceManager()->persistDocumentMetadata(proxyTi->proxy());
+
+ groupTi->removeChild(proxyTi);
+ mTrashTi->addChild(proxyTi);
+ proxyTi->setFlags(proxyTi->flags() ^ Qt::ItemIsEditable);
+
+ showMessage(QString("%1 deleted").arg(groupTi->groupName()));
+ }
+
+ // dont remove default group
+ if (!groupTi->isDefaultFolder())
+ {
+ int index = mDocumentUI->documentTreeWidget->indexOfTopLevelItem(groupTi);
+
+ if (index >= 0)
+ {
+ mDocumentUI->documentTreeWidget->takeTopLevelItem(index);
+ }
+ }
+
+ if (changeCurrentDocument)
+ {
+ bool documentFound = false;
+ for (int i = 0; i < mDocumentUI->documentTreeWidget->topLevelItemCount(); i++)
+ {
+ QTreeWidgetItem* item = mDocumentUI->documentTreeWidget->topLevelItem(i);
+ UBDocumentGroupTreeItem* groupItem = dynamic_cast(item);
+ if (!groupItem->isTrashFolder() && groupItem != groupTi)
+ {
+ for(int j=0; jchildCount(); j++)
+ {
+ if (((UBDocumentProxyTreeItem*)groupItem->child(j))->proxy() != mBoardController->selectedDocument())
+ {
+ selectDocument(((UBDocumentProxyTreeItem*)groupItem->child(0))->proxy(), true);
+ documentFound = true;
+ break;
+ }
+ }
+ }
+ if (documentFound)
+ break;
+ }
+ if (!documentFound)
+ {
+ UBDocumentProxy *document = UBPersistenceManager::persistenceManager()->createDocument( UBSettings::defaultDocumentGroupName );
+ selectDocument(document, true);
+ }
+ }
+
+ reloadThumbnails();
+}
void UBDocumentController::deleteSelectedItem()
{
@@ -551,64 +701,21 @@ void UBDocumentController::deleteSelectedItem()
{
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)
+ if (proxyTi->parent() != mTrashTi)
{
- int index = proxyTi->parent()->indexOfChild(proxyTi);
- index --;
-
- if (index >= 0)
- {
- if (proxyTi->proxy() == mBoardController->selectedDocument())
- {
- selectDocument(((UBDocumentProxyTreeItem*)proxyTi->parent()->child(index))->proxy());
- }
- else
- proxyTi->parent()->child(index)->setSelected(true);
- }
- else if (proxyTi->parent()->childCount() > 1)
- {
- if (proxyTi->proxy() == mBoardController->selectedDocument())
- {
- selectDocument(((UBDocumentProxyTreeItem*)proxyTi->parent()->child(1))->proxy());
- }
- else
- proxyTi->parent()->child(1)->setSelected(true);
- }
- else
- {
- if (proxyTi->proxy() == mBoardController->selectedDocument())
- {
- for (int i = 0; i < mDocumentUI->documentTreeWidget->topLevelItemCount(); i++)
- {
- QTreeWidgetItem* item = mDocumentUI->documentTreeWidget->topLevelItem(i);
- UBDocumentGroupTreeItem* groupItem = dynamic_cast(item);
- if (groupItem != selectedDocumentGroupTreeItem() && groupItem->childCount() > 0)
- {
- selectDocument(((UBDocumentProxyTreeItem*)groupItem->child(0))->proxy());
- break;
- }
- }
- }
- else
- proxyTi->parent()->setSelected(true);
- }
-
- proxyTi->parent()->removeChild(proxyTi);
-
- UBPersistenceManager::persistenceManager()->deleteDocument(proxyTi->proxy());
-
- reloadThumbnails();
+ moveDocumentToTrash(groupTi, proxyTi);
}
else
{
- // Move document to trash
- QString oldGroupName = proxyTi->proxy()->metaData(UBSettings::documentGroupName).toString();
- proxyTi->proxy()->setMetaData(UBSettings::documentGroupName, UBSettings::trashedDocumentGroupNamePrefix + oldGroupName);
- UBPersistenceManager::persistenceManager()->persistDocumentMetadata(proxyTi->proxy());
-
+ // We have to physically delete document
proxyTi->parent()->removeChild(proxyTi);
- mTrashTi->addChild(proxyTi);
- proxyTi->setFlags(proxyTi->flags() ^ Qt::ItemIsEditable);
+ UBPersistenceManager::persistenceManager()->deleteDocument(proxyTi->proxy());
+
+ if (mTrashTi->childCount()==0)
+ selectDocument(NULL);
+ else
+ selectDocument(((UBDocumentProxyTreeItem*)mTrashTi->child(0))->proxy());
+ reloadThumbnails();
}
}
}
@@ -649,71 +756,7 @@ void UBDocumentController::deleteSelectedItem()
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;
- for (int i = 0; i < groupTi->childCount(); i++)
- {
- UBDocumentProxyTreeItem* proxyTi = dynamic_cast(groupTi->child(i));
- if (proxyTi && proxyTi->proxy() && proxyTi->proxy() == mBoardController->selectedDocument())
- {
- changeCurrentDocument = true;
- break;
- }
- }
-
- if (changeCurrentDocument)
- {
- for (int i = 0; i < mDocumentUI->documentTreeWidget->topLevelItemCount(); i++)
- {
- QTreeWidgetItem* item = mDocumentUI->documentTreeWidget->topLevelItem(i);
- UBDocumentGroupTreeItem* groupItem = dynamic_cast(item);
- if (groupItem != groupTi && groupItem->childCount() > 0)
- {
- selectDocument(((UBDocumentProxyTreeItem*)groupItem->child(0))->proxy());
- break;
- }
- }
- }
-
- QList toBeDeleted;
-
- for (int i = 0; i < groupTi->childCount(); i++)
- {
- UBDocumentProxyTreeItem* proxyTi = dynamic_cast(groupTi->child(i));
- if (proxyTi && proxyTi->proxy())
- toBeDeleted << proxyTi;
- }
-
- for (int i = 0; i < toBeDeleted.count(); i++)
- {
- UBDocumentProxyTreeItem* proxyTi = toBeDeleted.at(i);
-
- showMessage(QString("Deleting %1").arg(proxyTi->proxy()->metaData(UBSettings::documentName).toString()));
- // Move document to trash
- QString oldGroupName = proxyTi->proxy()->metaData(UBSettings::documentGroupName).toString();
- proxyTi->proxy()->setMetaData(UBSettings::documentGroupName, UBSettings::trashedDocumentGroupNamePrefix + oldGroupName);
- UBPersistenceManager::persistenceManager()->persistDocumentMetadata(proxyTi->proxy());
-
- groupTi->removeChild(proxyTi);
- mTrashTi->addChild(proxyTi);
- proxyTi->setFlags(proxyTi->flags() ^ Qt::ItemIsEditable);
-
- showMessage(QString("%1 deleted").arg(groupTi->groupName()));
- }
-
- // dont remove default group
- if (!groupTi->isDefaultFolder())
- {
- int index = mDocumentUI->documentTreeWidget->indexOfTopLevelItem(groupTi);
-
- if (index >= 0)
- {
- mDocumentUI->documentTreeWidget->takeTopLevelItem(index);
- }
- }
-
- reloadThumbnails();
-
+ moveFolderToTrash(groupTi);
QApplication::restoreOverrideCursor();
}
}
diff --git a/src/document/UBDocumentController.h b/src/document/UBDocumentController.h
index d27ca0a6..ac8a113f 100644
--- a/src/document/UBDocumentController.h
+++ b/src/document/UBDocumentController.h
@@ -111,6 +111,9 @@ class UBDocumentController : public UBDocumentContainer
bool mToolsPalettePositionned;
UBDocumentGroupTreeItem* mTrashTi;
+ void moveDocumentToTrash(UBDocumentGroupTreeItem* groupTi, UBDocumentProxyTreeItem *proxyTi);
+ void moveFolderToTrash(UBDocumentGroupTreeItem* groupTi);
+
private slots:
void documentZoomSliderValueChanged (int value);
void loadDocumentProxies();
diff --git a/src/domain/UBGraphicsDelegateFrame.cpp b/src/domain/UBGraphicsDelegateFrame.cpp
index a2da072a..de40ab43 100644
--- a/src/domain/UBGraphicsDelegateFrame.cpp
+++ b/src/domain/UBGraphicsDelegateFrame.cpp
@@ -226,7 +226,7 @@ void UBGraphicsDelegateFrame::mousePressEvent(QGraphicsSceneMouseEvent *event)
mInitialTransform = buildTransform();
mCurrentTool = toolFromPos(event->pos());
- setCursorFromAngle(QString(""));
+ setCursorFromAngle(QString::number((int)mAngle % 360));
event->accept();
prepareFramesToMove(getLinkedFrames());
diff --git a/src/domain/UBGraphicsGroupContainerItem.cpp b/src/domain/UBGraphicsGroupContainerItem.cpp
index bed3b219..818eb88e 100644
--- a/src/domain/UBGraphicsGroupContainerItem.cpp
+++ b/src/domain/UBGraphicsGroupContainerItem.cpp
@@ -28,18 +28,12 @@ UBGraphicsGroupContainerItem::UBGraphicsGroupContainerItem(QGraphicsItem *parent
setUuid(QUuid::createUuid());
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::ObjectItem)); //Necessary to set if we want z value to be assigned correctly
-
-
}
UBGraphicsGroupContainerItem::~UBGraphicsGroupContainerItem()
{
- foreach (QGraphicsItem *item, childItems())
- {
- removeFromGroup(item);
- if (item && item->scene())
- item->scene()->removeItem(item);
- }
+ if (mDelegate)
+ delete mDelegate;
}
void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item)
@@ -83,6 +77,13 @@ void UBGraphicsGroupContainerItem::addToGroup(QGraphicsItem *item)
QTransform newItemTransform(itemTransform);
item->setPos(mapFromItem(item, 0, 0));
+
+ if (item->scene()) {
+ item->scene()->removeItem(item);
+ }
+
+ if (corescene())
+ corescene()->removeItemFromDeletion(item);
item->setParentItem(this);
// removing position from translation component of the new transform
@@ -113,10 +114,12 @@ void UBGraphicsGroupContainerItem::removeFromGroup(QGraphicsItem *item)
{
if (!item) {
qDebug() << "can't specify the item because of the null pointer";
+ return;
}
- UBGraphicsScene *groupScene = scene();
- if (groupScene) {
+ UBCoreGraphicsScene *groupScene = corescene();
+ if (groupScene)
+ {
groupScene->addItemToDeletion(item);
}
@@ -170,9 +173,9 @@ void UBGraphicsGroupContainerItem::paint(QPainter *painter, const QStyleOptionGr
// }
}
-UBGraphicsScene *UBGraphicsGroupContainerItem::scene()
+UBCoreGraphicsScene *UBGraphicsGroupContainerItem::corescene()
{
- UBGraphicsScene *castScene = dynamic_cast(QGraphicsItem::scene());
+ UBCoreGraphicsScene *castScene = dynamic_cast(QGraphicsItem::scene());
return castScene;
}
@@ -218,15 +221,7 @@ void UBGraphicsGroupContainerItem::setUuid(const QUuid &pUuid)
void UBGraphicsGroupContainerItem::destroy() {
- UBGraphicsScene *groupScene = scene();
-
-
foreach (QGraphicsItem *item, childItems()) {
-
- if (groupScene) {
- groupScene->addItemToDeletion(item);
- }
-
pRemoveFromGroup(item);
item->setFlag(QGraphicsItem::ItemIsSelectable, true);
item->setFlag(QGraphicsItem::ItemIsFocusable, true);
@@ -235,6 +230,18 @@ void UBGraphicsGroupContainerItem::destroy() {
remove();
}
+void UBGraphicsGroupContainerItem::clearSource()
+{
+ foreach(QGraphicsItem *child, childItems())
+ {
+ UBGraphicsItem *item = dynamic_cast(child);
+ if (item)
+ {
+ item->clearSource();
+ }
+ }
+}
+
void UBGraphicsGroupContainerItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if (mDelegate->mousePressEvent(event)) {
@@ -327,6 +334,12 @@ void UBGraphicsGroupContainerItem::pRemoveFromGroup(QGraphicsItem *item)
item->setParentItem(newParent);
item->setPos(oldPos);
+ UBGraphicsScene *Scene = dynamic_cast(item->scene());
+ if (Scene)
+ {
+ Scene->addItem(item);
+ }
+
// removing position from translation component of the new transform
if (!item->pos().isNull())
itemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
diff --git a/src/domain/UBGraphicsGroupContainerItem.h b/src/domain/UBGraphicsGroupContainerItem.h
index 535627eb..e8fa77eb 100644
--- a/src/domain/UBGraphicsGroupContainerItem.h
+++ b/src/domain/UBGraphicsGroupContainerItem.h
@@ -4,6 +4,7 @@
#include
#include "domain/UBItem.h"
+#include "frameworks/UBCoreGraphicsScene.h"
class UBGraphicsGroupContainerItem : public QGraphicsItem, public UBItem, public UBGraphicsItem
{
@@ -23,7 +24,7 @@ public:
virtual UBGraphicsItemDelegate* Delegate() const { return mDelegate;}
- virtual UBGraphicsScene* scene();
+ virtual UBCoreGraphicsScene *corescene();
virtual UBGraphicsGroupContainerItem *deepCopy() const;
virtual void copyItemParameters(UBItem *copy) const;
@@ -38,6 +39,8 @@ public:
virtual void setUuid(const QUuid &pUuid);
void destroy();
+ virtual void clearSource();
+
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
diff --git a/src/domain/UBGraphicsItemDelegate.cpp b/src/domain/UBGraphicsItemDelegate.cpp
index 4abeb1a2..d5620d12 100644
--- a/src/domain/UBGraphicsItemDelegate.cpp
+++ b/src/domain/UBGraphicsItemDelegate.cpp
@@ -113,7 +113,6 @@ UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObjec
, mFlippable(false)
, mToolBarUsed(useToolBar)
{
- // NOOP
connect(UBApplication::boardController, SIGNAL(zoomChanged(qreal)), this, SLOT(onZoomChanged()));
}
@@ -167,7 +166,7 @@ void UBGraphicsItemDelegate::init()
UBGraphicsItemDelegate::~UBGraphicsItemDelegate()
{
- qDeleteAll(mButtons);
+ disconnect(UBApplication::boardController, SIGNAL(zoomChanged(qreal)), this, SLOT(onZoomChanged()));
// do not release mMimeData.
// the mMimeData is owned by QDrag since the setMimeData call as specified in the documentation
}
@@ -388,12 +387,25 @@ void UBGraphicsItemDelegate::remove(bool canUndo)
UBGraphicsScene* scene = dynamic_cast(mDelegated->scene());
if (scene)
{
- foreach(DelegateButton* button, mButtons)
- scene->removeItem(button);
+// bool shownOnDisplay = mDelegated->data(UBGraphicsItemData::ItemLayerType).toInt() != UBItemLayerType::Control;
+// showHide(shownOnDisplay);
+// updateFrame();
+// updateButtons();
+ if (mFrame && !mFrame->scene() && mDelegated->scene())
+ {
+ mDelegated->scene()->addItem(mFrame);
+ }
+ mFrame->setAntiScale(mAntiScaleRatio);
+ mFrame->positionHandles();
+ updateButtons(true);
+
+ foreach(DelegateButton* button, mButtons) {
+ scene->removeItem(button);
+ }
scene->removeItem(mFrame);
- /* this is performed because when removing delegated from scene while it contains flash content, segfault happens because of QGraphicsScene::removeItem() */
+ /* this is performed because when removing delegated from scene while it contains flash content, segfault happens because of QGraphicsScene::removeItem() */
UBGraphicsWebView *mDelegated_casted = dynamic_cast(mDelegated);
if (mDelegated_casted)
mDelegated_casted->setHtml(QString());
diff --git a/src/domain/UBGraphicsItemDelegate.h b/src/domain/UBGraphicsItemDelegate.h
index c782c94b..01ef854b 100644
--- a/src/domain/UBGraphicsItemDelegate.h
+++ b/src/domain/UBGraphicsItemDelegate.h
@@ -244,6 +244,7 @@ class UBGraphicsItemDelegate : public QObject
UBGraphicsToolBarItem* getToolBarItem() const { return mToolBarItem; }
qreal antiScaleRatio() const { return mAntiScaleRatio; }
+ virtual void update() {positionHandles();}
signals:
void showOnDisplayChanged(bool shown);
diff --git a/src/domain/UBGraphicsPolygonItem.cpp b/src/domain/UBGraphicsPolygonItem.cpp
index b21f2760..e5dd4fd7 100644
--- a/src/domain/UBGraphicsPolygonItem.cpp
+++ b/src/domain/UBGraphicsPolygonItem.cpp
@@ -142,14 +142,14 @@ QColor UBGraphicsPolygonItem::color() const
UBItem* UBGraphicsPolygonItem::deepCopy() const
-{
- UBGraphicsPolygonItem* copy = new UBGraphicsPolygonItem(polygon(), parentItem());
+{
+ UBGraphicsPolygonItem* copy = new UBGraphicsPolygonItem(polygon(), 0);
+ UBGraphicsStroke *stroke = new UBGraphicsStroke();
+
copyItemParameters(copy);
- copy->mOriginalLine = this->mOriginalLine;
- copy->mOriginalWidth = this->mOriginalWidth;
- copy->mIsNominalLine = this->mIsNominalLine;
+ copy->setStroke(stroke);
return copy;
}
@@ -160,17 +160,15 @@ void UBGraphicsPolygonItem::copyItemParameters(UBItem *copy) const
UBGraphicsPolygonItem *cp = dynamic_cast(copy);
if (cp)
{
- cp->mOriginalLine = QLineF();
- cp->mOriginalWidth = -1;
- cp->mIsNominalLine = false;
+ cp->mOriginalLine = this->mOriginalLine;
+ cp->mOriginalWidth = this->mOriginalWidth;
+ cp->mIsNominalLine = this->mIsNominalLine;
- cp->setStroke(this->stroke());
- cp->setStrokesGroup(this->strokesGroup());
+ cp->setTransform(transform());
cp->setBrush(this->brush());
cp->setPen(this->pen());
cp->mHasAlpha = this->mHasAlpha;
-
cp->setColorOnDarkBackground(this->colorOnDarkBackground());
cp->setColorOnLightBackground(this->colorOnLightBackground());
diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp
index 48ddb3dc..be2c2ed3 100644
--- a/src/domain/UBGraphicsScene.cpp
+++ b/src/domain/UBGraphicsScene.cpp
@@ -264,7 +264,6 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
, mCrossedBackground(false)
, mIsDesktopMode(false)
, mZoomFactor(1)
- , mIsModified(true)
, mBackgroundObject(0)
, mPreviousWidth(0)
, mInputDeviceIsPressed(false)
@@ -306,7 +305,10 @@ UBGraphicsScene::~UBGraphicsScene()
{
if (mCurrentStroke)
if (mCurrentStroke->polygons().empty())
+ {
delete mCurrentStroke;
+ mCurrentStroke = NULL;
+ }
if (mZLayerController)
delete mZLayerController;
@@ -434,6 +436,11 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
}
}
+ if (mCurrentStroke && mCurrentStroke->polygons().empty()){
+ delete mCurrentStroke;
+ mCurrentStroke = NULL;
+ }
+
return accepted;
}
@@ -475,6 +482,10 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
UBCoreGraphicsScene::removeItemFromDeletion(mpLastPolygon);
mAddedItems.remove(mpLastPolygon);
mCurrentStroke->remove(mpLastPolygon);
+ if (mCurrentStroke->polygons().empty()){
+ delete mCurrentStroke;
+ mCurrentStroke = NULL;
+ }
removeItem(mpLastPolygon);
mPreviousPolygonItems.removeAll(mpLastPolygon);
}
@@ -892,25 +903,18 @@ void UBGraphicsScene::recolorAllItems()
view->setViewportUpdateMode(QGraphicsView::NoViewportUpdate);
}
- for(int i = 0; i < mFastAccessItems.size(); i++)
- {
- UBGraphicsPolygonItem *polygonItem = qgraphicsitem_cast (mFastAccessItems.at(i));
-
- if (polygonItem)
- {
- QColor color;
-
- if (mDarkBackground)
- {
- color = polygonItem->colorOnDarkBackground();
- }
- else
- {
- color = polygonItem->colorOnLightBackground();
+ bool currentIslight = isLightBackground();
+ foreach (QGraphicsItem *item, items()) {
+ if (item->type() == UBGraphicsStrokesGroup::Type) {
+ UBGraphicsStrokesGroup *curGroup = static_cast(item);
+ QColor compareColor = curGroup->color(currentIslight ? UBGraphicsStrokesGroup::colorOnDarkBackground
+ : UBGraphicsStrokesGroup::colorOnLightBackground);
+
+ if (curGroup->color() == compareColor) {
+ QColor newColor = curGroup->color(!currentIslight ? UBGraphicsStrokesGroup::colorOnDarkBackground
+ : UBGraphicsStrokesGroup::colorOnLightBackground);
+ curGroup->setColor(newColor);
}
-
- polygonItem->setColor(color);
- continue;
}
}
@@ -1061,116 +1065,72 @@ UBItem* UBGraphicsScene::deepCopy() const
return sceneDeepCopy();
}
-void UBGraphicsScene::clearItemsAndAnnotations()
-{
- deselectAllItems();
-
- QSet emptyList;
- QSet removedItems;
-
- QListIterator itItems(mFastAccessItems);
-
- while (itItems.hasNext())
- {
- QGraphicsItem* item = itItems.next();
-
- if(!mTools.contains(item) && !isBackgroundObject(item))
- {
- removeItem(item);
- removedItems << item;
- }
- }
-
- // force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
- update(sceneRect());
-
- if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
- UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, emptyList);
- UBApplication::undoStack->push(uc);
- }
-
- setDocumentUpdated();
-}
-
-void UBGraphicsScene::clearItems()
+void UBGraphicsScene::clearContent(clearCase pCase)
{
- deselectAllItems();
-
- QSet emptyList;
QSet removedItems;
- QListIterator itItems(mFastAccessItems);
+ switch (pCase) {
+ case clearBackground :
+ removeItem(mBackgroundObject);
+ removedItems << mBackgroundObject;
+ break;
+
+ case clearItemsAndAnnotations :
+ case clearItems :
+ case clearAnnotations :
+ foreach(QGraphicsItem* item, items()) {
+
+ bool isGroup = item->type() == UBGraphicsGroupContainerItem::Type;
+ bool isStrokesGroup = item->type() == UBGraphicsStrokesGroup::Type;
+
+ UBGraphicsGroupContainerItem *itemGroup = item->parentItem()
+ ? qgraphicsitem_cast(item->parentItem())
+ : 0;
+ UBGraphicsItemDelegate *curDelegate = UBGraphicsItem::Delegate(item);
+ if (!curDelegate) {
+ continue;
+ }
- while (itItems.hasNext())
- {
- QGraphicsItem* item = itItems.next();
+ bool shouldDelete = false;
+ switch (static_cast(pCase)) {
+ case clearAnnotations :
+ shouldDelete = isStrokesGroup;
+ break;
+ case clearItems :
+ shouldDelete = !isGroup && !isBackgroundObject(item) && !isStrokesGroup;
+ break;
+ case clearItemsAndAnnotations:
+ shouldDelete = !isGroup && !isBackgroundObject(item);
+ break;
+ }
- if (!item->parentItem())
- {
- UBGraphicsPolygonItem* pi = qgraphicsitem_cast(item);
+ if(shouldDelete) {
+ if (itemGroup) {
+ itemGroup->removeFromGroup(item);
+ if (itemGroup->childItems().count() == 1) {
+ itemGroup->destroy();
+ }
+ itemGroup->Delegate()->update();
+ }
- if(!pi && !mTools.contains(item) && !isBackgroundObject(item))
- {
- removeItem(item);
+ curDelegate->remove(false);
removedItems << item;
}
}
+ break;
}
// force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
update(sceneRect());
-
if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
- UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, emptyList);
+ UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, QSet());
UBApplication::undoStack->push(uc);
}
- setDocumentUpdated();
-}
-
-void UBGraphicsScene::clearAnnotations()
-{
- QSet emptyList;
- QSet removedItems;
-
- QListIterator itItems(mFastAccessItems);
-
- while (itItems.hasNext())
- {
- QGraphicsItem* item = itItems.next();
- UBGraphicsStrokesGroup* pi = qgraphicsitem_cast(item);
- if (pi)
- {
- removeItem(item);
- removedItems << item;
- }
- }
-
- // force refresh, QT is a bit lazy and take a lot of time (nb item ^2 ?) to trigger repaint
- update(sceneRect());
-
-
- if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
- UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, removedItems, emptyList);
- UBApplication::undoStack->push(uc);
- }
-
- setDocumentUpdated();
-}
-
-void UBGraphicsScene::clearBackground()
-{
- if(mBackgroundObject){
- removeItem(mBackgroundObject);
-
- if (enableUndoRedoStack) { //should be deleted after scene own undo stack implemented
- UBGraphicsItemUndoCommand* uc = new UBGraphicsItemUndoCommand(this, mBackgroundObject, NULL);
- UBApplication::undoStack->push(uc);
- }
+ if (pCase == clearBackground) {
mBackgroundObject = 0;
}
- update(sceneRect());
setDocumentUpdated();
}
@@ -1365,6 +1325,7 @@ UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QListtype() == UBGraphicsGroupContainerItem::Type) {
QList childItems = item->childItems();
@@ -1374,13 +1335,14 @@ UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QListaddToGroup(chItem);
+ mFastAccessItems.removeAll(chItem);
}
} else {
groupItem->addToGroup(item);
+ mFastAccessItems.removeAll(item);
}
}
- addItem(groupItem);
groupItem->setVisible(true);
groupItem->setFocus();
@@ -1397,6 +1359,15 @@ UBGraphicsGroupContainerItem *UBGraphicsScene::createGroup(QListchildItems().count(); i++)
+ {
+ QGraphicsItem *it = qgraphicsitem_cast(groupItem->childItems().at(i));
+ if (it)
+ {
+ mFastAccessItems.removeAll(it);
+ }
+ }
+
groupItem->setVisible(true);
groupItem->setFocus();
@@ -1565,7 +1536,6 @@ UBGraphicsTextItem *UBGraphicsScene::addTextHtml(const QString &pString, const Q
void UBGraphicsScene::addItem(QGraphicsItem* item)
{
- setModified(true);
UBCoreGraphicsScene::addItem(item);
UBGraphicsItem::assignZValue(item, mZLayerController->generateZLevel(item));
@@ -1578,8 +1548,6 @@ void UBGraphicsScene::addItem(QGraphicsItem* item)
void UBGraphicsScene::addItems(const QSet& items)
{
- setModified(true);
-
foreach(QGraphicsItem* item, items) {
UBCoreGraphicsScene::addItem(item);
UBGraphicsItem::assignZValue(item, mZLayerController->generateZLevel(item));
@@ -1592,7 +1560,7 @@ void UBGraphicsScene::addItems(const QSet& items)
void UBGraphicsScene::removeItem(QGraphicsItem* item)
{
- setModified(true);
+ item->setSelected(false);
UBCoreGraphicsScene::removeItem(item);
UBApplication::boardController->freezeW3CWidget(item, true);
@@ -1604,8 +1572,6 @@ void UBGraphicsScene::removeItem(QGraphicsItem* item)
void UBGraphicsScene::removeItems(const QSet& items)
{
- setModified(true);
-
foreach(QGraphicsItem* item, items)
UBCoreGraphicsScene::removeItem(item);
@@ -1763,7 +1729,6 @@ void UBGraphicsScene::addRuler(QPointF center)
addItem(ruler);
ruler->setVisible(true);
- setModified(true);
}
void UBGraphicsScene::addProtractor(QPointF center)
@@ -1781,7 +1746,6 @@ void UBGraphicsScene::addProtractor(QPointF center)
protractor->moveBy(center.x() - itemSceneCenter.x(), center.y() - itemSceneCenter.y());
protractor->setVisible(true);
- setModified(true);
}
void UBGraphicsScene::addTriangle(QPointF center)
@@ -1799,7 +1763,6 @@ void UBGraphicsScene::addTriangle(QPointF center)
triangle->moveBy(center.x() - itemSceneCenter.x(), center.y() - itemSceneCenter.y());
triangle->setVisible(true);
- setModified(true);
}
void UBGraphicsScene::addMagnifier(UBMagnifierParams params)
@@ -1858,6 +1821,7 @@ void UBGraphicsScene::moveMagnifier()
{
QPoint magnifierPos = QPoint(magniferControlViewWidget->pos().x() + magniferControlViewWidget->size().width() / 2, magniferControlViewWidget->pos().y() + magniferControlViewWidget->size().height() / 2 );
moveMagnifier(magnifierPos, true);
+ setModified(true);
}
}
@@ -1890,6 +1854,7 @@ void UBGraphicsScene::moveMagnifier(QPoint newPos, bool forceGrab)
void UBGraphicsScene::closeMagnifier()
{
DisposeMagnifierQWidgets();
+ setModified(true);
}
void UBGraphicsScene::zoomInMagnifier()
@@ -1907,6 +1872,7 @@ void UBGraphicsScene::zoomOutMagnifier()
{
magniferControlViewWidget->setZoom(magniferControlViewWidget->params.zoom - 0.5);
magniferDisplayViewWidget->setZoom(magniferDisplayViewWidget->params.zoom - 0.5);
+ setModified(true);
}
}
@@ -1918,6 +1884,7 @@ void UBGraphicsScene::resizedMagnifier(qreal newPercent)
magniferControlViewWidget->grabPoint();
magniferDisplayViewWidget->setSize(newPercent);
magniferDisplayViewWidget->grabPoint();
+ setModified(true);
}
}
@@ -1933,7 +1900,6 @@ void UBGraphicsScene::addCompass(QPointF center)
compass->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
compass->setVisible(true);
- setModified(true);
}
void UBGraphicsScene::addAristo(QPointF center)
@@ -1979,7 +1945,6 @@ void UBGraphicsScene::addMask(const QPointF ¢er)
curtain->setRect(rect);
curtain->setVisible(true);
curtain->setSelected(true);
- setModified(true);
}
void UBGraphicsScene::setRenderingQuality(UBItem::RenderingQuality pRenderingQuality)
@@ -2229,7 +2194,6 @@ void UBGraphicsScene::keyReleaseEvent(QKeyEvent * keyEvent)
default:
{
- item->setSelected(false);
UBGraphicsItem *ubgi = dynamic_cast(item);
if (0 != ubgi)
ubgi->remove();
@@ -2291,6 +2255,11 @@ void UBGraphicsScene::setToolCursor(int tool)
{
deselectAllItems();
}
+
+ if (mCurrentStroke && mCurrentStroke->polygons().empty()){
+ delete mCurrentStroke;
+ }
+ mCurrentStroke = NULL;
}
void UBGraphicsScene::initStroke(){
diff --git a/src/domain/UBGraphicsScene.h b/src/domain/UBGraphicsScene.h
index 6d65e075..18b7adda 100644
--- a/src/domain/UBGraphicsScene.h
+++ b/src/domain/UBGraphicsScene.h
@@ -101,6 +101,13 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
public:
+ enum clearCase {
+ clearItemsAndAnnotations = 0
+ , clearAnnotations
+ , clearItems
+ , clearBackground
+ };
+
// tmp stub for divide addings scene objects from undo mechanism implementation
void setURStackEnable(bool set = true) {enableUndoRedoStack = set;}
bool isURStackIsEnabled(){ return enableUndoRedoStack;}
@@ -114,10 +121,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBGraphicsScene* sceneDeepCopy() const;
- void clearItemsAndAnnotations();
- void clearItems();
- void clearAnnotations();
- void clearBackground();
+ void clearContent(clearCase pCase = clearItemsAndAnnotations);
bool inputDevicePress(const QPointF& scenePos, const qreal& pressure = 1.0);
bool inputDeviceMove(const QPointF& scenePos, const qreal& pressure = 1.0);
@@ -179,16 +183,6 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
bool isEmpty() const;
- bool isModified() const
- {
- return mIsModified;
- }
-
- void setModified(bool pModified)
- {
- mIsModified = pModified;
- }
-
void setDocument(UBDocumentProxy* pDocument);
UBDocumentProxy* document() const
@@ -381,8 +375,6 @@ public slots:
bool mIsDesktopMode;
qreal mZoomFactor;
- bool mIsModified;
-
QGraphicsItem* mBackgroundObject;
QPointF mPreviousPoint;
diff --git a/src/domain/UBGraphicsStrokesGroup.cpp b/src/domain/UBGraphicsStrokesGroup.cpp
index a5320924..e9993375 100644
--- a/src/domain/UBGraphicsStrokesGroup.cpp
+++ b/src/domain/UBGraphicsStrokesGroup.cpp
@@ -32,6 +32,54 @@ void UBGraphicsStrokesGroup::setUuid(const QUuid &pUuid)
UBItem::setUuid(pUuid);
setData(UBGraphicsItemData::ItemUuid, QVariant(pUuid)); //store item uuid inside the QGraphicsItem to fast operations with Items on the scene
}
+void UBGraphicsStrokesGroup::setColor(const QColor &color, colorType pColorType)
+{
+ //TODO Implement common mechanism of managing groups, drop UBGraphicsStroke if it's obsolete
+ //Using casting for the moment
+ foreach (QGraphicsItem *item, childItems()) {
+ if (item->type() == UBGraphicsPolygonItem::Type) {
+ UBGraphicsPolygonItem *curPolygon = static_cast(item);
+
+ switch (pColorType) {
+ case currentColor :
+ curPolygon->setColor(color);
+ break;
+ case colorOnLightBackground :
+ curPolygon->setColorOnLightBackground(color);
+ break;
+ case colorOnDarkBackground :
+ curPolygon->setColorOnDarkBackground(color);
+ break;
+ }
+ }
+ }
+}
+
+QColor UBGraphicsStrokesGroup::color(colorType pColorType) const
+{
+ QColor result;
+
+ foreach (QGraphicsItem *item, childItems()) {
+ if (item->type() == UBGraphicsPolygonItem::Type) {
+ UBGraphicsPolygonItem *curPolygon = static_cast(item);
+
+ switch (pColorType) {
+ case currentColor :
+ result = curPolygon->color();
+ break;
+ case colorOnLightBackground :
+ result = curPolygon->colorOnLightBackground();
+ break;
+ case colorOnDarkBackground :
+ result = curPolygon->colorOnDarkBackground();
+ break;
+ }
+
+ }
+ }
+
+ return result;
+}
void UBGraphicsStrokesGroup::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
@@ -65,29 +113,30 @@ void UBGraphicsStrokesGroup::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
UBItem* UBGraphicsStrokesGroup::deepCopy() const
{
- UBGraphicsStrokesGroup* copy = new UBGraphicsStrokesGroup();
+ UBGraphicsStrokesGroup* copy = new UBGraphicsStrokesGroup();
-
- QList chl = childItems();
+ QList chl = childItems();
foreach(QGraphicsItem *child, chl)
{
UBGraphicsPolygonItem *polygon = dynamic_cast(child);
if (polygon)
+ {
copy->addToGroup(dynamic_cast(polygon->deepCopy()));
+ polygon->setStrokesGroup(copy);
+ }
}
copyItemParameters(copy);
- return copy;
+ return copy;
}
void UBGraphicsStrokesGroup::copyItemParameters(UBItem *copy) const
{
UBGraphicsStrokesGroup *cp = dynamic_cast(copy);
{
- cp->setPos(this->pos());
+ cp->setTransform(transform());
- cp->setTransform(this->transform());
cp->setFlag(QGraphicsItem::ItemIsMovable, true);
cp->setFlag(QGraphicsItem::ItemIsSelectable, true);
cp->setData(UBGraphicsItemData::ItemLayerType, this->data(UBGraphicsItemData::ItemLayerType));
diff --git a/src/domain/UBGraphicsStrokesGroup.h b/src/domain/UBGraphicsStrokesGroup.h
index b2310773..2c286d11 100644
--- a/src/domain/UBGraphicsStrokesGroup.h
+++ b/src/domain/UBGraphicsStrokesGroup.h
@@ -11,6 +11,12 @@ class UBGraphicsStrokesGroup : public QObject, public QGraphicsItemGroup, public
{
Q_OBJECT
public:
+ enum colorType {
+ currentColor = 0
+ , colorOnLightBackground
+ , colorOnDarkBackground
+ };
+
UBGraphicsStrokesGroup(QGraphicsItem* parent = 0);
~UBGraphicsStrokesGroup();
virtual UBItem* deepCopy() const;
@@ -23,6 +29,8 @@ public:
return Type;
}
virtual void setUuid(const QUuid &pUuid);
+ void setColor(const QColor &color, colorType pColorType = currentColor);
+ QColor color(colorType pColorType = currentColor) const;
protected:
diff --git a/src/domain/UBGraphicsTextItemDelegate.cpp b/src/domain/UBGraphicsTextItemDelegate.cpp
index 6e7e730e..9f7b5fdb 100644
--- a/src/domain/UBGraphicsTextItemDelegate.cpp
+++ b/src/domain/UBGraphicsTextItemDelegate.cpp
@@ -263,6 +263,11 @@ void UBGraphicsTextItemDelegate::setEditable(bool editable)
mDelegated->setData(UBGraphicsItemData::ItemEditable, QVariant(false));
}
}
+void UBGraphicsTextItemDelegate::remove(bool canUndo)
+{
+ UBGraphicsItemDelegate::remove(canUndo);
+}
+
bool UBGraphicsTextItemDelegate::isEditable()
{
return mDelegated->data(UBGraphicsItemData::ItemEditable).toBool();
@@ -419,8 +424,8 @@ QVariant UBGraphicsTextItemDelegate::itemChange(QGraphicsItem::GraphicsItemChang
QTextCursor c = delegated()->textCursor();
if (c.hasSelection())
{
- c.clearSelection();
- delegated()->setTextCursor(c);
+ c.clearSelection();
+ delegated()->setTextCursor(c);
}
}
}
diff --git a/src/domain/UBGraphicsTextItemDelegate.h b/src/domain/UBGraphicsTextItemDelegate.h
index 26b3ba9b..2cf6f447 100644
--- a/src/domain/UBGraphicsTextItemDelegate.h
+++ b/src/domain/UBGraphicsTextItemDelegate.h
@@ -46,6 +46,7 @@ class UBGraphicsTextItemDelegate : public UBGraphicsItemDelegate
public slots:
void contentsChanged();
virtual void setEditable(bool);
+ virtual void remove(bool canUndo);
protected:
virtual void buildButtons();
diff --git a/src/domain/UBItem.cpp b/src/domain/UBItem.cpp
index 9d999a94..10d3d6ce 100644
--- a/src/domain/UBItem.cpp
+++ b/src/domain/UBItem.cpp
@@ -17,6 +17,15 @@
#include "core/memcheck.h"
+#include "domain/UBGraphicsPixmapItem.h"
+#include "domain/UBGraphicsTextItem.h"
+#include "domain/UBGraphicsSvgItem.h"
+#include "domain/UBGraphicsMediaItem.h"
+#include "domain/UBGraphicsStrokesGroup.h"
+#include "domain/UBGraphicsGroupContainerItem.h"
+#include "domain/UBGraphicsWidgetItem.h"
+#include "tools/UBGraphicsCurtainItem.h"
+
UBItem::UBItem()
: mUuid(QUuid())
, mRenderingQuality(UBItem::RenderingQualityNormal)
@@ -44,3 +53,37 @@ bool UBGraphicsItem::isRotatable(QGraphicsItem *item)
{
return item->data(UBGraphicsItemData::ItemRotatable).toBool();
}
+
+UBGraphicsItemDelegate *UBGraphicsItem::Delegate(QGraphicsItem *pItem)
+{
+ UBGraphicsItemDelegate *result = 0;
+
+ switch (static_cast(pItem->type())) {
+ case UBGraphicsPixmapItem::Type :
+ result = (static_cast(pItem))->Delegate();
+ break;
+ case UBGraphicsTextItem::Type :
+ result = (static_cast(pItem))->Delegate();
+ break;
+ case UBGraphicsSvgItem::Type :
+ result = (static_cast(pItem))->Delegate();
+ break;
+ case UBGraphicsMediaItem::Type:
+ result = (static_cast(pItem))->Delegate();
+ break;
+ case UBGraphicsStrokesGroup::Type :
+ result = (static_cast(pItem))->Delegate();
+ break;
+ case UBGraphicsGroupContainerItem::Type :
+ result = (static_cast(pItem))->Delegate();
+ break;
+ case UBGraphicsWidgetItem::Type :
+ result = (static_cast(pItem))->Delegate();
+ break;
+ case UBGraphicsCurtainItem::Type :
+ result = (static_cast(pItem))->Delegate();
+ break;
+ }
+
+ return result;
+}
diff --git a/src/domain/UBItem.h b/src/domain/UBItem.h
index 99c3e6a6..ca8a0f3b 100644
--- a/src/domain/UBItem.h
+++ b/src/domain/UBItem.h
@@ -108,6 +108,7 @@ public:
static bool isRotatable(QGraphicsItem *item);
static bool isFlippable(QGraphicsItem *item);
+ static UBGraphicsItemDelegate *Delegate(QGraphicsItem *pItem);
virtual UBGraphicsItemDelegate *Delegate() const = 0;
virtual void remove() = 0;
diff --git a/src/frameworks/UBCoreGraphicsScene.cpp b/src/frameworks/UBCoreGraphicsScene.cpp
index fd4948ec..28dd6a9f 100644
--- a/src/frameworks/UBCoreGraphicsScene.cpp
+++ b/src/frameworks/UBCoreGraphicsScene.cpp
@@ -23,6 +23,7 @@
UBCoreGraphicsScene::UBCoreGraphicsScene(QObject * parent)
: QGraphicsScene ( parent )
+ , mIsModified(true)
{
//NOOP
}
@@ -30,27 +31,40 @@ UBCoreGraphicsScene::UBCoreGraphicsScene(QObject * parent)
UBCoreGraphicsScene::~UBCoreGraphicsScene()
{
//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::iterator it = mItemsToDelete.begin();
+ QGraphicsItem* item = *it;
+ do
{
- delete item;
- }
+ item = *it;
+ if (item && (item->scene() == NULL || item->scene() == this))
+ {
+ mItemsToDelete.remove(*it);
+ delete item;
+ }
+
+ it = mItemsToDelete.begin();
+
+ }while(mItemsToDelete.count());
}
}
void UBCoreGraphicsScene::addItem(QGraphicsItem* item)
{
+ addItemToDeletion(item);
+
if (item->type() == UBGraphicsGroupContainerItem::Type && item->childItems().count()) {
foreach (QGraphicsItem *curItem, item->childItems()) {
removeItemFromDeletion(curItem);
}
}
-
- mItemsToDelete << item;
-
+
if (item->scene() != this)
QGraphicsScene::addItem(item);
+
+ setModified(true);
}
@@ -59,27 +73,17 @@ void UBCoreGraphicsScene::removeItem(QGraphicsItem* item, bool forceDelete)
QGraphicsScene::removeItem(item);
if (forceDelete)
{
- mItemsToDelete.remove(item);
- delete item;
- item = 0;
+ qDebug() << "force delete is " << forceDelete;
+ deleteItem(item);
}
+ setModified(true);
}
bool UBCoreGraphicsScene::deleteItem(QGraphicsItem* item)
{
if(mItemsToDelete.contains(item))
{
- UBGraphicsItem* item_casted = 0;
- switch (item->type())
- {
- case UBGraphicsMediaItem::Type:
- item_casted = dynamic_cast(item);
- break;
- case UBGraphicsW3CWidgetItem::Type:
- item_casted = dynamic_cast(item);
- break;
- }
-
+ UBGraphicsItem *item_casted = dynamic_cast(item);
if (0 != item_casted)
item_casted->clearSource();
diff --git a/src/frameworks/UBCoreGraphicsScene.h b/src/frameworks/UBCoreGraphicsScene.h
index d518db4c..19ed9da9 100644
--- a/src/frameworks/UBCoreGraphicsScene.h
+++ b/src/frameworks/UBCoreGraphicsScene.h
@@ -33,8 +33,21 @@ class UBCoreGraphicsScene : public QGraphicsScene
void removeItemFromDeletion(QGraphicsItem* item);
void addItemToDeletion(QGraphicsItem *item);
+ bool isModified() const
+ {
+ return mIsModified;
+ }
+
+ void setModified(bool pModified)
+ {
+ mIsModified = pModified;
+ }
+
+
private:
QSet mItemsToDelete;
+
+ bool mIsModified;
};
#endif /* UBCOREGRAPHICSSCENE_H_ */
diff --git a/src/frameworks/UBPlatformUtils.h b/src/frameworks/UBPlatformUtils.h
index ebac3995..46acb6f6 100644
--- a/src/frameworks/UBPlatformUtils.h
+++ b/src/frameworks/UBPlatformUtils.h
@@ -171,6 +171,7 @@ class UBPlatformUtils
static int nKeyboardLayouts;
static UBKeyboardLocale** keyboardLayouts;
+
public:
static void init();
static void destroy();
@@ -192,6 +193,10 @@ public:
static UBKeyboardLocale** getKeyboardLayouts(int& nCount);
static QString urlFromClipboard();
static QStringList availableTranslations();
+
+#ifdef Q_WS_MAC
+ static void SetMacLocaleByIdentifier(const QString& id);
+#endif
};
diff --git a/src/frameworks/UBPlatformUtils_mac.mm b/src/frameworks/UBPlatformUtils_mac.mm
index 66191a95..72dcb75c 100644
--- a/src/frameworks/UBPlatformUtils_mac.mm
+++ b/src/frameworks/UBPlatformUtils_mac.mm
@@ -440,6 +440,9 @@ void UBPlatformUtils::initializeKeyboardLayouts()
int count = CFArrayGetCount(kbds);
QList result;
+ qDebug() << "initializeKeyboardLayouts";
+ qDebug() << "Found system locales: " << count;
+
for(int i=0; i metadata )
}break;
}
- UBFeature feature( QString(), QImage(previewImageUrl), QString(), metadata["Url"], FEATURE_ITEM );
+ UBFeature feature( "/root", QImage(previewImageUrl), QString(), metadata["Url"], FEATURE_ITEM );
feature.setMetadata( metadata );
centralWidget->showElement(feature, UBFeaturesCentralWidget::FeaturePropertiesList);
@@ -676,7 +676,7 @@ UBFeaturesProgressInfo::UBFeaturesProgressInfo(QWidget *parent) :
void UBFeaturesProgressInfo::setCommmonInfoText(const QString &str)
{
- mProgressBar->setFormat(str + tr(" load") + "(%p%)");
+ mProgressBar->setFormat(tr("Loading ") + str + " (%p%)");
}
void UBFeaturesProgressInfo::setDetailedInfoText(const QString &str)
@@ -1080,7 +1080,7 @@ QVariant UBFeaturesModel::data(const QModelIndex &index, int role) const
return QVariant();
if (role == Qt::DisplayRole) {
- return featuresList->at(index.row()).getName();
+ return featuresList->at(index.row()).getDisplayName();
}
else if (role == Qt::DecorationRole) {
@@ -1311,7 +1311,7 @@ void UBFeaturesModel::moveData(const UBFeature &source, const UBFeature &destina
}
}
- UBFeature newElement( destVirtualPath, sourceIcon, name, QUrl::fromLocalFile(destFullPath), sourceType );
+ UBFeature newElement( destVirtualPath + "/" + name, sourceIcon, name, QUrl::fromLocalFile(destFullPath), sourceType );
addItem(newElement);
if (deleteManualy) {
diff --git a/src/gui/UBKeyboardPalette.cpp b/src/gui/UBKeyboardPalette.cpp
index 3f1fe242..2a496526 100644
--- a/src/gui/UBKeyboardPalette.cpp
+++ b/src/gui/UBKeyboardPalette.cpp
@@ -60,7 +60,10 @@ UBKeyboardPalette::UBKeyboardPalette(QWidget *parent)
createCtrlButtons();
nCurrentLocale = UBSettings::settings()->KeyboardLocale->get().toInt();
- setInput(locales[nCurrentLocale]);
+ if (nCurrentLocale < 0 || nCurrentLocale >= nLocalesCount)
+ nCurrentLocale = 0;
+ if (locales!=NULL)
+ setInput(locales[nCurrentLocale]);
setContentsMargins( 22, 22, 22, 22 );
diff --git a/src/gui/UBKeyboardPalette_mac.cpp b/src/gui/UBKeyboardPalette_mac.cpp
index 3b179c36..79e48e36 100644
--- a/src/gui/UBKeyboardPalette_mac.cpp
+++ b/src/gui/UBKeyboardPalette_mac.cpp
@@ -57,22 +57,6 @@ void UBKeyboardPalette::createCtrlButtons()
ctrlButtons[8] = new UBLocaleButton(this);
}
-void SetMacLocaleByIdentifier(const QString& id)
-{
- const char * strName = id.toAscii().data();
- CFStringRef iName = CFStringCreateWithCString(NULL, strName, kCFStringEncodingMacRoman );
-
- CFStringRef keys[] = { kTISPropertyInputSourceCategory, kTISPropertyInputSourceID };
- CFStringRef values[] = { kTISCategoryKeyboardInputSource, iName };
- CFDictionaryRef dict = CFDictionaryCreate(NULL, (const void **)keys, (const void **)values, 2, NULL, NULL);
- CFArrayRef kbds = TISCreateInputSourceList(dict, true);
- if (CFArrayGetCount(kbds)!=0)
- {
- TISInputSourceRef klRef = (TISInputSourceRef)CFArrayGetValueAtIndex(kbds, 0);
- if (klRef!=NULL)
- TISSelectInputSource(klRef);
- }
-}
void UBKeyboardPalette::checkLayout()
@@ -107,6 +91,6 @@ void UBKeyboardPalette::onActivated(bool)
void UBKeyboardPalette::onLocaleChanged(UBKeyboardLocale* locale)
{
- SetMacLocaleByIdentifier(locale->id);
+ UBPlatformUtils::SetMacLocaleByIdentifier(locale->id);
}
diff --git a/src/gui/UBPropertyPalette.cpp b/src/gui/UBPropertyPalette.cpp
index 8d587c99..643f87a7 100644
--- a/src/gui/UBPropertyPalette.cpp
+++ b/src/gui/UBPropertyPalette.cpp
@@ -25,6 +25,7 @@ UBPropertyPalette::UBPropertyPalette(QWidget *parent, const char *name):UBAction
{
setObjectName(name);
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)
{
mbGrip = false;
+ setMaximumHeight(MAX_HEIGHT);
}
/**
diff --git a/src/gui/UBPropertyPalette.h b/src/gui/UBPropertyPalette.h
index 777e976e..47bacf13 100644
--- a/src/gui/UBPropertyPalette.h
+++ b/src/gui/UBPropertyPalette.h
@@ -20,6 +20,8 @@
#include "UBActionPalette.h"
+#define MAX_HEIGHT 20
+
class UBPropertyPalette : public UBActionPalette
{
Q_OBJECT
diff --git a/src/gui/UBTeacherGuideWidget.cpp b/src/gui/UBTeacherGuideWidget.cpp
index 7de10dbf..ca73ec76 100644
--- a/src/gui/UBTeacherGuideWidget.cpp
+++ b/src/gui/UBTeacherGuideWidget.cpp
@@ -685,6 +685,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpSessionTitle = new UBTGAdaptableText(0, this, "UBTGSessionTitle");
mpSessionTitle->setPlaceHolderText(tr("Type session title here ..."));
mpButtonTitleLayout->addWidget(mpSessionTitle);
+ connect(this, SIGNAL(resized()), mpSessionTitle, SLOT(onTextChanged()));
mpLayout->addLayout(mpButtonTitleLayout);
@@ -703,6 +704,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpAuthors->setObjectName("UBTGZeroPageInputText");
mpAuthors->setPlaceHolderText(tr("Type authors here ..."));
mpLayout->addWidget(mpAuthors);
+ connect(this, SIGNAL(resized()), mpAuthors, SLOT(onTextChanged()));
mpCreationLabel = new QLabel(this);
mpCreationLabel->setObjectName("UBTGZeroPageDateLabel");
@@ -727,6 +729,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpObjectives->setObjectName("UBTGZeroPageInputText");
mpObjectives->setPlaceHolderText(tr("Type objectives here..."));
mpLayout->addWidget(mpObjectives);
+ connect(this, SIGNAL(resized()), mpObjectives, SLOT(onTextChanged()));
mpSeparatorObjectives = new QFrame(this);
mpSeparatorObjectives->setFixedHeight(UBTG_SEPARATOR_FIXED_HEIGHT);
@@ -747,6 +750,7 @@ UBTeacherGuidePageZeroWidget::UBTeacherGuidePageZeroWidget(QWidget* parent, cons
mpKeywords = new UBTGAdaptableText(0, this);
mpKeywords->setPlaceHolderText(tr("Type keywords here ..."));
mpLayout->addWidget(mpKeywords);
+ connect(this, SIGNAL(resized()), mpKeywords, SLOT(onTextChanged()));
mpSchoolLevelItemLabel = new QLabel(this);
mpSchoolLevelItemLabel->setObjectName("UBTGZeroPageItemLabel");
@@ -1122,6 +1126,12 @@ bool UBTeacherGuidePageZeroWidget::isModified()
return result;
}
+void UBTeacherGuidePageZeroWidget::resizeEvent(QResizeEvent* ev){
+ emit resized();
+
+ QWidget::resizeEvent(ev);
+}
+
/***************************************************************************
* class UBTeacherGuideWidget *
***************************************************************************/
@@ -1238,3 +1248,4 @@ bool UBTeacherGuideWidget::isModified()
else
return mpEditionWidget->isModified();
}
+
diff --git a/src/gui/UBTeacherGuideWidget.h b/src/gui/UBTeacherGuideWidget.h
index 1d165f13..a970807e 100644
--- a/src/gui/UBTeacherGuideWidget.h
+++ b/src/gui/UBTeacherGuideWidget.h
@@ -136,11 +136,16 @@ public:
QVector getData();
bool isModified();
+signals:
+ void resized();
public slots:
void onActiveSceneChanged();
void switchToMode(tUBTGZeroPageMode mode = tUBTGZeroPageMode_EDITION);
+protected:
+ void resizeEvent(QResizeEvent* ev);
+
private:
void fillComboBoxes();
void loadData();
diff --git a/src/gui/UBTeacherGuideWidgetsTools.cpp b/src/gui/UBTeacherGuideWidgetsTools.cpp
index d9c88efd..6300c65b 100644
--- a/src/gui/UBTeacherGuideWidgetsTools.cpp
+++ b/src/gui/UBTeacherGuideWidgetsTools.cpp
@@ -174,6 +174,7 @@ void UBTGAdaptableText::showEvent(QShowEvent* e)
if(!mIsUpdatingSize && mHasPlaceHolder && toPlainText().isEmpty())
setPlainText(mPlaceHolderText);
else
+ // If the teacherguide is collapsed, don't updated the size. Or set the size as the expanded size
onTextChanged();
}
@@ -188,9 +189,12 @@ QString UBTGAdaptableText::text()
void UBTGAdaptableText::onTextChanged()
{
+ //qDebug() << ">> onTextChanged CALLED!";
qreal documentSize = document()->size().height();
- if(height() == documentSize + mBottomMargin)
- return;
+ //qDebug() << ">> documentSize: " << documentSize << ", height: " << height();
+ if(height() == documentSize + mBottomMargin){
+ return;
+ }
mIsUpdatingSize = true;
@@ -208,6 +212,7 @@ void UBTGAdaptableText::onTextChanged()
setFocus();
}
mIsUpdatingSize = false;
+
}
void UBTGAdaptableText::setInitialText(const QString& text)
{
diff --git a/src/gui/UBThumbnailWidget.cpp b/src/gui/UBThumbnailWidget.cpp
index 24f7442f..3057761b 100644
--- a/src/gui/UBThumbnailWidget.cpp
+++ b/src/gui/UBThumbnailWidget.cpp
@@ -12,11 +12,13 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+#include
#include
#include
#include "UBThumbnailWidget.h"
#include "UBRubberBand.h"
+#include "UBMainWindow.h"
#include "board/UBBoardController.h"
@@ -858,7 +860,9 @@ void UBSceneThumbnailNavigPixmap::updateButtonsState()
void UBSceneThumbnailNavigPixmap::deletePage()
{
- UBApplication::boardController->deleteScene(sceneIndex());
+ 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());
+ }
}
void UBSceneThumbnailNavigPixmap::duplicatePage()
diff --git a/src/web/UBWebController.cpp b/src/web/UBWebController.cpp
index ee69e3d3..9ad0861e 100644
--- a/src/web/UBWebController.cpp
+++ b/src/web/UBWebController.cpp
@@ -733,6 +733,7 @@ bool UBWebController::isEduMedia(const QUrl& pUrl)
void UBWebController::loadUrl(const QUrl& url)
{
+ bool webBrowserAlreadyInstanciated = dynamic_cast(mStackedWidget->widget(WebBrowser)) != NULL;
UBApplication::applicationController->showInternet();
if (UBSettings::settings()->webUseExternalBrowser->get().toBool())
{
@@ -740,8 +741,6 @@ void UBWebController::loadUrl(const QUrl& url)
}
else
{
- bool webBrowserAlreadyInstanciated = mStackedWidget->widget(WebBrowser) != NULL;
-
if (!webBrowserAlreadyInstanciated) {
(*mCurrentWebBrowser)->loadUrl(url);
}
diff --git a/src/web/browser/WBBrowserWindow.cpp b/src/web/browser/WBBrowserWindow.cpp
index 83d41992..cb89dd09 100644
--- a/src/web/browser/WBBrowserWindow.cpp
+++ b/src/web/browser/WBBrowserWindow.cpp
@@ -270,28 +270,6 @@ void WBBrowserWindow::setupToolBarForTutorial()
if (tb && tb->menu())
tb->setMenu(NULL);
}
-// mTabWidget->addWebAction(mUniboardMainWindow->actionWebReload, QWebPage::Reload);
-// mTabWidget->addWebAction(mUniboardMainWindow->actionStopLoading, QWebPage::Stop);
-
-// mWebToolBar->insertWidget(mUniboardMainWindow->actionWebBigger, mTabWidget->lineEditStack());
-
-// mSearchToolBar = new WBToolbarSearch(mWebToolBar);
-
-// mSearchAction = mWebToolBar->insertWidget(mUniboardMainWindow->actionWebBigger, mSearchToolBar);
-
-// connect(mSearchToolBar, SIGNAL(search(const QUrl&)), SLOT(loadUrl(const QUrl&)));
-
-// mChaseWidget = new WBChaseWidget(this);
-// mWebToolBar->insertWidget(mUniboardMainWindow->actionWebBigger, mChaseWidget);
-
-// mWebToolBar->insertSeparator(mUniboardMainWindow->actionWebBigger);
-
-// connect(mUniboardMainWindow->actionHome, SIGNAL(triggered()), this , SLOT(slotHome()));
-
-// connect(mUniboardMainWindow->actionBookmarks, SIGNAL(triggered()), this , SLOT(bookmarks()));
-// connect(mUniboardMainWindow->actionAddBookmark, SIGNAL(triggered()), this , SLOT(addBookmark()));
-// connect(mUniboardMainWindow->actionWebBigger, SIGNAL(triggered()), this , SLOT(slotViewZoomIn()));
-// connect(mUniboardMainWindow->actionWebSmaller, SIGNAL(triggered()), this , SLOT(slotViewZoomOut()));
mWebToolBar->show();
}
@@ -662,4 +640,4 @@ void WBBrowserWindow::openActionUrl(QAction *action)
history->goToItem(history->backItems(-1*offset).first());
else if (offset > 0)
history->goToItem(history->forwardItems(history->count() - offset + 1).back());
- }
\ No newline at end of file
+ }