diff --git a/resources/library/applications/Notes.wgt/js/ubw-main.js b/resources/library/applications/Notes.wgt/js/ubw-main.js index cea778fa..de5c2ed3 100644 --- a/resources/library/applications/Notes.wgt/js/ubw-main.js +++ b/resources/library/applications/Notes.wgt/js/ubw-main.js @@ -199,7 +199,7 @@ function init(){ if(text) textField.html(text); else - textField.html("Enter your notes here ..."); + textField.html("Saisir votre texte ici ..."); textField.focus(); } diff --git a/resources/library/applications/iCell.wgt/js/textes_descriptifs.js b/resources/library/applications/iCell.wgt/js/textes_descriptifs.js index 003d0c8e..0533292f 100644 --- a/resources/library/applications/iCell.wgt/js/textes_descriptifs.js +++ b/resources/library/applications/iCell.wgt/js/textes_descriptifs.js @@ -147,64 +147,64 @@ switch(lang){ break; case "fr": txt_vesicule = "

Vesicule
Transporteurs

"+ - "

Structure:

Bicouche phospholipidique

"+ - "

Role:

Transport de proteines ou d'autres elements a l'interieur de la cellule, vers l'exterieur (exocytose) ou vers l'interieur (endocytose).

"+ - '

Fonctionnement:

Transporteur "remorque" par des proteines prenant appui sur le cytosquelette.

' + "

Structure :

Bicouche phospholipidique

"+ + "

Rôle :

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).

"+ + '

Fonctionnement :

Transporteur "remorque" par des protéines prenant appui sur le cytosquelette.

' txt_lysosome = "

Lysosome
Estomacs cellulaires

"+ - "

Structure:

Bicouche phospholipidique

"+ - "

Role:

Digestion intra-cellulaire a l'aide d'enzymes

"+ - "

Fonctionnement:

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.

" + "

Structure :

Bicouche phospholipidique

"+ + "

Role :

Digestion intracellulaire à l'aide d'enzymes

"+ + "

Fonctionnement :

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.

" txt_mitoch = "

Mitochondrie
Piles

"+ - "

Structure:

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.

"+ - "

Role:

Centrale energetique de la cellule.

"+ - "

Fonctionnement:

L'energie - sous forme d'ATP (adenosine triphosphate) - est issue de differentes etapes de reactions chimique partant d'une molecule de glucose.

" + "

Structure :

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.

"+ + "

Rôle :

Centrale énergétique de la cellule.

"+ + "

Fonctionnement :

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.

" txt_golgi = "

Appareil de Golgi
Usines miniatures

"+ - "

Structure:

Forme d'un empilement de saccules membranaires applatis.

"+ - "

Role:

Modification de certaines proteines au cours d'un cheminement au travers de ses saccules.

"+ - "

Fonctionnement:

Suite de reactions chimiques, notamment par glycosilation.

" + "

Structure :

Forme d'un empilement de saccules membranaires aplatis.

"+ + "

Rôle :

Modification de certaines protéines au cours d'un cheminement au travers de ses saccules.

"+ + "

Fonctionnement :

Suite de réactions chimiques, notamment par glycosilation.

" txt_rer = "

Reticulum endoplasmique rugueux - Tunnel

"+ - "

Structure:

Compose d'une bicouche phospholipidique piquetee de ribosomes (d'un aspect rugueux) delimitant la lumiere, un espace interne pouvant tre compare a un tunnel.

"+ - "

Role:

Plus specialise que le REL, il participe au transport et a la finalisation des proteines, qui sont synthetisees par les ribosomes.

"+ - '

Fonctionnement:

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.

' + "

Structure :

Composé d'une bicouche phospholipidique piquetée de ribosomes (d'un aspect rugueux) délimitant la lumière, un espace interne pouvant être comparé à un tunnel.

"+ + "

Rôle :

Plus spécialisé que le REL, il participe au transport et à la finalisation des protéines, qui sont synthétisées par les ribosomes.

"+ + '

Fonctionnement :

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.

' txt_noy = "

Noyau - Le coffre-fort

"+ - "

Structure:

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.

"+ - "

Role:

Stockage de la totalite des informations genetiques necessaires a la vie de la cellule.

"+ - "

Fonctionnement:

Site de la transcription (copie de l'information genetique sur des ARNm).

" + "

Structure :

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.

"+ + "

Rôle :

Stockage de la totalité des informations génétiques nécessaires à la vie de la cellule.

"+ + "

Fonctionnement :

Site de la transcription (copie de l'information génétique sur des ARNm).

" txt_rel = "

Reticulum endoplasmique lisse - REL

"+ - "

Structure:

Similaires a celle du RER, a la difference que sa membranne n'est pas parsemee de ribosomes, d'o son aspect lisse.

"+ - "

Role:

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.

"+ - "

Fonctionnement:

Il est le siege de beaucoup de reactions chimiques complexes (ex: detoxification, differentes syntheses).

" + "

Structure :

Similaire à celle du RER, à la différence que sa membrane n'est pas parsemée de ribosomes, d'où son aspect lisse.

"+ + "

Rôle :

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.

"+ + "

Fonctionnement :

Il est le siège de beaucoup de réactions chimiques complexes (ex : détoxification, différentes synthèses).

" txt_adn = "

ADN - Le livre de la vie

"+ - "

Structure:

echelle a la celebre forme de double helice composee de deux colonnes sucre-phosphate-sucre-phosphate-... et dont les echelons sont apelles bases azotees.

"+ - "

Role:

L'ADN contient toutes les informations necessaires a la vie.

"+ - "

Fonctionnement:

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.

" + "

Structure :

é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.

"+ + "

Rôle :

L'ADN contient toutes les informations nécessaires à la vie.

"+ + "

Fonctionnement :

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.

" - txt_centr= "

Centrioles - Remorqueurs de choromosomes

"+ - "

Structure:

Neuf triplets de microtubules entoures par un certain nombre de proteines.

"+ - "

Role:

Separer les differents chromosomes durant la division cellulaire.

"+ - "

Fonctionnement:

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.

" + txt_centr= "

Centrioles - Remorqueurs de chromosomes

"+ + "

Structure :

Neuf triplets de microtubules entourent par un certain nombre de protéines.

"+ + "

Rôle :

Séparer les différents chromosomes durant la division cellulaire.

"+ + "

Fonctionnement :

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.

" - txt_rib = "

Ribosome - Decodeurs

"+ - "

Structure:

Forme par deux sous-unites composees d'ARN ribosomique et de proteines.

"+ - "

Role:

Le ribosome synthetise les proteines.

"+ - "

Fonctionnement:

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.

" + txt_rib = "

Ribosome - Décodeurs

"+ + "

Structure :

Formé par deux sous-unités composées d'ARN ribosomique et de protéines.

"+ + "

Rôle :

Le ribosome synthétise les protéines.

"+ + "

Fonctionnement :

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.

" txt_arn = "

ARN - Multifonction

"+ - "

Structure:

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.

"+ - "

Role:

Multiples, il existe des ARN de transport, messagers, regulateus, guides, satellites, ...

"+ - "

Fonctionnement:

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.

" + "

Structure :

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.

"+ + "

Rôle :

Multiples, il existe des ARN de transport, messagers, régulateurs, guides, satellites...

"+ + "

Fonctionnement :

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.

" - txt_nucl = "

Nucleole - Fabrique d'ARN

"+ - "

Structure:

Compose d'aucune membranne, c'est un agglomerat de proteines et d'ARN.

"+ - "

Role:

Lieu de la transcription d'ARN, nottament d'ARNr (ribosomiques) qui, associes avec des proteines, vont former les deux sous-unites des ribosomes.

"+ - "

Fonctionnement:

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.

" + txt_nucl = "

Nucléole - Fabrique d'ARN

"+ + "

Structure :

Composé d'aucune membrane, c'est un agglomérat de protéines et d'ARN.

"+ + "

Rôle :

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.

"+ + "

Fonctionnement :

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.

" break; default: txt_vesicule = "

Vesicle
Transporter

"+ diff --git a/resources/library/interactivities/BlackYellow.wgt/locales/fr/scripts/blackYellow.js b/resources/library/interactivities/BlackYellow.wgt/locales/fr/scripts/blackYellow.js index 61b709f9..56976f82 100644 --- a/resources/library/interactivities/BlackYellow.wgt/locales/fr/scripts/blackYellow.js +++ b/resources/library/interactivities/BlackYellow.wgt/locales/fr/scripts/blackYellow.js @@ -13,7 +13,7 @@ * along with this program. If not, see . */ -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(){ diff --git a/resources/library/interactivities/Choisir.wgt/scripts/languages.js b/resources/library/interactivities/Choisir.wgt/scripts/languages.js index 071f5c67..a2989844 100644 --- a/resources/library/interactivities/Choisir.wgt/scripts/languages.js +++ b/resources/library/interactivities/Choisir.wgt/scripts/languages.js @@ -6,20 +6,20 @@ var sankoreLang = { "example_question":"This is an example of the question", "answer":"This is an example of the answer", "q":"Q", - "add_new_question":"Add new question ...", + "add_new_question":"Add a new question ...", "options":"Options", "close":"Close", - "delete_question":"Delete question", - "delete_answer":"Delete answer", + "delete_question":"Delete the question", + "delete_answer":"Delete a possibility", "right_answer":"Right answer", - "template_question":"Enter your question here ...", - "template_answer":"Enter the answer here ...", - "add_answer":"Add answer", + "template_question":"Enter a question here ...", + "template_answer":"Enter a possibility here ...", + "add_answer":"Add a possibility", "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.", - "radio_desc":"This option allow to choose one answer only and the answers are displayed as radio buttons.", - "checkbox_desc":"This option allow to choose several answers and the answers are displayed as checkboxes.", - "select_desc":"This option allow to chose one answer only and the answers are displayed as pull-down menu.", + "options_desc":"Types of question", + "radio_desc":"Option 1 : one right answer, possibilities are displayed as radio buttons.", + "checkbox_desc":"Option 2 : several right answers, possibilities are displayed as checkboxes.", + "select_desc":"Option 3 : one right answer, possibilities are displayed as pull-down menu.", "a":"A" }, "ru":{ @@ -59,7 +59,7 @@ var sankoreLang = { "delete_answer":"Supprimer la possibilité", "right_answer":"Bonne réponse", "template_question":"Saisir la question ici ...", - "template_answer":"Saisir la réponse ici ...", + "template_answer":"Saisir une possibilité ici ...", "add_answer":"Ajouter une possibilité", "select_text":"Choisir la bonne réponse", "options_desc":"Types de questions", diff --git a/resources/library/interactivities/associer_images.wgt/js/script.js b/resources/library/interactivities/associer_images.wgt/js/script.js index c850c3cb..633d943f 100644 --- a/resources/library/interactivities/associer_images.wgt/js/script.js +++ b/resources/library/interactivities/associer_images.wgt/js/script.js @@ -3,7 +3,7 @@ var sankoreLang = { edit: "Edit", short_desc: "Select the number \"three\".", add: "Add new block", - enter: "Enter your condition here ..." + enter: "Enter what to do here..." }; //main function diff --git a/resources/library/interactivities/categoriser_images.wgt/js/script.js b/resources/library/interactivities/categoriser_images.wgt/js/script.js index 0eef29e0..79e1647e 100644 --- a/resources/library/interactivities/categoriser_images.wgt/js/script.js +++ b/resources/library/interactivities/categoriser_images.wgt/js/script.js @@ -3,7 +3,7 @@ var sankoreLang = { edit: "Edit", first_desc: "Odd numbers", second_desc: "Even numbers", - enter: "Enter your category name here ...", + enter: "Enter a category name here ...", add: "Add new block" }; diff --git a/resources/library/interactivities/categoriser_text.wgt/js/script.js b/resources/library/interactivities/categoriser_text.wgt/js/script.js index 6e209d47..a6491291 100644 --- a/resources/library/interactivities/categoriser_text.wgt/js/script.js +++ b/resources/library/interactivities/categoriser_text.wgt/js/script.js @@ -3,12 +3,12 @@ var sankoreLang = { edit: "Edit", first_desc: "Fruits", second_desc: "Vegetables", - potatoes: "Potatoes", + potatoes: "Potato", carrot: "Carrot", onion: "Onion", apple: "Apple", pear: "Pear", - enter: "Enter your category name here ...", + enter: "Enter a category name here ...", add: "Add new block", text: "Some text" }; diff --git a/resources/library/interactivities/etudier.wgt/js/script.js b/resources/library/interactivities/etudier.wgt/js/script.js index 0c8dbd3d..074b169b 100644 --- a/resources/library/interactivities/etudier.wgt/js/script.js +++ b/resources/library/interactivities/etudier.wgt/js/script.js @@ -1,9 +1,9 @@ var sankoreLang = { display: "Display", 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_slide: "This is new slide." + new_slide: "This is a new slide." }; //some flags diff --git a/resources/library/interactivities/ord-words.wgt/locales/fr/scripts/template2.js b/resources/library/interactivities/ord-words.wgt/locales/fr/scripts/template2.js index 9418604a..fe887a32 100644 --- a/resources/library/interactivities/ord-words.wgt/locales/fr/scripts/template2.js +++ b/resources/library/interactivities/ord-words.wgt/locales/fr/scripts/template2.js @@ -29,7 +29,7 @@ function checkResponse() var sankoreLang = { view: "Afficher", edit: "Modifier", - example: "Il*y*a*longtemps*,*nous*Žtions*ˆ*la*mer*." + example: "Il*était*une*fois*..." }; var word = ""; diff --git a/resources/library/interactivities/ordonner_des_images.wgt/locales/fr/js/script.js b/resources/library/interactivities/ordonner_des_images.wgt/locales/fr/js/script.js index 7c8a2f19..45944117 100644 --- a/resources/library/interactivities/ordonner_des_images.wgt/locales/fr/js/script.js +++ b/resources/library/interactivities/ordonner_des_images.wgt/locales/fr/js/script.js @@ -1,10 +1,10 @@ var sankoreLang = { - display: "Affichage", + display: "Afficher", edit: "Modifier", - short_desc: "Placez les photos dans l'ordre croissant.", + short_desc: "Placer les photos dans l'ordre croissant.", add: "Nouveau bloc", - enter: "Saisissez votre texte ici ..." + enter: "Saisir votre texte ici ..." }; //main function diff --git a/resources/library/interactivities/ordonner_des_letters.wgt/locales/fr/js/script.js b/resources/library/interactivities/ordonner_des_letters.wgt/locales/fr/js/script.js index c0949d22..6530c52a 100644 --- a/resources/library/interactivities/ordonner_des_letters.wgt/locales/fr/js/script.js +++ b/resources/library/interactivities/ordonner_des_letters.wgt/locales/fr/js/script.js @@ -1,9 +1,9 @@ var sankoreLang = { - display: "D'affichage", + display: "Afficher", 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", - enter: "Entrez votre description ici ...", + enter: "Saisir la consigne ici ...", example: "exemple" }; diff --git a/resources/library/interactivities/selectionner.wgt/locales/fr/js/script.js b/resources/library/interactivities/selectionner.wgt/locales/fr/js/script.js index 7440523c..093aad50 100644 --- a/resources/library/interactivities/selectionner.wgt/locales/fr/js/script.js +++ b/resources/library/interactivities/selectionner.wgt/locales/fr/js/script.js @@ -1,9 +1,9 @@ var sankoreLang = { display: "Affichage", 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", - enter: "Saisissez votre texte ici ...", + enter: "Saisir le texte ici ...", cat: "chat", ball: "balle", shovel: "pelle", diff --git a/resources/library/interactivities/spl-phrase.wgt/locales/fr/scripts/wcontainer.js b/resources/library/interactivities/spl-phrase.wgt/locales/fr/scripts/wcontainer.js index cc1edff6..60ad007e 100644 --- a/resources/library/interactivities/spl-phrase.wgt/locales/fr/scripts/wcontainer.js +++ b/resources/library/interactivities/spl-phrase.wgt/locales/fr/scripts/wcontainer.js @@ -1,7 +1,7 @@ var sankoreLang = { - view: "D'affichage", + view: "Afficher", 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 diff --git a/resources/library/interactivities/spl-text.wgt/locales/fr/scripts/wcontainer.js b/resources/library/interactivities/spl-text.wgt/locales/fr/scripts/wcontainer.js index 46ac92a9..465f59fc 100644 --- a/resources/library/interactivities/spl-text.wgt/locales/fr/scripts/wcontainer.js +++ b/resources/library/interactivities/spl-text.wgt/locales/fr/scripts/wcontainer.js @@ -1,5 +1,5 @@ var sankoreLang = { - view: "D'affichage", + view: "Afficher", 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." }; diff --git a/resources/library/interactivities/spl-word.wgt/locales/fr/scripts/wcontainer.js b/resources/library/interactivities/spl-word.wgt/locales/fr/scripts/wcontainer.js index 1f3edcca..f2ad8832 100644 --- a/resources/library/interactivities/spl-word.wgt/locales/fr/scripts/wcontainer.js +++ b/resources/library/interactivities/spl-word.wgt/locales/fr/scripts/wcontainer.js @@ -1,5 +1,5 @@ var sankoreLang = { - view: "D'affichage", + view: "Afficher", edit: "Modifier", example: "so*phis*ti*qué" }; diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp index b39b7d25..33a5a091 100644 --- a/src/adaptors/UBSvgSubsetAdaptor.cpp +++ b/src/adaptors/UBSvgSubsetAdaptor.cpp @@ -2559,7 +2559,6 @@ UBGraphicsRuler* UBSvgSubsetAdaptor::UBSvgSubsetReader::rulerFromSvg() graphicsItemFromSvg(ruler); - UBGraphicsItem::assignZValue(ruler, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetRuler); ruler->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); QStringRef svgWidth = mXmlReader.attributes().value("width"); @@ -2617,7 +2616,6 @@ UBGraphicsCompass* UBSvgSubsetAdaptor::UBSvgSubsetReader::compassFromSvg() graphicsItemFromSvg(compass); - UBGraphicsItem::assignZValue(compass, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCompass); compass->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); QStringRef svgX = mXmlReader.attributes().value("x"); @@ -2681,7 +2679,6 @@ UBGraphicsProtractor* UBSvgSubsetAdaptor::UBSvgSubsetReader::protractorFromSvg() { UBGraphicsProtractor* protractor = new UBGraphicsProtractor(); - UBGraphicsItem::assignZValue(protractor, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetProtractor); protractor->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); graphicsItemFromSvg(protractor); @@ -2751,7 +2748,6 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg() { UBGraphicsTriangle* triangle = new UBGraphicsTriangle(); - UBGraphicsItem::assignZValue(triangle, UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetTriangle); triangle->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); graphicsItemFromSvg(triangle); diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index e1d1f0b2..46ec93a4 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -419,21 +419,22 @@ UBBoardView::mousePressEvent (QMouseEvent *event) movingItem = scene()->itemAt(this->mapToScene(event->posF().toPoint())); - if (!movingItem + if (!movingItem || movingItem->isSelected() || movingItem->type() == UBGraphicsDelegateFrame::Type - || movingItem->type() == DelegateButton::Type + || movingItem->type() == DelegateButton::Type || movingItem->type() == UBGraphicsCompass::Type || movingItem->type() == UBGraphicsPDFItem::Type || movingItem->type() == UBGraphicsPolygonItem::Type || movingItem->type() == UBGraphicsCache::Type - || movingItem->type() == UBGraphicsTriangle::Type) + || movingItem->type() == UBGraphicsTriangle::Type + || movingItem == this->scene()->backgroundObject()) { movingItem = NULL; QGraphicsView::mousePressEvent (event); } - else + else { mLastPressedMousePos = mapToScene(event->pos()); if (suspendedMousePressEvent) diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp index afd08aa9..efea1136 100644 --- a/src/core/UBSettings.cpp +++ b/src/core/UBSettings.cpp @@ -86,6 +86,7 @@ const int UBSettings::defaultWidgetIconWidth = 110; const int UBSettings::defaultVideoWidth = 80; const int UBSettings::thumbnailSpacing = 20; +const int UBSettings::longClickInterval = 2000; 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); 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; } + diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h index 4e8c9666..caf05033 100644 --- a/src/core/UBSettings.h +++ b/src/core/UBSettings.h @@ -97,8 +97,7 @@ class UBSettings : public QObject void setCommunityPassword(const QString& password); void init(); - - + //user directories static QString userDataDirectory(); static QString userDocumentDirectory(); @@ -179,6 +178,7 @@ class UBSettings : public QObject static const int defaultSoundWidth; static const int thumbnailSpacing; + static const int longClickInterval; static const qreal minScreenRatio; @@ -326,6 +326,9 @@ class UBSettings : public QObject UBSetting* KeyboardLocale; UBSetting* swapControlAndDisplayScreens; + UBSetting* angleTolerance; + UBSetting* historyLimit; + public slots: void setPenWidthIndex(int index); diff --git a/src/domain/UBAngleWidget.cpp b/src/domain/UBAngleWidget.cpp new file mode 100644 index 00000000..542a7eed --- /dev/null +++ b/src/domain/UBAngleWidget.cpp @@ -0,0 +1,46 @@ +#include "UBAngleWidget.h" +#include + +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)); +} \ No newline at end of file diff --git a/src/domain/UBAngleWidget.h b/src/domain/UBAngleWidget.h new file mode 100644 index 00000000..20b09431 --- /dev/null +++ b/src/domain/UBAngleWidget.h @@ -0,0 +1,25 @@ +#ifndef UBANGLEWIDGET_H +#define UBANGLEWIDGET_H + +#include +#include + +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 diff --git a/src/domain/UBGraphicsDelegateFrame.cpp b/src/domain/UBGraphicsDelegateFrame.cpp index cdf184a4..c0e22a16 100644 --- a/src/domain/UBGraphicsDelegateFrame.cpp +++ b/src/domain/UBGraphicsDelegateFrame.cpp @@ -29,8 +29,6 @@ #include "core/memcheck.h" -qreal const UBGraphicsDelegateFrame::mAngleTolerance = 6; - UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelegate, QRectF pRect, qreal pFrameWidth, bool respectRatio) : QGraphicsRectItem(), QObject(pDelegate) , mCurrentTool(None) @@ -51,6 +49,8 @@ UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelega , mMirrorX(false) , mMirrorY(false) { + mAngleTolerance = UBSettings::settings()->angleTolerance->get().toReal(); + setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setAcceptedMouseButtons(Qt::LeftButton); @@ -90,11 +90,14 @@ UBGraphicsDelegateFrame::UBGraphicsDelegateFrame(UBGraphicsItemDelegate* pDelega positionHandles(); this->setAcceptHoverEvents(true); + + angleWidget = new UBAngleWidget(); } UBGraphicsDelegateFrame::~UBGraphicsDelegateFrame() { +delete angleWidget; // NOOP } @@ -390,7 +393,9 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) QLineF startLine(sceneBoundingRect().center(), event->lastScenePos()); QLineF currentLine(sceneBoundingRect().center(), event->scenePos()); 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; mAngleOffset += startLine.angleTo(currentLine); @@ -400,6 +405,23 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) 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()) @@ -487,6 +509,9 @@ QTransform UBGraphicsDelegateFrame::buildTransform() void UBGraphicsDelegateFrame::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { + if (angleWidget->isVisible()) + angleWidget->hide(); + updateResizeCursors(); mDelegate->commitUndoStep(); diff --git a/src/domain/UBGraphicsDelegateFrame.h b/src/domain/UBGraphicsDelegateFrame.h index 7a825d53..7aa2bd57 100644 --- a/src/domain/UBGraphicsDelegateFrame.h +++ b/src/domain/UBGraphicsDelegateFrame.h @@ -18,6 +18,7 @@ #include #include "core/UB.h" +#include "domain/UBAngleWidget.h" class QGraphicsSceneMouseEvent; class UBGraphicsItemDelegate; @@ -92,7 +93,8 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject qreal mTranslateY; qreal mTotalTranslateX; qreal mTotalTranslateY; - static const qreal mAngleTolerance; + qreal mAngleTolerance; + QRect mAngleRect; QPointF mStartingPoint; QTransform mInitialTransform; @@ -118,5 +120,8 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject bool mResizing; bool mMirroredXAtStart; bool mMirroredYAtStart; + + UBAngleWidget *angleWidget; + }; #endif /* UBGRAPHICSDELEGATEFRAME_H_ */ diff --git a/src/domain/UBGraphicsItemDelegate.cpp b/src/domain/UBGraphicsItemDelegate.cpp index 5c962d1b..778068c8 100644 --- a/src/domain/UBGraphicsItemDelegate.cpp +++ b/src/domain/UBGraphicsItemDelegate.cpp @@ -47,6 +47,28 @@ 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) : QObject(parent) , mDelegated(pDelegated) @@ -88,11 +110,13 @@ void UBGraphicsItemDelegate::init() mButtons << mMenuButton; 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; 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; buildButtons(); @@ -149,23 +173,22 @@ QVariant UBGraphicsItemDelegate::itemChange(QGraphicsItem::GraphicsItemChange ch return value; } +UBGraphicsScene *UBGraphicsItemDelegate::castUBGraphicsScene() +{ + UBGraphicsScene *castScene = dynamic_cast(delegated()->scene()); + + return castScene; +} bool UBGraphicsItemDelegate::mousePressEvent(QGraphicsSceneMouseEvent *event) { - if(NULL != mMimeData) - { - QDrag* mDrag = new QDrag(event->widget()); - mDrag->setMimeData(mMimeData); - mDrag->start(); - } + mDragStartPosition = event->pos(); startUndoStep(); if (!mDelegated->isSelected()) { mDelegated->setSelected(true); - qDebug() << mDelegated->zValue(); - positionHandles(); return true; } @@ -182,13 +205,27 @@ void UBGraphicsItemDelegate::setMimeData(QMimeData *mimeData) 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()) { event->accept(); return true; } else - return false; + return true; } bool UBGraphicsItemDelegate::weelEvent(QGraphicsSceneWheelEvent *event) @@ -215,81 +252,65 @@ bool UBGraphicsItemDelegate::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) 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()) - { - if (mFrame && !mFrame->scene() && mDelegated->scene()) - { - mDelegated->scene()->addItem(mFrame); - } + Q_UNUSED(event) +// if (!mDelegated->isSelected()) { +// setZOrderButtonsVisible(false); +// } +} - mFrame->setAntiScale(mAntiScaleRatio); - mFrame->positionHandles(); +void UBGraphicsItemDelegate::positionHandles() +{ + if (mDelegated->isSelected()) { + bool shownOnDisplay = mDelegated->data(UBGraphicsItemData::ItemLayerType).toInt() != UBItemLayerType::Control; + showHide(shownOnDisplay); + lock(isLocked()); + updateFrame(); mFrame->show(); - QTransform tr; - tr.scale(mAntiScaleRatio, mAntiScaleRatio); + updateButtons(true); - mDeleteButton->setTransform(tr); + } else { + foreach(DelegateButton* button, mButtons) + button->hide(); - qreal topX = mFrame->rect().left()- mDeleteButton->renderer()->viewBox().width() * mAntiScaleRatio / 2; - qreal topY = mFrame->rect().top() - mDeleteButton->renderer()->viewBox().height() * mAntiScaleRatio / 2; + mFrame->hide(); + } +} +void UBGraphicsItemDelegate::setZOrderButtonsVisible(bool visible) +{ + if (visible) { + updateFrame(); + updateButtons(); - qreal bottomX = mFrame->rect().left()- mDeleteButton->renderer()->viewBox().width() * mAntiScaleRatio / 2; - qreal bottomY = mFrame->rect().bottom() - mDeleteButton->renderer()->viewBox().height() * mAntiScaleRatio / 2; + QPointF newUpPoint = mFrame->mapToItem(mDelegated, mZOrderUpButton->pos()); + QPointF newDownPoint = mFrame->mapToItem(mDelegated, mZOrderDownButton->pos()); - mDeleteButton->setPos(topX, topY); - 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); - } + mZOrderUpButton->setParentItem(mDelegated); + mZOrderDownButton->setParentItem(mDelegated); - if(!mFrame->isResizing()){ - mDeleteButton->show(); - } + mZOrderUpButton->setPos(newUpPoint + QPointF(0,0)); + mZOrderDownButton->setPos(newDownPoint + QPointF(0,0)); - bool shownOnDisplay = mDelegated->data(UBGraphicsItemData::ItemLayerType).toInt() != UBItemLayerType::Control; - showHide(shownOnDisplay); - - 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); - } - if(!mFrame->isResizing()){ - button->show(); - button->setZValue(delegated()->zValue()); - } -} } else { - foreach(DelegateButton* button, mButtons) - button->hide(); - - mFrame->hide(); + mZOrderUpButton->hide(); + mZOrderDownButton->hide(); } } - void UBGraphicsItemDelegate::remove(bool canUndo) { // QGraphicsScene* scene = mDelegated->scene(); @@ -324,18 +345,34 @@ void UBGraphicsItemDelegate::duplicate() UBApplication::boardController->copy(); UBApplication::boardController->paste(); } -void UBGraphicsItemDelegate::increaseZLevel(int delta) -{ - qDebug() << delegated()->scene()->items().count(); -// UBGraphicsItem::assignZValue(delegated(), ) - -// int valueCandidate = delegated()->data(UBGraphicsItemData::ItemOwnZValue).toInt(); -// if (delta < 0) { - -// } else if (delta > 0) { - -// } +void UBGraphicsItemDelegate::increaseZLevelUp() +{ + UBGraphicsScene *curScene = castUBGraphicsScene(); + 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) @@ -489,6 +526,67 @@ bool UBGraphicsItemDelegate::isFlippable() 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){ diff --git a/src/domain/UBGraphicsItemDelegate.h b/src/domain/UBGraphicsItemDelegate.h index 57e347bc..828f98d1 100644 --- a/src/domain/UBGraphicsItemDelegate.h +++ b/src/domain/UBGraphicsItemDelegate.h @@ -21,9 +21,11 @@ #include #include "core/UB.h" +#include "core/UBSettings.h" class QGraphicsSceneMouseEvent; class QGraphicsItem; +class UBGraphicsScene; class UBGraphicsProxyWidget; class UBGraphicsDelegateFrame; class UBGraphicsWidgetItem; @@ -63,20 +65,8 @@ class DelegateButton: public QGraphicsSvgItem protected: - virtual void mousePressEvent(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); - } + virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); + virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void modified(); @@ -84,12 +74,13 @@ class DelegateButton: public QGraphicsSvgItem QGraphicsItem* mDelegated; - + QTime mPressedTime; bool mIsTransparentToMouseEvent; Qt::WindowFrameSection mButtonAlignmentSection; signals: void clicked (bool checked = false); + void longClicked(); }; @@ -110,8 +101,12 @@ class UBGraphicsItemDelegate : public QObject virtual bool mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual bool weelEvent(QGraphicsSceneWheelEvent *event); + virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event); + virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); + virtual QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value); + virtual UBGraphicsScene *castUBGraphicsScene(); void printMessage(const QString &mess) {qDebug() << mess;} @@ -123,6 +118,7 @@ class UBGraphicsItemDelegate : public QObject void setCanDuplicate(bool allow){ mCanDuplicate = allow; } virtual void positionHandles(); + void setZOrderButtonsVisible(bool visible); void startUndoStep(); void commitUndoStep(); @@ -135,6 +131,7 @@ class UBGraphicsItemDelegate : public QObject QMimeData* mimeData(){ return mMimeData; } void setMimeData(QMimeData* mimeData); + void setDragPixmap(const QPixmap &pix) {mDragPixmap = pix;} void setFlippable(bool flippable); bool isFlippable(); @@ -153,8 +150,10 @@ class UBGraphicsItemDelegate : public QObject virtual void lock(bool lock); virtual void duplicate(); - virtual void increaseZLevel() {increaseZLevel(1);} - virtual void decreaseZLevel() {increaseZLevel(-1);} + void increaseZLevelUp(); + void increaseZLevelDown(); + void increaseZlevelTop(); + void increaseZlevelBottom(); protected: virtual void buildButtons() {;} @@ -189,18 +188,22 @@ protected slots: virtual void gotoContentSource(bool checked); private: + void updateFrame(); + void updateButtons(bool showUpdated = false); + - virtual void increaseZLevel(int delta); QPointF mOffset; QTransform mPreviousTransform; QPointF mPreviousPosition; + QPointF mDragStartPosition; qreal mPreviousZValue; QSizeF mPreviousSize; bool mCanRotate; bool mCanDuplicate; bool mRespectRatio; QMimeData* mMimeData; + QPixmap mDragPixmap; /** A boolean saying that this object can be flippable (mirror effect) */ bool mFlippable; diff --git a/src/domain/UBGraphicsPixmapItem.cpp b/src/domain/UBGraphicsPixmapItem.cpp index 07dc4679..9298d775 100644 --- a/src/domain/UBGraphicsPixmapItem.cpp +++ b/src/domain/UBGraphicsPixmapItem.cpp @@ -58,13 +58,18 @@ void UBGraphicsPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) QMimeData* pMime = new QMimeData(); pMime->setImageData(pixmap().toImage()); 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)) { //NOOP } else { - QGraphicsPixmapItem::mousePressEvent(event); +// QGraphicsPixmapItem::mousePressEvent(event); } } diff --git a/src/domain/UBGraphicsPixmapItem.h b/src/domain/UBGraphicsPixmapItem.h index 56608ba1..5cb7d599 100644 --- a/src/domain/UBGraphicsPixmapItem.h +++ b/src/domain/UBGraphicsPixmapItem.h @@ -61,10 +61,6 @@ protected: virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); - - -// UBGraphicsItemDelegate* mDelegate; - }; #endif /* UBGRAPHICSPIXMAPITEM_H_ */ diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index 6f7f4d77..1fbb2340 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -61,24 +61,11 @@ #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; +UBZLayerController::UBZLayerController(QGraphicsScene *scene) : + mScene(scene) -UBZLayerController::UBZLayerController() { scopeMap.insert(itemLayerType::NoLayer, ItemLayerTypeData( errorNumber, errorNumber)); 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 top = scopeMap.value(key).topLimit; + qreal incrementalStep = scopeMap.value(key).incStep; - result++; + result += incrementalStep; if (result >= top) { - qDebug() << "new values are over for the scope" << key; - result = top - 1; + // If not only one variable presents in the scope, notify that values for scope are over + 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; return result; } +qreal UBZLayerController::generateZLevel(QGraphicsItem *item) +{ + qreal result = errorNumber; + itemLayerType::Enum type = static_cast(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 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(); + } + + QMapIteratoriCurElement(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(item->data(UBGraphicsItemData::itemLayerType).toInt()); + + if (!scopeMap.contains(result)) { + result = itemLayerType::NoLayer; + } + + return result; +} UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent) : UBCoreGraphicsScene(parent) @@ -135,8 +267,8 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent) , enableUndoRedoStack(true) , magniferControlViewWidget(0) , magniferDisplayViewWidget(0) + , mZLayerController(new UBZLayerController(this)) , mIsDesktopMode(false) - { #ifdef __ppc__ @@ -164,6 +296,9 @@ UBGraphicsScene::~UBGraphicsScene() if (mCurrentStroke) if (mCurrentStroke->polygons().empty()) delete mCurrentStroke; + + if (mZLayerController) + delete mZLayerController; } void UBGraphicsScene::selectionChangedProcessing() @@ -177,7 +312,7 @@ void UBGraphicsScene::selectionChangedProcessing() QGraphicsItem *nextItem = allItemsList.at(i); if (nextItem->isSelected()) { - nextItem->setZValue(mZLayerController.generateZLevel(itemLayerType::SelectedItem)); + nextItem->setZValue(mZLayerController->generateZLevel(itemLayerType::SelectedItem)); } else { nextItem->setZValue(nextItem->data(UBGraphicsItemData::ItemOwnZValue).toReal()); } @@ -831,7 +966,6 @@ void UBGraphicsScene::leaveEvent(QEvent * event) hideEraser(); } - UBGraphicsScene* UBGraphicsScene::sceneDeepCopy() const { UBGraphicsScene* copy = new UBGraphicsScene(this->document()); @@ -1338,7 +1472,7 @@ void UBGraphicsScene::addItem(QGraphicsItem* item) setModified(true); UBCoreGraphicsScene::addItem(item); - UBGraphicsItem::assignZValue(item, generateZLevel(item)); + UBGraphicsItem::assignZValue(item, mZLayerController->generateZLevel(item)); if (!mTools.contains(item)) ++mItemCount; @@ -1352,7 +1486,7 @@ void UBGraphicsScene::addItems(const QSet& items) foreach(QGraphicsItem* item, items) { UBCoreGraphicsScene::addItem(item); - UBGraphicsItem::assignZValue(item, generateZLevel(item)); + UBGraphicsItem::assignZValue(item, mZLayerController->generateZLevel(item)); } mItemCount += items.size(); @@ -1414,7 +1548,7 @@ QGraphicsItem* UBGraphicsScene::setAsBackgroundObject(QGraphicsItem* item, bool item->setAcceptedMouseButtons(Qt::NoButton); item->setData(UBGraphicsItemData::ItemLayerType, UBItemLayerType::FixedBackground); - UBGraphicsItem::assignZValue(item, mZLayerController.generateZLevel(itemLayerType::BackgroundItem)); + UBGraphicsItem::assignZValue(item, mZLayerController->generateZLevel(itemLayerType::BackgroundItem)); if (pAdaptTransformation) { @@ -1787,6 +1921,23 @@ void UBGraphicsScene::setNominalSize(int pWidth, int pHeight) setNominalSize(QSize(pWidth, pHeight)); } +void UBGraphicsScene::setSelectedZLevel(QList itemList) +{ + foreach (QGraphicsItem *item, itemList) { + item->setZValue(mZLayerController->generateZLevel(itemLayerType::SelectedItem)); + } +} +void UBGraphicsScene::setOwnZlevel(QList 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 { @@ -2011,18 +2162,6 @@ void UBGraphicsScene::createPointer() addItem(mPointer); } -qreal UBGraphicsScene::generateZLevel(QGraphicsItem *item) -{ - qreal result = UBZLayerController::errorNum(); - itemLayerType::Enum type = static_cast(item->data(UBGraphicsItemData::itemLayerType).toInt()); - - if (mZLayerController.validLayerType(type)) { - result = mZLayerController.generateZLevel(type); - } - - return result; -} - void UBGraphicsScene::setToolCursor(int tool) { if (tool != (int)UBStylusTool::Selector diff --git a/src/domain/UBGraphicsScene.h b/src/domain/UBGraphicsScene.h index 1cdd37e4..829a3bb8 100644 --- a/src/domain/UBGraphicsScene.h +++ b/src/domain/UBGraphicsScene.h @@ -49,33 +49,47 @@ class UBGraphicsCache; const double PI = 4.0 * atan(1.0); -class UBZLayerController +class UBZLayerController : public QObject { -public: + Q_OBJECT +public: struct ItemLayerTypeData { - ItemLayerTypeData() : bottomLimit(0), topLimit(0), curValue(0) {;} - ItemLayerTypeData(qreal bot, qreal top) : bottomLimit(bot), topLimit(top), curValue(bot) {;} - qreal bottomLimit; - qreal topLimit; - qreal curValue; + ItemLayerTypeData() : bottomLimit(0), topLimit(0), curValue(0), incStep(1) {;} + ItemLayerTypeData(qreal bot, qreal top, qreal increment = 1) : bottomLimit(bot), topLimit(top), curValue(bot), incStep(increment) {;} + qreal bottomLimit; //bottom bound of the layer + qreal topLimit;//top bound of the layer + qreal curValue;//current value of variable + qreal incStep;//incremental step + }; + + enum moveDestination { + up + , down + , top + , bottom }; typedef QMap ScopeMap; - UBZLayerController(); + UBZLayerController(QGraphicsScene *scene); qreal getBottomLimit(itemLayerType::Enum key) const {return scopeMap.value(key).bottomLimit;} qreal getTopLimit(itemLayerType::Enum key) const {return scopeMap.value(key).topLimit;} bool validLayerType(itemLayerType::Enum key) const {return scopeMap.contains(key);} + static qreal errorNum() {return errorNumber;} qreal generateZLevel(itemLayerType::Enum key); + qreal generateZLevel(QGraphicsItem *item); - private: - ScopeMap scopeMap; - static qreal errorNumber; + qreal changeZLevelTo(QGraphicsItem *item, moveDestination dest); + itemLayerType::Enum typeForData(QGraphicsItem *item) const; +private: + ScopeMap scopeMap; + static qreal errorNumber; + QGraphicsScene *mScene; }; 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 void setURStackEnable(bool set = true) {enableUndoRedoStack = set;} - UBGraphicsScene(UBDocumentProxy *parent); + UBGraphicsScene(UBDocumentProxy *parent); virtual ~UBGraphicsScene(); virtual UBItem* deepCopy() const; @@ -242,6 +256,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem void setNominalSize(int pWidth, int pHeight); + qreal changeZLevelTo(QGraphicsItem *item, UBZLayerController::moveDestination dest); + enum RenderingContext { Screen = 0, NonScreen, PdfExport, Podcast @@ -257,20 +273,6 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem 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 tools(){ return mTools;} void registerTool(QGraphicsItem* item) @@ -283,7 +285,9 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem return mPreviousPoint; } - public slots: + void setSelectedZLevel(QList itemList); + void setOwnZlevel(QList itemList); +public slots: void hideEraser(); @@ -339,8 +343,6 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem void createEraiser(); void createPointer(); - qreal generateZLevel(QGraphicsItem *item); - QGraphicsEllipseItem* mEraser; QGraphicsEllipseItem* mPointer; @@ -392,7 +394,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem UBMagnifier *magniferControlViewWidget; UBMagnifier *magniferDisplayViewWidget; - UBZLayerController mZLayerController; + UBZLayerController *mZLayerController; }; diff --git a/src/domain/UBGraphicsVideoItem.cpp b/src/domain/UBGraphicsVideoItem.cpp index 887fdb7a..9fa9d345 100644 --- a/src/domain/UBGraphicsVideoItem.cpp +++ b/src/domain/UBGraphicsVideoItem.cpp @@ -109,10 +109,10 @@ void UBGraphicsVideoItem::showOnDisplayChanged(bool shown) void UBGraphicsVideoItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { - QDrag* mDrag = new QDrag(event->widget()); - QMimeData* pMime = new QMimeData(); - mDrag->setMimeData(pMime); - mDrag->start(); +// QDrag* mDrag = new QDrag(event->widget()); +// QMimeData* pMime = new QMimeData(); +// mDrag->setMimeData(pMime); +// mDrag->start(); mShouldMove = (event->buttons() & Qt::LeftButton); mMousePressPos = event->scenePos(); diff --git a/src/domain/UBGraphicsWidgetItem.cpp b/src/domain/UBGraphicsWidgetItem.cpp index 899a7714..13487641 100644 --- a/src/domain/UBGraphicsWidgetItem.cpp +++ b/src/domain/UBGraphicsWidgetItem.cpp @@ -82,11 +82,13 @@ void UBGraphicsWidgetItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void UBGraphicsWidgetItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { sendJSEnterEvent(); + mDelegate->hoverEnterEvent(event); UBGraphicsProxyWidget::hoverEnterEvent(event); } void UBGraphicsWidgetItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { sendJSLeaveEvent(); + mDelegate->hoverLeaveEvent(event); UBGraphicsProxyWidget::hoverLeaveEvent(event); } diff --git a/src/domain/UBItem.cpp b/src/domain/UBItem.cpp index 3e6f68cf..54c16e73 100644 --- a/src/domain/UBItem.cpp +++ b/src/domain/UBItem.cpp @@ -29,7 +29,7 @@ UBItem::~UBItem() // NOOP } -void UBGraphicsItem::assignZValue(QGraphicsItem *item, int value) +void UBGraphicsItem::assignZValue(QGraphicsItem *item, qreal value) { item->setZValue(value); item->setData(UBGraphicsItemData::ItemOwnZValue, value); diff --git a/src/domain/UBItem.h b/src/domain/UBItem.h index e10cd57a..301395fa 100644 --- a/src/domain/UBItem.h +++ b/src/domain/UBItem.h @@ -101,7 +101,7 @@ protected: public: - static void assignZValue(QGraphicsItem*, int value); + static void assignZValue(QGraphicsItem*, qreal value); virtual UBGraphicsItemDelegate *Delegate() const = 0; virtual void remove() = 0; diff --git a/src/domain/domain.pri b/src/domain/domain.pri index e3653576..a2d126ac 100644 --- a/src/domain/domain.pri +++ b/src/domain/domain.pri @@ -22,7 +22,8 @@ HEADERS += src/domain/UBGraphicsScene.h \ src/domain/UBGraphicsMediaItem.h \ src/domain/UBGraphicsAudioItem.h \ src/domain/UBGraphicsAudioItemDelegate.h \ - src/domain/UBAbstractUndoCommand.h + src/domain/UBAbstractUndoCommand.h\ + src/domain/UBAngleWidget.h HEADERS += src/domain/UBGraphicsItemDelegate.h \ src/domain/UBGraphicsVideoItemDelegate.h \ @@ -54,7 +55,8 @@ SOURCES += src/domain/UBGraphicsScene.cpp \ src/domain/UBGraphicsMediaItem.cpp \ src/domain/UBGraphicsAudioItem.cpp \ src/domain/UBGraphicsAudioItemDelegate.cpp \ - src/domain/UBAbstractUndoCommand.cpp + src/domain/UBAbstractUndoCommand.cpp \ + src/domain/UBAngleWidget.cpp SOURCES += src/domain/UBGraphicsItemDelegate.cpp \ src/domain/UBGraphicsVideoItemDelegate.cpp \ diff --git a/src/tools/UBGraphicsRuler.h b/src/tools/UBGraphicsRuler.h index fb74dd9d..1c799bb1 100644 --- a/src/tools/UBGraphicsRuler.h +++ b/src/tools/UBGraphicsRuler.h @@ -44,7 +44,7 @@ class UBGraphicsRuler : public UBAbstractDrawRuler, public QGraphicsRectItem, pu virtual void StartLine(const QPointF& position, qreal width); virtual void DrawLine(const QPointF& position, qreal width); - virtual void EndLine(); + virtual void EndLine(); protected: diff --git a/src/web/browser/WBBrowserWindow.cpp b/src/web/browser/WBBrowserWindow.cpp index e8151811..7cfb79d5 100644 --- a/src/web/browser/WBBrowserWindow.cpp +++ b/src/web/browser/WBBrowserWindow.cpp @@ -196,6 +196,36 @@ void WBBrowserWindow::setupToolBar() mTabWidget->addWebAction(mUniboardMainWindow->actionWebReload, QWebPage::Reload); 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(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(menuWidget); + + if (tb && !tb->menu()) + { + tb->setMenu(mHistoryForwardMenu); + tb->setStyleSheet("QToolButton { padding-right: 8px; }"); + } + } + mWebToolBar->insertWidget(mUniboardMainWindow->actionWebBigger, mTabWidget->lineEditStack()); mSearchToolBar = new WBToolbarSearch(mWebToolBar); @@ -224,6 +254,22 @@ void WBBrowserWindow::setupToolBarForTutorial() mTabWidget->addWebAction(mUniboardMainWindow->actionWebBack, QWebPage::Back); mTabWidget->addWebAction(mUniboardMainWindow->actionWebForward, QWebPage::Forward); + + foreach (QWidget* menuWidget, mUniboardMainWindow->actionWebBack->associatedWidgets()) + { + QToolButton *tb = qobject_cast(menuWidget); + + if (tb && tb->menu()) + tb->setMenu(NULL); + } + + foreach (QWidget* menuWidget, mUniboardMainWindow->actionWebForward->associatedWidgets()) + { + QToolButton *tb = qobject_cast(menuWidget); + + if (tb && tb->menu()) + tb->setMenu(NULL); + } // mTabWidget->addWebAction(mUniboardMainWindow->actionWebReload, QWebPage::Reload); // mTabWidget->addWebAction(mUniboardMainWindow->actionStopLoading, QWebPage::Stop); @@ -534,4 +580,86 @@ void WBBrowserWindow::showTabAtTop(bool attop) 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()); + } \ No newline at end of file diff --git a/src/web/browser/WBBrowserWindow.h b/src/web/browser/WBBrowserWindow.h index 0cca883a..40cab320 100644 --- a/src/web/browser/WBBrowserWindow.h +++ b/src/web/browser/WBBrowserWindow.h @@ -112,6 +112,10 @@ class WBBrowserWindow : public QWidget void showTabAtTop(bool attop); + void aboutToShowBackMenu(); + void aboutToShowForwardMenu(); + void openActionUrl(QAction *action); + signals: void activeViewPageChanged(); void activeViewChange(QWidget*); @@ -160,6 +164,9 @@ class WBBrowserWindow : public QWidget QString mLastSearch; Ui::MainWindow* mUniboardMainWindow; + + QMenu *mHistoryBackMenu; + QMenu *mHistoryForwardMenu; }; #endif // WBBROWSERMAINWINDOW_H