Commit 896383fd authored by shibakaneki's avatar shibakaneki

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

parents 4d2990a9 05564470
......@@ -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();
}
......
......@@ -13,7 +13,7 @@
* 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(){
......
......@@ -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",
......
......@@ -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
......
......@@ -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"
};
......
......@@ -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: "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
......
......@@ -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 = "";
......
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é"
};
......
......@@ -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);
......
......@@ -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)
......
......@@ -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;
}
......@@ -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);
......
#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
......@@ -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();
......
......@@ -18,6 +18,7 @@
#include <QtGui>
#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_ */
This diff is collapsed.
......@@ -21,9 +21,11 @@
#include <QMimeData>
#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;
......
......@@ -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);
}
}
......
......@@ -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_ */
This diff is collapsed.
......@@ -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<itemLayerType::Enum, ItemLayerTypeData> 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<QGraphicsItem*> tools(){ return mTools;}
void registerTool(QGraphicsItem* item)
......@@ -283,7 +285,9 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
return mPreviousPoint;
}
public slots:
void setSelectedZLevel(QList<QGraphicsItem *> itemList);
void setOwnZlevel(QList<QGraphicsItem *> 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;
};
......
......@@ -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();
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -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 \
......
......@@ -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:
......
......@@ -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<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());
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<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->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
......@@ -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
......
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