Commit 20a787f1 authored by Claudio Valerio's avatar Claudio Valerio

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

Conflicts:
	src/board/UBBoardView.cpp
	src/domain/UBGraphicsItemDelegate.cpp
parents 93f69f80 05564470
...@@ -131,7 +131,7 @@ win32 { ...@@ -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 ...@@ -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(){ ...@@ -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();
} }
......
...@@ -13,7 +13,7 @@ ...@@ -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 = { ...@@ -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 = { ...@@ -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 = { ...@@ -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
......
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
......
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 = { ...@@ -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"
}; };
......
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 = { ...@@ -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"
}; };
......
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"
}; };
......
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
......
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-dposer 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() ...@@ -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() ...@@ -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 = "";
......
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
......
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"
}; };
......
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",
......
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
......
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."
}; };
......
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() ...@@ -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() ...@@ -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() ...@@ -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() ...@@ -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) ...@@ -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, ...@@ -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() ...@@ -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 @@ ...@@ -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"
...@@ -424,7 +425,9 @@ void UBBoardView::mousePressEvent (QMouseEvent *event) ...@@ -424,7 +425,9 @@ void UBBoardView::mousePressEvent (QMouseEvent *event)
|| 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 == this->scene()->backgroundObject())
{ {
movingItem = NULL; movingItem = NULL;
QGraphicsView::mousePressEvent (event); QGraphicsView::mousePressEvent (event);
......
...@@ -86,6 +86,7 @@ const int UBSettings::defaultWidgetIconWidth = 110; ...@@ -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() ...@@ -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) ...@@ -1139,3 +1143,4 @@ QString UBSettings::replaceWildcard(QString& path)
return result; return result;
} }
...@@ -98,7 +98,6 @@ class UBSettings : public QObject ...@@ -98,7 +98,6 @@ class UBSettings : public QObject
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 ...@@ -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 ...@@ -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) ...@@ -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);
......
#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));
}
\ No newline at end of file
#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
This diff is collapsed.
...@@ -18,6 +18,7 @@ ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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_ */
This diff is collapsed.
...@@ -21,9 +21,11 @@ ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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: ...@@ -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) ...@@ -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) ...@@ -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: ...@@ -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_ */
This diff is collapsed.
...@@ -49,33 +49,47 @@ class UBGraphicsCache; ...@@ -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);
itemLayerType::Enum typeForData(QGraphicsItem *item) const;
private:
ScopeMap scopeMap; ScopeMap scopeMap;
static qreal errorNumber; static qreal errorNumber;
QGraphicsScene *mScene;
}; };
class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
...@@ -242,6 +256,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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) ...@@ -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) ...@@ -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() ...@@ -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: ...@@ -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 \ ...@@ -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 \ ...@@ -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 \
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#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"
...@@ -27,7 +28,6 @@ UBMagnifier::UBMagnifier(QWidget *parent, bool isInteractive) ...@@ -27,7 +28,6 @@ UBMagnifier::UBMagnifier(QWidget *parent, bool isInteractive)
: QWidget(parent, parent ? Qt::Widget : Qt::Tool | (Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint)) : QWidget(parent, parent ? Qt::Widget : Qt::Tool | (Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint))
, mShouldMoveWidget(false) , mShouldMoveWidget(false)
, mShouldResizeWidget(false) , mShouldResizeWidget(false)
, inTimer(false)
, borderPen(Qt::darkGray) , borderPen(Qt::darkGray)
, gView(0) , gView(0)
, mView(0) , mView(0)
...@@ -70,16 +70,11 @@ UBMagnifier::UBMagnifier(QWidget *parent, bool isInteractive) ...@@ -70,16 +70,11 @@ UBMagnifier::UBMagnifier(QWidget *parent, bool isInteractive)
#endif #endif
} }
connect(&mRefreshTimer, SIGNAL(timeout()), this, SLOT(slot_refresh()));
} }
UBMagnifier::~UBMagnifier() UBMagnifier::~UBMagnifier()
{ {
if (timerUpdate != 0)
{
killTimer(timerUpdate);
timerUpdate = 0;
}
if(sClosePixmap) if(sClosePixmap)
{ {
delete sClosePixmap; delete sClosePixmap;
...@@ -285,12 +280,8 @@ void UBMagnifier::mouseReleaseEvent(QMouseEvent * event) ...@@ -285,12 +280,8 @@ void UBMagnifier::mouseReleaseEvent(QMouseEvent * event)
} }
void UBMagnifier::timerEvent(QTimerEvent *e) void UBMagnifier::slot_refresh()
{ {
if(inTimer) return;
if (e->timerId() == timerUpdate)
{
inTimer = true;
if(!(updPointGrab.isNull())) if(!(updPointGrab.isNull()))
grabPoint(updPointGrab); grabPoint(updPointGrab);
...@@ -307,28 +298,37 @@ void UBMagnifier::timerEvent(QTimerEvent *e) ...@@ -307,28 +298,37 @@ void UBMagnifier::timerEvent(QTimerEvent *e)
isCusrsorAlreadyStored = false; isCusrsorAlreadyStored = false;
setCursor(mOldCursor); setCursor(mOldCursor);
} }
}
inTimer = false;
} }
} }
void UBMagnifier::grabPoint() void UBMagnifier::grabPoint()
{ {
QMatrix transM = UBApplication::boardController->controlView()->matrix();
QPointF itemPos = gView->mapFromGlobal(updPointGrab); QPointF itemPos = gView->mapFromGlobal(updPointGrab);
qreal zWidth = size().width() / params.zoom; qreal zWidth = width() / (params.zoom * transM.m11());
qreal zWidthHalf = zWidth / 2; qreal zWidthHalf = zWidth / 2;
qreal zHeight = size().height() / params.zoom; qreal zHeight = height() / (params.zoom * transM.m22());
qreal zHeightHalf = zHeight / 2; qreal zHeightHalf = zHeight / 2;
int x = itemPos.x() - zWidthHalf;
int y = itemPos.y() - zHeightHalf;
QPixmap newPixMap(QSize(zWidth,zHeight)); QPointF pfScLtF(UBApplication::boardController->controlView()->mapToScene(QPoint(itemPos.x(), itemPos.y())));
((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight));
UBApplication::boardController->activeScene()->update();
QRect magnifierRect = rect();
float x = pfScLtF.x() - zWidthHalf;
float y = pfScLtF.y() - zHeightHalf;
QPointF leftTop(x,y);
QPointF rightBottom(x + zWidth, y + zHeight);
QRectF srcRect(leftTop, rightBottom);
QPixmap newPixMap(QSize(width(), height()));
QPainter painter(&newPixMap);
UBApplication::boardController->activeScene()->render(&painter, QRectF(0,0,width(),height()), srcRect);
painter.end();
pMap.fill(Qt::transparent); pMap.fill(Qt::transparent);
pMap = newPixMap.scaled(QSize(width(), height())); pMap = newPixMap.scaled(QSize(width(), height()));
...@@ -339,28 +339,43 @@ void UBMagnifier::grabPoint() ...@@ -339,28 +339,43 @@ void UBMagnifier::grabPoint()
void UBMagnifier::grabPoint(const QPoint &pGrab) void UBMagnifier::grabPoint(const QPoint &pGrab)
{ {
QMatrix transM = UBApplication::boardController->controlView()->matrix();
updPointGrab = pGrab; updPointGrab = pGrab;
QPointF itemPos = gView->mapFromGlobal(pGrab); QPointF itemPos = gView->mapFromGlobal(pGrab);
qreal zWidth = size().width() / params.zoom; qreal zWidth = width() / (params.zoom * transM.m11());
qreal zWidthHalf = zWidth / 2; qreal zWidthHalf = zWidth / 2;
qreal zHeight = size().height() / params.zoom; qreal zHeight = height() / (params.zoom * transM.m22());
qreal zHeightHalf = zHeight / 2; qreal zHeightHalf = zHeight / 2;
int x = itemPos.x() - zWidthHalf;
int y = itemPos.y() - zHeightHalf;
QPixmap newPixMap(QSize(zWidth,zHeight)); QPointF pfScLtF(UBApplication::boardController->controlView()->mapToScene(QPoint(itemPos.x(), itemPos.y())));
((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight));
UBApplication::boardController->activeScene()->update();
pMap.fill(Qt::transparent);
pMap = newPixMap.scaled(QSize(width(), height())); QRect magnifierRect = rect();
float x = pfScLtF.x() - zWidthHalf;
float y = pfScLtF.y() - zHeightHalf;
QPointF leftTop(x,y);
QPointF rightBottom(x + zWidth, y + zHeight);
QRectF srcRect(leftTop, rightBottom);
QPixmap newPixMap(QSize(width(), height()));
QPainter painter(&newPixMap);
UBApplication::boardController->activeScene()->render(&painter, QRectF(0,0,width(),height()), srcRect);
painter.end();
// pMap.fill(Qt::transparent);
pMap = newPixMap;
pMap.setMask(bmpMask); pMap.setMask(bmpMask);
update(); update();
} }
// from global // from global
void UBMagnifier::grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needGrab, bool needMove) void UBMagnifier::grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needGrab, bool needMove)
{ {
...@@ -380,9 +395,8 @@ void UBMagnifier::grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needG ...@@ -380,9 +395,8 @@ void UBMagnifier::grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needG
void UBMagnifier::setGrabView(QWidget *view) void UBMagnifier::setGrabView(QWidget *view)
{ {
if (timerUpdate != 0)
killTimer(timerUpdate);
gView = view; gView = view;
timerUpdate = startTimer(200); mRefreshTimer.setInterval(40);
mRefreshTimer.start();
} }
...@@ -54,9 +54,11 @@ signals: ...@@ -54,9 +54,11 @@ signals:
void magnifierZoomOut_Signal(); void magnifierZoomOut_Signal();
void magnifierResized_Signal(qreal newPercentSize); void magnifierResized_Signal(qreal newPercentSize);
public slots:
void slot_refresh();
protected: protected:
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *);
void timerEvent(QTimerEvent *);
virtual void mousePressEvent ( QMouseEvent * event ); virtual void mousePressEvent ( QMouseEvent * event );
virtual void mouseMoveEvent ( QMouseEvent * event ); virtual void mouseMoveEvent ( QMouseEvent * event );
...@@ -78,10 +80,9 @@ protected: ...@@ -78,10 +80,9 @@ protected:
QCursor mResizeCursor; QCursor mResizeCursor;
private: private:
bool inTimer; QTimer mRefreshTimer;
bool m_isInteractive; bool m_isInteractive;
int timerUpdate;
QPoint updPointGrab; QPoint updPointGrab;
QPoint updPointMove; QPoint updPointMove;
......
...@@ -196,6 +196,36 @@ void WBBrowserWindow::setupToolBar() ...@@ -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() ...@@ -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) ...@@ -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());
}
\ No newline at end of file
...@@ -112,6 +112,10 @@ class WBBrowserWindow : public QWidget ...@@ -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 ...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment