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

Conflicts:
	src/board/UBBoardView.cpp
	src/domain/UBGraphicsItemDelegate.cpp
preferencesAboutTextFull
Claudio Valerio 13 years ago
commit 20a787f157
  1. 2
      Sankore_3.1.pro
  2. 14
      plugins/cffadaptor/UBCFFAdaptor.pro
  3. 2
      resources/library/applications/Notes.wgt/js/ubw-main.js
  4. 78
      resources/library/applications/iCell.wgt/js/textes_descriptifs.js
  5. 2
      resources/library/interactivities/BlackYellow.wgt/locales/fr/scripts/blackYellow.js
  6. 46
      resources/library/interactivities/Choisir.wgt/scripts/languages.js
  7. 2
      resources/library/interactivities/associer_images.wgt/js/script.js
  8. 4
      resources/library/interactivities/associer_images.wgt/locales/fr/js/script.js
  9. 6
      resources/library/interactivities/associer_sounds.wgt/locales/fr/js/script.js
  10. 2
      resources/library/interactivities/categoriser_images.wgt/js/script.js
  11. 6
      resources/library/interactivities/categoriser_images.wgt/locales/fr/js/script.js
  12. 4
      resources/library/interactivities/categoriser_text.wgt/js/script.js
  13. 6
      resources/library/interactivities/categoriser_text.wgt/locales/fr/js/script.js
  14. 4
      resources/library/interactivities/etudier.wgt/js/script.js
  15. 6
      resources/library/interactivities/etudier.wgt/locales/fr/js/script.js
  16. 4
      resources/library/interactivities/ord-phrases.wgt/locales/fr/script/template2.js
  17. 4
      resources/library/interactivities/ord-words.wgt/locales/fr/scripts/template2.js
  18. 6
      resources/library/interactivities/ordonner_des_images.wgt/locales/fr/js/script.js
  19. 6
      resources/library/interactivities/ordonner_des_letters.wgt/locales/fr/js/script.js
  20. 4
      resources/library/interactivities/selectionner.wgt/locales/fr/js/script.js
  21. 4
      resources/library/interactivities/spl-phrase.wgt/locales/fr/scripts/wcontainer.js
  22. 2
      resources/library/interactivities/spl-text.wgt/locales/fr/scripts/wcontainer.js
  23. 2
      resources/library/interactivities/spl-word.wgt/locales/fr/scripts/wcontainer.js
  24. 4
      src/adaptors/UBSvgSubsetAdaptor.cpp
  25. 5
      src/board/UBBoardController.cpp
  26. 25
      src/board/UBBoardView.cpp
  27. 5
      src/core/UBSettings.cpp
  28. 7
      src/core/UBSettings.h
  29. 1
      src/desktop/UBDesktopAnnotationController.cpp
  30. 46
      src/domain/UBAngleWidget.cpp
  31. 25
      src/domain/UBAngleWidget.h
  32. 164
      src/domain/UBGraphicsDelegateFrame.cpp
  33. 17
      src/domain/UBGraphicsDelegateFrame.h
  34. 253
      src/domain/UBGraphicsItemDelegate.cpp
  35. 41
      src/domain/UBGraphicsItemDelegate.h
  36. 9
      src/domain/UBGraphicsPixmapItem.cpp
  37. 4
      src/domain/UBGraphicsPixmapItem.h
  38. 275
      src/domain/UBGraphicsScene.cpp
  39. 69
      src/domain/UBGraphicsScene.h
  40. 8
      src/domain/UBGraphicsVideoItem.cpp
  41. 2
      src/domain/UBGraphicsWidgetItem.cpp
  42. 2
      src/domain/UBItem.cpp
  43. 2
      src/domain/UBItem.h
  44. 6
      src/domain/domain.pri
  45. 790
      src/gui/UBMagnifer.cpp
  46. 193
      src/gui/UBMagnifer.h
  47. 2
      src/tools/UBGraphicsRuler.h
  48. 128
      src/web/browser/WBBrowserWindow.cpp
  49. 7
      src/web/browser/WBBrowserWindow.h

@ -131,7 +131,7 @@ win32 {
} }
macx { macx {
LIBS += "-Lplugins/cffadaptor/lib/mac" "-lCFF_Adaptor" LIBS += "-Lplugins/cffadaptor/lib/macx" "-lCFF_Adaptor"
LIBS += -framework Foundation LIBS += -framework Foundation
LIBS += -lcrypto LIBS += -lcrypto
LIBS += -framework AppKit LIBS += -framework AppKit

@ -10,14 +10,16 @@ linux-g++: SUB_DIR = linux
linux-g++-32: SUB_DIR = linux linux-g++-32: SUB_DIR = linux
linux-g++-64: SUB_DIR = linux linux-g++-64: SUB_DIR = linux
QUAZIP_DIR = "$$PWD/../../../Sankore-ThirdParty/quazip" THIRD_PARTY_PATH = ../../../Sankore-ThirdParty
ZLIB_DIR = "$$PWD/../../../Sankore-ThirdParty/zlib" QUAZIP_DIR = "$$PWD/../../../Sankore-ThirdParty/quazip/quazip-0.3"
INCLUDEPATH += src \ INCLUDEPATH += src
"$$QUAZIP_DIR/quazip-0.3" \
"$$ZLIB_DIR/1.2.3/include"
LIBS += "-L$$QUAZIP_DIR/lib/$$SUB_DIR" "-lquazip" DEPENDPATH += $$THIRD_PARTY_PATH/quazip/
INCLUDEPATH += $$THIRD_PARTY_PATH/quazip/
include($$THIRD_PARTY_PATH/quazip/quazip.pri)
LIBS += "-L$$THIRD_PARTY_PATH/quazip/lib/$$SUB_DIR" "-lquazip"
QT += xml xmlpatterns core QT += xml xmlpatterns core
QT += gui QT += gui

@ -199,7 +199,7 @@ function init(){
if(text) if(text)
textField.html(text); textField.html(text);
else else
textField.html("Enter your notes here ..."); textField.html("Saisir votre texte ici ...");
textField.focus(); textField.focus();
} }

@ -147,64 +147,64 @@ switch(lang){
break; break;
case "fr": case "fr":
txt_vesicule = "<h2>Vesicule<br/>Transporteurs</h2>"+ txt_vesicule = "<h2>Vesicule<br/>Transporteurs</h2>"+
"<h4>Structure:</h4><span><p>Bicouche phospholipidique</p></span>"+ "<h4>Structure : </h4><span><p>Bicouche phospholipidique</p></span>"+
"<h4>Role:</h4><span><p>Transport de proteines ou d'autres elements a l'interieur de la cellule, vers l'exterieur (exocytose) ou vers l'interieur (endocytose).</p></span>"+ "<h4>Rôle : </h4><span><p>Transport de protéines ou d'autres éléments à l'intérieur de la cellule, vers l'extérieur (exocytose) ou vers l'intérieur (endocytose).</p></span>"+
'<h4>Fonctionnement:</h4><span><p>Transporteur "remorque" par des proteines prenant appui sur le cytosquelette.</p></span>' '<h4>Fonctionnement : </h4><span><p>Transporteur "remorque" par des protéines prenant appui sur le cytosquelette.</p></span>'
txt_lysosome = "<h2>Lysosome<br/>Estomacs cellulaires</h2>"+ txt_lysosome = "<h2>Lysosome<br/>Estomacs cellulaires</h2>"+
"<h4>Structure:</h4><span><p>Bicouche phospholipidique</p></span>"+ "<h4>Structure : </h4><span><p>Bicouche phospholipidique</p></span>"+
"<h4>Role:</h4><span><p>Digestion intra-cellulaire a l'aide d'enzymes</p></span>"+ "<h4>Role : </h4><span><p>Digestion intracellulaire à l'aide d'enzymes</p></span>"+
"<h4>Fonctionnement:</h4><span><p>Absorption de nutriments par endocytose ou d'elements cellulaires abimes, digestion de ceux-ci, puis distribution des resultats de la reaction chimique dans la cellule et enfin expulsion des dechets par exocytose.</p></span>" "<h4>Fonctionnement : </h4><span><p>Absorption de nutriments par endocytose ou d'éléments cellulaires abimés, digestion de ceux-ci, puis distribution des résultats de la réaction chimique dans la cellule et enfin expulsion des déchets par exocytose.</p></span>"
txt_mitoch = "<h2>Mitochondrie<br/>Piles</h2>"+ txt_mitoch = "<h2>Mitochondrie<br/>Piles</h2>"+
"<h4>Structure:</h4><span><p>Deux bichouches phospholipidiques appelees membranes mitochondriales, une externe et une interne. La mitochondrie contient des ribosomes, de l'ATP de l'ADN et bien d'autres molecules.</p></span>"+ "<h4>Structure : </h4><span><p>Deux bicouches phospholipidiques appelées membranes mitochondriales, une externe et une interne. La mitochondrie contient des ribosomes, de l'ATP de l'ADN et bien d'autres molécules.</p></span>"+
"<h4>Role:</h4><span><p>Centrale energetique de la cellule.</p></span>"+ "<h4>Rôle : </h4><span><p>Centrale énergétique de la cellule.</p></span>"+
"<h4>Fonctionnement:</h4><span><p>L'energie - sous forme d'ATP (adenosine triphosphate) - est issue de differentes etapes de reactions chimique partant d'une molecule de glucose.</p></span>" "<h4>Fonctionnement : </h4><span><p>L'énergie - sous forme d'ATP (adénosine triphosphate) - est issue de différentes étapes de réactions chimiques partant d'une molécule de glucose.</p></span>"
txt_golgi = "<h2>Appareil de Golgi<br/>Usines miniatures</h2>"+ txt_golgi = "<h2>Appareil de Golgi<br/>Usines miniatures</h2>"+
"<h4>Structure:</h4><span><p>Forme d'un empilement de saccules membranaires applatis.</p></span>"+ "<h4>Structure : </h4><span><p>Forme d'un empilement de saccules membranaires aplatis.</p></span>"+
"<h4>Role:</h4><span><p>Modification de certaines proteines au cours d'un cheminement au travers de ses saccules.</p></span>"+ "<h4>Rôle : </h4><span><p>Modification de certaines protéines au cours d'un cheminement au travers de ses saccules.</p></span>"+
"<h4>Fonctionnement:</h4><span><p>Suite de reactions chimiques, notamment par glycosilation.</p></span>" "<h4>Fonctionnement : </h4><span><p>Suite de réactions chimiques, notamment par glycosilation.</p></span>"
txt_rer = "<h2>Reticulum endoplasmique rugueux - Tunnel</h2>"+ txt_rer = "<h2>Reticulum endoplasmique rugueux - Tunnel</h2>"+
"<h4>Structure:</h4><span><p>Compose d'une bicouche phospholipidique piquetee de ribosomes (d'un aspect <i>rugueux</i>) delimitant la lumiere, un espace interne pouvant tre compare a un tunnel.</p></span>"+ "<h4>Structure : </h4><span><p>Composé d'une bicouche phospholipidique piquetée de ribosomes (d'un aspect <i>rugueux</i>) délimitant la lumière, un espace interne pouvant être comparé à un tunnel.</p></span>"+
"<h4>Role:</h4><span><p>Plus specialise que le REL, il participe au transport et a la finalisation des proteines, qui sont synthetisees par les ribosomes.</p></span>"+ "<h4>Rôle : </h4><span><p>Plus spécialisé que le REL, il participe au transport et à la finalisation des protéines, qui sont synthétisées par les ribosomes.</p></span>"+
'<h4>Fonctionnement:</h4><span><p>Les proteines "tombent" dans la lumiere du RER o elles sont modifiees et deplacees. Elles quittent le RER dans une vesucule issue de la membrane de ce dernier.</p></span>' '<h4>Fonctionnement : </h4><span><p>Les protéines "tombent" dans la lumière du RER où elles sont modifiées et déplacées. Elles quittent le RER dans une vésicule issue de la membrane de ce dernier.</p></span>'
txt_noy = "<h2>Noyau - Le coffre-fort</h2>"+ txt_noy = "<h2>Noyau - Le coffre-fort</h2>"+
"<h4>Structure:</h4><span><p>Entoure par une double membrane appelee enveloppe nucleaire en lien par endroits avec le RER. Ces deux membranes fusionnent a intervalles reguliers pour former les pores nucleaires. a l'interieur se trouvent le nucleole et l'ADN, sous forme de chromatine ou de chomosomes.</p></span>"+ "<h4>Structure : </h4><span><p>Entouré par une double membrane appelée enveloppe nucléaire en lien par endroits avec le RER. Ces deux membranes fusionnent à intervalles réguliers pour former les pores nucléaires. À l'intérieur se trouve le nucléole et l'ADN, sous forme de chromatine ou de chromosomes.</p></span>"+
"<h4>Role:</h4><span><p>Stockage de la totalite des informations genetiques necessaires a la vie de la cellule.</p></span>"+ "<h4>Rôle : </h4><span><p>Stockage de la totalité des informations génétiques nécessaires à la vie de la cellule.</p></span>"+
"<h4>Fonctionnement:</h4><span><p>Site de la transcription (copie de l'information genetique sur des ARNm).</p></span>" "<h4>Fonctionnement : </h4><span><p>Site de la transcription (copie de l'information génétique sur des ARNm).</p></span>"
txt_rel = "<h2>Reticulum endoplasmique lisse - REL</h2>"+ txt_rel = "<h2>Reticulum endoplasmique lisse - REL</h2>"+
"<h4>Structure:</h4><span><p>Similaires a celle du RER, a la difference que sa membranne n'est pas parsemee de ribosomes, d'o son aspect <i>lisse</i>.</p></span>"+ "<h4>Structure : </h4><span><p>Similaire à celle du RER, à la différence que sa membrane n'est pas parsemée de ribosomes, d'où son aspect <i>lisse</i>.</p></span>"+
"<h4>Role:</h4><span><p>Sinthese des phospholipides,stockage du calcium, transformation de certaines molecules exterieures (medicament, alcool, ...). Dans certaines cellules, le REL remplit aussi des fonctions supplementaires, telles la production d'hormones, d'acides gastriques, etc.</p></span>"+ "<h4>Rôle : </h4><span><p>Synthèse des phospholipides, stockage du calcium, transformation de certaines molécules extérieures (médicament, alcool...). Dans certaines cellules, le REL remplit aussi des fonctions supplémentaires, telles que la production d'hormones, d'acides gastriques, etc.</p></span>"+
"<h4>Fonctionnement:</h4><span><p>Il est le siege de beaucoup de reactions chimiques complexes (ex: detoxification, differentes syntheses).</p></span>" "<h4>Fonctionnement : </h4><span><p>Il est le siège de beaucoup de réactions chimiques complexes (ex : détoxification, différentes synthèses).</p></span>"
txt_adn = "<h2>ADN - Le livre de la vie</h2>"+ txt_adn = "<h2>ADN - Le livre de la vie</h2>"+
"<h4>Structure:</h4><span><p>echelle a la celebre forme de double helice composee de deux colonnes sucre-phosphate-sucre-phosphate-... et dont les echelons sont apelles bases azotees.</p></span>"+ "<h4>Structure : </h4><span><p>échelle à la célèbre forme de double hélice composée de deux colonnes sucre-phosphate-sucre-phosphate-... et dont les échelons sont appelés bases azotées.</p></span>"+
"<h4>Role:</h4><span><p>L'ADN contient toutes les informations necessaires a la vie.</p></span>"+ "<h4>Rôle : </h4><span><p>L'ADN contient toutes les informations nécessaires à la vie.</p></span>"+
"<h4>Fonctionnement:</h4><span><p>Toutes les informations sont ecrites a l'aide des quatre lettres A, T, G, et C. Grace a ces combinaisons, il est possible d'ecrire tout ce qui est utile a la cellule.</p></span>" "<h4>Fonctionnement : </h4><span><p>Toutes les informations sont écrites à l'aide des quatre lettres A, T, G, et C. Grâce à ces combinaisons, il est possible d'écrire tout ce qui est utile à la cellule.</p></span>"
txt_centr= "<h2>Centrioles - Remorqueurs de choromosomes</h2>"+ txt_centr= "<h2>Centrioles - Remorqueurs de chromosomes</h2>"+
"<h4>Structure:</h4><span><p>Neuf triplets de microtubules entoures par un certain nombre de proteines.</p></span>"+ "<h4>Structure : </h4><span><p>Neuf triplets de microtubules entourent par un certain nombre de protéines.</p></span>"+
"<h4>Role:</h4><span><p>Separer les differents chromosomes durant la division cellulaire.</p></span>"+ "<h4>Rôle : </h4><span><p>Séparer les différents chromosomes durant la division cellulaire.</p></span>"+
"<h4>Fonctionnement:</h4><span><p>Les centrioles, une fois places aux deux poles de la cellule, deploient des microtubules vers les centromeres des chromosomes et les tirent vers eux pour les separer.</p></span>" "<h4>Fonctionnement : </h4><span><p>Les centrioles, une fois placés aux deux pôles de la cellule, déploient des microtubules vers les centromères des chromosomes et les tirent vers eux pour les séparer.</p></span>"
txt_rib = "<h2>Ribosome - Decodeurs</h2>"+ txt_rib = "<h2>Ribosome - Décodeurs</h2>"+
"<h4>Structure:</h4><span><p>Forme par deux sous-unites composees d'ARN ribosomique et de proteines.</p></span>"+ "<h4>Structure : </h4><span><p>Formé par deux sous-unités composées d'ARN ribosomique et de protéines.</p></span>"+
"<h4>Role:</h4><span><p>Le ribosome synthetise les proteines.</p></span>"+ "<h4>Rôle : </h4><span><p>Le ribosome synthétise les protéines.</p></span>"+
"<h4>Fonctionnement:</h4><span><p>Un brin d'ARNm (messager) passe dans le ribosome et un ARNt (de transfert) entre dans la grande sous-unite si son codon (groupe de trois bases azotees) correspond a celui qui est en face sur l'ARNm. Cet ARNt porte avec lui un acide amine specifique qui est ajoute a la chaine deja assemblee.</p></span>" "<h4>Fonctionnement : </h4><span><p>Un brin d'ARNm (messager) passe dans le ribosome et un ARNt (de transfert) entre dans la grande sous-unité si son codon (groupe de trois bases azotées) correspond à celui qui est en face sur l'ARNm. Cet ARNt porte avec lui un acide aminé spécifique qui est ajouté à la chaîne déjà assemblée.</p></span>"
txt_arn = "<h2>ARN - Multifonction</h2>"+ txt_arn = "<h2>ARN - Multifonction</h2>"+
"<h4>Structure:</h4><span><p>Tres similaire a l'ADN a la difference qu'il ne possede qu'un brin et que la thymine (T) de l'ADN est remplacee par l'uracile (U). De plus, il est chimiquement plus instable que l'ADN, c'est pourquoi il n'est pas utilise pour le stockage d'informations a long terme.</p></span>"+ "<h4>Structure : </h4><span><p>Très similaire à l'ADN à la différence qu'il ne possède qu'un brin et que la thymine (T) de l'ADN est remplacée par l'uracile (U). De plus, il est chimiquement plus instable que l'ADN, c'est pourquoi il n'est pas utilisé pour le stockage d'informations à long terme.</p></span>"+
"<h4>Role:</h4><span><p>Multiples, il existe des ARN de transport, messagers, regulateus, guides, satellites, ...</p></span>"+ "<h4>Rôle : </h4><span><p>Multiples, il existe des ARN de transport, messagers, régulateurs, guides, satellites... </p></span>"+
"<h4>Fonctionnement:</h4><span><p>La copie d'informations genetiques se fait grace a l'ouverture de la double-helice d'ADN, puis la copie des codons sur l'ARN. Celui-ci peut alors sortir du noyau, ce que l'ADN ne peut pas faire.</p></span>" "<h4>Fonctionnement : </h4><span><p>La copie d'informations génétiques se fait grâce à l'ouverture de la double hélice d'ADN, puis la copie des codons sur l'ARN. Celui-ci peut alors sortir du noyau, ce que l'ADN ne peut pas faire.</p></span>"
txt_nucl = "<h2>Nucleole - Fabrique d'ARN</h2>"+ txt_nucl = "<h2>Nucléole - Fabrique d'ARN</h2>"+
"<h4>Structure:</h4><span><p>Compose d'aucune membranne, c'est un agglomerat de proteines et d'ARN.</p></span>"+ "<h4>Structure : </h4><span><p>Composé d'aucune membrane, c'est un agglomérat de protéines et d'ARN.</p></span>"+
"<h4>Role:</h4><span><p>Lieu de la transcription d'ARN, nottament d'ARNr (ribosomiques) qui, associes avec des proteines, vont former les deux sous-unites des ribosomes.</p></span>"+ "<h4>Rôle : </h4><span><p>Lieu de la transcription d'ARN, notamment d'ARNr (ribosomiques) qui, associés avec des protéines, vont former les deux sous-unités des ribosomes.</p></span>"+
"<h4>Fonctionnement:</h4><span><p>Creation d'un ribosome: Transcription des ARNr ainsi que des proteines necessaires (cette etape est effectuee dans le cytoplasme par d'autres ribosomes) qui rentrent dans le noyau, association des molecules franchement formees en un nouveau ribosome, qui sort du noyau pour jouer son Role.</p></span>" "<h4>Fonctionnement : </h4><span><p>Création d'un ribosome: Transcription des ARNr ainsi que des protéines nécessaires (cette étape est effectuée dans le cytoplasme par d'autres ribosomes) qui rentrent dans le noyau, association des molécules franchement formées en un nouveau ribosome, qui sort du noyau pour jouer son rôle.</p></span>"
break; break;
default: default:
txt_vesicule = "<h2>Vesicle<br/>Transporter</h2>"+ txt_vesicule = "<h2>Vesicle<br/>Transporter</h2>"+

@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
var sankoreLang = {display: "Afficher", edit: "Modifier", add: "Ajouter", enter_data: "Saisir la donnée:", enter_result: "Saisir le résultat:", ok: "Accepter", cancel: "Annuler"}; var sankoreLang = {display: "Afficher", edit: "Modifier", add: "Ajouter", enter_data: "Saisir la donnée:", enter_result: "Saisir le résultat:", ok: "Valider", cancel: "Annuler"};
function init(){ function init(){

@ -6,20 +6,20 @@ var sankoreLang = {
"example_question":"This is an example of the question", "example_question":"This is an example of the question",
"answer":"This is an example of the answer", "answer":"This is an example of the answer",
"q":"Q", "q":"Q",
"add_new_question":"Add new question ...", "add_new_question":"Add a new question ...",
"options":"Options", "options":"Options",
"close":"Close", "close":"Close",
"delete_question":"Delete question", "delete_question":"Delete the question",
"delete_answer":"Delete answer", "delete_answer":"Delete a possibility",
"right_answer":"Right answer", "right_answer":"Right answer",
"template_question":"Enter your question here ...", "template_question":"Enter a question here ...",
"template_answer":"Enter the answer here ...", "template_answer":"Enter a possibility here ...",
"add_answer":"Add answer", "add_answer":"Add a possibility",
"select_text":"Choose the right answer", "select_text":"Choose the right answer",
"options_desc":"You can choose any of these three options of displaying your answers. See a short their description.", "options_desc":"Types of question",
"radio_desc":"This option allow to choose one answer only and the answers are displayed as radio buttons.", "radio_desc":"Option 1 : one right answer, possibilities are displayed as radio buttons.",
"checkbox_desc":"This option allow to choose several answers and the answers are displayed as checkboxes.", "checkbox_desc":"Option 2 : several right answers, possibilities are displayed as checkboxes.",
"select_desc":"This option allow to chose one answer only and the answers are displayed as pull-down menu.", "select_desc":"Option 3 : one right answer, possibilities are displayed as pull-down menu.",
"a":"A" "a":"A"
}, },
"ru":{ "ru":{
@ -49,23 +49,23 @@ var sankoreLang = {
"edit": "Modifier", "edit": "Modifier",
"display":"Afficher", "display":"Afficher",
"question":"La question", "question":"La question",
"example_question":"Ceci est un exemple de la question", "example_question":"Ceci est un exemple de question",
"answer":"Ceci est un exemple de la réponse", "answer":"Ceci est un exemple de réponse",
"q":"Q", "q":"Q",
"add_new_question":"Ajouter nouvelle question ...", "add_new_question":"Ajouter une nouvelle question ...",
"options":"Les options", "options":"Options",
"close":"Fermer", "close":"Fermer",
"delete_question":"Supprimer la question", "delete_question":"Supprimer la question",
"delete_answer":"Supprimer réponse", "delete_answer":"Supprimer la possibilité",
"right_answer":"Bonne réponse", "right_answer":"Bonne réponse",
"template_question":"Saisissez votre question ici ...", "template_question":"Saisir la question ici ...",
"template_answer":"Entrez la réponse ici ...", "template_answer":"Saisir une possibilité ici ...",
"add_answer":"Ajouter une réponse", "add_answer":"Ajouter une possibilité",
"select_text":"Choisissez la bonne réponse", "select_text":"Choisir la bonne réponse",
"options_desc":"Vous pouvez choisir n'importe lequel de ces trois options d'affichage de vos réponses. Voir un court leur description.", "options_desc":"Types de questions",
"radio_desc":"Cette option permet de choisir une seule réponse et les réponses sont affichées sous forme de boutons radio.", "radio_desc":"Option 1 : une seule bonne réponse, les possibilités sont affichées sous forme de boutons radio.",
"checkbox_desc":"Cette option permet de choisir plusieurs réponses et les réponses sont affichées comme des cases à cocher.", "checkbox_desc":"Option 2 : plusieurs bonnes réponses, les possibilités sont affichées sous forme de cases à cocher.",
"select_desc":"Cette option permet de choisir une seule réponse et les réponses sont affichées sous forme de menu déroulant.", "select_desc":"Option 3 : une seule bonne réponse, les possibilités sont affichées sous forme de menu déroulant.",
"a":"R" "a":"R"
} }
}; };

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

@ -1,9 +1,9 @@
var sankoreLang = { var sankoreLang = {
display: "Affichage", display: "Afficher",
edit: "Modifier", edit: "Modifier",
short_desc: "Sélectionner le numéro «trois».", short_desc: "Sélectionner le numéro «trois».",
add: "Nouveau bloc", add: "Nouveau bloc",
enter: "Saisissez la consigne ici ..." enter: "Saisir la consigne ici ..."
}; };
//main function //main function

@ -1,9 +1,9 @@
var sankoreLang = { var sankoreLang = {
display: "D'affichage", display: "Afficher",
edit: "Modifier", edit: "Modifier",
short_desc: "Combien de signaux entendez-vous?", short_desc: "Combien de signaux sonores entendez-vous?",
add: "Nouveau bloc", add: "Nouveau bloc",
enter: "Entrez votre description ici ..." enter: "Saisir votre description ici ..."
}; };
//main function //main function

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

@ -1,9 +1,9 @@
var sankoreLang = { var sankoreLang = {
display: "D'affichage", display: "Afficher",
edit: "Modifier", edit: "Modifier",
first_desc: "Les nombres impairs", first_desc: "Les nombres impairs",
second_desc: "Même les chiffres", second_desc: "Les nombres pairs",
enter: "Entrez votre nom de la catégorie ici ...", enter: "Saisir le nom de la catégorie ici ...",
add: "Nouveau bloc" add: "Nouveau bloc"
}; };

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

@ -1,14 +1,14 @@
var sankoreLang = { var sankoreLang = {
display: "D'affichage", display: "Afficher",
edit: "Modifier", edit: "Modifier",
first_desc: "Fruits", first_desc: "Fruits",
second_desc: "Légumes", second_desc: "Légumes",
potatoes: "Pommes de terre", potatoes: "Pomme de terre",
carrot: "Carotte", carrot: "Carotte",
onion: "Oignon", onion: "Oignon",
apple: "Pomme", apple: "Pomme",
pear: "Poire", pear: "Poire",
enter: "Entrez votre nom de la catégorie ici ...", enter: "Saisir le nom de la catégorie ici ...",
add: "Nouveau bloc", add: "Nouveau bloc",
text: "Texte" text: "Texte"
}; };

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

@ -1,9 +1,9 @@
var sankoreLang = { var sankoreLang = {
display: "D'affichage", display: "Afficher",
edit: "Modifier", edit: "Modifier",
text_content: "Ceci est un exemple. Au lieu de ce texte, vous pouvez mettre votre propre contenu.", text_content: "Ceci est un exemple. Au lieu de ce texte, vous pouvez saisir votre propre texte ou glisser-dŽposer une image, un son.",
new_txt: "Nouveau bloc de texte", new_txt: "Nouveau bloc de texte",
new_slide: "C'est une nouvelle diapositive." new_slide: "Ceci est une nouvelle diapositive."
}; };
//some flags //some flags

@ -26,9 +26,9 @@ function checkResponse()
*/ */
var sankoreLang = { var sankoreLang = {
view: "D'affichage", view: "Afficher",
edit: "Modifier", edit: "Modifier",
example: "il\ns'agit\nd'une\nphrase\nd'exemple" example: "Cette phrase\nest un\nexemple."
}; };

@ -27,9 +27,9 @@ function checkResponse()
*/ */
var sankoreLang = { var sankoreLang = {
view: "D'affichage", view: "Afficher",
edit: "Modifier", edit: "Modifier",
example: "une*longue*,*il*ya*bien*longtemps*..." example: "Il*était*une*fois*..."
}; };
var word = ""; var word = "";

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

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

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

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

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

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

@ -2559,7 +2559,6 @@ UBGraphicsRuler* UBSvgSubsetAdaptor::UBSvgSubsetReader::rulerFromSvg()
graphicsItemFromSvg(ruler); graphicsItemFromSvg(ruler);
UBGraphicsItem::assignZValue(ruler, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetRuler);
ruler->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); ruler->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
QStringRef svgWidth = mXmlReader.attributes().value("width"); QStringRef svgWidth = mXmlReader.attributes().value("width");
@ -2617,7 +2616,6 @@ UBGraphicsCompass* UBSvgSubsetAdaptor::UBSvgSubsetReader::compassFromSvg()
graphicsItemFromSvg(compass); graphicsItemFromSvg(compass);
UBGraphicsItem::assignZValue(compass, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCompass);
compass->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); compass->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
QStringRef svgX = mXmlReader.attributes().value("x"); QStringRef svgX = mXmlReader.attributes().value("x");
@ -2681,7 +2679,6 @@ UBGraphicsProtractor* UBSvgSubsetAdaptor::UBSvgSubsetReader::protractorFromSvg()
{ {
UBGraphicsProtractor* protractor = new UBGraphicsProtractor(); UBGraphicsProtractor* protractor = new UBGraphicsProtractor();
UBGraphicsItem::assignZValue(protractor, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetProtractor);
protractor->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); protractor->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
graphicsItemFromSvg(protractor); graphicsItemFromSvg(protractor);
@ -2751,7 +2748,6 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg()
{ {
UBGraphicsTriangle* triangle = new UBGraphicsTriangle(); UBGraphicsTriangle* triangle = new UBGraphicsTriangle();
UBGraphicsItem::assignZValue(triangle, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetTriangle);
triangle->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); triangle->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
graphicsItemFromSvg(triangle); graphicsItemFromSvg(triangle);

@ -664,6 +664,7 @@ void UBBoardController::zoom(const qreal ratio, QPointF scenePoint)
UBApplication::applicationController->adjustDisplayView(); UBApplication::applicationController->adjustDisplayView();
emit controlViewportChanged(); emit controlViewportChanged();
mActiveScene->setBackgroundZoomFactor(mControlView->transform().m11());
} }
@ -1163,7 +1164,7 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
mControlView->setScene(mActiveScene); mControlView->setScene(mActiveScene);
mDisplayView->setScene(mActiveScene); mDisplayView->setScene(mActiveScene);
mActiveScene->setBackgroundZoomFactor(mControlView->transform().m11());
pDocumentProxy->setDefaultDocumentSize(mActiveScene->nominalSize()); pDocumentProxy->setDefaultDocumentSize(mActiveScene->nominalSize());
updatePageSizeState(); updatePageSizeState();
@ -1564,7 +1565,7 @@ void UBBoardController::updateSystemScaleFactor()
mControlView->setTransform(scalingTransform); mControlView->setTransform(scalingTransform);
mControlView->horizontalScrollBar()->setValue(viewState.horizontalPosition); mControlView->horizontalScrollBar()->setValue(viewState.horizontalPosition);
mControlView->verticalScrollBar()->setValue(viewState.verticalPostition); mControlView->verticalScrollBar()->setValue(viewState.verticalPostition);
} mActiveScene->setBackgroundZoomFactor(mControlView->transform().m11());}
void UBBoardController::setWidePageSize(bool checked) void UBBoardController::setWidePageSize(bool checked)

@ -51,6 +51,7 @@
#include "tools/UBGraphicsCompass.h" #include "tools/UBGraphicsCompass.h"
#include "tools/UBGraphicsCache.h" #include "tools/UBGraphicsCache.h"
#include "tools/UBGraphicsTriangle.h"
#include "core/memcheck.h" #include "core/memcheck.h"
@ -418,18 +419,20 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
movingItem = scene()->itemAt(this->mapToScene(event->posF().toPoint())); movingItem = scene()->itemAt(this->mapToScene(event->posF().toPoint()));
if (!movingItem if (!movingItem
|| movingItem->isSelected() || movingItem->isSelected()
|| movingItem->type() == UBGraphicsDelegateFrame::Type || movingItem->type() == UBGraphicsDelegateFrame::Type
|| movingItem->type() == DelegateButton::Type || movingItem->type() == DelegateButton::Type
|| movingItem->type() == UBGraphicsCompass::Type || movingItem->type() == UBGraphicsCompass::Type
|| movingItem->type() == UBGraphicsPDFItem::Type || movingItem->type() == UBGraphicsPDFItem::Type
|| movingItem->type() == UBGraphicsPolygonItem::Type || movingItem->type() == UBGraphicsPolygonItem::Type
|| movingItem->type() == UBGraphicsCache::Type) || movingItem->type() == UBGraphicsCache::Type
{ || movingItem->type() == UBGraphicsTriangle::Type
movingItem = NULL; || movingItem == this->scene()->backgroundObject())
QGraphicsView::mousePressEvent (event); {
movingItem = NULL;
QGraphicsView::mousePressEvent (event);
} }
else else
{ {
mLastPressedMousePos = mapToScene(event->pos()); mLastPressedMousePos = mapToScene(event->pos());

@ -86,6 +86,7 @@ const int UBSettings::defaultWidgetIconWidth = 110;
const int UBSettings::defaultVideoWidth = 80; const int UBSettings::defaultVideoWidth = 80;
const int UBSettings::thumbnailSpacing = 20; const int UBSettings::thumbnailSpacing = 20;
const int UBSettings::longClickInterval = 2000;
const qreal UBSettings::minScreenRatio = 1.33; // 800/600 or 1024/768 const qreal UBSettings::minScreenRatio = 1.33; // 800/600 or 1024/768
@ -377,6 +378,9 @@ void UBSettings::init()
KeyboardLocale = new UBSetting(this, "Board", "StartupKeyboardLocale", 0); KeyboardLocale = new UBSetting(this, "Board", "StartupKeyboardLocale", 0);
swapControlAndDisplayScreens = new UBSetting(this, "App", "SwapControlAndDisplayScreens", false); swapControlAndDisplayScreens = new UBSetting(this, "App", "SwapControlAndDisplayScreens", false);
angleTolerance = new UBSetting(this, "App", "AngleTolerance", 4);
historyLimit = new UBSetting(this, "Web", "HistoryLimit", 15);
} }
@ -1139,3 +1143,4 @@ QString UBSettings::replaceWildcard(QString& path)
return result; return result;
} }

@ -97,8 +97,7 @@ class UBSettings : public QObject
void setCommunityPassword(const QString& password); void setCommunityPassword(const QString& password);
void init(); void init();
//user directories //user directories
static QString userDataDirectory(); static QString userDataDirectory();
static QString userDocumentDirectory(); static QString userDocumentDirectory();
@ -179,6 +178,7 @@ class UBSettings : public QObject
static const int defaultSoundWidth; static const int defaultSoundWidth;
static const int thumbnailSpacing; static const int thumbnailSpacing;
static const int longClickInterval;
static const qreal minScreenRatio; static const qreal minScreenRatio;
@ -326,6 +326,9 @@ class UBSettings : public QObject
UBSetting* KeyboardLocale; UBSetting* KeyboardLocale;
UBSetting* swapControlAndDisplayScreens; UBSetting* swapControlAndDisplayScreens;
UBSetting* angleTolerance;
UBSetting* historyLimit;
public slots: public slots:
void setPenWidthIndex(int index); void setPenWidthIndex(int index);

@ -88,6 +88,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
mTransparentDrawingScene = new UBGraphicsScene(0); mTransparentDrawingScene = new UBGraphicsScene(0);
mTransparentDrawingView->setScene(mTransparentDrawingScene); mTransparentDrawingView->setScene(mTransparentDrawingScene);
mTransparentDrawingScene->setDrawingMode(true);
// mRightPalette = UBApplication::boardController->paletteManager()->createDesktopRightPalette(mTransparentDrawingView); // mRightPalette = UBApplication::boardController->paletteManager()->createDesktopRightPalette(mTransparentDrawingView);
//mRightPalette = new UBRightPalette(mTransparentDrawingView); //mRightPalette = new UBRightPalette(mTransparentDrawingView);

@ -0,0 +1,46 @@
#include "UBAngleWidget.h"
#include <QPainter>
UBAngleWidget::UBAngleWidget(QWidget *parent)
: QWidget(parent)
{
this->setFixedSize(45,30);
this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
this->setAttribute(Qt::WA_TranslucentBackground);
QImage mask_img(width(), height(), QImage::Format_Mono);
mask_img.fill(0xff);
QPainter mask_ptr(&mask_img);
mask_ptr.setBrush( QBrush( QColor(0, 0, 0) ) );
mask_ptr.drawRoundedRect(0,0,this->geometry().width() - 6,this->geometry().height() - 6,1,1);
bmpMask = QBitmap::fromImage(mask_img);
this->setMask(bmpMask);
}
UBAngleWidget::~UBAngleWidget()
{
}
void UBAngleWidget::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
this->move(this->cursor().pos().x(), this->cursor().pos().y() - 30);
QPainter painter(this);
painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
QBrush brush(Qt::white);
painter.setBrush(brush);
painter.drawRoundedRect(1,1,this->geometry().width() - 10,this->geometry().height() - 10,1,1);
painter.setPen(QColor(85,50,127));
painter.setFont(QFont("Arial", 10));
painter.drawText(1,1,this->geometry().width() - 10,this->geometry().height() - 10, Qt::AlignCenter, text);
}
void UBAngleWidget::setText(QString newText)
{
text = newText;
text.append(QChar(176));
}

@ -0,0 +1,25 @@
#ifndef UBANGLEWIDGET_H
#define UBANGLEWIDGET_H
#include <QWidget>
#include <QBitmap>
class UBAngleWidget : public QWidget
{
Q_OBJECT
public:
UBAngleWidget(QWidget *parent = 0);
~UBAngleWidget();
void setText(QString);
protected:
void paintEvent(QPaintEvent *event);
private:
QString text;
QBitmap bmpMask;
};
#endif // UBANGLEWIDGET_H

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

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

@ -47,6 +47,28 @@
class UBGraphicsParaschoolEditorWidgetItem; class UBGraphicsParaschoolEditorWidgetItem;
void DelegateButton::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
// make sure delegate is selected, to avoid control being hidden
mPressedTime = QTime::currentTime();
// mDelegated->setSelected(true);
event->setAccepted(!mIsTransparentToMouseEvent);
}
void DelegateButton::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
int timeto = qAbs(QTime::currentTime().msecsTo(mPressedTime));
if (timeto < UBSettings::longClickInterval) {
emit clicked();
} else {
emit longClicked();
}
event->setAccepted(!mIsTransparentToMouseEvent);
}
UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObject * parent, bool respectRatio, bool canRotate) UBGraphicsItemDelegate::UBGraphicsItemDelegate(QGraphicsItem* pDelegated, QObject * parent, bool respectRatio, bool canRotate)
: QObject(parent) : QObject(parent)
, mDelegated(pDelegated) , mDelegated(pDelegated)
@ -88,11 +110,13 @@ void UBGraphicsItemDelegate::init()
mButtons << mMenuButton; mButtons << mMenuButton;
mZOrderUpButton = new DelegateButton(":/images/plus.svg", mDelegated, mFrame, Qt::BottomLeftSection); mZOrderUpButton = new DelegateButton(":/images/plus.svg", mDelegated, mFrame, Qt::BottomLeftSection);
connect(mZOrderUpButton, SIGNAL(clicked()), this, SLOT(increaseZLevel())); connect(mZOrderUpButton, SIGNAL(clicked()), this, SLOT(increaseZLevelUp()));
connect(mZOrderUpButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelTop()));
mButtons << mZOrderUpButton; mButtons << mZOrderUpButton;
mZOrderDownButton = new DelegateButton(":/images/minus.svg", mDelegated, mFrame, Qt::BottomLeftSection); mZOrderDownButton = new DelegateButton(":/images/minus.svg", mDelegated, mFrame, Qt::BottomLeftSection);
connect(mZOrderDownButton, SIGNAL(clicked()), this, SLOT(decreaseZLevel())); connect(mZOrderDownButton, SIGNAL(clicked()), this, SLOT(increaseZLevelDown()));
connect(mZOrderDownButton, SIGNAL(longClicked()), this, SLOT(increaseZlevelBottom()));
mButtons << mZOrderDownButton; mButtons << mZOrderDownButton;
buildButtons(); buildButtons();
@ -149,23 +173,22 @@ QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange ch
return value; return value;
} }
UBGraphicsScene *UBGraphicsItemDelegate::castUBGraphicsScene()
{
UBGraphicsScene *castScene = dynamic_cast<UBGraphicsScene*>(delegated()->scene());
return castScene;
}
bool UBGraphicsItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event) bool UBGraphicsItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
if(NULL != mMimeData) mDragStartPosition = event->pos();
{
QDrag* mDrag = new QDrag(event->widget());
mDrag->setMimeData(mMimeData);
mDrag->start();
}
startUndoStep(); startUndoStep();
if (!mDelegated->isSelected()) if (!mDelegated->isSelected())
{ {
mDelegated->setSelected(true); mDelegated->setSelected(true);
qDebug() << mDelegated->zValue();
positionHandles(); positionHandles();
return true; return true;
} }
@ -182,13 +205,27 @@ void UBGraphicsItemDelegate::setMimeData(QMimeData *mimeData)
bool UBGraphicsItemDelegate::mouseMoveEvent(QGraphicsSceneMouseEvent *event) bool UBGraphicsItemDelegate::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{ {
if((NULL != mMimeData) && ((event->pos() - mDragStartPosition).manhattanLength() < QApplication::startDragDistance()))
{
QDrag* mDrag = new QDrag(event->widget());
mDrag->setMimeData(mMimeData);
if (!mDragPixmap.isNull()) {
mDrag->setPixmap(mDragPixmap);
mDrag->setHotSpot(mDragPixmap.rect().center());
}
mDrag->exec();
mDragPixmap = QPixmap();
return true;
}
if(isLocked()) if(isLocked())
{ {
event->accept(); event->accept();
return true; return true;
} }
else else
return false; return true;
} }
bool UBGraphicsItemDelegate::weelEvent(QGraphicsSceneWheelEvent *event) bool UBGraphicsItemDelegate::weelEvent(QGraphicsSceneWheelEvent *event)
@ -215,77 +252,65 @@ bool UBGraphicsItemDelegate::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
return true; return true;
} }
void UBGraphicsItemDelegate::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event)
// if (!mDelegated->isSelected()) {
// setZOrderButtonsVisible(true);
// }
}
void UBGraphicsItemDelegate::positionHandles() void UBGraphicsItemDelegate::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{ {
if (mDelegated->isSelected()) Q_UNUSED(event)
{ // if (!mDelegated->isSelected()) {
if (mFrame && !mFrame->scene() && mDelegated->scene()) // setZOrderButtonsVisible(false);
{ // }
mDelegated->scene()->addItem(mFrame); }
}
mFrame->setAntiScale(mAntiScaleRatio); void UBGraphicsItemDelegate::positionHandles()
mFrame->positionHandles(); {
if (mDelegated->isSelected()) {
bool shownOnDisplay = mDelegated->data(UBGraphicsItemData::ItemLayerType).toInt() != UBItemLayerType::Control;
showHide(shownOnDisplay);
lock(isLocked());
updateFrame();
mFrame->show(); mFrame->show();
QTransform tr; updateButtons(true);
tr.scale(mAntiScaleRatio, mAntiScaleRatio);
mDeleteButton->setTransform(tr);
qreal topX = mFrame->rect().left()- mDeleteButton->renderer()->viewBox().width() * mAntiScaleRatio / 2; } else {
qreal topY = mFrame->rect().top() - mDeleteButton->renderer()->viewBox().height() * mAntiScaleRatio / 2; foreach(DelegateButton* button, mButtons)
button->hide();
qreal bottomX = mFrame->rect().left()- mDeleteButton->renderer()->viewBox().width() * mAntiScaleRatio / 2; mFrame->hide();
qreal bottomY = mFrame->rect().bottom() - mDeleteButton->renderer()->viewBox().height() * mAntiScaleRatio / 2; }
}
void UBGraphicsItemDelegate::setZOrderButtonsVisible(bool visible)
{
if (visible) {
updateFrame();
updateButtons();
mDeleteButton->setPos(topX, topY); QPointF newUpPoint = mFrame->mapToItem(mDelegated, mZOrderUpButton->pos());
QPointF newDownPoint = mFrame->mapToItem(mDelegated, mZOrderDownButton->pos());
if (!mDeleteButton->scene())
{
mDeleteButton->setParentItem(mFrame);//update parent for the case the item has been previously removed from scene
if (mDelegated->scene())
mDelegated->scene()->addItem(mDeleteButton);
}
mDeleteButton->show(); mZOrderUpButton->setParentItem(mDelegated);
mZOrderDownButton->setParentItem(mDelegated);
bool shownOnDisplay = mDelegated->data(UBGraphicsItemData::ItemLayerType).toInt() != UBItemLayerType::Control; mZOrderUpButton->setPos(newUpPoint + QPointF(0,0));
showHide(shownOnDisplay); mZOrderDownButton->setPos(newDownPoint + QPointF(0,0));
lock(isLocked()); mZOrderUpButton->show();
mZOrderDownButton->show();
int i = 1, j = 0, k = 0;
while ((i + j) < mButtons.size()) {
DelegateButton* button = mButtons[i + j];
button->setTransform(tr);
if (button->getSection() == Qt::TopLeftSection) {
button->setPos(topX + (i++ * 1.6 * mFrameWidth * mAntiScaleRatio), topY);
} else if (button->getSection() == Qt::BottomLeftSection) {
button->setPos(bottomX + (++j * 1.6 * mFrameWidth * mAntiScaleRatio), bottomY);
} else if (button->getSection() == Qt::NoSection) {
++k;
}
if (!button->scene())
{
button->setParentItem(mFrame);//update parent for the case the item has been previously removed from scene
if (mDelegated->scene())
mDelegated->scene()->addItem(button);
}
button->show();
button->setZValue(delegated()->zValue());
}
} else { } else {
foreach(DelegateButton* button, mButtons) mZOrderUpButton->hide();
button->hide(); mZOrderDownButton->hide();
mFrame->hide();
} }
} }
void UBGraphicsItemDelegate::remove(bool canUndo) void UBGraphicsItemDelegate::remove(bool canUndo)
{ {
// QGraphicsScene* scene = mDelegated->scene(); // QGraphicsScene* scene = mDelegated->scene();
@ -320,10 +345,34 @@ void UBGraphicsItemDelegate::duplicate()
UBApplication::boardController->copy(); UBApplication::boardController->copy();
UBApplication::boardController->paste(); UBApplication::boardController->paste();
} }
void UBGraphicsItemDelegate::increaseZLevel(int delta)
void UBGraphicsItemDelegate::increaseZLevelUp()
{ {
Q_UNUSED(delta) UBGraphicsScene *curScene = castUBGraphicsScene();
qDebug() << delegated()->scene()->items().count(); if (curScene) {
curScene->changeZLevelTo(delegated(), UBZLayerController::up);
}
}
void UBGraphicsItemDelegate::increaseZlevelTop()
{
UBGraphicsScene *curScene = castUBGraphicsScene();
if (curScene) {
curScene->changeZLevelTo(delegated(), UBZLayerController::top);
}
}
void UBGraphicsItemDelegate::increaseZLevelDown()
{
UBGraphicsScene *curScene = castUBGraphicsScene();
if (curScene) {
curScene->changeZLevelTo(delegated(), UBZLayerController::down);
}
}
void UBGraphicsItemDelegate::increaseZlevelBottom()
{
UBGraphicsScene *curScene = castUBGraphicsScene();
if (curScene) {
curScene->changeZLevelTo(delegated(), UBZLayerController::bottom);
}
} }
void UBGraphicsItemDelegate::lock(bool locked) void UBGraphicsItemDelegate::lock(bool locked)
@ -476,3 +525,71 @@ bool UBGraphicsItemDelegate::isFlippable()
{ {
return mFlippable; return mFlippable;
} }
void UBGraphicsItemDelegate::updateFrame()
{
if (mFrame && !mFrame->scene() && mDelegated->scene())
{
mDelegated->scene()->addItem(mFrame);
}
mFrame->setAntiScale(mAntiScaleRatio);
mFrame->positionHandles();
}
void UBGraphicsItemDelegate::updateButtons(bool showUpdated)
{
QTransform tr;
tr.scale(mAntiScaleRatio, mAntiScaleRatio);
mDeleteButton->setParentItem(mFrame);
mDeleteButton->setTransform(tr);
qreal topX = mFrame->rect().left() - mDeleteButton->renderer()->viewBox().width() * mAntiScaleRatio / 2;
qreal topY = mFrame->rect().top() - mDeleteButton->renderer()->viewBox().height() * mAntiScaleRatio / 2;
qreal bottomX = mFrame->rect().left() - mDeleteButton->renderer()->viewBox().width() * mAntiScaleRatio / 2;
qreal bottomY = mFrame->rect().bottom() - mDeleteButton->renderer()->viewBox().height() * mAntiScaleRatio / 2;
mDeleteButton->setPos(topX, topY);
if (!mDeleteButton->scene())
{
if (mDelegated->scene())
mDelegated->scene()->addItem(mDeleteButton);
}
if (showUpdated /*&& mFrame->isResizing()*/)
mDeleteButton->show();
int i = 1, j = 0, k = 0;
while ((i + j + k) < mButtons.size()) {
DelegateButton* button = mButtons[i + j];
button->setParentItem(mFrame);
button->setTransform(tr);
if (button->getSection() == Qt::TopLeftSection) {
button->setPos(topX + (i++ * 1.6 * mFrameWidth * mAntiScaleRatio), topY);
} else if (button->getSection() == Qt::BottomLeftSection) {
button->setPos(bottomX + (++j * 1.6 * mFrameWidth * mAntiScaleRatio), bottomY);
} else if (button->getSection() == Qt::NoSection) {
++k;
}
if (!button->scene())
{
if (mDelegated->scene())
mDelegated->scene()->addItem(button);
}
if (showUpdated) {
button->show();
button->setZValue(delegated()->zValue());
}
}
}
void UBGraphicsItemDelegate::setButtonsVisible(bool visible)
{
foreach(DelegateButton* pButton, mButtons){
pButton->setVisible(visible);
}
}

@ -21,9 +21,11 @@
#include <QMimeData> #include <QMimeData>
#include "core/UB.h" #include "core/UB.h"
#include "core/UBSettings.h"
class QGraphicsSceneMouseEvent; class QGraphicsSceneMouseEvent;
class QGraphicsItem; class QGraphicsItem;
class UBGraphicsScene;
class UBGraphicsProxyWidget; class UBGraphicsProxyWidget;
class UBGraphicsDelegateFrame; class UBGraphicsDelegateFrame;
class UBGraphicsWidgetItem; class UBGraphicsWidgetItem;
@ -63,20 +65,8 @@ class DelegateButton: public QGraphicsSvgItem
protected: protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
{ virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
// make sure delegate is selected, to avoid control being hidden
mDelegated->setSelected(true);
event->setAccepted(!mIsTransparentToMouseEvent);
}
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
emit clicked();
event->setAccepted(!mIsTransparentToMouseEvent);
}
void modified(); void modified();
@ -84,12 +74,13 @@ class DelegateButton: public QGraphicsSvgItem
QGraphicsItem* mDelegated; QGraphicsItem* mDelegated;
QTime mPressedTime;
bool mIsTransparentToMouseEvent; bool mIsTransparentToMouseEvent;
Qt::WindowFrameSection mButtonAlignmentSection; Qt::WindowFrameSection mButtonAlignmentSection;
signals: signals:
void clicked (bool checked = false); void clicked (bool checked = false);
void longClicked();
}; };
@ -110,8 +101,12 @@ class UBGraphicsItemDelegate : public QObject
virtual bool mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual bool mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
virtual bool weelEvent(QGraphicsSceneWheelEvent *event); virtual bool weelEvent(QGraphicsSceneWheelEvent *event);
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change,
const QVariant &value); const QVariant &value);
virtual UBGraphicsScene *castUBGraphicsScene();
void printMessage(const QString &mess) {qDebug() << mess;} void printMessage(const QString &mess) {qDebug() << mess;}
@ -123,6 +118,7 @@ class UBGraphicsItemDelegate : public QObject
void setCanDuplicate(bool allow){ mCanDuplicate = allow; } void setCanDuplicate(bool allow){ mCanDuplicate = allow; }
virtual void positionHandles(); virtual void positionHandles();
void setZOrderButtonsVisible(bool visible);
void startUndoStep(); void startUndoStep();
void commitUndoStep(); void commitUndoStep();
@ -135,10 +131,13 @@ class UBGraphicsItemDelegate : public QObject
QMimeData* mimeData(){ return mMimeData; } QMimeData* mimeData(){ return mMimeData; }
void setMimeData(QMimeData* mimeData); void setMimeData(QMimeData* mimeData);
void setDragPixmap(const QPixmap &pix) {mDragPixmap = pix;}
void setFlippable(bool flippable); void setFlippable(bool flippable);
bool isFlippable(); bool isFlippable();
void setButtonsVisible(bool visible);
signals: signals:
void showOnDisplayChanged(bool shown); void showOnDisplayChanged(bool shown);
void lockChanged(bool locked); void lockChanged(bool locked);
@ -151,8 +150,10 @@ class UBGraphicsItemDelegate : public QObject
virtual void lock(bool lock); virtual void lock(bool lock);
virtual void duplicate(); virtual void duplicate();
virtual void increaseZLevel() {increaseZLevel(1);} void increaseZLevelUp();
virtual void decreaseZLevel() {increaseZLevel(-1);} void increaseZLevelDown();
void increaseZlevelTop();
void increaseZlevelBottom();
protected: protected:
virtual void buildButtons() {;} virtual void buildButtons() {;}
@ -187,18 +188,22 @@ protected slots:
virtual void gotoContentSource(bool checked); virtual void gotoContentSource(bool checked);
private: private:
void updateFrame();
void updateButtons(bool showUpdated = false);
virtual void increaseZLevel(int delta);
QPointF mOffset; QPointF mOffset;
QTransform mPreviousTransform; QTransform mPreviousTransform;
QPointF mPreviousPosition; QPointF mPreviousPosition;
QPointF mDragStartPosition;
qreal mPreviousZValue; qreal mPreviousZValue;
QSizeF mPreviousSize; QSizeF mPreviousSize;
bool mCanRotate; bool mCanRotate;
bool mCanDuplicate; bool mCanDuplicate;
bool mRespectRatio; bool mRespectRatio;
QMimeData* mMimeData; QMimeData* mMimeData;
QPixmap mDragPixmap;
/** A boolean saying that this object can be flippable (mirror effect) */ /** A boolean saying that this object can be flippable (mirror effect) */
bool mFlippable; bool mFlippable;

@ -32,7 +32,7 @@ UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent)
mDelegate->init(); mDelegate->init();
// NOTE: Do not remove this code, I'm just doing a backup of my changes! thx.. // NOTE: Do not remove this code, I'm just doing a backup of my changes! thx..
//mDelegate->setFlippable(true); mDelegate->setFlippable(true);
setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object); setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::Object);
setTransformationMode(Qt::SmoothTransformation); setTransformationMode(Qt::SmoothTransformation);
@ -58,13 +58,18 @@ void UBGraphicsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
QMimeData* pMime = new QMimeData(); QMimeData* pMime = new QMimeData();
pMime->setImageData(pixmap().toImage()); pMime->setImageData(pixmap().toImage());
mDelegate->setMimeData(pMime); mDelegate->setMimeData(pMime);
int k = pixmap().width() / 100;
QSize newSize(pixmap().width() / k, pixmap().height() / k);
mDelegate->setDragPixmap(pixmap().scaled(newSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
if (mDelegate->mousePressEvent(event)) if (mDelegate->mousePressEvent(event))
{ {
//NOOP //NOOP
} }
else else
{ {
QGraphicsPixmapItem::mousePressEvent(event); // QGraphicsPixmapItem::mousePressEvent(event);
} }
} }

@ -61,10 +61,6 @@ protected:
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
// UBGraphicsItemDelegate* mDelegate;
}; };
#endif /* UBGRAPHICSPIXMAPITEM_H_ */ #endif /* UBGRAPHICSPIXMAPITEM_H_ */

@ -61,24 +61,11 @@
#include "core/memcheck.h" #include "core/memcheck.h"
qreal UBGraphicsScene::drawingLayerStart = 0.0;
qreal UBGraphicsScene::toolLayerStart = 10000000.0;
qreal UBGraphicsScene::toolOffsetRuler = 100;
qreal UBGraphicsScene::toolOffsetProtractor = 100;
qreal UBGraphicsScene::toolOffsetTriangle = 100;
qreal UBGraphicsScene::toolOffsetCompass = 100;
qreal UBGraphicsScene::toolOffsetEraser = 200;
qreal UBGraphicsScene::toolOffsetCurtain = 1000;
qreal UBGraphicsScene::toolOffsetPointer = 1100;
qreal UBGraphicsScene::toolOffsetCache = 1000;//Didier please define offset you want
qreal UBZLayerController::errorNumber = -20000001.0; qreal UBZLayerController::errorNumber = -20000001.0;
UBZLayerController::UBZLayerController(QGraphicsScene *scene) :
mScene(scene)
UBZLayerController::UBZLayerController()
{ {
scopeMap.insert(itemLayerType::NoLayer, ItemLayerTypeData( errorNumber, errorNumber)); scopeMap.insert(itemLayerType::NoLayer, ItemLayerTypeData( errorNumber, errorNumber));
scopeMap.insert(itemLayerType::BackgroundItem, ItemLayerTypeData(-10000000.0, -10000000.0 )); scopeMap.insert(itemLayerType::BackgroundItem, ItemLayerTypeData(-10000000.0, -10000000.0 ));
@ -104,17 +91,162 @@ qreal UBZLayerController::generateZLevel(itemLayerType::Enum key)
qreal result = scopeMap.value(key).curValue; qreal result = scopeMap.value(key).curValue;
qreal top = scopeMap.value(key).topLimit; qreal top = scopeMap.value(key).topLimit;
qreal incrementalStep = scopeMap.value(key).incStep;
result++; result += incrementalStep;
if (result >= top) { if (result >= top) {
qDebug() << "new values are over for the scope" << key; // If not only one variable presents in the scope, notify that values for scope are over
result = top - 1; if (scopeMap.value(key).topLimit != scopeMap.value(key).bottomLimit) {
qDebug() << "new values are over for the scope" << key;
}
result = top - incrementalStep;
} }
scopeMap[key].curValue = result; scopeMap[key].curValue = result;
return result; return result;
} }
qreal UBZLayerController::generateZLevel(QGraphicsItem *item)
{
qreal result = errorNumber;
itemLayerType::Enum type = static_cast<itemLayerType::Enum>(item->data(UBGraphicsItemData::itemLayerType).toInt());
if (validLayerType(type)) {
result = generateZLevel(type);
}
return result;
}
qreal UBZLayerController::changeZLevelTo(QGraphicsItem *item, moveDestination dest)
{
itemLayerType::Enum curItemLayerType = typeForData(item);
if (curItemLayerType == itemLayerType::NoLayer) {
qDebug() << "item's layer is out of the scope. Can't implement z-layer changing operation";
return errorNum();
}
//select only items wiht the same z-level as item's one and push it to sortedItems QMultiMap
QMultiMap<qreal, QGraphicsItem*> sortedItems;
if (mScene->items().count()) {
foreach (QGraphicsItem *tmpItem, mScene->items()) {
if (typeForData(tmpItem) == curItemLayerType) {
sortedItems.insert(tmpItem->data(UBGraphicsItemData::ItemOwnZValue).toReal(), tmpItem);
}
}
}
//If only one item itself - do nothing, return it's z-value
if (sortedItems.count() == 1 && sortedItems.values().first() == item) {
qDebug() << "only one item exists in layer. Have nothing to change";
return item->data(UBGraphicsItemData::ItemOwnZValue).toReal();
}
QMapIterator<qreal, QGraphicsItem*>iCurElement(sortedItems);
if (dest == up) {
if (iCurElement.findNext(item)) {
if (iCurElement.hasNext()) {
qreal nextZ = iCurElement.peekNext().value()->data(UBGraphicsItemData::ItemOwnZValue).toReal();
UBGraphicsItem::assignZValue(iCurElement.peekNext().value(), item->data(UBGraphicsItemData::ItemOwnZValue).toReal());
UBGraphicsItem::assignZValue(item, nextZ);
iCurElement.next();
while (iCurElement.hasNext() && iCurElement.peekNext().value()->data(UBGraphicsItemData::ItemOwnZValue).toReal() == nextZ) {
UBGraphicsItem::assignZValue(iCurElement.next().value(), nextZ);
}
item->scene()->clearSelection();
item->setSelected(true);
}
}
} else if (dest == top) {
if (iCurElement.findNext(item)) {
if (iCurElement.hasNext()) {
UBGraphicsItem::assignZValue(item, generateZLevel(item));
}
}
} else if (dest == down) {
iCurElement.toBack();
if (iCurElement.findPrevious(item)) {
if (iCurElement.hasPrevious()) {
qreal nextZ = iCurElement.peekPrevious().value()->data(UBGraphicsItemData::ItemOwnZValue).toReal();
UBGraphicsItem::assignZValue(iCurElement.peekPrevious().value(), item->data(UBGraphicsItemData::ItemOwnZValue).toReal());
UBGraphicsItem::assignZValue(item, nextZ);
while (iCurElement.hasNext() && iCurElement.peekNext().value()->data(UBGraphicsItemData::ItemOwnZValue).toReal() == nextZ) {
UBGraphicsItem::assignZValue(iCurElement.next().value(), nextZ);
}
}
}
} else if (dest == bottom) {
iCurElement.toBack();
if (iCurElement.findPrevious(item)) {
if (iCurElement.hasPrevious()) {
// qreal oldz = iCurElement.peekPrevious().value()->data(UBGraphicsItemData::ItemOwnZValue).toReal();
qreal oldz = item->data(UBGraphicsItemData::ItemOwnZValue).toReal();
iCurElement.toFront();
qreal nextZ = iCurElement.next().value()->data(UBGraphicsItemData::ItemOwnZValue).toReal();
ItemLayerTypeData curItemLayerTypeData = scopeMap.value(curItemLayerType);
//
//if we have some free space between lowest graphics item and layer's bottom bound,
//insert element close to first element in layer
if (nextZ >= curItemLayerTypeData.bottomLimit + curItemLayerTypeData.incStep) {
qreal result = nextZ - curItemLayerTypeData.incStep;
UBGraphicsItem::assignZValue(item, result);
} else {
UBGraphicsItem::assignZValue(item, nextZ);
bool doubleGap = false; //to detect if we can finish rundown since we can insert item to the free space
while (iCurElement.peekNext().value() != item) {
qreal curZ = iCurElement.value()->data(UBGraphicsItemData::ItemOwnZValue).toReal();
qreal curNextZ = iCurElement.peekNext().value()->data(UBGraphicsItemData::ItemOwnZValue).toReal();
if (curNextZ - curZ >= 2 * curItemLayerTypeData.incStep) {
UBGraphicsItem::assignZValue(iCurElement.value(), curZ + curItemLayerTypeData.incStep);
doubleGap = true;
break;
} else {
UBGraphicsItem::assignZValue(iCurElement.value(), iCurElement.next().value()->data(UBGraphicsItemData::ItemOwnZValue).toReal());
}
}
if (!doubleGap) {
UBGraphicsItem::assignZValue(iCurElement.value(), oldz);
while (iCurElement.hasNext() && (iCurElement.peekNext().value()->data(UBGraphicsItemData::ItemOwnZValue).toReal() == oldz)) {
UBGraphicsItem::assignZValue(iCurElement.next().value(), oldz);
}
}
}
}
}
}
//clear selection of the item and then select it again to activate selectionChangeProcessing()
item->scene()->clearSelection();
item->setSelected(true);
//Return new z value assigned to item
return item->data(UBGraphicsItemData::ItemOwnZValue).toReal();
}
itemLayerType::Enum UBZLayerController::typeForData(QGraphicsItem *item) const
{
itemLayerType::Enum result = static_cast<itemLayerType::Enum>(item->data(UBGraphicsItemData::itemLayerType).toInt());
if (!scopeMap.contains(result)) {
result = itemLayerType::NoLayer;
}
return result;
}
UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent) UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
: UBCoreGraphicsScene(parent) : UBCoreGraphicsScene(parent)
@ -135,7 +267,8 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
, enableUndoRedoStack(true) , enableUndoRedoStack(true)
, magniferControlViewWidget(0) , magniferControlViewWidget(0)
, magniferDisplayViewWidget(0) , magniferDisplayViewWidget(0)
, mZLayerController(new UBZLayerController(this))
, mIsDesktopMode(false)
{ {
#ifdef __ppc__ #ifdef __ppc__
@ -160,11 +293,12 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
UBGraphicsScene::~UBGraphicsScene() UBGraphicsScene::~UBGraphicsScene()
{ {
DisposeMagnifierQWidgets();
if (mCurrentStroke) if (mCurrentStroke)
if (mCurrentStroke->polygons().empty()) if (mCurrentStroke->polygons().empty())
delete mCurrentStroke; delete mCurrentStroke;
if (mZLayerController)
delete mZLayerController;
} }
void UBGraphicsScene::selectionChangedProcessing() void UBGraphicsScene::selectionChangedProcessing()
@ -178,7 +312,7 @@ void UBGraphicsScene::selectionChangedProcessing()
QGraphicsItem *nextItem = allItemsList.at(i); QGraphicsItem *nextItem = allItemsList.at(i);
if (nextItem->isSelected()) { if (nextItem->isSelected()) {
nextItem->setZValue(mZLayerController.generateZLevel(itemLayerType::SelectedItem)); nextItem->setZValue(mZLayerController->generateZLevel(itemLayerType::SelectedItem));
} else { } else {
nextItem->setZValue(nextItem->data(UBGraphicsItemData::ItemOwnZValue).toReal()); nextItem->setZValue(nextItem->data(UBGraphicsItemData::ItemOwnZValue).toReal());
} }
@ -711,6 +845,15 @@ void UBGraphicsScene::setBackground(bool pIsDark, bool pIsCrossed)
} }
} }
void UBGraphicsScene::setBackgroundZoomFactor(qreal zoom)
{
mZoomFactor = zoom;
}
void UBGraphicsScene::setDrawingMode(bool bModeDesktop)
{
mIsDesktopMode = bModeDesktop;
}
void UBGraphicsScene::recolorAllItems() void UBGraphicsScene::recolorAllItems()
{ {
@ -823,7 +966,6 @@ void UBGraphicsScene::leaveEvent(QEvent * event)
hideEraser(); hideEraser();
} }
UBGraphicsScene* UBGraphicsScene::sceneDeepCopy() const UBGraphicsScene* UBGraphicsScene::sceneDeepCopy() const
{ {
UBGraphicsScene* copy = new UBGraphicsScene(this->document()); UBGraphicsScene* copy = new UBGraphicsScene(this->document());
@ -1330,7 +1472,7 @@ void UBGraphicsScene::addItem(QGraphicsItem* item)
setModified(true); setModified(true);
UBCoreGraphicsScene::addItem(item); UBCoreGraphicsScene::addItem(item);
UBGraphicsItem::assignZValue(item, generateZLevel(item)); UBGraphicsItem::assignZValue(item, mZLayerController->generateZLevel(item));
if (!mTools.contains(item)) if (!mTools.contains(item))
++mItemCount; ++mItemCount;
@ -1344,7 +1486,7 @@ void UBGraphicsScene::addItems(const QSet<QGraphicsItem*>& items)
foreach(QGraphicsItem* item, items) { foreach(QGraphicsItem* item, items) {
UBCoreGraphicsScene::addItem(item); UBCoreGraphicsScene::addItem(item);
UBGraphicsItem::assignZValue(item, generateZLevel(item)); UBGraphicsItem::assignZValue(item, mZLayerController->generateZLevel(item));
} }
mItemCount += items.size(); mItemCount += items.size();
@ -1406,7 +1548,7 @@ QGraphicsItem* UBGraphicsScene::setAsBackgroundObject(QGraphicsItem* item, bool
item->setAcceptedMouseButtons(Qt::NoButton); item->setAcceptedMouseButtons(Qt::NoButton);
item->setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::FixedBackground); item->setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::FixedBackground);
UBGraphicsItem::assignZValue(item, mZLayerController.generateZLevel(itemLayerType::BackgroundItem)); UBGraphicsItem::assignZValue(item, mZLayerController->generateZLevel(itemLayerType::BackgroundItem));
if (pAdaptTransformation) if (pAdaptTransformation)
{ {
@ -1779,6 +1921,23 @@ void UBGraphicsScene::setNominalSize(int pWidth, int pHeight)
setNominalSize(QSize(pWidth, pHeight)); setNominalSize(QSize(pWidth, pHeight));
} }
void UBGraphicsScene::setSelectedZLevel(QList<QGraphicsItem *> itemList)
{
foreach (QGraphicsItem *item, itemList) {
item->setZValue(mZLayerController->generateZLevel(itemLayerType::SelectedItem));
}
}
void UBGraphicsScene::setOwnZlevel(QList<QGraphicsItem *> itemList)
{
foreach (QGraphicsItem *item, itemList) {
item->setZValue(item->data(UBGraphicsItemData::ItemOwnZValue).toReal());
}
}
qreal UBGraphicsScene::changeZLevelTo(QGraphicsItem *item, UBZLayerController::moveDestination dest)
{
return mZLayerController->changeZLevelTo(item, dest);
}
QGraphicsItem* UBGraphicsScene::rootItem(QGraphicsItem* item) const QGraphicsItem* UBGraphicsScene::rootItem(QGraphicsItem* item) const
{ {
@ -1854,6 +2013,58 @@ void UBGraphicsScene::drawItems (QPainter * painter, int numItems,
} }
} }
void UBGraphicsScene::drawBackground(QPainter *painter, const QRectF &rect)
{
if (mIsDesktopMode)
{
QGraphicsScene::drawBackground (painter, rect);
return;
}
bool darkBackground = isDarkBackground ();
if (darkBackground)
{
painter->fillRect (rect, QBrush (QColor (Qt::black)));
}
else
{
painter->fillRect (rect, QBrush (QColor (Qt::white)));
}
if (mZoomFactor > 0.5)
{
QColor bgCrossColor;
if (darkBackground)
bgCrossColor = UBSettings::crossDarkBackground;
else
bgCrossColor = UBSettings::crossLightBackground;
if (mZoomFactor < 1.0)
{
int alpha = 255 * mZoomFactor / 2;
bgCrossColor.setAlpha (alpha); // fade the crossing on small zooms
}
painter->setPen (bgCrossColor);
if (isCrossedBackground())
{
qreal firstY = ((int) (rect.y () / UBSettings::crossSize)) * UBSettings::crossSize;
for (qreal yPos = firstY; yPos < rect.y () + rect.height (); yPos += UBSettings::crossSize)
{
painter->drawLine (rect.x (), yPos, rect.x () + rect.width (), yPos);
}
qreal firstX = ((int) (rect.x () / UBSettings::crossSize)) * UBSettings::crossSize;
for (qreal xPos = firstX; xPos < rect.x () + rect.width (); xPos += UBSettings::crossSize)
{
painter->drawLine (xPos, rect.y (), xPos, rect.y () + rect.height ());
}
}
}
}
void UBGraphicsScene::keyReleaseEvent(QKeyEvent * keyEvent) void UBGraphicsScene::keyReleaseEvent(QKeyEvent * keyEvent)
{ {
@ -1951,18 +2162,6 @@ void UBGraphicsScene::createPointer()
addItem(mPointer); addItem(mPointer);
} }
qreal UBGraphicsScene::generateZLevel(QGraphicsItem *item)
{
qreal result = UBZLayerController::errorNum();
itemLayerType::Enum type = static_cast<itemLayerType::Enum>(item->data(UBGraphicsItemData::itemLayerType).toInt());
if (mZLayerController.validLayerType(type)) {
result = mZLayerController.generateZLevel(type);
}
return result;
}
void UBGraphicsScene::setToolCursor(int tool) void UBGraphicsScene::setToolCursor(int tool)
{ {
if (tool != (int)UBStylusTool::Selector if (tool != (int)UBStylusTool::Selector

@ -49,33 +49,47 @@ class UBGraphicsCache;
const double PI = 4.0 * atan(1.0); const double PI = 4.0 * atan(1.0);
class UBZLayerController class UBZLayerController : public QObject
{ {
public: Q_OBJECT
public:
struct ItemLayerTypeData { struct ItemLayerTypeData {
ItemLayerTypeData() : bottomLimit(0), topLimit(0), curValue(0) {;} ItemLayerTypeData() : bottomLimit(0), topLimit(0), curValue(0), incStep(1) {;}
ItemLayerTypeData(qreal bot, qreal top) : bottomLimit(bot), topLimit(top), curValue(bot) {;} ItemLayerTypeData(qreal bot, qreal top, qreal increment = 1) : bottomLimit(bot), topLimit(top), curValue(bot), incStep(increment) {;}
qreal bottomLimit; qreal bottomLimit; //bottom bound of the layer
qreal topLimit; qreal topLimit;//top bound of the layer
qreal curValue; qreal curValue;//current value of variable
qreal incStep;//incremental step
};
enum moveDestination {
up
, down
, top
, bottom
}; };
typedef QMap<itemLayerType::Enum, ItemLayerTypeData> ScopeMap; typedef QMap<itemLayerType::Enum, ItemLayerTypeData> ScopeMap;
UBZLayerController(); UBZLayerController(QGraphicsScene *scene);
qreal getBottomLimit(itemLayerType::Enum key) const {return scopeMap.value(key).bottomLimit;} qreal getBottomLimit(itemLayerType::Enum key) const {return scopeMap.value(key).bottomLimit;}
qreal getTopLimit(itemLayerType::Enum key) const {return scopeMap.value(key).topLimit;} qreal getTopLimit(itemLayerType::Enum key) const {return scopeMap.value(key).topLimit;}
bool validLayerType(itemLayerType::Enum key) const {return scopeMap.contains(key);} bool validLayerType(itemLayerType::Enum key) const {return scopeMap.contains(key);}
static qreal errorNum() {return errorNumber;} static qreal errorNum() {return errorNumber;}
qreal generateZLevel(itemLayerType::Enum key); qreal generateZLevel(itemLayerType::Enum key);
qreal generateZLevel(QGraphicsItem *item);
private: qreal changeZLevelTo(QGraphicsItem *item, moveDestination dest);
ScopeMap scopeMap; itemLayerType::Enum typeForData(QGraphicsItem *item) const;
static qreal errorNumber;
private:
ScopeMap scopeMap;
static qreal errorNumber;
QGraphicsScene *mScene;
}; };
class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
@ -87,7 +101,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
// tmp stub for divide addings scene objects from undo mechanism implementation // tmp stub for divide addings scene objects from undo mechanism implementation
void setURStackEnable(bool set = true) {enableUndoRedoStack = set;} void setURStackEnable(bool set = true) {enableUndoRedoStack = set;}
UBGraphicsScene(UBDocumentProxy *parent); UBGraphicsScene(UBDocumentProxy *parent);
virtual ~UBGraphicsScene(); virtual ~UBGraphicsScene();
virtual UBItem* deepCopy() const; virtual UBItem* deepCopy() const;
@ -242,6 +256,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void setNominalSize(int pWidth, int pHeight); void setNominalSize(int pWidth, int pHeight);
qreal changeZLevelTo(QGraphicsItem *item, UBZLayerController::moveDestination dest);
enum RenderingContext enum RenderingContext
{ {
Screen = 0, NonScreen, PdfExport, Podcast Screen = 0, NonScreen, PdfExport, Podcast
@ -257,20 +273,6 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
return mRenderingContext; return mRenderingContext;
} }
static qreal backgroundLayerStart;
static qreal objectLayerStart;
static qreal drawingLayerStart;
static qreal toolLayerStart;
static qreal toolOffsetEraser;
static qreal toolOffsetPointer;
static qreal toolOffsetRuler;
static qreal toolOffsetProtractor;
static qreal toolOffsetCompass;
static qreal toolOffsetCurtain;
static qreal toolOffsetTriangle;
static qreal toolOffsetCache;
QSet<QGraphicsItem*> tools(){ return mTools;} QSet<QGraphicsItem*> tools(){ return mTools;}
void registerTool(QGraphicsItem* item) void registerTool(QGraphicsItem* item)
@ -283,12 +285,15 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
return mPreviousPoint; return mPreviousPoint;
} }
public slots: void setSelectedZLevel(QList<QGraphicsItem *> itemList);
void setOwnZlevel(QList<QGraphicsItem *> itemList);
public slots:
void hideEraser(); void hideEraser();
void setBackground(bool pIsDark, bool pIsCrossed); void setBackground(bool pIsDark, bool pIsCrossed);
void setBackgroundZoomFactor(qreal zoom);
void setDrawingMode(bool bModeDesktop);
void deselectAllItems(); void deselectAllItems();
UBGraphicsPixmapItem* addPixmap(const QPixmap& pPixmap, const QPointF& pPos = QPointF(0,0), qreal scaleFactor = 1.0, bool pUseAnimation = false); UBGraphicsPixmapItem* addPixmap(const QPixmap& pPixmap, const QPointF& pPos = QPointF(0,0), qreal scaleFactor = 1.0, bool pUseAnimation = false);
@ -331,13 +336,13 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
QGraphicsItem* rootItem(QGraphicsItem* item) const; QGraphicsItem* rootItem(QGraphicsItem* item) const;
virtual void drawBackground(QPainter *painter, const QRectF &rect);
private: private:
void setDocumentUpdated(); void setDocumentUpdated();
void createEraiser(); void createEraiser();
void createPointer(); void createPointer();
qreal generateZLevel(QGraphicsItem *item);
QGraphicsEllipseItem* mEraser; QGraphicsEllipseItem* mEraser;
QGraphicsEllipseItem* mPointer; QGraphicsEllipseItem* mPointer;
@ -348,6 +353,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
bool mDarkBackground; bool mDarkBackground;
bool mCrossedBackground; bool mCrossedBackground;
bool mIsDesktopMode;
qreal mZoomFactor;
bool mIsModified; bool mIsModified;
@ -387,7 +394,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
UBMagnifier *magniferControlViewWidget; UBMagnifier *magniferControlViewWidget;
UBMagnifier *magniferDisplayViewWidget; UBMagnifier *magniferDisplayViewWidget;
UBZLayerController mZLayerController; UBZLayerController *mZLayerController;
}; };

@ -109,10 +109,10 @@ void UBGraphicsVideoItem::showOnDisplayChanged(bool shown)
void UBGraphicsVideoItem::mousePressEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsVideoItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
QDrag* mDrag = new QDrag(event->widget()); // QDrag* mDrag = new QDrag(event->widget());
QMimeData* pMime = new QMimeData(); // QMimeData* pMime = new QMimeData();
mDrag->setMimeData(pMime); // mDrag->setMimeData(pMime);
mDrag->start(); // mDrag->start();
mShouldMove = (event->buttons() & Qt::LeftButton); mShouldMove = (event->buttons() & Qt::LeftButton);
mMousePressPos = event->scenePos(); mMousePressPos = event->scenePos();

@ -82,11 +82,13 @@ void UBGraphicsWidgetItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void UBGraphicsWidgetItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsWidgetItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
sendJSEnterEvent(); sendJSEnterEvent();
mDelegate->hoverEnterEvent(event);
UBGraphicsProxyWidget::hoverEnterEvent(event); UBGraphicsProxyWidget::hoverEnterEvent(event);
} }
void UBGraphicsWidgetItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void UBGraphicsWidgetItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{ {
sendJSLeaveEvent(); sendJSLeaveEvent();
mDelegate->hoverLeaveEvent(event);
UBGraphicsProxyWidget::hoverLeaveEvent(event); UBGraphicsProxyWidget::hoverLeaveEvent(event);
} }

@ -29,7 +29,7 @@ UBItem::~UBItem()
// NOOP // NOOP
} }
void UBGraphicsItem::assignZValue(QGraphicsItem *item, int value) void UBGraphicsItem::assignZValue(QGraphicsItem *item, qreal value)
{ {
item->setZValue(value); item->setZValue(value);
item->setData(UBGraphicsItemData::ItemOwnZValue, value); item->setData(UBGraphicsItemData::ItemOwnZValue, value);

@ -101,7 +101,7 @@ protected:
public: public:
static void assignZValue(QGraphicsItem*, int value); static void assignZValue(QGraphicsItem*, qreal value);
virtual UBGraphicsItemDelegate *Delegate() const = 0; virtual UBGraphicsItemDelegate *Delegate() const = 0;
virtual void remove() = 0; virtual void remove() = 0;

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

@ -1,388 +1,402 @@
/* /*
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <QtGui> #include <QtGui>
#include "UBMagnifer.h" #include "UBMagnifer.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "board/UBBoardController.h" #include "board/UBBoardController.h"
#include "domain/UBGraphicsScene.h" #include "domain/UBGraphicsScene.h"
#include "board/UBBoardView.h"
#include "core/memcheck.h"
#include "core/memcheck.h"
UBMagnifier::UBMagnifier(QWidget *parent, bool isInteractive)
: QWidget(parent, parent ? Qt::Widget : Qt::Tool | (Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint)) UBMagnifier::UBMagnifier(QWidget *parent, bool isInteractive)
, mShouldMoveWidget(false) : QWidget(parent, parent ? Qt::Widget : Qt::Tool | (Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint))
, mShouldResizeWidget(false) , mShouldMoveWidget(false)
, inTimer(false) , mShouldResizeWidget(false)
, borderPen(Qt::darkGray) , borderPen(Qt::darkGray)
, gView(0) , gView(0)
, mView(0) , mView(0)
{ {
isCusrsorAlreadyStored = false; isCusrsorAlreadyStored = false;
setMouseTracking(true); setMouseTracking(true);
//--------------------------------------------------// //--------------------------------------------------//
QPixmap pix(":/images/cursors/resize.png"); QPixmap pix(":/images/cursors/resize.png");
QTransform tr; QTransform tr;
tr.rotate(45); tr.rotate(45);
mResizeCursor = QCursor(pix.transformed(tr, Qt::SmoothTransformation), pix.width() / 2, pix.height() / 2); mResizeCursor = QCursor(pix.transformed(tr, Qt::SmoothTransformation), pix.width() / 2, pix.height() / 2);
//--------------------------------------------------// //--------------------------------------------------//
params.sizePercentFromScene = 20; params.sizePercentFromScene = 20;
m_isInteractive = isInteractive; m_isInteractive = isInteractive;
sClosePixmap = new QPixmap(":/images/close.svg"); sClosePixmap = new QPixmap(":/images/close.svg");
sIncreasePixmap = new QPixmap(":/images/increase.svg"); sIncreasePixmap = new QPixmap(":/images/increase.svg");
sDecreasePixmap = new QPixmap(":/images/decrease.svg"); sDecreasePixmap = new QPixmap(":/images/decrease.svg");
mResizeItem = new QPixmap(":/images/resize.svg"); mResizeItem = new QPixmap(":/images/resize.svg");
if (parent) if (parent)
{ {
setAttribute(Qt::WA_NoMousePropagation); setAttribute(Qt::WA_NoMousePropagation);
} }
else else
{ {
// standalone window // standalone window
// !!!! Should be included into Windows after QT recompilation // !!!! Should be included into Windows after QT recompilation
#ifndef Q_WS_WIN #ifndef Q_WS_WIN
// setAttribute(Qt::WA_TranslucentBackground); // setAttribute(Qt::WA_TranslucentBackground);
setAttribute(Qt::WA_MacAlwaysShowToolWindow); setAttribute(Qt::WA_MacAlwaysShowToolWindow);
#endif #endif
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
setAttribute(Qt::WA_MacAlwaysShowToolWindow); setAttribute(Qt::WA_MacAlwaysShowToolWindow);
setAttribute(Qt::WA_MacNonActivatingToolWindow); setAttribute(Qt::WA_MacNonActivatingToolWindow);
setAttribute(Qt::WA_MacNoShadow); setAttribute(Qt::WA_MacNoShadow);
#endif #endif
} }
} connect(&mRefreshTimer, SIGNAL(timeout()), this, SLOT(slot_refresh()));
}
UBMagnifier::~UBMagnifier()
{ UBMagnifier::~UBMagnifier()
if (timerUpdate != 0) {
{ if(sClosePixmap)
killTimer(timerUpdate); {
timerUpdate = 0; delete sClosePixmap;
} sClosePixmap = NULL;
}
if(sClosePixmap)
{ if(sIncreasePixmap)
delete sClosePixmap; {
sClosePixmap = NULL; delete sIncreasePixmap;
} sIncreasePixmap = NULL;
}
if(sIncreasePixmap)
{ if(sDecreasePixmap)
delete sIncreasePixmap; {
sIncreasePixmap = NULL; delete sDecreasePixmap;
} sDecreasePixmap = NULL;
}
if(sDecreasePixmap) }
{
delete sDecreasePixmap; void UBMagnifier::setSize(qreal percentFromScene)
sDecreasePixmap = NULL; {
} if(gView == NULL || mView == NULL) return;
}
// calculate object size
void UBMagnifier::setSize(qreal percentFromScene) params.sizePercentFromScene = percentFromScene;
{ QSize sceneSize = mView->size();
if(gView == NULL || mView == NULL) return; qreal size = params.sizePercentFromScene * sceneSize.width() / 100;
// calculate object size QRect currGeom = geometry();
params.sizePercentFromScene = percentFromScene; if(currGeom.width() == currGeom.height())
QSize sceneSize = mView->size(); {
qreal size = params.sizePercentFromScene * sceneSize.width() / 100; QPoint newPos = mView->mapFromGlobal(updPointMove);
setGeometry(newPos.x() - size / 2, newPos.y() - size / 2, size, size);
QRect currGeom = geometry(); }
if(currGeom.width() == currGeom.height()) else
{ setGeometry(0, 0, size, size);
QPoint newPos = mView->mapFromGlobal(updPointMove);
setGeometry(newPos.x() - size / 2, newPos.y() - size / 2, size, size); // prepare transparent bit mask
} QImage mask_img(width(), height(), QImage::Format_Mono);
else mask_img.fill(0xff);
setGeometry(0, 0, size, size); QPainter mask_ptr(&mask_img);
mask_ptr.setBrush( QBrush( QColor(0, 0, 0) ) );
// prepare transparent bit mask mask_ptr.drawEllipse(QPointF(size/2, size/2), size / 2 - sClosePixmap->width(), size / 2 - sClosePixmap->width());
QImage mask_img(width(), height(), QImage::Format_Mono); bmpMask = QBitmap::fromImage(mask_img);
mask_img.fill(0xff);
QPainter mask_ptr(&mask_img); // prepare general image
mask_ptr.setBrush( QBrush( QColor(0, 0, 0) ) ); pMap = QPixmap(width(), height());
mask_ptr.drawEllipse(QPointF(size/2, size/2), size / 2 - sClosePixmap->width(), size / 2 - sClosePixmap->width()); pMap.fill(Qt::transparent);
bmpMask = QBitmap::fromImage(mask_img); pMap.setMask(bmpMask);
}
// prepare general image
pMap = QPixmap(width(), height()); void UBMagnifier::setZoom(qreal zoom)
pMap.fill(Qt::transparent); {
pMap.setMask(bmpMask); params.zoom = zoom;
} }
void UBMagnifier::setZoom(qreal zoom) void UBMagnifier::paintEvent(QPaintEvent * event)
{ {
params.zoom = zoom; Q_UNUSED(event);
} QPainter painter(this);
void UBMagnifier::paintEvent(QPaintEvent * event) painter.setRenderHint(QPainter::Antialiasing);
{ painter.setPen(Qt::NoPen);
Q_UNUSED(event);
QPainter painter(this); if (m_isInteractive)
{
painter.setRenderHint(QPainter::Antialiasing); painter.setBrush(QColor(127, 127, 127, 127));
painter.setPen(Qt::NoPen); painter.drawRoundedRect(QRectF(size().width() / 2, size().height() / 2, ( size().width() - sClosePixmap->width() ) / 2, ( size().height() - sClosePixmap->width() ) / 2), 15, 15);
if (m_isInteractive) painter.setBrush(QColor(190, 190, 190, 255));
{ painter.drawEllipse(QPoint( size().width() / 2, size().height() / 2), ( size().width() - sClosePixmap->width() ) / 2, ( size().height() - sClosePixmap->height() ) / 2);
painter.setBrush(QColor(127, 127, 127, 127));
painter.drawRoundedRect(QRectF(size().width() / 2, size().height() / 2, ( size().width() - sClosePixmap->width() ) / 2, ( size().height() - sClosePixmap->width() ) / 2), 15, 15); painter.drawPixmap(size().width() - sClosePixmap->width(), size().height() / 2 + sClosePixmap->height() * 1, *sClosePixmap);
painter.drawPixmap(size().width() - sIncreasePixmap->width(), size().height() / 2 + sIncreasePixmap->height() * 2.5, *sIncreasePixmap);
painter.setBrush(QColor(190, 190, 190, 255)); painter.drawPixmap(size().width() - sDecreasePixmap->width(), size().height() / 2 + sDecreasePixmap->height() * 3.6, *sDecreasePixmap);
painter.drawEllipse(QPoint( size().width() / 2, size().height() / 2), ( size().width() - sClosePixmap->width() ) / 2, ( size().height() - sClosePixmap->height() ) / 2);
painter.drawPixmap(size().width() - mResizeItem->width() - 20, size().height() - mResizeItem->height() - 20, *mResizeItem);
painter.drawPixmap(size().width() - sClosePixmap->width(), size().height() / 2 + sClosePixmap->height() * 1, *sClosePixmap); }
painter.drawPixmap(size().width() - sIncreasePixmap->width(), size().height() / 2 + sIncreasePixmap->height() * 2.5, *sIncreasePixmap); else
painter.drawPixmap(size().width() - sDecreasePixmap->width(), size().height() / 2 + sDecreasePixmap->height() * 3.6, *sDecreasePixmap); {
painter.setBrush(QColor(127, 127, 127, 127));
painter.drawPixmap(size().width() - mResizeItem->width() - 20, size().height() - mResizeItem->height() - 20, *mResizeItem); painter.drawEllipse(QPoint( size().width() / 2, size().height() / 2), ( size().width() - sClosePixmap->width() ) / 2, ( size().height() - sClosePixmap->height() ) / 2);
} }
else
{ painter.drawPixmap(0, 0, pMap);
painter.setBrush(QColor(127, 127, 127, 127)); }
painter.drawEllipse(QPoint( size().width() / 2, size().height() / 2), ( size().width() - sClosePixmap->width() ) / 2, ( size().height() - sClosePixmap->height() ) / 2);
} void UBMagnifier::mousePressEvent ( QMouseEvent * event )
{
painter.drawPixmap(0, 0, pMap); if(m_isInteractive)
} {
void UBMagnifier::mousePressEvent ( QMouseEvent * event ) QWidget::mousePressEvent(event);
{
if(m_isInteractive) if (event->pos().x() >= size().width() - mResizeItem->width() - 20 &&
{ event->pos().x() < size().width() - 20 &&
event->pos().y() >= size().height() - mResizeItem->height() - 20 &&
QWidget::mousePressEvent(event); event->pos().y() < size().height() - - 20)
{
if (event->pos().x() >= size().width() - mResizeItem->width() - 20 && mShouldResizeWidget = true;
event->pos().x() < size().width() - 20 && }
event->pos().y() >= size().height() - mResizeItem->height() - 20 && else
event->pos().y() < size().height() - - 20) {
{ mShouldMoveWidget = !event->isAccepted() && (event->buttons() & Qt::LeftButton);
mShouldResizeWidget = true; }
}
else mMousePressPos = event->pos();
{ mMousePressDelta = (qreal)updPointGrab.x() + (qreal)size().width() / 2 - (qreal)event->globalPos().x();
mShouldMoveWidget = !event->isAccepted() && (event->buttons() & Qt::LeftButton);
} event->accept();
mMousePressPos = event->pos(); update();
mMousePressDelta = (qreal)updPointGrab.x() + (qreal)size().width() / 2 - (qreal)event->globalPos().x(); }
else
event->accept(); event->ignore();
}
update();
} void UBMagnifier::mouseMoveEvent ( QMouseEvent * event )
else {
event->ignore(); if(m_isInteractive)
} {
if(mShouldMoveWidget && (event->buttons() & Qt::LeftButton))
void UBMagnifier::mouseMoveEvent ( QMouseEvent * event ) {
{ move(pos() - mMousePressPos + event->pos());
if(m_isInteractive) event->accept();
{
if(mShouldMoveWidget && (event->buttons() & Qt::LeftButton)) QWidget::mouseMoveEvent(event);
{ emit magnifierMoved_Signal(QPoint(this->pos().x() + size().width() / 2, this->pos().y() + size().height() / 2 ));
move(pos() - mMousePressPos + event->pos()); return;
event->accept(); }
QWidget::mouseMoveEvent(event); if(mShouldResizeWidget && (event->buttons() & Qt::LeftButton))
emit magnifierMoved_Signal(QPoint(this->pos().x() + size().width() / 2, this->pos().y() + size().height() / 2 )); {
return;
} QPoint currGlobalPos = event->globalPos();
qreal cvW = mView->width();
if(mShouldResizeWidget && (event->buttons() & Qt::LeftButton))
{ qreal newXSize = ( currGlobalPos.x() + mMousePressDelta - updPointGrab.x() ) * 2;
qreal newPercentSize = newXSize * 100 / cvW;
QPoint currGlobalPos = event->globalPos();
qreal cvW = mView->width(); emit magnifierResized_Signal(newPercentSize);
qreal newXSize = ( currGlobalPos.x() + mMousePressDelta - updPointGrab.x() ) * 2; event->ignore();
qreal newPercentSize = newXSize * 100 / cvW; return;
}
emit magnifierResized_Signal(newPercentSize);
if (event->pos().x() >= size().width() - mResizeItem->width() - 20 &&
event->ignore(); event->pos().x() < size().width() - 20 &&
return; event->pos().y() >= size().height() - mResizeItem->height() - 20 &&
} event->pos().y() < size().height() - - 20 &&
isCusrsorAlreadyStored == false
if (event->pos().x() >= size().width() - mResizeItem->width() - 20 && )
event->pos().x() < size().width() - 20 && {
event->pos().y() >= size().height() - mResizeItem->height() - 20 && mOldCursor = cursor();
event->pos().y() < size().height() - - 20 && isCusrsorAlreadyStored = true;
isCusrsorAlreadyStored == false setCursor(mResizeCursor);
) }
{
mOldCursor = cursor(); }
isCusrsorAlreadyStored = true; else
setCursor(mResizeCursor); event->ignore();
} }
}
else void UBMagnifier::mouseReleaseEvent(QMouseEvent * event)
event->ignore(); {
} if(m_isInteractive)
{
mShouldMoveWidget = false;
void UBMagnifier::mouseReleaseEvent(QMouseEvent * event) mShouldResizeWidget = false;
{
if(m_isInteractive) if (event->pos().x() >= size().width() - sClosePixmap->width() &&
{ event->pos().x() < size().width()&&
mShouldMoveWidget = false; event->pos().y() >= size().height() / 2 + sClosePixmap->height() * 1 &&
mShouldResizeWidget = false; event->pos().y() < size().height() / 2 + sClosePixmap->height() * 2)
{
if (event->pos().x() >= size().width() - sClosePixmap->width() && event->accept();
event->pos().x() < size().width()&& emit magnifierClose_Signal();
event->pos().y() >= size().height() / 2 + sClosePixmap->height() * 1 && }
event->pos().y() < size().height() / 2 + sClosePixmap->height() * 2) else
{ if (event->pos().x() >= size().width() - sIncreasePixmap->width() &&
event->accept(); event->pos().x() < size().width()&&
emit magnifierClose_Signal(); event->pos().y() >= size().height() / 2 + sIncreasePixmap->height() * 2.5 &&
} event->pos().y() < size().height() / 2 + sIncreasePixmap->height() * 3.5)
else {
if (event->pos().x() >= size().width() - sIncreasePixmap->width() && event->accept();
event->pos().x() < size().width()&& emit magnifierZoomIn_Signal();
event->pos().y() >= size().height() / 2 + sIncreasePixmap->height() * 2.5 && }
event->pos().y() < size().height() / 2 + sIncreasePixmap->height() * 3.5) else
{ if (event->pos().x() >= size().width() - sDecreasePixmap->width() &&
event->accept(); event->pos().x() < size().width()&&
emit magnifierZoomIn_Signal(); event->pos().y() >= size().height() / 2 + sDecreasePixmap->height() * 3.6 &&
} event->pos().y() < size().height() / 2 + sDecreasePixmap->height() * 4.6)
else {
if (event->pos().x() >= size().width() - sDecreasePixmap->width() && event->accept();
event->pos().x() < size().width()&& emit magnifierZoomOut_Signal();
event->pos().y() >= size().height() / 2 + sDecreasePixmap->height() * 3.6 && }
event->pos().y() < size().height() / 2 + sDecreasePixmap->height() * 4.6) else
{ QWidget::mouseReleaseEvent(event); // don't propgate to parent, the widget is deleted in UBApplication::boardController->removeTool
event->accept(); }
emit magnifierZoomOut_Signal(); else
} event->ignore();
else
QWidget::mouseReleaseEvent(event); // don't propgate to parent, the widget is deleted in UBApplication::boardController->removeTool }
}
else void UBMagnifier::slot_refresh()
event->ignore(); {
if(!(updPointGrab.isNull()))
} grabPoint(updPointGrab);
void UBMagnifier::timerEvent(QTimerEvent *e) if(isCusrsorAlreadyStored)
{ {
if(inTimer) return; QPoint globalCursorPos = QCursor::pos();
if (e->timerId() == timerUpdate) QPoint cursorPos = mapFromGlobal(globalCursorPos);
{ if (cursorPos.x() < size().width() - mResizeItem->width() - 20 ||
inTimer = true; cursorPos.x() > size().width() - 20 ||
if(!(updPointGrab.isNull())) cursorPos.y() < size().height() - mResizeItem->height() - 20 ||
grabPoint(updPointGrab); cursorPos.y() > size().height() - - 20
)
if(isCusrsorAlreadyStored) {
{ isCusrsorAlreadyStored = false;
QPoint globalCursorPos = QCursor::pos(); setCursor(mOldCursor);
QPoint cursorPos = mapFromGlobal(globalCursorPos); }
if (cursorPos.x() < size().width() - mResizeItem->width() - 20 || }
cursorPos.x() > size().width() - 20 || }
cursorPos.y() < size().height() - mResizeItem->height() - 20 ||
cursorPos.y() > size().height() - - 20 void UBMagnifier::grabPoint()
) {
{ QMatrix transM = UBApplication::boardController->controlView()->matrix();
isCusrsorAlreadyStored = false; QPointF itemPos = gView->mapFromGlobal(updPointGrab);
setCursor(mOldCursor);
} qreal zWidth = width() / (params.zoom * transM.m11());
qreal zWidthHalf = zWidth / 2;
} qreal zHeight = height() / (params.zoom * transM.m22());
qreal zHeightHalf = zHeight / 2;
inTimer = false;
}
} QPointF pfScLtF(UBApplication::boardController->controlView()->mapToScene(QPoint(itemPos.x(), itemPos.y())));
void UBMagnifier::grabPoint()
{ QRect magnifierRect = rect();
QPointF itemPos = gView->mapFromGlobal(updPointGrab);
float x = pfScLtF.x() - zWidthHalf;
qreal zWidth = size().width() / params.zoom; float y = pfScLtF.y() - zHeightHalf;
qreal zWidthHalf = zWidth / 2;
qreal zHeight = size().height() / params.zoom; QPointF leftTop(x,y);
qreal zHeightHalf = zHeight / 2; QPointF rightBottom(x + zWidth, y + zHeight);
QRectF srcRect(leftTop, rightBottom);
int x = itemPos.x() - zWidthHalf;
int y = itemPos.y() - zHeightHalf; QPixmap newPixMap(QSize(width(), height()));
QPainter painter(&newPixMap);
QPixmap newPixMap(QSize(zWidth,zHeight));
((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight)); UBApplication::boardController->activeScene()->render(&painter, QRectF(0,0,width(),height()), srcRect);
UBApplication::boardController->activeScene()->update(); painter.end();
pMap.fill(Qt::transparent); pMap.fill(Qt::transparent);
pMap = newPixMap.scaled(QSize(width(), height())); pMap = newPixMap.scaled(QSize(width(), height()));
pMap.setMask(bmpMask); pMap.setMask(bmpMask);
update(); update();
} }
void UBMagnifier::grabPoint(const QPoint &pGrab) void UBMagnifier::grabPoint(const QPoint &pGrab)
{ {
updPointGrab = pGrab; QMatrix transM = UBApplication::boardController->controlView()->matrix();
QPointF itemPos = gView->mapFromGlobal(pGrab); updPointGrab = pGrab;
QPointF itemPos = gView->mapFromGlobal(pGrab);
qreal zWidth = size().width() / params.zoom;
qreal zWidthHalf = zWidth / 2; qreal zWidth = width() / (params.zoom * transM.m11());
qreal zHeight = size().height() / params.zoom; qreal zWidthHalf = zWidth / 2;
qreal zHeightHalf = zHeight / 2; qreal zHeight = height() / (params.zoom * transM.m22());
qreal zHeightHalf = zHeight / 2;
int x = itemPos.x() - zWidthHalf;
int y = itemPos.y() - zHeightHalf;
QPointF pfScLtF(UBApplication::boardController->controlView()->mapToScene(QPoint(itemPos.x(), itemPos.y())));
QPixmap newPixMap(QSize(zWidth,zHeight));
((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight));
UBApplication::boardController->activeScene()->update(); QRect magnifierRect = rect();
pMap.fill(Qt::transparent); float x = pfScLtF.x() - zWidthHalf;
pMap = newPixMap.scaled(QSize(width(), height())); float y = pfScLtF.y() - zHeightHalf;
pMap.setMask(bmpMask);
QPointF leftTop(x,y);
update(); QPointF rightBottom(x + zWidth, y + zHeight);
} QRectF srcRect(leftTop, rightBottom);
// from global QPixmap newPixMap(QSize(width(), height()));
void UBMagnifier::grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needGrab, bool needMove) QPainter painter(&newPixMap);
{
updPointGrab = pGrab; UBApplication::boardController->activeScene()->render(&painter, QRectF(0,0,width(),height()), srcRect);
updPointMove = pMove; painter.end();
if(needGrab) // pMap.fill(Qt::transparent);
grabPoint(pGrab); pMap = newPixMap;
pMap.setMask(bmpMask);
if(needMove)
{ update();
QPoint movePos = mView->mapFromGlobal(pMove); }
move(movePos.x() - width()/2, movePos.y() - height()/2);
// move(itemPos.x(), itemPos.y());
}
} // from global
void UBMagnifier::grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needGrab, bool needMove)
void UBMagnifier::setGrabView(QWidget *view) {
{ updPointGrab = pGrab;
if (timerUpdate != 0) updPointMove = pMove;
killTimer(timerUpdate);
gView = view; if(needGrab)
timerUpdate = startTimer(200); grabPoint(pGrab);
}
if(needMove)
{
QPoint movePos = mView->mapFromGlobal(pMove);
move(movePos.x() - width()/2, movePos.y() - height()/2);
// move(itemPos.x(), itemPos.y());
}
}
void UBMagnifier::setGrabView(QWidget *view)
{
gView = view;
mRefreshTimer.setInterval(40);
mRefreshTimer.start();
}

@ -1,96 +1,97 @@
/* /*
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef UBMAGNIFIER_H #ifndef UBMAGNIFIER_H
#define UBMAGNIFIER_H #define UBMAGNIFIER_H
#include <QtGui> #include <QtGui>
class UBMagnifierParams class UBMagnifierParams
{ {
public : public :
int x; int x;
int y; int y;
qreal zoom; qreal zoom;
qreal sizePercentFromScene; qreal sizePercentFromScene;
}; };
class UBMagnifier : public QWidget class UBMagnifier : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
UBMagnifier(QWidget *parent = 0, bool isInteractive = false); UBMagnifier(QWidget *parent = 0, bool isInteractive = false);
~UBMagnifier(); ~UBMagnifier();
void setSize(qreal percentFromScene); void setSize(qreal percentFromScene);
void setZoom(qreal zoom); void setZoom(qreal zoom);
void setGrabView(QWidget *view); void setGrabView(QWidget *view);
void setMoveView(QWidget *view) {mView = view;} void setMoveView(QWidget *view) {mView = view;}
void grabPoint(); void grabPoint();
void grabPoint(const QPoint &point); void grabPoint(const QPoint &point);
void grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needGrab = true, bool needMove = true); void grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needGrab = true, bool needMove = true);
UBMagnifierParams params; UBMagnifierParams params;
signals: signals:
void magnifierMoved_Signal(QPoint newPos); void magnifierMoved_Signal(QPoint newPos);
void magnifierClose_Signal(); void magnifierClose_Signal();
void magnifierZoomIn_Signal(); void magnifierZoomIn_Signal();
void magnifierZoomOut_Signal(); void magnifierZoomOut_Signal();
void magnifierResized_Signal(qreal newPercentSize); void magnifierResized_Signal(qreal newPercentSize);
protected: public slots:
void paintEvent(QPaintEvent *); void slot_refresh();
void timerEvent(QTimerEvent *);
protected:
virtual void mousePressEvent ( QMouseEvent * event ); void paintEvent(QPaintEvent *);
virtual void mouseMoveEvent ( QMouseEvent * event );
virtual void mouseReleaseEvent ( QMouseEvent * event ); virtual void mousePressEvent ( QMouseEvent * event );
virtual void mouseMoveEvent ( QMouseEvent * event );
QPoint mMousePressPos; virtual void mouseReleaseEvent ( QMouseEvent * event );
qreal mMousePressDelta;
bool mShouldMoveWidget; QPoint mMousePressPos;
bool mShouldResizeWidget; qreal mMousePressDelta;
bool mShouldMoveWidget;
bool mShouldResizeWidget;
QPixmap *sClosePixmap;
QPixmap *sIncreasePixmap;
QPixmap *sDecreasePixmap; QPixmap *sClosePixmap;
QPixmap *mResizeItem; QPixmap *sIncreasePixmap;
QPixmap *sDecreasePixmap;
bool isCusrsorAlreadyStored; QPixmap *mResizeItem;
QCursor mOldCursor;
QCursor mResizeCursor; bool isCusrsorAlreadyStored;
QCursor mOldCursor;
private: QCursor mResizeCursor;
bool inTimer;
bool m_isInteractive; private:
QTimer mRefreshTimer;
int timerUpdate; bool m_isInteractive;
QPoint updPointGrab;
QPoint updPointMove; QPoint updPointGrab;
QPoint updPointMove;
QPixmap pMap;
QBitmap bmpMask; QPixmap pMap;
QPen borderPen; QBitmap bmpMask;
QPen borderPen;
QWidget *gView;
QWidget *mView; QWidget *gView;
}; QWidget *mView;
};
#endif // UBMAGNIFIER_H
#endif // UBMAGNIFIER_H

@ -44,7 +44,7 @@ class UBGraphicsRuler : public UBAbstractDrawRuler, public QGraphicsRectItem, pu
virtual void StartLine(const QPointF& position, qreal width); virtual void StartLine(const QPointF& position, qreal width);
virtual void DrawLine(const QPointF& position, qreal width); virtual void DrawLine(const QPointF& position, qreal width);
virtual void EndLine(); virtual void EndLine();
protected: protected:

@ -196,6 +196,36 @@ void WBBrowserWindow::setupToolBar()
mTabWidget->addWebAction(mUniboardMainWindow->actionWebReload, QWebPage::Reload); mTabWidget->addWebAction(mUniboardMainWindow->actionWebReload, QWebPage::Reload);
mTabWidget->addWebAction(mUniboardMainWindow->actionStopLoading, QWebPage::Stop); mTabWidget->addWebAction(mUniboardMainWindow->actionStopLoading, QWebPage::Stop);
mHistoryBackMenu = new QMenu(this);
connect(mHistoryBackMenu, SIGNAL(aboutToShow()),this, SLOT(aboutToShowBackMenu()));
connect(mHistoryBackMenu, SIGNAL(triggered(QAction *)), this, SLOT(openActionUrl(QAction *)));
foreach (QWidget* menuWidget, mUniboardMainWindow->actionWebBack->associatedWidgets())
{
QToolButton *tb = qobject_cast<QToolButton*>(menuWidget);
if (tb && !tb->menu())
{
tb->setMenu(mHistoryBackMenu);
tb->setStyleSheet("QToolButton::menu-indicator { subcontrol-position: bottom left; }");
}
}
mHistoryForwardMenu = new QMenu(this);
connect(mHistoryForwardMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowForwardMenu()));
connect(mHistoryForwardMenu, SIGNAL(triggered(QAction *)), this, SLOT(openActionUrl(QAction *)));
foreach (QWidget* menuWidget, mUniboardMainWindow->actionWebForward->associatedWidgets())
{
QToolButton *tb = qobject_cast<QToolButton*>(menuWidget);
if (tb && !tb->menu())
{
tb->setMenu(mHistoryForwardMenu);
tb->setStyleSheet("QToolButton { padding-right: 8px; }");
}
}
mWebToolBar->insertWidget(mUniboardMainWindow->actionWebBigger, mTabWidget->lineEditStack()); mWebToolBar->insertWidget(mUniboardMainWindow->actionWebBigger, mTabWidget->lineEditStack());
mSearchToolBar = new WBToolbarSearch(mWebToolBar); mSearchToolBar = new WBToolbarSearch(mWebToolBar);
@ -224,6 +254,22 @@ void WBBrowserWindow::setupToolBarForTutorial()
mTabWidget->addWebAction(mUniboardMainWindow->actionWebBack, QWebPage::Back); mTabWidget->addWebAction(mUniboardMainWindow->actionWebBack, QWebPage::Back);
mTabWidget->addWebAction(mUniboardMainWindow->actionWebForward, QWebPage::Forward); mTabWidget->addWebAction(mUniboardMainWindow->actionWebForward, QWebPage::Forward);
foreach (QWidget* menuWidget, mUniboardMainWindow->actionWebBack->associatedWidgets())
{
QToolButton *tb = qobject_cast<QToolButton*>(menuWidget);
if (tb && tb->menu())
tb->setMenu(NULL);
}
foreach (QWidget* menuWidget, mUniboardMainWindow->actionWebForward->associatedWidgets())
{
QToolButton *tb = qobject_cast<QToolButton*>(menuWidget);
if (tb && tb->menu())
tb->setMenu(NULL);
}
// mTabWidget->addWebAction(mUniboardMainWindow->actionWebReload, QWebPage::Reload); // mTabWidget->addWebAction(mUniboardMainWindow->actionWebReload, QWebPage::Reload);
// mTabWidget->addWebAction(mUniboardMainWindow->actionStopLoading, QWebPage::Stop); // mTabWidget->addWebAction(mUniboardMainWindow->actionStopLoading, QWebPage::Stop);
@ -534,4 +580,86 @@ void WBBrowserWindow::showTabAtTop(bool attop)
mTabWidget->setTabPosition(QTabWidget::South); mTabWidget->setTabPosition(QTabWidget::South);
} }
void WBBrowserWindow::aboutToShowBackMenu()
{
mHistoryBackMenu->clear();
if (!currentTabWebView())
return;
QWebHistory *history = currentTabWebView()->history();
int historyCount = history->count();
int historyLimit = history->backItems(historyCount).count() - UBSettings::settings()->historyLimit->get().toReal();
if (historyLimit < 0)
historyLimit = 0;
for (int i = history->backItems(historyCount).count() - 1; i >= historyLimit; --i)
{
QWebHistoryItem item = history->backItems(historyCount).at(i);
QAction *action = new QAction(this);
action->setData(-1*(historyCount-i-1));
if (!QWebSettings::iconForUrl(item.originalUrl()).isNull())
action->setIcon(item.icon());
action->setText(item.title().isEmpty() ? item.url().toString() : item.title());
mHistoryBackMenu->addAction(action);
}
mHistoryBackMenu->addSeparator();
QAction *action = new QAction(this);
action->setData("clear");
action->setText("Clear history");
mHistoryBackMenu->addAction(action);
}
void WBBrowserWindow::aboutToShowForwardMenu()
{
mHistoryForwardMenu->clear();
if (!currentTabWebView())
return;
QWebHistory *history = currentTabWebView()->history();
int historyCount = history->count();
int historyLimit = history->forwardItems(historyCount).count();
if (historyLimit > UBSettings::settings()->historyLimit->get().toReal())
historyLimit = UBSettings::settings()->historyLimit->get().toReal();
for (int i = 0; i < historyLimit; ++i)
{
QWebHistoryItem item = history->forwardItems(historyCount).at(i);
QAction *action = new QAction(this);
action->setData(historyCount-i);
if (!QWebSettings::iconForUrl(item.originalUrl()).isNull())
action->setIcon(item.icon());
action->setText(item.title().isEmpty() ? item.url().toString() : item.title());
mHistoryForwardMenu->addAction(action);
}
mHistoryForwardMenu->addSeparator();
QAction *action = new QAction(this);
action->setData("clear");
action->setText("Clear history");
mHistoryForwardMenu->addAction(action);
}
void WBBrowserWindow::openActionUrl(QAction *action)
{
QWebHistory *history = currentTabWebView()->history();
if (action->data() == "clear")
{
history->clear();
return;
}
int offset = action->data().toInt();
if (offset < 0)
history->goToItem(history->backItems(-1*offset).first());
else if (offset > 0)
history->goToItem(history->forwardItems(history->count() - offset + 1).back());
}

@ -112,6 +112,10 @@ class WBBrowserWindow : public QWidget
void showTabAtTop(bool attop); void showTabAtTop(bool attop);
void aboutToShowBackMenu();
void aboutToShowForwardMenu();
void openActionUrl(QAction *action);
signals: signals:
void activeViewPageChanged(); void activeViewPageChanged();
void activeViewChange(QWidget*); void activeViewChange(QWidget*);
@ -160,6 +164,9 @@ class WBBrowserWindow : public QWidget
QString mLastSearch; QString mLastSearch;
Ui::MainWindow* mUniboardMainWindow; Ui::MainWindow* mUniboardMainWindow;
QMenu *mHistoryBackMenu;
QMenu *mHistoryForwardMenu;
}; };
#endif // WBBROWSERMAINWINDOW_H #endif // WBBROWSERMAINWINDOW_H

Loading…
Cancel
Save