diff --git a/resources/sankore.qrc b/resources/sankore.qrc
index 6c721712..39456848 100644
--- a/resources/sankore.qrc
+++ b/resources/sankore.qrc
@@ -176,7 +176,7 @@
images/cursors/rotate.png
images/cursors/resize.png
images/cursors/drawCompass.png
- images/cursors/drawRulerLine.png
+ images/cursors/drawRulerLine.png
images/print/onepage.png
images/print/thumbnails.png
images/print/twopages.png
@@ -289,8 +289,6 @@
images/toolbar/hide.png
images/toolbar/record.png
images/libpalette/MoviesCategory.svg
-
-
images/virtual.keyboard/41/centre-passive.png
images/virtual.keyboard/41/left-passive.png
images/virtual.keyboard/41/right-passive.png
@@ -300,7 +298,6 @@
images/virtual.keyboard/41/backspace.png
images/virtual.keyboard/41/capslock.png
images/virtual.keyboard/41/tab.png
-
images/virtual.keyboard/29/centre-passive.png
images/virtual.keyboard/29/left-passive.png
images/virtual.keyboard/29/right-passive.png
@@ -310,6 +307,6 @@
images/virtual.keyboard/29/backspace.png
images/virtual.keyboard/29/capslock.png
images/virtual.keyboard/29/tab.png
-
+ images/toolPalette/cacheTool.png
diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp
index 2e9c417f..43f30741 100644
--- a/src/adaptors/UBSvgSubsetAdaptor.cpp
+++ b/src/adaptors/UBSvgSubsetAdaptor.cpp
@@ -35,6 +35,7 @@
#include "tools/UBGraphicsProtractor.h"
#include "tools/UBGraphicsCurtainItem.h"
#include "tools/UBGraphicsTriangle.h"
+#include "tools/UBGraphicsCache.h"
#include "document/UBDocumentProxy.h"
@@ -654,7 +655,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene->registerTool(protractor);
}
}
- else if (mXmlReader.name() == "protractor")
+ else if (mXmlReader.name() == "triangle")
{
UBGraphicsTriangle *triangle = triangleFromSvg();
@@ -664,6 +665,15 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene->registerTool(triangle);
}
}
+ else if(mXmlReader.name() == "cache")
+ {
+ UBGraphicsCache* cache = cacheFromSvg();
+ if(cache)
+ {
+ scene->addItem(cache);
+ scene->registerTool(cache);
+ }
+ }
else if (mXmlReader.name() == "foreignObject")
{
QString href = mXmlReader.attributes().value(nsXLink, "href").toString();
@@ -1045,6 +1055,13 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene()
continue;
}
+ UBGraphicsCache* cache = qgraphicsitem_cast(item);
+ if(cache && cache->isVisible())
+ {
+ cacheToSvg(cache);
+ continue;
+ }
+
UBGraphicsCompass *compass = qgraphicsitem_cast (item);
if (compass && compass->isVisible())
@@ -1060,6 +1077,7 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene()
protractorToSvg(protractor);
continue;
}
+
}
if (openStroke)
@@ -2615,6 +2633,38 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg()
return triangle;
}
+UBGraphicsCache* UBSvgSubsetAdaptor::UBSvgSubsetReader::cacheFromSvg()
+{
+ UBGraphicsCache* pCache = new UBGraphicsCache();
+ pCache->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
+ pCache->setVisible(true);
+
+ return pCache;
+}
+
+void UBSvgSubsetAdaptor::UBSvgSubsetWriter::cacheToSvg(UBGraphicsCache* item)
+{
+ mXmlWriter.writeStartElement(UBSettings::uniboardDocumentNamespaceUri, "cache");
+
+ mXmlWriter.writeAttribute("x", QString("%1").arg(item->rect().x()));
+ mXmlWriter.writeAttribute("y", QString("%1").arg(item->rect().y()));
+ mXmlWriter.writeAttribute("width", QString("%1").arg(item->rect().width()));
+ mXmlWriter.writeAttribute("height", QString("%1").arg(item->rect().height()));
+
+ QString zs;
+ zs.setNum(item->zValue(), 'f'); // 'f' keeps precision
+ mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "z-value", zs);
+
+ UBItem* ubItem = dynamic_cast(item);
+
+ if (ubItem)
+ {
+ mXmlWriter.writeAttribute(UBSettings::uniboardDocumentNamespaceUri, "uuid", UBStringUtils::toCanonicalUuid(ubItem->uuid()));
+ }
+
+ mXmlWriter.writeEndElement();
+}
+
void UBSvgSubsetAdaptor::convertPDFObjectsToImages(UBDocumentProxy* proxy)
{
for (int i = 0; i < proxy->pageCount(); i++)
diff --git a/src/adaptors/UBSvgSubsetAdaptor.h b/src/adaptors/UBSvgSubsetAdaptor.h
index aa60eae1..a18fa34c 100644
--- a/src/adaptors/UBSvgSubsetAdaptor.h
+++ b/src/adaptors/UBSvgSubsetAdaptor.h
@@ -40,6 +40,7 @@ class UBDocumentProxy;
class UBGraphicsStroke;
class UBPersistenceManager;
class UBGraphicsTriangle;
+class UBGraphicsCache;
class UBSvgSubsetAdaptor
{
@@ -127,7 +128,9 @@ class UBSvgSubsetAdaptor
UBGraphicsProtractor* protractorFromSvg();
- UBGraphicsTriangle* triangleFromSvg();
+ UBGraphicsTriangle* triangleFromSvg();
+
+ UBGraphicsCache* cacheFromSvg();
void graphicsItemFromSvg(QGraphicsItem* gItem);
@@ -210,6 +213,7 @@ class UBSvgSubsetAdaptor
void rulerToSvg(UBGraphicsRuler *item);
void compassToSvg(UBGraphicsCompass *item);
void protractorToSvg(UBGraphicsProtractor *item);
+ void cacheToSvg(UBGraphicsCache* item);
void writeSvgElement();
private:
diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp
index 97e7bdb8..782cf085 100644
--- a/src/board/UBBoardController.cpp
+++ b/src/board/UBBoardController.cpp
@@ -1009,11 +1009,16 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
mActiveScene->addProtractor(pPos);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
}
- else if (sourceUrl.toString() == UBToolsManager::manager()->triangle.id)
+ else if (sourceUrl.toString() == UBToolsManager::manager()->triangle.id)
{
mActiveScene->addTriangle(pPos);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
}
+ else if(sourceUrl.toString() == UBToolsManager::manager()->cache.id)
+ {
+ mActiveScene->addCache();
+ UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
+ }
else if (sourceUrl.toString() == UBToolsManager::manager()->mask.id)
{
mActiveScene->addMask();
@@ -1557,7 +1562,7 @@ void UBBoardController::stylusToolChanged(int tool)
if(eTool != UBStylusTool::Selector && eTool != UBStylusTool::Text)
{
if(mPaletteManager->mKeyboardPalette->m_isVisible)
- UBApplication::mainWindow->actionVirtualKeyboard->activate(QAction::Trigger);
+ UBApplication::mainWindow->actionVirtualKeyboard->activate(QAction::Trigger);
}
}
diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp
index 0974105f..bd8e0ee6 100644
--- a/src/domain/UBGraphicsScene.cpp
+++ b/src/domain/UBGraphicsScene.cpp
@@ -34,6 +34,7 @@
#include "tools/UBGraphicsCompass.h"
#include "tools/UBGraphicsTriangle.h"
#include "tools/UBGraphicsCurtainItem.h"
+#include "tools/UBGraphicsCache.h"
#include "document/UBDocumentProxy.h"
@@ -68,6 +69,7 @@ qreal UBGraphicsScene::toolOffsetProtractor = 100;
qreal UBGraphicsScene::toolOffsetTriangle = 100;
qreal UBGraphicsScene::toolOffsetCompass = 100;
qreal UBGraphicsScene::toolOffsetEraser = 200;
+qreal UBGraphicsScene::toolOffsetCache = 1000;
qreal UBGraphicsScene::toolOffsetCurtain = 1000;
qreal UBGraphicsScene::toolOffsetPointer = 1100;
@@ -132,7 +134,7 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
}
connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing()));
-
+ mHasCache = false;
}
@@ -1484,6 +1486,24 @@ void UBGraphicsScene::addCompass(QPointF center)
setModified(true);
}
+void UBGraphicsScene::addCache()
+{
+ UBGraphicsCache* cache = new UBGraphicsCache();
+ mTools << cache;
+ QGraphicsView* view;
+
+ if(UBApplication::applicationController->displayManager()->hasDisplay())
+ {
+ view = (QGraphicsView*)(UBApplication::boardController->displayView());
+ }
+ else
+ {
+ view = (QGraphicsView*)(UBApplication::boardController->controlView());
+ }
+ addItem(cache);
+ cache->setVisible(true);
+ cache->setSelected(true);
+}
void UBGraphicsScene::addMask()
{
diff --git a/src/domain/UBGraphicsScene.h b/src/domain/UBGraphicsScene.h
index e3d30af3..fd29b21c 100644
--- a/src/domain/UBGraphicsScene.h
+++ b/src/domain/UBGraphicsScene.h
@@ -44,6 +44,7 @@ class UBAbstractWidget;
class UBDocumentProxy;
class UBGraphicsCurtainItem;
class UBGraphicsStroke;
+class UBGraphicsCache;
const double PI = 4.0 * atan(1.0);
@@ -164,9 +165,10 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
qreal getNextObjectZIndex();
void addRuler(QPointF center);
- void addTriangle(QPointF center);
+ void addTriangle(QPointF center);
void addProtractor(QPointF center);
void addCompass(QPointF center);
+ void addCache();
void addMask();
@@ -243,7 +245,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
static qreal toolOffsetProtractor;
static qreal toolOffsetCompass;
static qreal toolOffsetCurtain;
- static qreal toolOffsetTriangle;
+ static qreal toolOffsetTriangle;
+ static qreal toolOffsetCache;
QSet tools(){ return mTools;}
@@ -347,6 +350,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
QList mFastAccessItems; // a local copy as QGraphicsScene::items() is very slow in Qt 4.6
//int mMesure1Ms, mMesure2Ms;
+
+ bool mHasCache;
};
#endif /* UBGRAPHICSSCENE_H_ */
diff --git a/src/gui/UBDockPalette.cpp b/src/gui/UBDockPalette.cpp
index 49fbddd6..e1e44528 100644
--- a/src/gui/UBDockPalette.cpp
+++ b/src/gui/UBDockPalette.cpp
@@ -53,9 +53,13 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
, mCollapseWidth(150)
, mLastWidth(-1)
, mHTab(0)
+ , mpStackWidget(NULL)
{
setObjectName(name);
+ // clear the tab widgets
+ mTabWidgets.clear();
+
// We let 2 pixels in order to keep a small border for the resizing
setMinimumWidth(2*border() + 2);
@@ -91,7 +95,11 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
*/
UBDockPalette::~UBDockPalette()
{
-
+ if(NULL != mpStackWidget)
+ {
+ delete mpStackWidget;
+ mpStackWidget = NULL;
+ }
}
/**
@@ -314,36 +322,39 @@ void UBDockPalette::paintEvent(QPaintEvent *event)
painter.setPen(Qt::NoPen);
painter.setBrush(mBackgroundBrush);
- if(eUBDockTabOrientation_Up == mTabsOrientation)
+ for(int i = 0; i < mTabWidgets.size(); i++)
{
- mHTab = border();
- }
- else
- {
- mHTab = height() - border() - TABSIZE;
- }
+ if(eUBDockTabOrientation_Up == mTabsOrientation)
+ {
+ mHTab = border();
+ }
+ else
+ {
+ mHTab = height() - border() - i*TABSIZE;
+ }
- if(mOrientation == eUBDockOrientation_Left)
- {
- QPainterPath path;
- path.setFillRule(Qt::WindingFill);
- path.addRect(0.0, 0.0, width()-2*border(), height());
- path.addRoundedRect(width()-4*border(), mHTab, 4*border(), TABSIZE, radius(), radius());
- painter.drawPath(path);
- painter.drawPixmap(width() - border() + 1, mHTab + 1 , border() - 4, TABSIZE - 2, mIcon);
- }
- else if(mOrientation == eUBDockOrientation_Right)
- {
- QPainterPath path;
- path.setFillRule(Qt::WindingFill);
- path.addRect(2*border(), 0.0, width()-2*border(), height());
- path.addRoundedRect(0.0, mHTab, 4*border(), TABSIZE, radius(), radius());
- painter.drawPath(path);
- painter.drawPixmap(2, mHTab + 1, border() - 3, TABSIZE - 2, mIcon);
- }
- else
- {
- painter.drawRoundedRect(border(), border(), width() - 2 * border(), height() - 2 * border(), radius(), radius());
+ if(mOrientation == eUBDockOrientation_Left)
+ {
+ QPainterPath path;
+ path.setFillRule(Qt::WindingFill);
+ path.addRect(0.0, 0.0, width()-2*border(), height());
+ path.addRoundedRect(width()-4*border(), mHTab, 4*border(), TABSIZE, radius(), radius());
+ painter.drawPath(path);
+ //painter.drawPixmap(width() - border() + 1, mHTab + 1 , border() - 4, TABSIZE - 2, mIcon);
+ }
+ else if(mOrientation == eUBDockOrientation_Right)
+ {
+ QPainterPath path;
+ path.setFillRule(Qt::WindingFill);
+ path.addRect(2*border(), 0.0, width()-2*border(), height());
+ path.addRoundedRect(0.0, mHTab, 4*border(), TABSIZE, radius(), radius());
+ painter.drawPath(path);
+ //painter.drawPixmap(2, mHTab + 1, border() - 3, TABSIZE - 2, mIcon);
+ }
+ else
+ {
+ painter.drawRoundedRect(border(), border(), width() - 2 * border(), height() - 2 * border(), radius(), radius());
+ }
}
}
@@ -437,3 +448,13 @@ int UBDockPalette::customMargin()
{
return 5;
}
+
+void UBDockPalette::addTabWidget(const QString &widgetName, UBDockPaletteWidget *widget)
+{
+ mTabWidgets[widgetName] = widget;
+}
+
+void UBDockPalette::removeTab(const QString &widgetName)
+{
+ mTabWidgets.remove(widgetName);
+}
diff --git a/src/gui/UBDockPalette.h b/src/gui/UBDockPalette.h
index 17440662..06c1df54 100644
--- a/src/gui/UBDockPalette.h
+++ b/src/gui/UBDockPalette.h
@@ -24,6 +24,10 @@
#include
#include
#include
+#include
+#include
+
+#include "UBDockPaletteWidget.h"
#define TABSIZE 50
#define CLICKTIME 1000000
@@ -64,6 +68,8 @@ public:
virtual void leaveEvent(QEvent *);
void setBackgroundBrush(const QBrush& brush);
+ void addTabWidget(const QString& widgetName, UBDockPaletteWidget* widget);
+ void removeTab(const QString& widgetName);
protected:
virtual int border();
@@ -93,12 +99,16 @@ protected:
QTime mClickTime;
/** The mouse pressed position */
QPoint mMousePressPos;
- /** The palette icon */
- QPixmap mIcon;
+ ///** The palette icon */
+ //QPixmap mIcon;
/** The tab orientation */
eUBDockTabOrientation mTabsOrientation;
/** The h position of the tab */
int mHTab;
+ /** The tab widgets */
+ QMap mTabWidgets;
+ /** The stacked widget */
+ QStackedWidget* mpStackWidget;
private slots:
void onToolbarPosUpdated();
diff --git a/src/gui/UBDockPaletteWidget.cpp b/src/gui/UBDockPaletteWidget.cpp
new file mode 100644
index 00000000..bf8e51c7
--- /dev/null
+++ b/src/gui/UBDockPaletteWidget.cpp
@@ -0,0 +1,36 @@
+#include "UBDockPaletteWidget.h"
+
+UBDockPaletteWidget::UBDockPaletteWidget(const char *name, QWidget *parent):QWidget(parent)
+ , mpWidget(NULL)
+{
+ setObjectName(name);
+
+}
+
+UBDockPaletteWidget::~UBDockPaletteWidget()
+{
+ if(NULL != mpWidget)
+ {
+ delete mpWidget;
+ mpWidget = NULL;
+ }
+}
+
+QWidget* UBDockPaletteWidget::widget()
+{
+ return mpWidget;
+}
+
+QIcon UBDockPaletteWidget::icon()
+{
+ return mIcon;
+}
+
+QIcon UBDockPaletteWidget::collapsedIcon()
+{
+ return mCollapsedIcon;
+}
+ QString UBDockPaletteWidget::name()
+ {
+ return mName;
+ }
diff --git a/src/gui/UBDockPaletteWidget.h b/src/gui/UBDockPaletteWidget.h
new file mode 100644
index 00000000..6d21a15a
--- /dev/null
+++ b/src/gui/UBDockPaletteWidget.h
@@ -0,0 +1,27 @@
+#ifndef UBDOCKPALETTEWIDGET_H
+#define UBDOCKPALETTEWIDGET_H
+
+#include
+#include
+#include
+
+class UBDockPaletteWidget : public QWidget
+{
+public:
+ UBDockPaletteWidget(const char* name="UBDockPaletteWidget", QWidget* parent=0);
+ ~UBDockPaletteWidget();
+
+ QWidget* widget();
+ QIcon icon();
+ QIcon collapsedIcon();
+ QString name();
+
+protected:
+ QWidget* mpWidget;
+ QIcon mIcon;
+ QIcon mCollapsedIcon;
+ QString mName;
+
+};
+
+#endif // UBDOCKPALETTEWIDGET_H
diff --git a/src/gui/UBLibPalette.cpp b/src/gui/UBLibPalette.cpp
index fb5c9a1f..4e495559 100644
--- a/src/gui/UBLibPalette.cpp
+++ b/src/gui/UBLibPalette.cpp
@@ -31,7 +31,7 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare
, mDropWidget(NULL)
{
setOrientation(eUBDockOrientation_Right);
- mIcon = QPixmap(":images/paletteLibrary.png");
+ //mIcon = QPixmap(":images/paletteLibrary.png");
setAcceptDrops(true);
resize(UBSettings::settings()->libPaletteWidth->get().toInt(), parentWidget()->height());
diff --git a/src/gui/UBNavigatorPalette.cpp b/src/gui/UBNavigatorPalette.cpp
index 8ac69e5e..ffedfae5 100644
--- a/src/gui/UBNavigatorPalette.cpp
+++ b/src/gui/UBNavigatorPalette.cpp
@@ -32,7 +32,7 @@ UBNavigatorPalette::UBNavigatorPalette(QWidget *parent, const char *name):UBDock
{
setOrientation(eUBDockOrientation_Left);
setMaximumWidth(300);
- mIcon = QPixmap(":images/paletteNavigator.png");
+ //mIcon = QPixmap(":images/paletteNavigator.png");
resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), height());
mLastWidth = 300;
diff --git a/src/gui/gui.pri b/src/gui/gui.pri
index c1f18185..67bab1be 100644
--- a/src/gui/gui.pri
+++ b/src/gui/gui.pri
@@ -38,7 +38,8 @@ HEADERS += src/gui/UBThumbnailView.h \
src/gui/UBLibActionBar.h \
src/gui/UBLibraryWidget.h \
src/gui/UBLibPathViewer.h \
- src/gui/UBUpdateDlg.h
+ src/gui/UBUpdateDlg.h \
+ src/gui/UBDockPaletteWidget.h
SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBFloatingPalette.cpp \
@@ -79,7 +80,8 @@ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBLibActionBar.cpp \
src/gui/UBLibraryWidget.cpp \
src/gui/UBLibPathViewer.cpp \
- src/gui/UBUpdateDlg.cpp
+ src/gui/UBUpdateDlg.cpp \
+ src/gui/UBDockPaletteWidget.cpp
win32 {
diff --git a/src/tools/UBGraphicsCache.cpp b/src/tools/UBGraphicsCache.cpp
new file mode 100644
index 00000000..b226132c
--- /dev/null
+++ b/src/tools/UBGraphicsCache.cpp
@@ -0,0 +1,142 @@
+/*
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#include
+
+#include "UBGraphicsCache.h"
+
+#include "core/UBApplication.h"
+
+#include "board/UBBoardController.h"
+#include "board/UBBoardView.h"
+#include "domain/UBGraphicsScene.h"
+
+
+UBGraphicsCache::UBGraphicsCache():QGraphicsRectItem()
+ , mMaskColor(Qt::black)
+ , mMaskShape(eMaskShape_Circle)
+ , mShapeWidth(100)
+ , mDrawMask(false)
+{
+ // Get the board size and pass it to the shape
+ QRect boardRect = UBApplication::boardController->displayView()->rect();
+ setRect(-15*boardRect.width(), -15*boardRect.height(), 30*boardRect.width(), 30*boardRect.height());
+ setZValue(CACHE_ZVALUE);
+}
+
+UBGraphicsCache::~UBGraphicsCache()
+{
+
+}
+
+UBItem* UBGraphicsCache::deepCopy() const
+{
+ UBGraphicsCache* copy = new UBGraphicsCache();
+
+ copy->setPos(this->pos());
+ copy->setRect(this->rect());
+ copy->setZValue(this->zValue());
+ copy->setTransform(this->transform());
+
+ // TODO UB 4.7 ... complete all members ?
+
+ return copy;
+}
+
+QColor UBGraphicsCache::maskColor()
+{
+ return mMaskColor;
+}
+
+void UBGraphicsCache::setMaskColor(QColor color)
+{
+ mMaskColor = color;
+}
+
+eMaskShape UBGraphicsCache::maskshape()
+{
+ return mMaskShape;
+}
+
+void UBGraphicsCache::setMaskShape(eMaskShape shape)
+{
+ mMaskShape = shape;
+}
+
+void UBGraphicsCache::init()
+{
+ setFlag(QGraphicsItem::ItemIsMovable, true);
+ setFlag(QGraphicsItem::ItemIsSelectable, true);
+ setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
+}
+
+void UBGraphicsCache::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ Q_UNUSED(option);
+ Q_UNUSED(widget);
+
+ setZValue(CACHE_ZVALUE);
+
+ painter->setBrush(mMaskColor);
+ painter->setPen(mMaskColor);
+
+ QPainterPath path;
+ path.addRect(rect());
+
+ if(mDrawMask)
+ {
+ if(eMaskShape_Circle == mMaskShape)
+ {
+ path.addEllipse(mShapePos, mShapeWidth, mShapeWidth);
+ }
+ else if(eMaskShap_Rectangle == mMaskShape)
+ {
+ path.addRect(mShapePos.x(), mShapePos.y(), mShapeWidth, mShapeWidth);
+ }
+ path.setFillRule(Qt::OddEvenFill);
+ }
+
+ painter->drawPath(path);
+}
+
+void UBGraphicsCache::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_UNUSED(event);
+ mShapePos = event->pos();
+ mDrawMask = true;
+ update();
+}
+
+void UBGraphicsCache::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ mShapePos = event->pos();
+ update();
+}
+
+void UBGraphicsCache::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_UNUSED(event);
+ mDrawMask = false;
+ update();
+}
+
+int UBGraphicsCache::shapeWidth()
+{
+ return mShapeWidth;
+}
+
+void UBGraphicsCache::setShapeWidth(int width)
+{
+ mShapeWidth = width;
+}
diff --git a/src/tools/UBGraphicsCache.h b/src/tools/UBGraphicsCache.h
new file mode 100644
index 00000000..1f41dbf8
--- /dev/null
+++ b/src/tools/UBGraphicsCache.h
@@ -0,0 +1,61 @@
+/*
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+#ifndef UBGRAPHICSCACHE_H
+#define UBGRAPHICSCACHE_H
+
+#include
+#include
+
+#include "domain/UBItem.h"
+
+#define CACHE_ZVALUE 100000
+
+typedef enum
+{
+ eMaskShape_Circle,
+ eMaskShap_Rectangle
+}eMaskShape;
+
+class UBGraphicsCache : public QGraphicsRectItem, public UBItem
+{
+public:
+ UBGraphicsCache();
+ ~UBGraphicsCache();
+ virtual UBItem* deepCopy() const;
+
+ QColor maskColor();
+ void setMaskColor(QColor color);
+ eMaskShape maskshape();
+ void setMaskShape(eMaskShape shape);
+ int shapeWidth();
+ void setShapeWidth(int width);
+
+protected:
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+
+private:
+ void init();
+
+ QColor mMaskColor;
+ eMaskShape mMaskShape;
+ int mShapeWidth;
+ bool mDrawMask;
+ QPointF mShapePos;
+};
+
+#endif // UBGRAPHICSCACHE_H
diff --git a/src/tools/UBToolsManager.cpp b/src/tools/UBToolsManager.cpp
index 0b58a5c6..8bf10e24 100644
--- a/src/tools/UBToolsManager.cpp
+++ b/src/tools/UBToolsManager.cpp
@@ -58,9 +58,15 @@ UBToolsManager::UBToolsManager(QObject *parent)
mToolsIcon.insert(triangle.id,":/images/toolPalette/triangleTool.png");
mDescriptors << triangle;
+ cache.id = "uniboardTool://uniboard.mnemis.com/cache";
+ cache.icon = QPixmap(":/images/toolPalette/cacheTool.png");
+ cache.label = tr("Cache");
+ cache.version = "1.0";
+ mToolsIcon.insert(cache.id, ":/images/toolPalette/cacheTool.png");
+ mDescriptors << cache;
}
UBToolsManager::~UBToolsManager()
{
// NOOP
-}
\ No newline at end of file
+}
diff --git a/src/tools/UBToolsManager.h b/src/tools/UBToolsManager.h
index 8844bdd2..8517822b 100644
--- a/src/tools/UBToolsManager.h
+++ b/src/tools/UBToolsManager.h
@@ -77,7 +77,8 @@ class UBToolsManager : public QObject
UBToolDescriptor protractor;
UBToolDescriptor compass;
UBToolDescriptor mask;
- UBToolDescriptor triangle;
+ UBToolDescriptor triangle;
+ UBToolDescriptor cache;
QString iconFromToolId(QString id) { return mToolsIcon.value(id);}
diff --git a/src/tools/tools.pri b/src/tools/tools.pri
index a7247816..90e69659 100644
--- a/src/tools/tools.pri
+++ b/src/tools/tools.pri
@@ -1,18 +1,20 @@
-
-HEADERS += src/tools/UBGraphicsRuler.h \
- src/tools/UBGraphicsTriangle.h \
- src/tools/UBGraphicsProtractor.h \
- src/tools/UBGraphicsCompass.h \
- src/tools/UBToolsManager.h \
- src/tools/UBGraphicsCurtainItem.h \
- src/tools/UBGraphicsCurtainItemDelegate.h \
- src/tools/UBAbstractDrawRuler.h
-
-SOURCES += src/tools/UBGraphicsRuler.cpp \
- src/tools/UBGraphicsTriangle.cpp \
- src/tools/UBGraphicsProtractor.cpp \
- src/tools/UBGraphicsCompass.cpp \
- src/tools/UBToolsManager.cpp \
- src/tools/UBGraphicsCurtainItem.cpp \
- src/tools/UBGraphicsCurtainItemDelegate.cpp \
- src/tools/UBAbstractDrawRuler.cpp
\ No newline at end of file
+
+HEADERS += src/tools/UBGraphicsRuler.h \
+ src/tools/UBGraphicsTriangle.h \
+ src/tools/UBGraphicsProtractor.h \
+ src/tools/UBGraphicsCompass.h \
+ src/tools/UBToolsManager.h \
+ src/tools/UBGraphicsCurtainItem.h \
+ src/tools/UBGraphicsCurtainItemDelegate.h \
+ src/tools/UBAbstractDrawRuler.h \
+ src/tools/UBGraphicsCache.h
+
+SOURCES += src/tools/UBGraphicsRuler.cpp \
+ src/tools/UBGraphicsTriangle.cpp \
+ src/tools/UBGraphicsProtractor.cpp \
+ src/tools/UBGraphicsCompass.cpp \
+ src/tools/UBToolsManager.cpp \
+ src/tools/UBGraphicsCurtainItem.cpp \
+ src/tools/UBGraphicsCurtainItemDelegate.cpp \
+ src/tools/UBAbstractDrawRuler.cpp \
+ src/tools/UBGraphicsCache.cpp