Commit d8bc5839 authored by Ivan Ilin's avatar Ivan Ilin

Delete button is now available

parents da61ebad 80bfc86a
......@@ -131,7 +131,7 @@ win32 {
}
macx {
LIBS += "-Lplugins/cffadaptor/lib/mac" "-lCFF_Adaptor"
LIBS += "-Lplugins/cffadaptor/lib/macx" "-lCFF_Adaptor"
LIBS += -framework Foundation
LIBS += -lcrypto
LIBS += -framework AppKit
......
......@@ -10,14 +10,16 @@ linux-g++: SUB_DIR = linux
linux-g++-32: SUB_DIR = linux
linux-g++-64: SUB_DIR = linux
QUAZIP_DIR = "$$PWD/../../../Sankore-ThirdParty/quazip"
ZLIB_DIR = "$$PWD/../../../Sankore-ThirdParty/zlib"
THIRD_PARTY_PATH = ../../../Sankore-ThirdParty
QUAZIP_DIR = "$$PWD/../../../Sankore-ThirdParty/quazip/quazip-0.3"
INCLUDEPATH += src \
"$$QUAZIP_DIR/quazip-0.3" \
"$$ZLIB_DIR/1.2.3/include"
INCLUDEPATH += src
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 += gui
......
......@@ -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":{
......@@ -49,23 +49,23 @@ var sankoreLang = {
"edit": "Modifier",
"display":"Afficher",
"question":"La question",
"example_question":"Ceci est un exemple de la question",
"answer":"Ceci est un exemple de la réponse",
"example_question":"Ceci est un exemple de question",
"answer":"Ceci est un exemple de réponse",
"q":"Q",
"add_new_question":"Ajouter nouvelle question ...",
"options":"Les options",
"add_new_question":"Ajouter une nouvelle question ...",
"options":"Options",
"close":"Fermer",
"delete_question":"Supprimer la question",
"delete_answer":"Supprimer réponse",
"delete_answer":"Supprimer la possibilité",
"right_answer":"Bonne réponse",
"template_question":"Saisissez votre question ici ...",
"template_answer":"Entrez la réponse ici ...",
"add_answer":"Ajouter une réponse",
"select_text":"Choisissez 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.",
"radio_desc":"Cette option permet de choisir une seule réponse et les réponses 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.",
"select_desc":"Cette option permet de choisir une seule réponse et les réponses sont affichées sous forme de menu déroulant.",
"template_question":"Saisir la question ici ...",
"template_answer":"Saisir une possibilité ici ...",
"add_answer":"Ajouter une possibilité",
"select_text":"Choisir la bonne réponse",
"options_desc":"Types de questions",
"radio_desc":"Option 1 : une seule bonne réponse, les possibilités sont affichées sous forme de boutons radio.",
"checkbox_desc":"Option 2 : plusieurs bonnes réponses, les possibilités sont affichées sous forme de cases à cocher.",
"select_desc":"Option 3 : une seule bonne réponse, les possibilités sont affichées sous forme de menu déroulant.",
"a":"R"
}
};
......
......@@ -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
......
var sankoreLang = {
display: "Affichage",
display: "Afficher",
edit: "Modifier",
short_desc: "Sélectionner le numéro «trois».",
add: "Nouveau bloc",
enter: "Saisissez la consigne ici ..."
enter: "Saisir la consigne ici ..."
};
//main function
......
var sankoreLang = {
display: "D'affichage",
display: "Afficher",
edit: "Modifier",
short_desc: "Combien de signaux entendez-vous?",
short_desc: "Combien de signaux sonores entendez-vous?",
add: "Nouveau bloc",
enter: "Entrez votre description ici ..."
enter: "Saisir votre description ici ..."
};
//main function
......
......@@ -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"
};
......
var sankoreLang = {
display: "D'affichage",
display: "Afficher",
edit: "Modifier",
first_desc: "Les nombres impairs",
second_desc: "Même les chiffres",
enter: "Entrez votre nom de la catégorie ici ...",
second_desc: "Les nombres pairs",
enter: "Saisir le nom de la catégorie ici ...",
add: "Nouveau bloc"
};
......
......@@ -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"
};
......
var sankoreLang = {
display: "D'affichage",
display: "Afficher",
edit: "Modifier",
first_desc: "Fruits",
second_desc: "Légumes",
potatoes: "Pommes de terre",
potatoes: "Pomme de terre",
carrot: "Carotte",
onion: "Oignon",
apple: "Pomme",
pear: "Poire",
enter: "Entrez votre nom de la catégorie ici ...",
enter: "Saisir le nom de la catégorie ici ...",
add: "Nouveau bloc",
text: "Texte"
};
......
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
......
var sankoreLang = {
display: "D'affichage",
display: "Afficher",
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_slide: "C'est une nouvelle diapositive."
new_slide: "Ceci est une nouvelle diapositive."
};
//some flags
......
......@@ -26,9 +26,9 @@ function checkResponse()
*/
var sankoreLang = {
view: "D'affichage",
view: "Afficher",
edit: "Modifier",
example: "il\ns'agit\nd'une\nphrase\nd'exemple"
example: "Cette phrase\nest un\nexemple."
};
......
......@@ -27,9 +27,9 @@ function checkResponse()
*/
var sankoreLang = {
view: "D'affichage",
view: "Afficher",
edit: "Modifier",
example: "une*longue*,*il*ya*bien*longtemps*..."
example: "Il*était*une*fois*..."
};
var word = "";
......
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
......
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"
};
......
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",
......
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
......
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."
};
......
var sankoreLang = {
view: "D'affichage",
view: "Afficher",
edit: "Modifier",
example: "so*phis*ti*qué"
};
......
......@@ -664,6 +664,7 @@ void UBBoardController::zoom(const qreal ratio, QPointF scenePoint)
UBApplication::applicationController->adjustDisplayView();
emit controlViewportChanged();
mActiveScene->setBackgroundZoomFactor(mControlView->transform().m11());
}
......@@ -1163,7 +1164,7 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
mControlView->setScene(mActiveScene);
mDisplayView->setScene(mActiveScene);
mActiveScene->setBackgroundZoomFactor(mControlView->transform().m11());
pDocumentProxy->setDefaultDocumentSize(mActiveScene->nominalSize());
updatePageSizeState();
......@@ -1564,7 +1565,7 @@ void UBBoardController::updateSystemScaleFactor()
mControlView->setTransform(scalingTransform);
mControlView->horizontalScrollBar()->setValue(viewState.horizontalPosition);
mControlView->verticalScrollBar()->setValue(viewState.verticalPostition);
}
mActiveScene->setBackgroundZoomFactor(mControlView->transform().m11());}
void UBBoardController::setWidePageSize(bool checked)
......
......@@ -54,6 +54,7 @@
#include "tools/UBGraphicsCompass.h"
#include "tools/UBGraphicsCache.h"
#include "tools/UBGraphicsTriangle.h"
#include "core/memcheck.h"
......@@ -425,7 +426,9 @@ UBBoardView::mousePressEvent (QMouseEvent *event)
|| movingItem->type() == UBGraphicsCompass::Type
|| movingItem->type() == UBGraphicsPDFItem::Type
|| movingItem->type() == UBGraphicsPolygonItem::Type
|| movingItem->type() == UBGraphicsCache::Type)
|| movingItem->type() == UBGraphicsCache::Type
|| movingItem->type() == UBGraphicsTriangle::Type
|| movingItem == this->scene()->backgroundObject())
{
movingItem = NULL;
QGraphicsView::mousePressEvent (event);
......
......@@ -378,6 +378,8 @@ void UBSettings::init()
KeyboardLocale = new UBSetting(this, "Board", "StartupKeyboardLocale", 0);
swapControlAndDisplayScreens = new UBSetting(this, "App", "SwapControlAndDisplayScreens", false);
angleTolerance = new UBSetting(this, "App", "AngleTolerance", 4);
}
......@@ -1140,3 +1142,4 @@ QString UBSettings::replaceWildcard(QString& path)
return result;
}
......@@ -98,7 +98,6 @@ class UBSettings : public QObject
void init();
//user directories
static QString userDataDirectory();
static QString userDocumentDirectory();
......@@ -327,6 +326,8 @@ class UBSettings : public QObject
UBSetting* KeyboardLocale;
UBSetting* swapControlAndDisplayScreens;
UBSetting* angleTolerance;
public slots:
void setPenWidthIndex(int index);
......
......@@ -88,6 +88,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
mTransparentDrawingScene = new UBGraphicsScene(0);
mTransparentDrawingView->setScene(mTransparentDrawingScene);
mTransparentDrawingScene->setDrawingMode(true);
// mRightPalette = UBApplication::boardController->paletteManager()->createDesktopRightPalette(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 @@
#include <QtGui>
#include "core/UB.h"
#include "domain/UBAngleWidget.h"
class QGraphicsSceneMouseEvent;
class UBGraphicsItemDelegate;
......@@ -47,6 +48,7 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
enum OperationMode {Scaling, Resizing};
void setOperationMode(OperationMode pMode) {mOperationMode = pMode;}
bool isResizing(){return mResizing;}
private:
QRectF bottomRightResizeGripRect() const;
......@@ -69,8 +71,8 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
void initializeTransform ();
enum FrameTool {None, Move, Rotate, ResizeBottomRight, ResizeTop, ResizeRight, ResizeBottom, ResizeLeft};
FrameTool toolFromPos (QPointF pos);
void refreshGeometry();
FrameTool mCurrentTool;
UBGraphicsItemDelegate* mDelegate;
......@@ -90,7 +92,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;
......@@ -111,5 +114,13 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
OperationMode mOperationMode;
QGraphicsItem* delegated();
bool mMirrorX;
bool mMirrorY;
bool mResizing;
bool mMirroredXAtStart;
bool mMirroredYAtStart;
UBAngleWidget *angleWidget;
};
#endif /* UBGRAPHICSDELEGATEFRAME_H_ */
......@@ -268,7 +268,6 @@ void UBGraphicsItemDelegate::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
// }
}
void UBGraphicsItemDelegate::positionHandles()
{
if (mDelegated->isSelected()) {
......@@ -560,7 +559,7 @@ void UBGraphicsItemDelegate::updateButtons(bool showUpdated)
mDelegated->scene()->addItem(mDeleteButton);
}
if (showUpdated)
if (showUpdated /*&& mFrame->isResizing()*/)
mDeleteButton->show();
int i = 1, j = 0, k = 0;
......@@ -587,3 +586,10 @@ void UBGraphicsItemDelegate::updateButtons(bool showUpdated)
}
}
}
void UBGraphicsItemDelegate::setButtonsVisible(bool visible)
{
foreach(DelegateButton* pButton, mButtons){
pButton->setVisible(visible);
}
}
......@@ -136,6 +136,8 @@ class UBGraphicsItemDelegate : public QObject
void setFlippable(bool flippable);
bool isFlippable();
void setButtonsVisible(bool visible);
signals:
void showOnDisplayChanged(bool shown);
void lockChanged(bool locked);
......
......@@ -32,7 +32,7 @@ UBGraphicsPixmapItem::UBGraphicsPixmapItem(QGraphicsItem* parent)
mDelegate->init();
// 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);
setTransformationMode(Qt::SmoothTransformation);
......
......@@ -268,6 +268,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
, magniferControlViewWidget(0)
, magniferDisplayViewWidget(0)
, mZLayerController(new UBZLayerController(this))
, mIsDesktopMode(false)
{
#ifdef __ppc__
......@@ -292,8 +293,6 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
UBGraphicsScene::~UBGraphicsScene()
{
DisposeMagnifierQWidgets();
if (mCurrentStroke)
if (mCurrentStroke->polygons().empty())
delete mCurrentStroke;
......@@ -846,6 +845,15 @@ void UBGraphicsScene::setBackground(bool pIsDark, bool pIsCrossed)
}
}
void UBGraphicsScene::setBackgroundZoomFactor(qreal zoom)
{
mZoomFactor = zoom;
}
void UBGraphicsScene::setDrawingMode(bool bModeDesktop)
{
mIsDesktopMode = bModeDesktop;
}
void UBGraphicsScene::recolorAllItems()
{
......@@ -2005,6 +2013,58 @@ void UBGraphicsScene::drawItems (QPainter * painter, int numItems,
}
}
void UBGraphicsScene::drawBackground(QPainter *painter, const QRectF &rect)
{
if (mIsDesktopMode)
{
QGraphicsScene::drawBackground (painter, rect);
return;
}
bool darkBackground = isDarkBackground ();
if (darkBackground)
{
painter->fillRect (rect, QBrush (QColor (Qt::black)));
}
else
{
painter->fillRect (rect, QBrush (QColor (Qt::white)));
}
if (mZoomFactor > 0.5)
{
QColor bgCrossColor;
if (darkBackground)
bgCrossColor = UBSettings::crossDarkBackground;
else
bgCrossColor = UBSettings::crossLightBackground;
if (mZoomFactor < 1.0)
{
int alpha = 255 * mZoomFactor / 2;
bgCrossColor.setAlpha (alpha); // fade the crossing on small zooms
}
painter->setPen (bgCrossColor);
if (isCrossedBackground())
{
qreal firstY = ((int) (rect.y () / UBSettings::crossSize)) * UBSettings::crossSize;
for (qreal yPos = firstY; yPos < rect.y () + rect.height (); yPos += UBSettings::crossSize)
{
painter->drawLine (rect.x (), yPos, rect.x () + rect.width (), yPos);
}
qreal firstX = ((int) (rect.x () / UBSettings::crossSize)) * UBSettings::crossSize;
for (qreal xPos = firstX; xPos < rect.x () + rect.width (); xPos += UBSettings::crossSize)
{
painter->drawLine (xPos, rect.y (), xPos, rect.y () + rect.height ());
}
}
}
}
void UBGraphicsScene::keyReleaseEvent(QKeyEvent * keyEvent)
{
......
......@@ -292,7 +292,8 @@ public slots:
void hideEraser();
void setBackground(bool pIsDark, bool pIsCrossed);
void setBackgroundZoomFactor(qreal zoom);
void setDrawingMode(bool bModeDesktop);
void deselectAllItems();
UBGraphicsPixmapItem* addPixmap(const QPixmap& pPixmap, const QPointF& pPos = QPointF(0,0), qreal scaleFactor = 1.0, bool pUseAnimation = false);
......@@ -335,6 +336,8 @@ public slots:
QGraphicsItem* rootItem(QGraphicsItem* item) const;
virtual void drawBackground(QPainter *painter, const QRectF &rect);
private:
void setDocumentUpdated();
void createEraiser();
......@@ -350,6 +353,8 @@ public slots:
bool mDarkBackground;
bool mCrossedBackground;
bool mIsDesktopMode;
qreal mZoomFactor;
bool mIsModified;
......
......@@ -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 \
......
......@@ -19,6 +19,7 @@
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "domain/UBGraphicsScene.h"
#include "board/UBBoardView.h"
#include "core/memcheck.h"
......@@ -27,7 +28,6 @@ UBMagnifier::UBMagnifier(QWidget *parent, bool isInteractive)
: QWidget(parent, parent ? Qt::Widget : Qt::Tool | (Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint))
, mShouldMoveWidget(false)
, mShouldResizeWidget(false)
, inTimer(false)
, borderPen(Qt::darkGray)
, gView(0)
, mView(0)
......@@ -70,16 +70,11 @@ UBMagnifier::UBMagnifier(QWidget *parent, bool isInteractive)
#endif
}
connect(&mRefreshTimer, SIGNAL(timeout()), this, SLOT(slot_refresh()));
}
UBMagnifier::~UBMagnifier()
{
if (timerUpdate != 0)
{
killTimer(timerUpdate);
timerUpdate = 0;
}
if(sClosePixmap)
{
delete sClosePixmap;
......@@ -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()))
grabPoint(updPointGrab);
......@@ -307,28 +298,37 @@ void UBMagnifier::timerEvent(QTimerEvent *e)
isCusrsorAlreadyStored = false;
setCursor(mOldCursor);
}
}
inTimer = false;
}
}
void UBMagnifier::grabPoint()
{
QMatrix transM = UBApplication::boardController->controlView()->matrix();
QPointF itemPos = gView->mapFromGlobal(updPointGrab);
qreal zWidth = size().width() / params.zoom;
qreal zWidth = width() / (params.zoom * transM.m11());
qreal zWidthHalf = zWidth / 2;
qreal zHeight = size().height() / params.zoom;
qreal zHeight = height() / (params.zoom * transM.m22());
qreal zHeightHalf = zHeight / 2;
int x = itemPos.x() - zWidthHalf;
int y = itemPos.y() - zHeightHalf;
QPixmap newPixMap(QSize(zWidth,zHeight));
((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight));
UBApplication::boardController->activeScene()->update();
QPointF pfScLtF(UBApplication::boardController->controlView()->mapToScene(QPoint(itemPos.x(), itemPos.y())));
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.scaled(QSize(width(), height()));
......@@ -339,28 +339,43 @@ void UBMagnifier::grabPoint()
void UBMagnifier::grabPoint(const QPoint &pGrab)
{
QMatrix transM = UBApplication::boardController->controlView()->matrix();
updPointGrab = pGrab;
QPointF itemPos = gView->mapFromGlobal(pGrab);
qreal zWidth = size().width() / params.zoom;
qreal zWidth = width() / (params.zoom * transM.m11());
qreal zWidthHalf = zWidth / 2;
qreal zHeight = size().height() / params.zoom;
qreal zHeight = height() / (params.zoom * transM.m22());
qreal zHeightHalf = zHeight / 2;
int x = itemPos.x() - zWidthHalf;
int y = itemPos.y() - zHeightHalf;
QPixmap newPixMap(QSize(zWidth,zHeight));
((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight));
UBApplication::boardController->activeScene()->update();
QPointF pfScLtF(UBApplication::boardController->controlView()->mapToScene(QPoint(itemPos.x(), itemPos.y())));
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);
update();
}
// from global
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
void UBMagnifier::setGrabView(QWidget *view)
{
if (timerUpdate != 0)
killTimer(timerUpdate);
gView = view;
timerUpdate = startTimer(200);
mRefreshTimer.setInterval(40);
mRefreshTimer.start();
}
......@@ -54,9 +54,11 @@ signals:
void magnifierZoomOut_Signal();
void magnifierResized_Signal(qreal newPercentSize);
public slots:
void slot_refresh();
protected:
void paintEvent(QPaintEvent *);
void timerEvent(QTimerEvent *);
virtual void mousePressEvent ( QMouseEvent * event );
virtual void mouseMoveEvent ( QMouseEvent * event );
......@@ -78,10 +80,9 @@ protected:
QCursor mResizeCursor;
private:
bool inTimer;
QTimer mRefreshTimer;
bool m_isInteractive;
int timerUpdate;
QPoint updPointGrab;
QPoint updPointMove;
......
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