diff --git a/resources/forms/mainWindow.ui b/resources/forms/mainWindow.ui
index e0b23cad..790c01fc 100644
--- a/resources/forms/mainWindow.ui
+++ b/resources/forms/mainWindow.ui
@@ -1638,115 +1638,6 @@
Ctrl+H
-
-
- true
-
-
-
- :/images/stylusPalette/magnifier.png
- :/images/stylusPalette/magnifierOn.png:/images/stylusPalette/magnifier.png
-
-
- Magnifier
-
-
- Magnifier
-
-
-
-
- true
-
-
-
- :/images/toolbar/smallMagnifierZoom.png:/images/toolbar/smallMagnifierZoom.png
-
-
- Zoom
-
-
- x2 Zoom
-
-
-
-
- true
-
-
- true
-
-
-
- :/images/toolbar/mediumMagnifierZoom.png:/images/toolbar/mediumMagnifierZoom.png
-
-
- Zoom
-
-
- x3 Zoom
-
-
-
-
- true
-
-
-
- :/images/toolbar/largeMagnifierZoom.png:/images/toolbar/largeMagnifierZoom.png
-
-
- Zoom
-
-
- x4 Zoom
-
-
-
-
- true
-
-
-
- :/images/toolbar/smallMagnifierSize.png:/images/toolbar/smallMagnifierSize.png
-
-
- Size
-
-
- 10% from scene size
-
-
-
-
- true
-
-
-
- :/images/toolbar/mediumMagnifierSize.png:/images/toolbar/mediumMagnifierSize.png
-
-
- Size
-
-
- 20% from scene size
-
-
-
-
- true
-
-
-
- :/images/toolbar/largeMagnifierSize.png:/images/toolbar/largeMagnifierSize.png
-
-
- Size
-
-
- 30% from scene size
-
-
diff --git a/resources/images/close.svg b/resources/images/close.svg
index 5fa855a2..f552d322 100644
--- a/resources/images/close.svg
+++ b/resources/images/close.svg
@@ -5,6 +5,5 @@
width="26px" height="26px" viewBox="0 0 26 26" style="enable-background:new 0 0 26 26;" xml:space="preserve">
-
+
diff --git a/resources/images/cursors/magnifier.png b/resources/images/cursors/magnifier.png
deleted file mode 100644
index f2decb01..00000000
Binary files a/resources/images/cursors/magnifier.png and /dev/null differ
diff --git a/resources/images/decrease.svg b/resources/images/decrease.svg
new file mode 100644
index 00000000..2f81bf5a
--- /dev/null
+++ b/resources/images/decrease.svg
@@ -0,0 +1,9 @@
+
+
+
+
diff --git a/resources/images/increase.svg b/resources/images/increase.svg
new file mode 100644
index 00000000..23a4cf44
--- /dev/null
+++ b/resources/images/increase.svg
@@ -0,0 +1,9 @@
+
+
+
+
diff --git a/resources/images/stylusPalette/magnifier.png b/resources/images/stylusPalette/magnifier.png
deleted file mode 100644
index f17b51c7..00000000
Binary files a/resources/images/stylusPalette/magnifier.png and /dev/null differ
diff --git a/resources/images/stylusPalette/magnifierOn.png b/resources/images/stylusPalette/magnifierOn.png
deleted file mode 100644
index 5e454e7f..00000000
Binary files a/resources/images/stylusPalette/magnifierOn.png and /dev/null differ
diff --git a/resources/images/toolPalette/cacheTool.png b/resources/images/toolPalette/cacheTool.png
new file mode 100644
index 00000000..d83c8d61
Binary files /dev/null and b/resources/images/toolPalette/cacheTool.png differ
diff --git a/resources/images/toolPalette/magnifierTool.png b/resources/images/toolPalette/magnifierTool.png
new file mode 100644
index 00000000..a0a19206
Binary files /dev/null and b/resources/images/toolPalette/magnifierTool.png differ
diff --git a/resources/images/toolbar/largeMagnifierSize.png b/resources/images/toolbar/largeMagnifierSize.png
deleted file mode 100644
index ef67e2d4..00000000
Binary files a/resources/images/toolbar/largeMagnifierSize.png and /dev/null differ
diff --git a/resources/images/toolbar/largeMagnifierZoom.png b/resources/images/toolbar/largeMagnifierZoom.png
deleted file mode 100644
index a5035a13..00000000
Binary files a/resources/images/toolbar/largeMagnifierZoom.png and /dev/null differ
diff --git a/resources/images/toolbar/mediumMagnifierSize.png b/resources/images/toolbar/mediumMagnifierSize.png
deleted file mode 100644
index feacbdee..00000000
Binary files a/resources/images/toolbar/mediumMagnifierSize.png and /dev/null differ
diff --git a/resources/images/toolbar/mediumMagnifierZoom.png b/resources/images/toolbar/mediumMagnifierZoom.png
deleted file mode 100644
index 5cad3740..00000000
Binary files a/resources/images/toolbar/mediumMagnifierZoom.png and /dev/null differ
diff --git a/resources/images/toolbar/smallMagnifierSize.png b/resources/images/toolbar/smallMagnifierSize.png
deleted file mode 100644
index 9d49d8e7..00000000
Binary files a/resources/images/toolbar/smallMagnifierSize.png and /dev/null differ
diff --git a/resources/images/toolbar/smallMagnifierZoom.png b/resources/images/toolbar/smallMagnifierZoom.png
deleted file mode 100644
index df7f8d56..00000000
Binary files a/resources/images/toolbar/smallMagnifierZoom.png and /dev/null differ
diff --git a/resources/library/interactive/Graphme.wgt/Grapheur.xhtml b/resources/library/interactive/Graphme.wgt/Grapheur.xhtml
index 14b7a9e5..7092abf5 100644
--- a/resources/library/interactive/Graphme.wgt/Grapheur.xhtml
+++ b/resources/library/interactive/Graphme.wgt/Grapheur.xhtml
@@ -148,8 +148,15 @@
$("#borneXGauche").val(sankore.preference("xAxisFrom", "-5"));
$("#borneXDroite").val(sankore.preference("xAxisTo", "5"));
$("#borneYGauche").val(sankore.preference("yAxisFrom", "-5"));
- $("#borneYDroite").val(sankore.preference("yAxisTo", "5"));
+ $("#borneYDroite").val(sankore.preference("yAxisTo", "5"));
+ var tempArray;
+ if(sankore.preference("graphmeHistory",""))
+ tempArray = sankore.preference("graphmeHistory","").split(",");
+ if(sankore.preference("graphmeHistory","")){
+ for(i in tempArray)
+ evaluer(tempArray[i]);
+ }
actualiserGraph();
loadingFlag = true;
}
@@ -225,6 +232,9 @@
sankore.setPreference("offsetDiagrammX", $("#inputDecalageX").val());
sankore.setPreference("offsetDiagrammY", $("#inputDecalageY").val());
sankore.setPreference("accuracyGraph", $("#inputPrecision").val());
+
+ if(historique.length)
+ sankore.setPreference("graphmeHistory", historique.toString());
}
});
});
diff --git a/resources/sankore.qrc b/resources/sankore.qrc
index 84693b88..ebd0fc91 100644
--- a/resources/sankore.qrc
+++ b/resources/sankore.qrc
@@ -3,6 +3,8 @@
images/uniboard.png
images/bigUniboard.png
images/close.svg
+ images/increase.svg
+ images/decrease.svg
images/resize.svg
images/play.svg
images/pause.svg
@@ -121,12 +123,6 @@
images/toolbar/eraserTool.png
images/toolbar/lineTool.png
images/toolbar/tools.png
- images/toolbar/largeMagnifierSize.png
- images/toolbar/mediumMagnifierSize.png
- images/toolbar/smallMagnifierSize.png
- images/toolbar/largeMagnifierZoom.png
- images/toolbar/mediumMagnifierZoom.png
- images/toolbar/smallMagnifierZoom.png
images/stylusPalette/arrow.png
images/stylusPalette/arrowOn.png
images/stylusPalette/eraser.png
@@ -150,8 +146,6 @@
images/stylusPalette/textOn.png
images/stylusPalette/captureArea.png
images/stylusPalette/captureAreaOn.png
- images/stylusPalette/magnifier.png
- images/stylusPalette/magnifierOn.png
images/backgroundPalette/background1.svg
images/backgroundPalette/background1On.svg
images/backgroundPalette/background2.svg
@@ -167,6 +161,7 @@
images/toolPalette/protractorTool.png
images/toolPalette/compassTool.png
images/toolPalette/maskTool.png
+ images/toolPalette/magnifierTool.png
images/extraPalette/blackout.png
images/extraPalette/keyboard.png
images/extraPalette/trapFlash.png
@@ -185,7 +180,6 @@
images/cursors/resize.png
images/cursors/drawCompass.png
images/cursors/drawRulerLine.png
- images/cursors/magnifier.png
images/print/onepage.png
images/print/thumbnails.png
images/print/twopages.png
@@ -315,6 +309,7 @@
images/virtual.keyboard/29/backspace.png
images/virtual.keyboard/29/capslock.png
images/virtual.keyboard/29/tab.png
+ images/toolPalette/cacheTool.png
images/libpalette/FlashCategory.svg
images/libpalette/FlashIcon.svg
images/toolbar/stylusTab.png
diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp
index aee459d8..acfdce99 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"
@@ -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();
@@ -1046,6 +1056,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())
@@ -2660,6 +2677,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 8a3412be..cd57ebcc 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 triangleToSvg(UBGraphicsTriangle *item);
void writeSvgElement();
diff --git a/src/adaptors/publishing/Sankore_Document_Web_Publication_Specification.doc b/src/adaptors/publishing/Sankore_Document_Web_Publication_Specification.doc
new file mode 100644
index 00000000..0526b243
Binary files /dev/null and b/src/adaptors/publishing/Sankore_Document_Web_Publication_Specification.doc differ
diff --git a/src/adaptors/publishing/UBDocumentPublisher.cpp b/src/adaptors/publishing/UBDocumentPublisher.cpp
index dad9259f..ed6e73f5 100644
--- a/src/adaptors/publishing/UBDocumentPublisher.cpp
+++ b/src/adaptors/publishing/UBDocumentPublisher.cpp
@@ -635,7 +635,7 @@ void UBDocumentPublisher::sendUbw(QString username, QString password)
request.setHeader(QNetworkRequest::ContentLengthHeader,datatoSend.size());
QString b64Auth = getBase64Of(QString("%0:%1").arg(username).arg(password));
request.setRawHeader("Authorization", QString("Basic %0").arg(b64Auth).toAscii().constData());
- request.setRawHeader("Host", "sankore.devxwiki.com");
+ request.setRawHeader("Host", "planete.sankore.org");
request.setRawHeader("Accept", "*/*");
request.setRawHeader("Accept-Language", "en-US,*");
diff --git a/src/adaptors/publishing/UBDocumentPublisher.h b/src/adaptors/publishing/UBDocumentPublisher.h
index 7c2ebacf..e0375c4c 100644
--- a/src/adaptors/publishing/UBDocumentPublisher.h
+++ b/src/adaptors/publishing/UBDocumentPublisher.h
@@ -22,7 +22,6 @@
#include "UBAbstractPublisher.h"
#define DOCPUBLICATION_URL "http://planete.sankore.org/xwiki/bin/view/CreateResources/UniboardUpload?xpage=plain&outputSyntax=plain"
-#define XWIKI_ORIGIN_HEADER "http://sankore.devxwiki.com"
typedef struct
{
diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp
index 9c5b9ccf..867ddac4 100644
--- a/src/board/UBBoardController.cpp
+++ b/src/board/UBBoardController.cpp
@@ -36,6 +36,7 @@
#include "gui/UBMainWindow.h"
#include "gui/UBToolWidget.h"
#include "gui/UBKeyboardPalette.h"
+#include "gui/UBMagnifer.h"
#include "domain/UBGraphicsPixmapItem.h"
#include "domain/UBGraphicsItemUndoCommand.h"
@@ -54,7 +55,6 @@
#include "document/UBDocumentProxy.h"
#include "document/UBDocumentController.h"
-#include "board/UBLibraryController.h"
#include "board/UBDrawingController.h"
#include "board/UBBoardView.h"
@@ -72,7 +72,6 @@ UBBoardController::UBBoardController(UBMainWindow* mainWindow)
, mActiveDocument(0)
, mActiveScene(0)
, mActiveSceneIndex(-1)
- , mLibraryController(0)
, mPaletteManager(0)
, mSoftwareUpdateDialog(0)
, mMessageWindow(0)
@@ -85,8 +84,6 @@ UBBoardController::UBBoardController(UBMainWindow* mainWindow)
, mSystemScaleFactor(1.0)
, mCleanupDone(false)
{
- mLibraryController = new UBLibraryController(mMainWindow->centralWidget(), this);
-
mZoomFactor = UBSettings::settings()->boardZoomFactor->get().toDouble();
int penColorIndex = UBSettings::settings()->penColorIndex();
@@ -312,42 +309,6 @@ void UBBoardController::setupToolbar()
//-----------------------------------------------------------//
- QList magnifierZoomActions;
- magnifierZoomActions.append(mMainWindow->actionMagnifierZoomSmall);
- magnifierZoomActions.append(mMainWindow->actionMagnifierZoomMedium);
- magnifierZoomActions.append(mMainWindow->actionMagnifierZoomLarge);
-
- UBToolbarButtonGroup *magnifierZoomChoice =
- new UBToolbarButtonGroup(mMainWindow->boardToolBar, magnifierZoomActions);
-
- mMainWindow->boardToolBar->insertWidget(mMainWindow->actionBackgrounds, magnifierZoomChoice);
-
- connect(settings->appToolBarDisplayText, SIGNAL(changed(QVariant)), magnifierZoomChoice, SLOT(displayText(QVariant)));
- connect(magnifierZoomChoice, SIGNAL(activated(int)), UBDrawingController::drawingController(), SLOT(setMagnifierZoomIndex(int)));
-
- magnifierZoomChoice->displayText(QVariant(settings->appToolBarDisplayText->get().toBool()));
- magnifierZoomChoice->setCurrentIndex(settings->magnifierZoomIndex());
-
- QList magnifierSizeActions;
- magnifierSizeActions.append(mMainWindow->actionMagnifierSizeSmall);
- magnifierSizeActions.append(mMainWindow->actionMagnifierSizeMedium);
- magnifierSizeActions.append(mMainWindow->actionMagnifierSizeLarge);
-
- UBToolbarButtonGroup *magnifierSizeChoice =
- new UBToolbarButtonGroup(mMainWindow->boardToolBar, magnifierSizeActions);
-
- mMainWindow->boardToolBar->insertWidget(mMainWindow->actionBackgrounds, magnifierSizeChoice);
-
- connect(settings->appToolBarDisplayText, SIGNAL(changed(QVariant)), magnifierSizeChoice, SLOT(displayText(QVariant)));
- connect(magnifierSizeChoice, SIGNAL(activated(int)), UBDrawingController::drawingController(), SLOT(setMagnifierSizeIndex(int)));
-
- magnifierSizeChoice->displayText(QVariant(settings->appToolBarDisplayText->get().toBool()));
- magnifierSizeChoice->setCurrentIndex(settings->magnifierSizeIndex());
-
- mMainWindow->boardToolBar->insertSeparator(mMainWindow->actionBackgrounds);
-
- //-----------------------------------------------------------//
-
UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->boardToolBar, mMainWindow->actionBoard);
UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->tutorialToolBar, mMainWindow->actionBoard);
@@ -1051,11 +1012,21 @@ 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()->magnifier.id)
+ {
+ UBMagnifierParams params;
+ params.x = controlContainer()->geometry().width() / 2;
+ params.y = controlContainer()->geometry().height() / 2;
+ params.zoom = 2;
+ params.sizePercentFromScene = 20;
+ mActiveScene->addMagnifier(params);
+ UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
+ }
else if (sourceUrl.toString() == UBToolsManager::manager()->mask.id)
{
mActiveScene->addMask();
@@ -1174,7 +1145,7 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
}
// Notify the navigator palette that the document has changed
- mPaletteManager->navigatorPalette()->setDocument(pDocumentProxy);
+ mPaletteManager->leftPalette()->pageNavigator()->setDocument(pDocumentProxy);
if (sceneChange)
emit activeSceneChanged();
diff --git a/src/board/UBBoardController.h b/src/board/UBBoardController.h
index 9309bdda..68961fa6 100644
--- a/src/board/UBBoardController.h
+++ b/src/board/UBBoardController.h
@@ -25,7 +25,6 @@ class UBApplication;
class UBBoardView;
class UBDocumentController;
-class UBLibraryController;
class UBMessageWindow;
class UBGraphicsScene;
class UBDocumentProxy;
@@ -81,6 +80,11 @@ class UBBoardController : public QObject
return mDisplayView;
}
+ UBGraphicsScene* activeScene()
+ {
+ return mActiveScene;
+ }
+
void setPenColorOnDarkBackground(const QColor& pColor)
{
if (mPenColorOnDarkBackground == pColor)
@@ -129,11 +133,6 @@ class UBBoardController : public QObject
return mMarkerColorOnLightBackground;
}
- UBLibraryController* libraryController()
- {
- return mLibraryController;
- }
-
qreal systemScaleFactor()
{
return mSystemScaleFactor;
@@ -285,7 +284,6 @@ class UBBoardController : public QObject
UBGraphicsScene* mActiveScene;
int mActiveSceneIndex;
- UBLibraryController* mLibraryController;
UBBoardPaletteManager *mPaletteManager;
UBSoftwareUpdateDialog *mSoftwareUpdateDialog;
diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp
index 5392cc28..86cb4736 100755
--- a/src/board/UBBoardPaletteManager.cpp
+++ b/src/board/UBBoardPaletteManager.cpp
@@ -49,7 +49,6 @@
#include "document/UBDocumentProxy.h"
#include "podcast/UBPodcastController.h"
-#include "board/UBLibraryController.h"
#include "board/UBDrawingController.h"
#include "tools/UBToolsManager.h"
@@ -65,8 +64,8 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll
, mBoardControler(pBoardController)
, mStylusPalette(0)
, mZoomPalette(0)
- , mNavigPalette(NULL)
- , mLibPalette(NULL)
+ , mLeftPalette(NULL)
+ , mRightPalette(NULL)
, mBackgroundsPalette(0)
, mToolsPalette(0)
, mAddItemPalette(0)
@@ -86,16 +85,16 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll
UBBoardPaletteManager::~UBBoardPaletteManager()
{
delete mAddItemPalette;
- if(NULL != mNavigPalette)
+ if(NULL != mLeftPalette)
{
- delete mNavigPalette;
- mNavigPalette = NULL;
+ delete mLeftPalette;
+ mLeftPalette = NULL;
}
- if(NULL != mLibPalette)
+ if(NULL != mRightPalette)
{
- delete mLibPalette;
- mLibPalette = NULL;
+ delete mRightPalette;
+ mRightPalette = NULL;
}
if(NULL != mStylusPalette)
@@ -119,10 +118,10 @@ void UBBoardPaletteManager::setupLayout()
void UBBoardPaletteManager::setupPalettes()
{
// Add the dock palettes
- mNavigPalette = new UBNavigatorPalette(mContainer);
+ mLeftPalette = new UBLeftPalette(mContainer);
// We disable the lib palette for the moment because it is not yet available
- mLibPalette = new UBLibPalette(mContainer);
+ mRightPalette = new UBRightPalette(mContainer);
// Add the other palettes
mStylusPalette = new UBStylusPalette(mContainer, UBSettings::settings()->appToolBarOrientationVertical->get().toBool() ? Qt::Vertical : Qt::Horizontal);
@@ -375,8 +374,8 @@ void UBBoardPaletteManager::containerResized()
mKeyboardPalette->adjustSizeAndPosition();
}
- mNavigPalette->resize(mNavigPalette->width(), mContainer->height());
- mLibPalette->resize(mLibPalette->width(), mContainer->height());
+ mLeftPalette->resize(mLeftPalette->width(), mContainer->height());
+ mRightPalette->resize(mRightPalette->width(), mContainer->height());
}
@@ -403,9 +402,9 @@ void UBBoardPaletteManager::activeSceneChanged()
if (mStylusPalette)
connect(mStylusPalette, SIGNAL(mouseEntered()), activeScene, SLOT(hideEraser()));
- if (mNavigPalette)
+ if (mLeftPalette)
{
- mNavigPalette->setPageNumber(pageIndex + 1, activeScene->document()->pageCount());
+ mLeftPalette->pageNavigator()->setPageNumber(pageIndex + 1, activeScene->document()->pageCount());
}
if (mZoomPalette)
@@ -569,7 +568,8 @@ void UBBoardPaletteManager::addItemToLibrary()
, Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
QImage image = mPixmap.toImage();
- UBApplication::boardController->libraryController()->importImageOnLibrary(image);
+ //UBApplication::boardController->libraryController()->importImageOnLibrary(image);
+
}
else
{
@@ -579,29 +579,6 @@ void UBBoardPaletteManager::addItemToLibrary()
mAddItemPalette->hide();
}
-//void UBBoardPaletteManager::shareItemOnWeb()
-//{
-// QPixmap pixmap = mPixmap;
-
-// if(mPixmap.isNull())
-// {
-// pixmap = QPixmap(mItemUrl.toLocalFile());
-// }
-
-// if(!pixmap.isNull())
-// {
-// UBCapturePublisher* publisher = new UBCapturePublisher(pixmap, this);
-// publisher->publish();
-// }
-// else
-// {
-// UBApplication::showMessage(tr("Error Publishing Image to the Web"));
-// }
-
-// mAddItemPalette->hide();
-//}
-
-
void UBBoardPaletteManager::zoomButtonPressed()
{
mZoomButtonPressedTime = QTime::currentTime();
diff --git a/src/board/UBBoardPaletteManager.h b/src/board/UBBoardPaletteManager.h
index e53abd96..1432ad0e 100644
--- a/src/board/UBBoardPaletteManager.h
+++ b/src/board/UBBoardPaletteManager.h
@@ -20,8 +20,8 @@
#include
#include "web/UBRoutedMouseEventWebView.h"
-#include "gui/UBNavigatorPalette.h"
-#include "gui/UBLibPalette.h"
+#include "gui/UBLeftPalette.h"
+#include "gui/UBRightPalette.h"
class UBStylusPalette;
class UBClockPalette;
@@ -43,8 +43,8 @@ class UBBoardPaletteManager : public QObject
virtual ~UBBoardPaletteManager();
void setupLayout();
- UBNavigatorPalette* navigatorPalette(){return mNavigPalette;}
- void showVirtualKeyboard(bool show = true);
+ UBLeftPalette* leftPalette(){return mLeftPalette;}
+ void showVirtualKeyboard(bool show = true);
void initPalettesPosAtStartup();
UBKeyboardPalette *mKeyboardPalette;
@@ -68,8 +68,9 @@ class UBBoardPaletteManager : public QObject
UBStylusPalette *mStylusPalette;
UBZoomPalette *mZoomPalette;
- UBNavigatorPalette* mNavigPalette;
- UBLibPalette* mLibPalette;
+
+ UBLeftPalette* mLeftPalette;
+ UBRightPalette* mRightPalette;
UBActionPalette *mBackgroundsPalette;
UBActionPalette *mToolsPalette;
@@ -113,7 +114,7 @@ class UBBoardPaletteManager : public QObject
void togglePagePalette(bool ckecked);
void pagePaletteClosed();
- void pagePaletteButtonPressed();
+ void pagePaletteButtonPressed();
void pagePaletteButtonReleased();
void addItemToCurrentPage();
diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp
index d38df42c..c7d18ea5 100644
--- a/src/board/UBBoardView.cpp
+++ b/src/board/UBBoardView.cpp
@@ -857,9 +857,6 @@ UBBoardView::setToolCursor (int tool)
case UBStylusTool::Eraser:
controlViewport->setCursor (UBResources::resources ()->eraserCursor);
break;
- case UBStylusTool::Magnifier:
- controlViewport->setCursor (UBResources::resources ()->magnifierCursor);
- break;
case UBStylusTool::Marker:
controlViewport->setCursor (UBResources::resources ()->markerCursor);
break;
diff --git a/src/board/UBDrawingController.cpp b/src/board/UBDrawingController.cpp
index 61196338..5d170470 100644
--- a/src/board/UBDrawingController.cpp
+++ b/src/board/UBDrawingController.cpp
@@ -44,7 +44,6 @@ UBDrawingController::UBDrawingController(QObject * parent)
connect(UBApplication::mainWindow->actionPen, SIGNAL(triggered(bool)), this, SLOT(penToolSelected(bool)));
connect(UBApplication::mainWindow->actionEraser, SIGNAL(triggered(bool)), this, SLOT(eraserToolSelected(bool)));
- connect(UBApplication::mainWindow->actionMagnifier, SIGNAL(triggered(bool)), this, SLOT(magnifierToolSelected(bool)));
connect(UBApplication::mainWindow->actionMarker, SIGNAL(triggered(bool)), this, SLOT(markerToolSelected(bool)));
connect(UBApplication::mainWindow->actionSelector, SIGNAL(triggered(bool)), this, SLOT(selectorToolSelected(bool)));
connect(UBApplication::mainWindow->actionHand, SIGNAL(triggered(bool)), this, SLOT(handToolSelected(bool)));
@@ -103,8 +102,6 @@ void UBDrawingController::setStylusTool(int tool)
UBApplication::mainWindow->actionPen->setChecked(true);
else if (mStylusTool == UBStylusTool::Eraser)
UBApplication::mainWindow->actionEraser->setChecked(true);
- else if (mStylusTool == UBStylusTool::Magnifier)
- UBApplication::mainWindow->actionMagnifier->setChecked(true);
else if (mStylusTool == UBStylusTool::Marker)
UBApplication::mainWindow->actionMarker->setChecked(true);
else if (mStylusTool == UBStylusTool::Selector)
@@ -265,21 +262,6 @@ void UBDrawingController::setEraserWidthIndex(int index)
UBSettings::settings()->setEraserWidthIndex(index);
}
-
-void UBDrawingController::setMagnifierZoomIndex(int index)
-{
- setStylusTool(UBStylusTool::Magnifier);
- UBSettings::settings()->setMagnifierZoomIndex(index);
-}
-
-
-void UBDrawingController::setMagnifierSizeIndex(int index)
-{
- setStylusTool(UBStylusTool::Magnifier);
- UBSettings::settings()->setMagnifierSizeIndex(index);
-}
-
-
void UBDrawingController::setPenColor(bool onDarkBackground, const QColor& color, int pIndex)
{
if (onDarkBackground)
@@ -340,12 +322,6 @@ void UBDrawingController::eraserToolSelected(bool checked)
setStylusTool(UBStylusTool::Eraser);
}
-void UBDrawingController::magnifierToolSelected(bool checked)
-{
- if (checked)
- setStylusTool(UBStylusTool::Magnifier);
-}
-
void UBDrawingController::markerToolSelected(bool checked)
{
if (checked)
diff --git a/src/board/UBDrawingController.h b/src/board/UBDrawingController.h
index 2e4e4394..2f6e8f3e 100644
--- a/src/board/UBDrawingController.h
+++ b/src/board/UBDrawingController.h
@@ -57,8 +57,6 @@ class UBDrawingController : public QObject
void setLineWidthIndex(int index);
void setColorIndex(int index);
void setEraserWidthIndex(int index);
- void setMagnifierZoomIndex(int index);
- void setMagnifierSizeIndex(int index);
signals:
void stylusToolChanged(int tool);
@@ -77,7 +75,6 @@ class UBDrawingController : public QObject
void penToolSelected(bool checked);
void eraserToolSelected(bool checked);
- void magnifierToolSelected(bool checked);
void markerToolSelected(bool checked);
void selectorToolSelected(bool checked);
void handToolSelected(bool checked);
diff --git a/src/board/UBLibraryController.cpp b/src/board/UBLibraryController.cpp
index 4aed8c49..e95f7767 100644
--- a/src/board/UBLibraryController.cpp
+++ b/src/board/UBLibraryController.cpp
@@ -45,10 +45,10 @@
static quint32 magicNumber = 0xACDCAFE0;
static QString favoriteVirtualPath = "$favorite$";
-UBLibraryController::UBLibraryController(QWidget *pParentWidget, UBBoardController *pBoardController) :
+UBLibraryController::UBLibraryController(QWidget *pParentWidget) :
QObject(pParentWidget),
mParentWidget(pParentWidget),
- mBoardController(pBoardController),
+ mBoardController(UBApplication::boardController),
mLastItemOffsetIndex(0)
{
readFavoriteList();
@@ -84,7 +84,7 @@ void UBLibraryController::createInternalWidgetItems()
UBToolsManager::UBToolDescriptor tool = UBToolsManager::manager()->toolByID(toolUri);
UBLibElement *newTool = new UBLibElement(eUBLibElementType_InteractiveItem, QUrl(tool.id), tool.label);
QImage toolImage = tool.icon.toImage();
- newTool->setThumbnail(&toolImage);
+ newTool->setThumbnail(toolImage);
newTool->setInformation(tool.label + " " + tool.version);
mInternalLibElements << newTool;
@@ -201,64 +201,54 @@ QList UBLibraryController::rootCategoriesList()
QList categories;
UBLibElement* element = new UBLibElement(eUBLibElementType_Folder, mAudioStandardDirectoryPath, tr("Audios", "Audio category element"));
- QImage* categoryImage = new QImage(":images/libpalette/AudiosCategory.svg");
- element->setThumbnail(categoryImage);
+ element->setThumbnail(QImage(":images/libpalette/AudiosCategory.svg"));
element->setMoveable(false);
categories << element;
element = new UBLibElement(eUBLibElementType_Folder, mVideoStandardDirectoryPath, tr("Movies", "Movies category element"));
- categoryImage = new QImage(":images/libpalette/MoviesCategory.svg");
- element->setThumbnail(categoryImage);
+ element->setThumbnail(QImage(":images/libpalette/MoviesCategory.svg"));
element->setMoveable(false);
categories << element;
element = new UBLibElement(eUBLibElementType_Folder, mPicturesStandardDirectoryPath, tr("Pictures", "Pictures category element"));
- categoryImage = new QImage(":images/libpalette/PicturesCategory.svg");
- element->setThumbnail(categoryImage);
+ element->setThumbnail(QImage(":images/libpalette/PicturesCategory.svg"));
element->setMoveable(false);
categories << element;
QString path = UBSettings::settings()->uniboardShapeLibraryDirectory();
- categoryImage = new QImage(":images/libpalette/ShapesCategory.svg");
element = new UBLibElement(eUBLibElementType_Folder, QUrl::fromLocalFile(path), tr("Shapes", "Shapes category element"));
- element->setThumbnail(categoryImage);
+ element->setThumbnail(QImage(":images/libpalette/ShapesCategory.svg"));
element->setMoveable(false);
categories << element;
- categoryImage = new QImage(":images/libpalette/ApplicationsCategory.svg");
element = new UBLibElement(eUBLibElementType_Folder, mInteractiveUserDirectoryPath, tr("Applications", "Applications category element"));
- element->setThumbnail(categoryImage);
+ element->setThumbnail(QImage(":images/libpalette/ApplicationsCategory.svg"));
element->setMoveable(false);
categories << element;
- categoryImage = new QImage(":images/libpalette/FavoritesCategory.svg");
element = new UBLibElement(eUBLibElementType_VirtualFolder, favoriteVirtualPath, tr("Favorite", "Favorite category element"));
- element->setThumbnail(categoryImage);
+ element->setThumbnail(QImage(":images/libpalette/FavoritesCategory.svg"));
element->setMoveable(false);
categories << element;
- categoryImage = new QImage(":images/libpalette/InteractivesCategory.svg");
mInteractiveCategoryPath = QUrl::fromLocalFile(UBSettings::settings()->uniboardGipLibraryDirectory());
element = new UBLibElement(eUBLibElementType_Folder, mInteractiveCategoryPath, tr("Interactivities", "Interactives category element"));
- element->setThumbnail(categoryImage);
+ element->setThumbnail(QImage(":images/libpalette/InteractivesCategory.svg"));
element->setMoveable(false);
categories << element;
- categoryImage = new QImage(":images/libpalette/FlashCategory.svg");
element = new UBLibElement(eUBLibElementType_Folder, mAnimationUserDirectoryPath, tr("Animations", "Animations category element"));
- element->setThumbnail(categoryImage);
+ element->setThumbnail(QImage(":images/libpalette/FlashCategory.svg"));
element->setMoveable(false);
categories << element;
-
-
categories << UBLibElement::trashElement();
return categories;
}
-QImage* UBLibraryController::createThumbnail(UBLibElement* pElement)
+QImage UBLibraryController::createThumbnail(UBLibElement* pElement)
{
QString thumbnailPath = UBFileSystemUtils::thumbnailPath(pElement->path().toLocalFile());
QString mimetype = UBFileSystemUtils::mimeTypeFromFileName(pElement->path().toLocalFile());
@@ -287,17 +277,17 @@ QImage* UBLibraryController::createThumbnail(UBLibElement* pElement)
}
}
- return new QImage(thumbnailPath);
+ return QImage(thumbnailPath);
}
-QImage* UBLibraryController::thumbnailForFile(UBLibElement* pElement)
+QImage UBLibraryController::thumbnailForFile(UBLibElement* pElement)
{
if (pElement->path().toString().contains("uniboardTool://")){
- QImage* image = new QImage(UBToolsManager::manager()->iconFromToolId(pElement->path().toString()));
+ QImage image = QImage(UBToolsManager::manager()->iconFromToolId(pElement->path().toString()));
return image;
}
if (pElement->type() == eUBLibElementType_InteractiveItem){
- QImage* image = new QImage(UBAbstractWidget::iconFilePath(pElement->path()));
+ QImage image = QImage(UBAbstractWidget::iconFilePath(pElement->path()));
return image;
}
@@ -307,7 +297,7 @@ QImage* UBLibraryController::thumbnailForFile(UBLibElement* pElement)
qWarning() << "thumbnailForFile impossible to create thumbnail path for the element " + pElement->path().toLocalFile();
if (QFileInfo(thumbnailPath).exists())
- return new QImage(thumbnailPath);
+ return QImage(thumbnailPath);
else
return createThumbnail(pElement);
}
@@ -318,7 +308,8 @@ QList UBLibraryController::addVirtualElementsForItemPath(const QS
if (pPath == mInteractiveUserDirectoryPath.toLocalFile()){
content << listElementsInPath(UBSettings::settings()->uniboardInteractiveLibraryDirectory());
content << listElementsInPath(UBSettings::settings()->uniboardInteractiveFavoritesDirectory());
- content << mInternalLibElements;
+ foreach(UBLibElement* eachElement, mInternalLibElements)
+ content << new UBLibElement(eachElement);
}
else if (pPath == mPicturesStandardDirectoryPath.toLocalFile()){
QUrl path = QUrl::fromLocalFile(UBSettings::settings()->uniboardImageLibraryDirectory());
@@ -353,8 +344,8 @@ QList UBLibraryController::listElementsInPath(const QString& pPat
UBLibElement *element = new UBLibElement(fileType, QUrl::fromLocalFile(fileInfo->absoluteFilePath()), itemName);
if (fileType == eUBLibElementType_Folder) {
- QImage* directoryImage = new QImage(":images/libpalette/folder.svg");
- element->setThumbnail(directoryImage);
+// QImage* directoryImage = new QImage(":images/libpalette/folder.svg");
+ element->setThumbnail(QImage(":images/libpalette/folder.svg"));
}
else if (fileType == eUBLibElementType_Item) {
if (element->path().toLocalFile().contains(".thumbnail."))
@@ -373,7 +364,10 @@ QList UBLibraryController::listElementsInPath(const QString& pPat
QList UBLibraryController::listElementsInVirtualForlder(UBLibElement* pElement)
{
Q_UNUSED(pElement);
- return mFavoriteList;
+ QList copyOfTheFavoriteList;
+ foreach(UBLibElement* eachElement, mFavoriteList)
+ copyOfTheFavoriteList << new UBLibElement(eachElement);
+ return copyOfTheFavoriteList;
}
void UBLibraryController::moveContent(QList sourceList, UBLibElement *pDestination)
@@ -416,21 +410,31 @@ void UBLibraryController::emptyElementsOnTrash( QList elementsLis
}
}
+void UBLibraryController::cleanElementsList()
+{
+// qDebug() << "cleanElementsList()";
+// qDebug() << this;
+// foreach(UBLibElement*eachElement, mElementsList)
+// qDebug() << eachElement;
+ qDeleteAll(mElementsList);
+ mElementsList.clear();
+}
+
QList UBLibraryController::getContent(UBLibElement *element)
{
- QList elementsList;
+ cleanElementsList();
switch (element->type()) {
case eUBLibElementType_Category: {
- elementsList = rootCategoriesList();
+ mElementsList = rootCategoriesList();
break;
}
case eUBLibElementType_VirtualFolder: {
- elementsList = listElementsInVirtualForlder(element);
+ mElementsList = listElementsInVirtualForlder(element);
break;
}
case eUBLibElementType_Folder: {
- elementsList = listElementsInPath(element->path().toLocalFile());
+ mElementsList = listElementsInPath(element->path().toLocalFile());
break;
}
case eUBLibElementType_Item: {
@@ -443,16 +447,20 @@ QList UBLibraryController::getContent(UBLibElement *element)
break;
}
- return elementsList;
+// qDebug() << "getContent()";
+// qDebug() << this;
+// foreach(UBLibElement*eachElement, mElementsList)
+// qDebug() << eachElement;
+
+ return mElementsList;
}
UBLibraryController::~UBLibraryController()
{
+ cleanElementsList();
//NOOP
}
-
-
void UBLibraryController::setItemAsBackground(UBLibElement* image)
{
if (!activeScene()){
@@ -501,9 +509,6 @@ void UBLibraryController::addItemToPage(UBLibElement* item)
else{
UBApplication::showMessage(tr("Adding to page failed for item %1.").arg(item->name()));
}
-
-
-
}
void UBLibraryController::removeBackground()
@@ -564,7 +569,8 @@ void UBLibraryController::readFavoriteList()
eachElement->setInformation(info);
eachElement->setExtension(extension);
eachElement->setThumbnail(thumbnailForFile(eachElement));
- mFavoriteList << eachElement;
+ if(!isOnFavoriteList(eachElement))
+ mFavoriteList << eachElement;
}
file.close();
@@ -582,10 +588,10 @@ UBLibElement* UBLibraryController::isOnFavoriteList(UBLibElement * element)
void UBLibraryController::addToFavorite(QList elementList)
{
- foreach(UBLibElement* eachElement, elementList){
+ foreach(UBLibElement* eachElement, elementList)
if(!isOnFavoriteList(eachElement))
- mFavoriteList << eachElement;
- }
+ mFavoriteList << new UBLibElement(eachElement);
+
persistFavoriteList();
}
@@ -601,7 +607,8 @@ void UBLibraryController::removeFromFavorite(QList elementList)
persistFavoriteList();
}
-QRectF UBLibraryController::visibleSceneRect() {
+QRectF UBLibraryController::visibleSceneRect()
+{
QRectF visibleSceneRect(0, 0, 0, 0);
if (activeScene() && mBoardController && mBoardController->controlView()) {
@@ -621,7 +628,8 @@ QRectF UBLibraryController::visibleSceneRect() {
return visibleSceneRect;
}
-void UBLibraryController::addImagesToCurrentPage(const QList& images) {
+void UBLibraryController::addImagesToCurrentPage(const QList& images)
+{
QPointF pos = visibleSceneRect().topLeft();
foreach(const QUrl url, images)
@@ -652,7 +660,8 @@ void UBLibraryController::addImagesToCurrentPage(const QList& images) {
}
}
-void UBLibraryController::addVideosToCurrentPage(const QList& videos) {
+void UBLibraryController::addVideosToCurrentPage(const QList& videos)
+{
QPointF pos = visibleSceneRect().topLeft();
foreach(const QUrl url, videos)
@@ -665,7 +674,8 @@ void UBLibraryController::addVideosToCurrentPage(const QList& videos) {
}
}
-void UBLibraryController::addAudiosToCurrentPage(const QList& sounds) {
+void UBLibraryController::addAudiosToCurrentPage(const QList& sounds)
+{
QPointF topLeftPos = visibleSceneRect().topLeft();
QPointF pos = topLeftPos;
@@ -680,12 +690,10 @@ void UBLibraryController::addAudiosToCurrentPage(const QList& sounds) {
}
}
-void UBLibraryController::addInteractivesToCurrentPage(
- const QList& widgets) {
+void UBLibraryController::addInteractivesToCurrentPage( const QList& widgets)
+{
foreach(const QUrl url, widgets)
- {
mBoardController->downloadURL(url, QPointF(0, 0));
- }
}
QString UBLibraryController::favoritePath()
@@ -699,6 +707,17 @@ UBLibElement::UBLibElement() {
mbMoveable = false;
}
+UBLibElement::UBLibElement(UBLibElement* element)
+{
+ mType = element->type();
+ mPath = element->path();
+ mThumbnail = *element->thumbnail();
+ mInfo = element->information();
+ mName = element->name();
+ mExtension = element->extension();
+ mbMoveable = element->isMoveable();
+}
+
UBLibElement::UBLibElement(eUBLibElementType type, const QUrl &path, const QString &name)
{
@@ -728,7 +747,7 @@ UBLibElement::~UBLibElement()
UBChainedLibElement::UBChainedLibElement(UBLibElement *pElem, UBChainedLibElement *pNextElem)
{
- mpElem = pElem;
+ mpElem = new UBLibElement(pElem);
mpNextElem = pNextElem;
}
@@ -747,13 +766,9 @@ void UBChainedLibElement::setNextElement(UBChainedLibElement *nextElem)
UBLibElement* UBLibElement::trashElement()
{
- static UBLibElement *trashElement;
- if (trashElement)
- return trashElement;
-
+ UBLibElement *trashElement;
trashElement = new UBLibElement(eUBLibElementType_Folder, QUrl::fromLocalFile(UBSettings::trashLibraryPaletteDirPath()), QObject::tr("Trash", "Pictures category element"));
- QImage *categoryImage = new QImage(":images/libpalette/TrashCategory.svg");
- trashElement->setThumbnail(categoryImage);
+ trashElement->setThumbnail(QImage(":images/libpalette/TrashCategory.svg"));
trashElement->setMoveable(false);
return trashElement;
diff --git a/src/board/UBLibraryController.h b/src/board/UBLibraryController.h
index e0422199..26b6fe61 100644
--- a/src/board/UBLibraryController.h
+++ b/src/board/UBLibraryController.h
@@ -42,6 +42,7 @@ class UBLibElement
public:
UBLibElement();
UBLibElement(eUBLibElementType type, const QUrl& path, const QString& name);
+ UBLibElement(UBLibElement* element);
~UBLibElement();
static UBLibElement* trashElement();
@@ -51,7 +52,7 @@ public:
QUrl path(){return mPath;}
void setPath(QUrl path){mPath = path;}
QImage* thumbnail(){return &mThumbnail;}
- void setThumbnail(QImage* pThumb){mThumbnail = *pThumb;}
+ void setThumbnail(QImage pThumb){mThumbnail = pThumb;}
QString information(){return mInfo;}
void setInformation(QString info){mInfo = info;}
QString name(){return mName;}
@@ -91,7 +92,7 @@ class UBLibraryController : public QObject
Q_OBJECT;
public:
- UBLibraryController(QWidget *parentWidget, UBBoardController *boardController);
+ UBLibraryController(QWidget *parentWidget);
virtual ~UBLibraryController();
QList getContent(UBLibElement* pElement);
@@ -134,14 +135,16 @@ class UBLibraryController : public QObject
void persistFavoriteList();
void readFavoriteList();
QList mInternalLibElements;
+ QList mElementsList;
+ void cleanElementsList();
private:
QList rootCategoriesList();
QList listElementsInPath(const QString& pPath);
QList listElementsInVirtualForlder(UBLibElement* pElement);
void userPath(QUrl &pPath);
- QImage* thumbnailForFile(UBLibElement* pPath);
- QImage* createThumbnail(UBLibElement* pPath);
+ QImage thumbnailForFile(UBLibElement* pPath);
+ QImage createThumbnail(UBLibElement* pPath);
QList addVirtualElementsForItemPath(const QString& pPath);
void createInternalWidgetItems();
diff --git a/src/core/UB.h b/src/core/UB.h
index 72fed56e..07ae8ecc 100644
--- a/src/core/UB.h
+++ b/src/core/UB.h
@@ -26,8 +26,7 @@ struct UBStylusTool
{
Pen = 0,
Eraser,
- Magnifier,
- Marker,
+ Marker,
Selector,
Hand,
ZoomIn,
diff --git a/src/core/UBApplication.cpp b/src/core/UBApplication.cpp
index 0e431005..90e2dfd3 100644
--- a/src/core/UBApplication.cpp
+++ b/src/core/UBApplication.cpp
@@ -38,7 +38,6 @@
#include "board/UBBoardController.h"
#include "board/UBDrawingController.h"
-#include "board/UBLibraryController.h"
#include "board/UBBoardView.h"
#include "web/UBWebController.h"
@@ -380,10 +379,10 @@ void UBApplication::toolBarDisplayTextChanged(QVariant display)
}
-void UBApplication::closeEvent(QCloseEvent *event)
-{
+void UBApplication::closeEvent(QCloseEvent *event)
+{
Q_UNUSED(event);
-
+
closing();
}
diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp
index 2e8997b6..373b22b9 100644
--- a/src/core/UBSettings.cpp
+++ b/src/core/UBSettings.cpp
@@ -624,170 +624,6 @@ qreal UBSettings::currentEraserWidth()
return width;
}
-//----------------------------------------//
-// magnifier
-
-//-------------//
-// zoom index
-
-int UBSettings::magnifierZoomIndex()
-{
- return value("Board/MagnifierZoomIndex", 1).toInt();
-}
-
-void UBSettings::setMagnifierZoomIndex(int index)
-{
- setValue("Board/MagnifierZoomIndex", index);
-}
-
-//-------------//
-// small zoom
-
-qreal UBSettings::magnifierSmallZoom()
-{
- return value("Board/MagnifierSmallZoom", 2).toDouble();
-}
-
-void UBSettings::setMagnifierSmallZoom(qreal xZoom)
-{
- setValue("Board/MagnifierSmallZoom", xZoom);
-}
-
-//-------------//
-// medium zoom
-
-qreal UBSettings::magnifierMediumZoom()
-{
- return value("Board/MagnifierMediumZoom", 3).toDouble();
-}
-
-void UBSettings::setMagnifierMediumZoom(qreal xZoom)
-{
- setValue("Board/MagnifierMediumZoom", xZoom);
-}
-
-//-------------//
-// large zoom
-
-qreal UBSettings::magnifierLargeZoom()
-{
- return value("Board/MagnifierLargeZoom", 4).toDouble();
-}
-
-void UBSettings::setMagnifierLargeZoom(qreal xZoom)
-{
- setValue("Board/MagnifierLargeZoom", xZoom);
-}
-
-//-------------//
-
-qreal UBSettings::currentMagnifierZoom()
-{
- qreal zoom = 0;
-
- switch (magnifierZoomIndex())
- {
- case UBZoom::Small:
- zoom = magnifierSmallZoom();
- break;
- case UBZoom::Medium:
- zoom = magnifierMediumZoom();
- break;
- case UBZoom::Large:
- zoom = magnifierLargeZoom();
- break;
- default:
- Q_ASSERT(false);
- //failsafe
- zoom = magnifierSmallZoom();
- break;
- }
-
- return zoom;
-}
-
-//-------------//
-// size index
-
-int UBSettings::magnifierSizeIndex()
-{
- return value("Board/MagnifierSizeIndex", 1).toInt();
-}
-
-void UBSettings::setMagnifierSizeIndex(int index)
-{
- setValue("Board/MagnifierSizeIndex", index);
-}
-
-//-------------//
-// small zoom
-
-qreal UBSettings::magnifierSmallSize()
-{
- return value("Board/MagnifierSmallSize", 10).toDouble();
-}
-
-void UBSettings::setMagnifierSmallSize(qreal xSize)
-{
- setValue("Board/MagnifierSmallSize", xSize);
-}
-
-//-------------//
-// medium zoom
-
-qreal UBSettings::magnifierMediumSize()
-{
- return value("Board/MagnifierMediumSize", 20).toDouble();
-}
-
-void UBSettings::setMagnifierMediumSize(qreal xSize)
-{
- setValue("Board/MagnifierMediumSize", xSize);
-}
-
-//-------------//
-// large zoom
-
-qreal UBSettings::magnifierLargeSize()
-{
- return value("Board/MagnifierLargeSize", 30).toDouble();
-}
-
-void UBSettings::setMagnifierLargeSize(qreal xSize)
-{
- setValue("Board/MagnifierLargeSize", xSize);
-}
-
-//-------------//
-
-qreal UBSettings::currentMagnifierSize()
-{
- qreal size = 0;
-
- switch (magnifierSizeIndex())
- {
- case UBSize::Small:
- size = magnifierSmallSize();
- break;
- case UBSize::Medium:
- size = magnifierMediumSize();
- break;
- case UBSize::Large:
- size = magnifierLargeSize();
- break;
- default:
- Q_ASSERT(false);
- //failsafe
- size = magnifierSmallSize();
- break;
- }
-
- return size;
-}
-
-//----------------------------------------//
-
-
bool UBSettings::isDarkBackground()
{
return value("Board/DarkBackground", 0).toBool();
diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h
index 67afc057..6b7a8961 100644
--- a/src/core/UBSettings.h
+++ b/src/core/UBSettings.h
@@ -66,19 +66,6 @@ class UBSettings : public QObject
qreal eraserStrongWidth();
qreal currentEraserWidth();
- // Magnifier related
- int magnifierZoomIndex();
- qreal magnifierSmallZoom();
- qreal magnifierMediumZoom();
- qreal magnifierLargeZoom();
- qreal currentMagnifierZoom();
-
- int magnifierSizeIndex();
- qreal magnifierSmallSize();
- qreal magnifierMediumSize();
- qreal magnifierLargeSize();
- qreal currentMagnifierSize();
-
// Background related
bool isDarkBackground();
bool isCrossedBackground();
@@ -360,18 +347,7 @@ class UBSettings : public QObject
void setEraserMediumWidth(qreal width);
void setEraserStrongWidth(qreal width);
- void setMagnifierZoomIndex(int index);
- void setMagnifierSmallZoom(qreal xZoom);
- void setMagnifierMediumZoom(qreal xZoom);
- void setMagnifierLargeZoom(qreal xZoom);
-
- void setMagnifierSizeIndex(int index);
- void setMagnifierSmallSize(qreal xSize);
- void setMagnifierMediumSize(qreal xSize);
- void setMagnifierLargeSize(qreal xSize);
-
-
- void setStylusPaletteVisible(bool visible);
+ void setStylusPaletteVisible(bool visible);
void setPenPressureSensitive(bool sensitive);
void setMarkerPressureSensitive(bool sensitive);
diff --git a/src/desktop/UBDesktopAnnotationController.cpp b/src/desktop/UBDesktopAnnotationController.cpp
index 5d6b3b34..cb44c140 100644
--- a/src/desktop/UBDesktopAnnotationController.cpp
+++ b/src/desktop/UBDesktopAnnotationController.cpp
@@ -56,7 +56,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
, mDesktopPenPalette(NULL)
, mDesktopMarkerPalette(NULL)
, mDesktopEraserPalette(NULL)
- , mLibPalette(NULL)
+ , mRightPalette(NULL)
, mWindowPositionInitialized(0)
, mIsFullyTransparent(false)
, mDesktopToolsPalettePositioned(false)
@@ -89,7 +89,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
mTransparentDrawingScene = new UBGraphicsScene(0);
mTransparentDrawingView->setScene(mTransparentDrawingScene);
- mLibPalette = new UBLibPalette(mTransparentDrawingView);
+ mRightPalette = new UBRightPalette(mTransparentDrawingView);
mDesktopPalette = new UBDesktopPalette(mTransparentDrawingView);
@@ -160,7 +160,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
#ifdef Q_WS_X11
connect(mDesktopPalette, SIGNAL(moving()), this, SLOT(refreshMask()));
- connect(mLibPalette, SIGNAL(resized()), this, SLOT(refreshMask()));
+ connect(mRightPalette, SIGNAL(resized()), this, SLOT(refreshMask()));
#endif
onDesktopPaletteMaximized();
}
@@ -212,10 +212,10 @@ UBDesktopAnnotationController::~UBDesktopAnnotationController()
delete mDesktopEraserPalette;
mDesktopEraserPalette = NULL;
}
- if(NULL != mLibPalette)
+ if(NULL != mRightPalette)
{
- delete mLibPalette;
- mLibPalette = NULL;
+ delete mRightPalette;
+ mRightPalette = NULL;
}
*/
}
@@ -800,7 +800,7 @@ void UBDesktopAnnotationController::onDesktopPaletteMinimize()
*/
void UBDesktopAnnotationController::onTransparentWidgetResized()
{
- mLibPalette->resize(mLibPalette->width(), mTransparentDrawingView->height());
+ mRightPalette->resize(mRightPalette->width(), mTransparentDrawingView->height());
}
void UBDesktopAnnotationController::updateMask(bool bTransparent)
@@ -827,9 +827,9 @@ void UBDesktopAnnotationController::updateMask(bool bTransparent)
{
p.drawRect(mKeyboardPalette->geometry().x(), mKeyboardPalette->geometry().y(), mKeyboardPalette->width(), mKeyboardPalette->height());
}
- if(mLibPalette->isVisible())
+ if(mRightPalette->isVisible())
{
- p.drawRect(mLibPalette->geometry().x(), mLibPalette->geometry().y(), mLibPalette->width(), mLibPalette->height());
+ p.drawRect(mRightPalette->geometry().x(), mRightPalette->geometry().y(), mRightPalette->width(), mRightPalette->height());
}
p.end();
diff --git a/src/desktop/UBDesktopAnnotationController.h b/src/desktop/UBDesktopAnnotationController.h
index c4e9fea3..f569332a 100644
--- a/src/desktop/UBDesktopAnnotationController.h
+++ b/src/desktop/UBDesktopAnnotationController.h
@@ -20,7 +20,7 @@
#include
#include
-#include "gui/UBLibPalette.h"
+#include "gui/UBRightPalette.h"
class UBDesktopPalette;
class UBDesktopToolsPalette;
@@ -117,7 +117,7 @@ class UBDesktopAnnotationController : public QObject
UBDesktopMarkerPalette* mDesktopMarkerPalette;
UBDesktopEraserPalette* mDesktopEraserPalette;
- UBLibPalette* mLibPalette;
+ UBRightPalette* mRightPalette;
QTime mPenHoldTimer;
QTime mMarkerHoldTimer;
diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp
index 24de0b36..f908c9e6 100644
--- a/src/domain/UBGraphicsScene.cpp
+++ b/src/domain/UBGraphicsScene.cpp
@@ -136,13 +136,13 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
}
connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing()));
-
}
UBGraphicsScene::~UBGraphicsScene()
{
// NOOP
+ DisposeMagnifierQWidgets();
}
void UBGraphicsScene::selectionChangedProcessing()
@@ -236,15 +236,6 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
drawPointer(scenePos);
accepted = true;
}
- else if (currentTool == UBStylusTool::Magnifier)
- {
- CreateMagnifierQWidgets();
- magniferControlViewWidget->grabNMove(QCursor::pos(), true);
- magniferDisplayViewWidget->grabNMove(scenePos, true);
- magniferControlViewWidget->show();
- magniferDisplayViewWidget->show();
- accepted = true;
- }
}
return accepted;
@@ -318,11 +309,6 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
{
drawPointer(position);
}
- else if (currentTool == UBStylusTool::Magnifier)
- {
- magniferControlViewWidget->grabNMove(QCursor::pos(), false);
- magniferDisplayViewWidget->grabNMove(position, false);
- }
accepted = true;
}
@@ -361,13 +347,7 @@ bool UBGraphicsScene::inputDeviceRelease()
{
mCurrentStroke = 0;
}
- else
- if (currentTool == UBStylusTool::Magnifier)
- {
- DisposeMagnifierQWidgets();
- //qDebug() << "deleted";
- }
-
+
if (mRemovedItems.size() > 0 || mAddedItems.size() > 0)
{
UBGraphicsItemUndoCommand* udcmd = new UBGraphicsItemUndoCommand(this, mRemovedItems, mAddedItems); //deleted by the undoStack
@@ -423,24 +403,6 @@ void UBGraphicsScene::drawPointer(const QPointF &pPoint)
}
}
-// call this function when user press mouse button in Magnifier mode
-void UBGraphicsScene::CreateMagnifierQWidgets()
-{
- UBApplication::app()->setOverrideCursor( QCursor( Qt::BlankCursor ) );
-
- magniferControlViewWidget = new UBMagnifer((QWidget*)(UBApplication::boardController->controlContainer()));
- magniferControlViewWidget->setGrabView((QGraphicsView*)UBApplication::boardController->controlView());
- magniferControlViewWidget->setMoveView((QGraphicsView*)UBApplication::boardController->controlContainer());
- magniferControlViewWidget->setSize(UBSettings::settings()->currentMagnifierSize());
- magniferControlViewWidget->setZoom(UBSettings::settings()->currentMagnifierZoom());
-
- magniferDisplayViewWidget = new UBMagnifer((QWidget*)(UBApplication::boardController->displayView()));
- magniferDisplayViewWidget->setGrabView((QGraphicsView*)UBApplication::boardController->controlView());
- magniferDisplayViewWidget->setMoveView((QGraphicsView*)UBApplication::boardController->displayView());
- magniferDisplayViewWidget->setSize(UBSettings::settings()->currentMagnifierSize());
- magniferDisplayViewWidget->setZoom(UBSettings::settings()->currentMagnifierZoom());
-}
-
// call this function when user release mouse button in Magnifier mode
void UBGraphicsScene::DisposeMagnifierQWidgets()
{
@@ -1534,6 +1496,119 @@ void UBGraphicsScene::addTriangle(QPointF center)
setModified(true);
}
+void UBGraphicsScene::addMagnifier(UBMagnifierParams params)
+{
+ // can have only one magnifier at one time
+ if(magniferControlViewWidget) return;
+
+ QWidget *cContainer = (QWidget*)(UBApplication::boardController->controlContainer());
+ QGraphicsView *cView = (QGraphicsView*)UBApplication::boardController->controlView();
+ QGraphicsView *dView = (QGraphicsView*)UBApplication::boardController->displayView();
+
+ QPoint ccZeroPoint = cContainer->mapToGlobal(QPoint(0,0));
+ QPoint cvZeroPoint = cView->mapToGlobal(QPoint(0,0));
+ QPoint dvZeroPoint = dView->mapToGlobal(QPoint(0,0));
+
+ int cvW = cView->width();
+ int dvW = dView->width();
+ qreal wCoeff = (qreal)dvW / (qreal)cvW;
+
+ int cvH = cView->height();
+ int dvH = dView->height();
+ qreal hCoeff = (qreal)dvH / (qreal)cvH;
+
+ QPoint ccPoint(params.x,params.y);
+ QPoint globalPoint = cContainer->mapToGlobal(ccPoint);
+ QPoint cvPoint = cView->mapFromGlobal(globalPoint);
+ QPoint dvPoint( cvPoint.x() * wCoeff + dvZeroPoint.x(), cvPoint.y() * hCoeff + dvZeroPoint.y());
+
+ magniferControlViewWidget = new UBMagnifier((QWidget*)(UBApplication::boardController->controlContainer()), true);
+ magniferControlViewWidget->setGrabView((QGraphicsView*)UBApplication::boardController->controlView());
+ magniferControlViewWidget->setMoveView((QWidget*)(UBApplication::boardController->controlContainer()));
+ magniferControlViewWidget->setSize(params.sizePercentFromScene);
+ magniferControlViewWidget->setZoom(params.zoom);
+
+ magniferDisplayViewWidget = new UBMagnifier((QWidget*)(UBApplication::boardController->displayView()), false);
+ magniferDisplayViewWidget->setGrabView((QGraphicsView*)UBApplication::boardController->controlView());
+ magniferDisplayViewWidget->setMoveView((QGraphicsView*)UBApplication::boardController->displayView());
+ magniferDisplayViewWidget->setSize(params.sizePercentFromScene);
+ magniferDisplayViewWidget->setZoom(params.zoom);
+
+ magniferControlViewWidget->grabNMove(globalPoint, globalPoint, true);
+ magniferDisplayViewWidget->grabNMove(globalPoint, dvPoint, true);
+ magniferControlViewWidget->show();
+ magniferDisplayViewWidget->show();
+
+ connect(magniferControlViewWidget, SIGNAL(magnifierMoved_Signal(QPoint)), this, SLOT(moveMagnifier(QPoint)));
+ connect(magniferControlViewWidget, SIGNAL(magnifierClose_Signal()), this, SLOT(closeMagnifier()));
+ connect(magniferControlViewWidget, SIGNAL(magnifierZoomIn_Signal()), this, SLOT(zoomInMagnifier()));
+ connect(magniferControlViewWidget, SIGNAL(magnifierZoomOut_Signal()), this, SLOT(zoomOutMagnifier()));
+ connect(magniferControlViewWidget, SIGNAL(magnifierResized_Signal(qreal)), this, SLOT(resizedMagnifier(qreal)));
+
+ setModified(true);
+}
+
+void UBGraphicsScene::moveMagnifier(QPoint newPos)
+{
+ QWidget *cContainer = (QWidget*)(UBApplication::boardController->controlContainer());
+ QGraphicsView *cView = (QGraphicsView*)UBApplication::boardController->controlView();
+ QGraphicsView *dView = (QGraphicsView*)UBApplication::boardController->displayView();
+
+ QPoint ccZeroPoint = cContainer->mapToGlobal(QPoint(0,0));
+ QPoint cvZeroPoint = cView->mapToGlobal(QPoint(0,0));
+ QPoint dvZeroPoint = dView->mapToGlobal(QPoint(0,0));
+
+ int cvW = cView->width();
+ int dvW = dView->width();
+ qreal wCoeff = (qreal)dvW / (qreal)cvW;
+
+ int cvH = cView->height();
+ int dvH = dView->height();
+ qreal hCoeff = (qreal)dvH / (qreal)cvH;
+
+ QPoint globalPoint = cContainer->mapToGlobal(newPos);
+ QPoint cvPoint = cView->mapFromGlobal(globalPoint);
+ QPoint dvPoint( cvPoint.x() * wCoeff + dvZeroPoint.x(), cvPoint.y() * hCoeff + dvZeroPoint.y());
+
+ magniferControlViewWidget->grabNMove(globalPoint, globalPoint, false, false);
+ magniferDisplayViewWidget->grabNMove(globalPoint, dvPoint, false, true);
+
+ setModified(true);
+}
+
+void UBGraphicsScene::closeMagnifier()
+{
+ DisposeMagnifierQWidgets();
+}
+
+void UBGraphicsScene::zoomInMagnifier()
+{
+ if(magniferControlViewWidget->params.zoom < 8)
+ {
+ magniferControlViewWidget->setZoom(magniferControlViewWidget->params.zoom + 0.5);
+ magniferDisplayViewWidget->setZoom(magniferDisplayViewWidget->params.zoom + 0.5);
+ }
+}
+
+void UBGraphicsScene::zoomOutMagnifier()
+{
+ if(magniferControlViewWidget->params.zoom > 1)
+ {
+ magniferControlViewWidget->setZoom(magniferControlViewWidget->params.zoom - 0.5);
+ magniferDisplayViewWidget->setZoom(magniferDisplayViewWidget->params.zoom - 0.5);
+ }
+}
+
+void UBGraphicsScene::resizedMagnifier(qreal newPercent)
+{
+ if(newPercent > 18 && newPercent < 50)
+ {
+ magniferControlViewWidget->setSize(newPercent);
+ magniferControlViewWidget->grabPoint();
+ magniferDisplayViewWidget->setSize(newPercent);
+ magniferDisplayViewWidget->grabPoint();
+ }
+}
void UBGraphicsScene::addCompass(QPointF center)
{
diff --git a/src/domain/UBGraphicsScene.h b/src/domain/UBGraphicsScene.h
index 520ea3cb..5a5ffe2e 100644
--- a/src/domain/UBGraphicsScene.h
+++ b/src/domain/UBGraphicsScene.h
@@ -44,7 +44,8 @@ class UBAbstractWidget;
class UBDocumentProxy;
class UBGraphicsCurtainItem;
class UBGraphicsStroke;
-class UBMagnifer;
+class UBMagnifierParams;
+class UBMagnifier;
const double PI = 4.0 * atan(1.0);
@@ -165,9 +166,10 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
qreal getNextObjectZIndex();
void addRuler(QPointF center);
- void addTriangle(QPointF center);
void addProtractor(QPointF center);
void addCompass(QPointF center);
+ void addTriangle(QPointF center);
+ void addMagnifier(UBMagnifierParams params);
void addMask();
@@ -244,7 +246,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
static qreal toolOffsetProtractor;
static qreal toolOffsetCompass;
static qreal toolOffsetCurtain;
- static qreal toolOffsetTriangle;
+ static qreal toolOffsetTriangle;
QSet tools(){ return mTools;}
@@ -274,6 +276,11 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void selectionChangedProcessing();
+ void moveMagnifier(QPoint newPos);
+ void closeMagnifier();
+ void zoomInMagnifier();
+ void zoomOutMagnifier();
+ void resizedMagnifier(qreal newPercent);
signals:
@@ -289,7 +296,6 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void drawEraser(const QPointF& pEndPoint);
void drawPointer(const QPointF& pEndPoint);
- void CreateMagnifierQWidgets();
void DisposeMagnifierQWidgets();
@@ -352,8 +358,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
//int mMesure1Ms, mMesure2Ms;
- UBMagnifer *magniferControlViewWidget;
- UBMagnifer *magniferDisplayViewWidget;
+ UBMagnifier *magniferControlViewWidget;
+ UBMagnifier *magniferDisplayViewWidget;
};
#endif /* UBGRAPHICSSCENE_H_ */
diff --git a/src/gui/UBDockPalette.cpp b/src/gui/UBDockPalette.cpp
index 1b37e1de..b342bc6a 100644
--- a/src/gui/UBDockPalette.cpp
+++ b/src/gui/UBDockPalette.cpp
@@ -24,22 +24,6 @@
#include "core/memcheck.h"
-/*
- Note to myself: I will have to modify this implementation when we will
- have to support mulitple tab. At this moment, a UBDockPalette
- will be only the palette that manages the tabs. This
- palette will maintain a list of tabs with icons and will
- contain a QStackedWidget that will be contains the different
- widget contents.
- A click on a tab that is not related to the current widget
- will show the related widget in the palette.
- A click on a tab that is related to the current widget will
- collapse the palette.
- If the palette is collapsed, a click on any tab will expand it
- and show the tab related widget.
-*/
-
-
/**
* \brief The constructor
*/
@@ -53,9 +37,21 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
, mCollapseWidth(150)
, mLastWidth(-1)
, mHTab(0)
+ , mpStackWidget(NULL)
+ , mpLayout(NULL)
+ , mCurrentTab(0)
{
setObjectName(name);
+ mpLayout = new QVBoxLayout();
+ setLayout(mpLayout);
+
+ mpStackWidget = new QStackedWidget(this);
+ mpLayout->addWidget(mpStackWidget);
+
+ // 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 +87,16 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
*/
UBDockPalette::~UBDockPalette()
{
-
+ if(NULL != mpStackWidget)
+ {
+ delete mpStackWidget;
+ mpStackWidget = NULL;
+ }
+ if(NULL != mpLayout)
+ {
+ delete mpLayout;
+ mpLayout = NULL;
+ }
}
/**
@@ -194,13 +199,13 @@ void UBDockPalette::mousePressEvent(QMouseEvent *event)
switch(mOrientation)
{
case eUBDockOrientation_Left:
- if((p.x() >= width() - border()) && (p.x() <= width()))
+ if((p.x() >= width() - 2 * border()) && (p.x() <= width()))
{
mCanResize = true;
}
break;
case eUBDockOrientation_Right:
- if((p.x() >= 0) && (p.x() <= border()))
+ if((p.x() >= 0) && (p.x() <= 2 * border()))
{
mCanResize = true;
}
@@ -225,15 +230,18 @@ void UBDockPalette::mouseReleaseEvent(QMouseEvent *event)
Q_UNUSED(event);
if(!mResized && mClickTime.elapsed() < CLICKTIME)
{
+ int nbTabs = mTabWidgets.size();
+ int clickedTab = 0;
// If the clicked position is in the tab, perform the related action
if(eUBDockOrientation_Left == mOrientation)
{
if(mMousePressPos.x() >= width() - 2*border() &&
mMousePressPos.y() >= mHTab &&
mMousePressPos.x() <= width() &&
- mMousePressPos.y() <= mHTab + TABSIZE)
+ mMousePressPos.y() <= mHTab + nbTabs*TABSIZE + (nbTabs -1)*tabSpacing())
{
- tabClicked();
+ clickedTab = (mMousePressPos.y() - mHTab)/(TABSIZE+tabSpacing());
+ tabClicked(clickedTab);
}
}
else if(eUBDockOrientation_Right == mOrientation)
@@ -241,9 +249,10 @@ void UBDockPalette::mouseReleaseEvent(QMouseEvent *event)
if(mMousePressPos.x() >= 0 &&
mMousePressPos.x() <= 2*border() &&
mMousePressPos.y() >= mHTab &&
- mMousePressPos.y() <= mHTab + TABSIZE)
+ mMousePressPos.y() <= mHTab + nbTabs*TABSIZE + (nbTabs -1)*tabSpacing())
{
- tabClicked();
+ clickedTab = (mMousePressPos.y() - mHTab)/(TABSIZE+tabSpacing());
+ tabClicked(clickedTab);
}
}
}
@@ -313,51 +322,77 @@ void UBDockPalette::paintEvent(QPaintEvent *event)
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(Qt::NoPen);
painter.setBrush(mBackgroundBrush);
+ QPainterPath path;
+ path.setFillRule(Qt::WindingFill);
- if(eUBDockTabOrientation_Up == mTabsOrientation)
- {
- mHTab = border();
- }
- else
- {
- mHTab = height() - border() - TABSIZE;
- }
-
- if(mOrientation == eUBDockOrientation_Left)
+ int nbTabs = mTabWidgets.size();
+ if(0 < nbTabs)
{
- 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);
- if(mCollapseWidth >= width())
+ // First draw the BIG RECTANGLE (I write it big because the rectangle is big...)
+ if(mOrientation == eUBDockOrientation_Left)
{
- painter.drawPixmap(width() - 2*border() + 1, mHTab + 1 , 2*border() - 4, TABSIZE - 2, mCollapsedIcon);
+ path.addRect(0.0, 0.0, width()-2*border(), height());
}
- else
+ else if(mOrientation == eUBDockOrientation_Right)
{
- painter.drawPixmap(width() - 2*border() + 1, mHTab + 1 , 2*border() - 4, TABSIZE - 2, mIcon);
+ path.addRect(2*border(), 0.0, width()-2*border(), height());
}
- }
- 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);
- if(width() <= mCollapseWidth)
+
+ // THEN DRAW THE small tabs (yes, the tabs are small...)
+ if(eUBDockTabOrientation_Up == mTabsOrientation)
{
- painter.drawPixmap(2, mHTab + 1, 2*border() - 3, TABSIZE - 2, mCollapsedIcon);
+ mHTab = border();
}
else
{
- painter.drawPixmap(2, mHTab + 1, 2*border() - 3, TABSIZE - 2, mIcon);
+ mHTab = height() - border() - nbTabs*TABSIZE - (nbTabs-1)*tabSpacing();
+ }
+
+ for(int i = 0; i < mTabWidgets.size(); i++)
+ {
+ UBDockPaletteWidget* pCrntWidget = mTabWidgets.at(i);
+ if(NULL != pCrntWidget)
+ {
+ if(mOrientation == eUBDockOrientation_Left)
+ {
+ path.addRoundedRect(width()-4*border(), mHTab + i*TABSIZE + i*tabSpacing(), 4*border(), TABSIZE, radius(), radius());
+ painter.drawPath(path);
+ QPixmap iconPixmap;
+ if(mCollapseWidth >= width())
+ {
+ // Get the collapsed icon
+ iconPixmap = pCrntWidget->iconToRight();
+ }
+ else
+ {
+ // Get the expanded icon
+ iconPixmap = pCrntWidget->iconToLeft();
+ }
+ painter.drawPixmap(width() - 2*border() + 1, mHTab + i*TABSIZE + i*tabSpacing() + 1 , 2*border() - 4, TABSIZE - 2, iconPixmap);
+ }
+ else if(mOrientation == eUBDockOrientation_Right)
+ {
+ path.addRoundedRect(0.0, mHTab + i*TABSIZE + i*tabSpacing(), 4*border(), TABSIZE, radius(), radius());
+ painter.drawPath(path);
+ QPixmap iconPixmap;
+ if(mCollapseWidth >= width())
+ {
+ // Get the collapsed icon
+ iconPixmap = pCrntWidget->iconToLeft();
+ }
+ else
+ {
+ // Get the expanded icon
+ iconPixmap = pCrntWidget->iconToRight();
+ }
+ painter.drawPixmap(2, mHTab + i*TABSIZE + i*tabSpacing() + 1, 2*border() - 4, TABSIZE - 2, iconPixmap);
+ }
+ else
+ {
+ painter.drawRoundedRect(border(), border(), width() - 2 * border(), height() - 2 * border(), radius(), radius());
+ }
+ }
}
- }
- else
- {
- painter.drawRoundedRect(border(), border(), width() - 2 * border(), height() - 2 * border(), radius(), radius());
}
}
@@ -412,7 +447,33 @@ int UBDockPalette::collapseWidth()
/**
* \brief collapse/expand automatically the palette after a click on its tab
*/
-void UBDockPalette::tabClicked()
+void UBDockPalette::tabClicked(int tabIndex)
+{
+ // If the current tab is not the clicked one, show its content
+ if(mCurrentTab != tabIndex)
+ {
+ showTabWidget(tabIndex);
+ }
+ // else collapse the palette
+ else
+ {
+ toggleCollapseExpand();
+ }
+}
+
+void UBDockPalette::showTabWidget(int tabIndex)
+{
+ mpStackWidget->setCurrentIndex(tabIndex);
+ mCurrentTab = tabIndex;
+
+ // Expand it if collapsed
+ if(mLastWidth != -1)
+ {
+ toggleCollapseExpand();
+ }
+}
+
+void UBDockPalette::toggleCollapseExpand()
{
if(mLastWidth == -1)
{
@@ -451,3 +512,35 @@ int UBDockPalette::customMargin()
{
return 5;
}
+
+void UBDockPalette::addTabWidget(UBDockPaletteWidget *widget)
+{
+ mTabWidgets.append(widget);
+ mpStackWidget->addWidget(widget);
+ update();
+}
+
+void UBDockPalette::removeTab(const QString &widgetName)
+{
+ for(int i = 0; i < mTabWidgets.size(); i++)
+ {
+ UBDockPaletteWidget* pCrntWidget = mTabWidgets.at(i);
+ if(NULL != pCrntWidget && (pCrntWidget->name() == widgetName))
+ {
+ mpStackWidget->removeWidget(pCrntWidget);
+ mTabWidgets.remove(i);
+ update();
+ break;
+ }
+ }
+}
+
+void UBDockPalette::onResizeRequest(QResizeEvent *event)
+{
+ resizeEvent(event);
+}
+
+int UBDockPalette::tabSpacing()
+{
+ return 2;
+}
diff --git a/src/gui/UBDockPalette.h b/src/gui/UBDockPalette.h
index 02fd32c2..34c3ee2b 100644
--- a/src/gui/UBDockPalette.h
+++ b/src/gui/UBDockPalette.h
@@ -24,6 +24,12 @@
#include
#include
#include
+#include
+#include
+#include
+#include
+
+#include "UBDockPaletteWidget.h"
#define TABSIZE 50
#define CLICKTIME 1000000
@@ -66,6 +72,9 @@ public:
void setBackgroundBrush(const QBrush& brush);
protected:
+ void addTabWidget(UBDockPaletteWidget* widget);
+ void removeTab(const QString& widgetName);
+
virtual int border();
virtual int radius();
virtual int customMargin();
@@ -93,19 +102,33 @@ protected:
QTime mClickTime;
/** The mouse pressed position */
QPoint mMousePressPos;
- /** The palette icon */
- QPixmap mIcon;
- QPixmap mCollapsedIcon;
+// /** The palette icon */
+// QPixmap mIcon;
+// QPixmap mCollapsedIcon;
/** The tab orientation */
eUBDockTabOrientation mTabsOrientation;
/** The h position of the tab */
int mHTab;
+ /** The tab widgets */
+ //QMap mTabWidgets;
+ /** The stacked widget */
+ QStackedWidget* mpStackWidget;
+ /** The layout */
+ QVBoxLayout* mpLayout;
+ /** The current tab index */
+ int mCurrentTab;
+ /** The tab widgets */
+ QVector mTabWidgets;
private slots:
void onToolbarPosUpdated();
+ void onResizeRequest(QResizeEvent* event);
private:
- void tabClicked();
+ void tabClicked(int tabIndex);
+ int tabSpacing();
+ void showTabWidget(int tabIndex);
+ void toggleCollapseExpand();
};
#endif // UBDOCKPALETTE_H
diff --git a/src/gui/UBDockPaletteWidget.cpp b/src/gui/UBDockPaletteWidget.cpp
new file mode 100644
index 00000000..d649d9a5
--- /dev/null
+++ b/src/gui/UBDockPaletteWidget.cpp
@@ -0,0 +1,26 @@
+#include "UBDockPaletteWidget.h"
+
+UBDockPaletteWidget::UBDockPaletteWidget(QWidget *parent, const char *name):QWidget(parent)
+{
+ setObjectName(name);
+}
+
+UBDockPaletteWidget::~UBDockPaletteWidget()
+{
+
+}
+
+QPixmap UBDockPaletteWidget::iconToRight()
+{
+ return mIconToRight;
+}
+
+QPixmap UBDockPaletteWidget::iconToLeft()
+{
+ return mIconToLeft;
+}
+
+QString UBDockPaletteWidget::name()
+{
+ return mName;
+}
diff --git a/src/gui/UBDockPaletteWidget.h b/src/gui/UBDockPaletteWidget.h
new file mode 100644
index 00000000..1158a858
--- /dev/null
+++ b/src/gui/UBDockPaletteWidget.h
@@ -0,0 +1,25 @@
+#ifndef UBDOCKPALETTEWIDGET_H
+#define UBDOCKPALETTEWIDGET_H
+
+#include
+#include
+#include
+
+class UBDockPaletteWidget : public QWidget
+{
+public:
+ UBDockPaletteWidget(QWidget* parent=0, const char* name="UBDockPaletteWidget");
+ ~UBDockPaletteWidget();
+
+ QPixmap iconToRight();
+ QPixmap iconToLeft();
+ QString name();
+
+protected:
+ QPixmap mIconToRight; // arrow like this: >
+ QPixmap mIconToLeft; // arrow like this: <
+ QString mName;
+
+};
+
+#endif // UBDOCKPALETTEWIDGET_H
diff --git a/src/gui/UBLeftPalette.cpp b/src/gui/UBLeftPalette.cpp
new file mode 100644
index 00000000..299e8494
--- /dev/null
+++ b/src/gui/UBLeftPalette.cpp
@@ -0,0 +1,44 @@
+/*
+ * 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 "UBLeftPalette.h"
+
+UBLeftPalette::UBLeftPalette(QWidget *parent, const char *name):UBDockPalette(parent)
+ , mpPageNavigator(NULL)
+{
+ setObjectName(name);
+ setOrientation(eUBDockOrientation_Left);
+ mLastWidth = 300;
+ setMaximumWidth(300);
+ resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), height());
+
+ mpLayout->setContentsMargins(customMargin(), customMargin(), 2*border() + customMargin(), customMargin());
+
+ mpPageNavigator = new UBPageNavigationWidget(this);
+ addTabWidget(mpPageNavigator);
+}
+
+UBLeftPalette::~UBLeftPalette()
+{
+ if(NULL != mpPageNavigator)
+ {
+ delete mpPageNavigator;
+ mpPageNavigator = NULL;
+ }
+}
+
+UBPageNavigationWidget* UBLeftPalette::pageNavigator()
+{
+ return mpPageNavigator;
+}
diff --git a/src/gui/UBLeftPalette.h b/src/gui/UBLeftPalette.h
new file mode 100644
index 00000000..61e0e1ce
--- /dev/null
+++ b/src/gui/UBLeftPalette.h
@@ -0,0 +1,34 @@
+/*
+ * 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 UBLEFTPALETTE_H
+#define UBLEFTPALETTE_H
+
+#include "UBDockPalette.h"
+#include "UBPageNavigationWidget.h"
+
+class UBLeftPalette : public UBDockPalette
+{
+public:
+ UBLeftPalette(QWidget* parent=0, const char* name="UBLeftPalette");
+ ~UBLeftPalette();
+
+ UBPageNavigationWidget* pageNavigator();
+
+private:
+ UBPageNavigationWidget* mpPageNavigator;
+
+};
+
+#endif // UBLEFTPALETTE_H
diff --git a/src/gui/UBLibActionBar.cpp b/src/gui/UBLibActionBar.cpp
index 31901971..6b4093c0 100644
--- a/src/gui/UBLibActionBar.cpp
+++ b/src/gui/UBLibActionBar.cpp
@@ -16,9 +16,9 @@
#include
#include
+#include "UBLibWidget.h"
#include "UBLibActionBar.h"
#include "core/UBApplication.h"
-#include "board/UBBoardController.h"
#include "core/memcheck.h"
@@ -361,7 +361,8 @@ void UBLibActionBar::onSelectionChanged(QList itemList, bool isI
*/
UBLibraryController* UBLibActionBar::libraryController()
{
- return UBApplication::boardController->libraryController();
+ UBLibWidget* libWidget = dynamic_cast(parentWidget());
+ return libWidget->libNavigator()->libraryWidget()->libraryController();
}
/**
diff --git a/src/gui/UBLibItemProperties.cpp b/src/gui/UBLibItemProperties.cpp
index 92739aaf..1b47fbef 100644
--- a/src/gui/UBLibItemProperties.cpp
+++ b/src/gui/UBLibItemProperties.cpp
@@ -12,15 +12,14 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+
+#include "UBLibWidget.h"
#include "UBLibItemProperties.h"
#include "core/UBApplication.h"
-#include "board/UBBoardController.h"
-
#include "frameworks/UBFileSystemUtils.h"
-
#include "core/memcheck.h"
/**
@@ -223,7 +222,8 @@ void UBLibItemProperties::adaptSize()
*/
void UBLibItemProperties::onAddToPage()
{
- UBApplication::boardController->libraryController()->addItemToPage(mpElement);
+ UBLibWidget* libWidget = dynamic_cast(parentWidget()->parentWidget());
+ libWidget->libNavigator()->libraryWidget()->libraryController()->addItemToPage(mpElement);
}
/**
@@ -239,7 +239,8 @@ void UBLibItemProperties::onAddToLib()
*/
void UBLibItemProperties::onSetAsBackground()
{
- UBApplication::boardController->libraryController()->setItemAsBackground(mpElement);
+ UBLibWidget* libWidget = dynamic_cast(parentWidget()->parentWidget());
+ libWidget->libNavigator()->libraryWidget()->libraryController()->setItemAsBackground(mpElement);
}
/**
diff --git a/src/gui/UBLibNavigatorWidget.cpp b/src/gui/UBLibNavigatorWidget.cpp
index adefdd1e..46908a29 100644
--- a/src/gui/UBLibNavigatorWidget.cpp
+++ b/src/gui/UBLibNavigatorWidget.cpp
@@ -13,7 +13,7 @@
* along with this program. If not, see .
*/
#include "UBLibNavigatorWidget.h"
-#include "UBLibPalette.h"
+#include "UBLibWidget.h"
#include "core/memcheck.h"
@@ -27,19 +27,18 @@ static int tickIntervalForSlider = 10;
* @param name as the object name
*/
UBLibNavigatorWidget::UBLibNavigatorWidget(QWidget *parent, const char *name):QWidget(parent)
- , mLayout(NULL)
- , mLibWidget(NULL)
- , mPathViewer(NULL)
- , mSlider(NULL)
- , mSliderWidthSetting(NULL)
+ , mLayout(NULL)
+ , mLibWidget(NULL)
+ , mPathViewer(NULL)
+ , mSlider(NULL)
+ , mSliderWidthSetting(NULL)
{
setObjectName(name);
setAcceptDrops(true);
- UBLibPalette* pLibPalette = dynamic_cast(parentWidget());
+ UBLibWidget* libWidget = dynamic_cast(parentWidget());
mLayout = new QVBoxLayout(this);
-// mLayout->setContentsMargins(20, 5, 5, 5);
setLayout(mLayout);
mPathViewer = new UBLibPathViewer(this);
@@ -66,15 +65,13 @@ UBLibNavigatorWidget::UBLibNavigatorWidget(QWidget *parent, const char *name):QW
connect(mSlider,SIGNAL(valueChanged(int)),this,SLOT(updateThumbnailsSize(int)));
connect(mPathViewer, SIGNAL(elementsDropped(QList,UBLibElement*)), mLibWidget, SLOT(onElementsDropped(QList,UBLibElement*)));
- if(NULL != pLibPalette)
- {
- connect(mLibWidget, SIGNAL(navigBarUpdate(UBLibElement*)), pLibPalette->actionBar(), SLOT(onNavigbarUpdate(UBLibElement*)));
- connect(mLibWidget, SIGNAL(itemsSelected(QList, bool)), pLibPalette->actionBar(), SLOT(onSelectionChanged(QList, bool)));
- connect(pLibPalette->actionBar(), SIGNAL(deleteDone()), mLibWidget, SLOT(onRefreshCurrentFolder()));
- connect(mLibWidget, SIGNAL(favoritesEntered(bool)), pLibPalette->actionBar(), SLOT(onFavoritesEntered(bool)));
- connect(pLibPalette->actionBar(), SIGNAL(searchElement(QString)), mLibWidget, SLOT(onSearchElement(QString)));
- connect(pLibPalette->actionBar(), SIGNAL(newFolderToCreate()), mLibWidget, SLOT(onNewFolderToCreate()));
- }
+
+ connect(mLibWidget, SIGNAL(navigBarUpdate(UBLibElement*)), libWidget->actionBar(), SLOT(onNavigbarUpdate(UBLibElement*)));
+ connect(mLibWidget, SIGNAL(itemsSelected(QList, bool)), libWidget->actionBar(), SLOT(onSelectionChanged(QList, bool)));
+ connect(libWidget->actionBar(), SIGNAL(deleteDone()), mLibWidget, SLOT(onRefreshCurrentFolder()));
+ connect(mLibWidget, SIGNAL(favoritesEntered(bool)), libWidget->actionBar(), SLOT(onFavoritesEntered(bool)));
+ connect(libWidget->actionBar(), SIGNAL(searchElement(QString)), mLibWidget, SLOT(onSearchElement(QString)));
+ connect(libWidget->actionBar(), SIGNAL(newFolderToCreate()), mLibWidget, SLOT(onNewFolderToCreate()));
mLibWidget->init();
}
@@ -147,6 +144,7 @@ void UBLibNavigatorWidget::removeNextChainedElements(UBChainedLibElement *fromEl
if(NULL != fromElem->nextElement())
{
removeNextChainedElements(fromElem->nextElement());
+ delete fromElem->nextElement()->element();
delete fromElem->nextElement();
fromElem->setNextElement(NULL);
}
diff --git a/src/gui/UBLibNavigatorWidget.h b/src/gui/UBLibNavigatorWidget.h
index 0917b6e3..a8750b38 100644
--- a/src/gui/UBLibNavigatorWidget.h
+++ b/src/gui/UBLibNavigatorWidget.h
@@ -32,6 +32,8 @@ public:
~UBLibNavigatorWidget();
void dropMe(const QMimeData* _data);
+ UBLibraryWidget* libraryWidget(){return mLibWidget;};
+
signals:
void propertiesRequested(UBLibElement* elem);
diff --git a/src/gui/UBLibPalette.cpp b/src/gui/UBLibWidget.cpp
similarity index 51%
rename from src/gui/UBLibPalette.cpp
rename to src/gui/UBLibWidget.cpp
index da9bb420..de9cf34d 100644
--- a/src/gui/UBLibPalette.cpp
+++ b/src/gui/UBLibWidget.cpp
@@ -13,8 +13,8 @@
* along with this program. If not, see .
*/
#include
-#include "UBLibPalette.h"
+#include "UBLibWidget.h"
#include "core/memcheck.h"
/**
@@ -22,27 +22,20 @@
* @param parent as the parent widget
* @param name as the object name
*/
-UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(parent, name)
- , mLayout(NULL)
- , mStackedWidget(NULL)
- , mNavigator(NULL)
- , mProperties(NULL)
- , mActionBar(NULL)
- , mDropWidget(NULL)
+UBLibWidget::UBLibWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent)
+ , mLayout(NULL)
+ , mStackedWidget(NULL)
+ , mNavigator(NULL)
+ , mProperties(NULL)
+ , mActionBar(NULL)
{
- setOrientation(eUBDockOrientation_Right);
- //mIcon = QPixmap(":images/paletteLibrary.png");
- mCollapsedIcon = QPixmap(":images/library_open.png");
- mIcon = QPixmap(":images/library_close.png");
+ setObjectName(name);
+ mName = "LibWidget";
+ mIconToLeft = QPixmap(":images/library_open.png");
+ mIconToRight = QPixmap(":images/library_close.png");
setAcceptDrops(true);
- resize(UBSettings::settings()->libPaletteWidth->get().toInt(), parentWidget()->height());
- setContentsMargins(border(), 0, 0, 0);
- mCollapseWidth = 180;
- mLastWidth = 300;
-
mLayout = new QVBoxLayout(this);
- mLayout->setContentsMargins(20, customMargin(), customMargin(), customMargin());
setLayout(mLayout);
// Build the GUI
@@ -50,14 +43,12 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare
mActionBar = new UBLibActionBar(this);
mNavigator = new UBLibNavigatorWidget(this);
mProperties = new UBLibItemProperties(this);
- //mDropWidget = new UBDropMeWidget(this);
mLayout->addWidget(mStackedWidget, 1);
mLayout->addWidget(mActionBar, 0);
mStackedWidget->addWidget(mNavigator);
mStackedWidget->addWidget(mProperties);
- //mStackedWidget->addWidget(mDropWidget);
mStackedWidget->setCurrentIndex(ID_NAVIGATOR);
miCrntStackWidget = ID_NAVIGATOR;
@@ -69,20 +60,9 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare
/**
* \brief Destructor
*/
-UBLibPalette::~UBLibPalette()
+UBLibWidget::~UBLibWidget()
{
- //if(NULL != mStackedWidget)
- //{
- // delete mStackedWidget;
- // mStackedWidget = NULL;
- //}
- //if(NULL != mNavigator)
- //{
- // delete mNavigator;
- // mNavigator = NULL;
- //}
-
- if(NULL != mProperties)
+ if(NULL != mProperties)
{
delete mProperties;
mProperties = NULL;
@@ -92,42 +72,20 @@ UBLibPalette::~UBLibPalette()
delete mActionBar;
mActionBar = NULL;
}
- if(NULL != mDropWidget)
- {
- delete mDropWidget;
- mDropWidget = NULL;
- }
- //if(NULL != mLayout)
- //{
- //delete mLayout;
- //mLayout = NULL;
- //}
-}
-
-/**
- * \brief Update the maximum width
- */
-void UBLibPalette::updateMaxWidth()
-{
- setMaximumWidth((int)((parentWidget()->width() * 2)/3));
- setMaximumHeight(parentWidget()->height());
- setMinimumHeight(parentWidget()->height());
}
/**
* \brief Handles the drag enter event
* @param pEvent as the drag enter event
*/
-void UBLibPalette::dragEnterEvent(QDragEnterEvent *pEvent)
+void UBLibWidget::dragEnterEvent(QDragEnterEvent *pEvent)
{
setBackgroundRole(QPalette::Highlight);
- //mStackedWidget->setCurrentIndex(ID_DROPME);
pEvent->acceptProposedAction();
}
-void UBLibPalette::dragLeaveEvent(QDragLeaveEvent *pEvent)
+void UBLibWidget::dragLeaveEvent(QDragLeaveEvent *pEvent)
{
- //mStackedWidget->setCurrentIndex(miCrntStackWidget);
pEvent->accept();
}
@@ -135,7 +93,7 @@ void UBLibPalette::dragLeaveEvent(QDragLeaveEvent *pEvent)
* \brief Handles the drop event
* @param pEvent as the drop event
*/
-void UBLibPalette::dropEvent(QDropEvent *pEvent)
+void UBLibWidget::dropEvent(QDropEvent *pEvent)
{
processMimeData(pEvent->mimeData());
setBackgroundRole(QPalette::Dark);
@@ -147,7 +105,7 @@ void UBLibPalette::dropEvent(QDropEvent *pEvent)
* \brief Handles the drag move event
* @param pEvent as the drag move event
*/
-void UBLibPalette::dragMoveEvent(QDragMoveEvent *pEvent)
+void UBLibWidget::dragMoveEvent(QDragMoveEvent *pEvent)
{
pEvent->acceptProposedAction();
}
@@ -156,7 +114,7 @@ void UBLibPalette::dragMoveEvent(QDragMoveEvent *pEvent)
* \brief Process the dropped MIME data
* @param pData as the mime dropped data
*/
-void UBLibPalette::processMimeData(const QMimeData *pData)
+void UBLibWidget::processMimeData(const QMimeData *pData)
{
// Display the different mime types contained in the mime data
QStringList qslFormats = pData->formats();
@@ -164,23 +122,9 @@ void UBLibPalette::processMimeData(const QMimeData *pData)
{
qDebug() << "Dropped element format " << i << " = "<< qslFormats.at(i);
}
- // mNavigator->dropMe(pData);
-
-}
-
-void UBLibPalette::mouseMoveEvent(QMouseEvent *event)
-{
- if(mCanResize)
- {
- UBDockPalette::mouseMoveEvent(event);
- }
- else
- {
- //qDebug() << "Mouse move event detected!" ;
- }
}
-void UBLibPalette::showProperties(UBLibElement *elem)
+void UBLibWidget::showProperties(UBLibElement *elem)
{
if(NULL != elem)
{
@@ -192,43 +136,19 @@ void UBLibPalette::showProperties(UBLibElement *elem)
}
}
-void UBLibPalette::showFolder()
+void UBLibWidget::showFolder()
{
mActionBar->setButtons(mActionBar->previousButtonSet());
mStackedWidget->setCurrentIndex(ID_NAVIGATOR);
miCrntStackWidget = ID_NAVIGATOR;
}
-void UBLibPalette::resizeEvent(QResizeEvent *event)
+int UBLibWidget::customMargin()
{
- UBDockPalette::resizeEvent(event);
- UBSettings::settings()->libPaletteWidth->set(width());
- emit resized();
+ return 5;
}
-// --------------------------------------------------------------------------
-UBDropMeWidget::UBDropMeWidget(QWidget *parent, const char *name):QWidget(parent)
- , mpLabel(NULL)
- , mpLayout(NULL)
+int UBLibWidget::border()
{
- setObjectName(name);
- mpLayout = new QVBoxLayout(this);
- setLayout(mpLayout);
-
- mpLabel = new QLabel(tr("Drop here"), this);
- mpLayout->addWidget(mpLabel);
-}
-
-UBDropMeWidget::~UBDropMeWidget()
-{
- if(NULL != mpLabel)
- {
- delete mpLabel;
- mpLabel = NULL;
- }
- if(NULL != mpLayout)
- {
- delete mpLayout;
- mpLayout = NULL;
- }
+ return 15;
}
diff --git a/src/gui/UBLibPalette.h b/src/gui/UBLibWidget.h
similarity index 74%
rename from src/gui/UBLibPalette.h
rename to src/gui/UBLibWidget.h
index afbe8ff9..644bd93f 100644
--- a/src/gui/UBLibPalette.h
+++ b/src/gui/UBLibWidget.h
@@ -12,8 +12,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-#ifndef UBLIBPALETTE_H
-#define UBLIBPALETTE_H
+#ifndef UBLIBWIDGET_H
+#define UBLIBWIDGET_H
#include
#include
@@ -26,46 +26,32 @@
#include
#include
-#include "UBDockPalette.h"
+#include "UBDockPaletteWidget.h"
#include "UBLibNavigatorWidget.h"
#include "UBLibItemProperties.h"
#include "UBLibActionBar.h"
#define ID_NAVIGATOR 0
#define ID_PROPERTIES 1
-#define ID_DROPME 2
-class UBDropMeWidget : public QWidget
-{
-public:
- UBDropMeWidget(QWidget* parent=0, const char* name="dropMeWidget");
- ~UBDropMeWidget();
-
-private:
- QLabel* mpLabel;
- QVBoxLayout* mpLayout;
-};
-
-class UBLibPalette : public UBDockPalette
+class UBLibWidget : public UBDockPaletteWidget
{
Q_OBJECT
public:
- UBLibPalette(QWidget* parent=0, const char* name="libPalette");
- ~UBLibPalette();
+ UBLibWidget(QWidget* parent=0, const char* name="UBLibWidget");
+ ~UBLibWidget();
UBLibActionBar* actionBar(){return mActionBar;}
+ UBLibNavigatorWidget* libNavigator() {return mNavigator;};
signals:
void resized();
protected:
- void updateMaxWidth();
void dragEnterEvent(QDragEnterEvent* pEvent);
void dropEvent(QDropEvent *pEvent);
void dragMoveEvent(QDragMoveEvent* pEvent);
void dragLeaveEvent(QDragLeaveEvent* pEvent);
- void mouseMoveEvent(QMouseEvent *event);
- void resizeEvent(QResizeEvent *event);
private slots:
void showProperties(UBLibElement* elem);
@@ -73,6 +59,8 @@ private slots:
private:
void processMimeData(const QMimeData* pData);
+ int customMargin();
+ int border();
/** The layout */
QVBoxLayout* mLayout;
@@ -84,10 +72,8 @@ private:
UBLibItemProperties* mProperties;
/** UBLibActionBar */
UBLibActionBar* mActionBar;
- /** The 'drop here' indicator */
- UBDropMeWidget* mDropWidget;
/** The current stack widget index*/
int miCrntStackWidget;
};
-#endif // UBLIBPALETTE_H
+#endif // UBLIBWIDGET_H
diff --git a/src/gui/UBLibraryWidget.cpp b/src/gui/UBLibraryWidget.cpp
index f887568b..d66f0b2c 100644
--- a/src/gui/UBLibraryWidget.cpp
+++ b/src/gui/UBLibraryWidget.cpp
@@ -12,573 +12,569 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-#include
-#include
-
-#include "UBLibraryWidget.h"
-#include "core/UBSettings.h"
-#include "core/UBSetting.h"
-#include "core/UBApplication.h"
-
-#include "board/UBBoardController.h"
-#include "board/UBLibraryController.h"
-
-#include "core/memcheck.h"
-
-/**
- * \brief Constructor
- * @param parent as the parent widget
- * @param name as the widget object name
- */
-UBLibraryWidget::UBLibraryWidget(QWidget *parent, const char *name):UBThumbnailWidget(parent)
- , chainedElements(NULL)
- , mpCrntDir(NULL)
- , mpCrntElem(NULL)
- , mCrntPath("/")
-{
- setObjectName(name);
- setSpacing(5);
- setStyleSheet(QString("background: #EEEEEE; border-radius : 10px; border : 2px solid #999999;"));
-}
-
-/**
- * \brief Destructor
- */
-UBLibraryWidget::~UBLibraryWidget()
-{
-// if(NULL != chainedElements)
-// {
-// delete chainedElements;
-// chainedElements = NULL;
-// }
-// if(NULL != mpCrntDir)
-// {
-// delete mpCrntDir;
-// mpCrntDir = NULL;
-// }
-// if(NULL != mpCrntElem)
-// {
-// delete mpCrntElem;
-// mpCrntElem = NULL;
-// }
-}
-
-/**
- * \brief Initialize the widget content
- */
-void UBLibraryWidget::init()
-{
- setAcceptDrops(true);
- mpCrntElem = new UBLibElement();
- mpCrntElem->setThumbnail(new QImage(":images/libpalette/home.png"));
- chainedElements = new UBChainedLibElement(mpCrntElem);
- QList qlElems = libraryController()->getContent(mpCrntElem);
- mCurrentElems = qlElems;
-
- setCurrentElemsAndRefresh(chainedElements);
-
- connect(this, SIGNAL(mouseClick(QGraphicsItem*,int)), this, SLOT(onItemClicked(QGraphicsItem*,int)));
- connect(this, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
-}
-
-/**
- * \brief Refresh the view
- */
-void UBLibraryWidget::refreshView()
-{
- // Clear the view
- mItems.clear();
- mLabels.clear();
- mItemsPaths.clear();
- mGraphicItems.clear();
-
- // Generate the graphics items
- generateItems();
-
- // Set the new items
- setGraphicsItems(mGraphicItems, mItemsPaths, mLabels);
-
- // Refresh the view
- refreshScene();
-
- emit navigBarUpdate(mpCrntElem);
-
- bool bFavorite = false;
- if(NULL != mpCrntDir && libraryController()->favoritePath() == mpCrntDir->path().toLocalFile())
- {
- bFavorite = true;
- }
- emit favoritesEntered(bFavorite);
-}
-
-/**
- * \brief Generate the graphic items related to the current directory
- */
-void UBLibraryWidget::generateItems()
-{
- for(int i = 0; i < mCurrentElems.size(); i++)
- {
- UBLibElement* pElem = mCurrentElems.at(i);
- mLabels << pElem->name();
- mItemsPaths << pElem->path();
- QGraphicsPixmapItem *pixmapItem = new UBThumbnailPixmap(QPixmap::fromImage(*pElem->thumbnail()));
- mGraphicItems << pixmapItem;
- }
-}
-
-/**
- * \brief Handles the click on an item
- * @param item as the clicked item
- * @param index as the given index
- */
-void UBLibraryWidget::onItemClicked(QGraphicsItem *item, int index)
-{
- Q_UNUSED(index);
- if(NULL != item)
- {
- int iItem = mGraphicItems.indexOf(item);
- if(0 <= iItem)
- {
- UBLibElement* pElem = mCurrentElems.at(iItem);
- if(NULL != pElem)
- {
- mpCrntElem = pElem;
- if(eUBLibElementType_Folder == pElem->type() ||
- eUBLibElementType_VirtualFolder == pElem->type())
- {
- // Add the clicked element to the end of the elements list
- // (at this level, the user can only go down in the path)
- UBChainedLibElement* pNextElem = new UBChainedLibElement(pElem);
- appendChainedElement(pNextElem, chainedElements);
-
- mpCrntDir = pElem;
- // Display the content of the folder
- QList qlElems = libraryController()->getContent(pElem);
- mCurrentElems = qlElems;
- refreshView();
- }
- else
- {
- // Display the properties view
- emit propertiesRequested(pElem);
- }
- }
- }
- }
-}
-
-/**
- * \brief Append the given element to the given chain
- * @param element as the element to append
- * @param toElem as the given chain
- */
-void UBLibraryWidget::appendChainedElement(UBChainedLibElement *element, UBChainedLibElement *toElem)
-{
- if(NULL != toElem)
- {
- if(NULL != toElem->nextElement())
- {
- appendChainedElement(element, toElem->nextElement());
- }
- else
- {
- toElem->setNextElement(element);
- }
- }
-}
-
-/**
- * \brief Set the current element and refresh the scene
- * @param elem as the current element
- */
-void UBLibraryWidget::setCurrentElemsAndRefresh(UBChainedLibElement *elem)
-{
- if(NULL != elem)
- {
- UBLibElement* pLibElem = elem->element();
- if(NULL != pLibElem)
- {
- if(eUBLibElementType_Item != pLibElem->type())
- {
- QList qlElements = libraryController()->getContent(pLibElem);
- mCurrentElems = qlElements;
- mpCrntElem = pLibElem;
- refreshView();
- mpCrntDir = pLibElem;
- bool bFavorite = false;
- if(NULL != mpCrntDir && libraryController()->favoritePath() == mpCrntDir->path().toLocalFile())
- {
- bFavorite = true;
- }
- emit favoritesEntered(bFavorite);
- }
- }
- }
-}
-
-/**
- * \brief Handles the selection changed event
- */
-void UBLibraryWidget::onSelectionChanged()
-{
- // Get the selected items
- QList qlSelectedItems;
- QList qlGI = selectedItems();
-
- bCanDrag = true;
- foreach(QGraphicsItem* it, qlGI)
- {
- int itIndex = mGraphicItems.indexOf(it);
- if(0 <= itIndex)
- {
- UBLibElement* pElem = mCurrentElems.at(itIndex);
- if(NULL != pElem)
- {
- if(eUBLibElementType_Category != pElem->type() &&
- eUBLibElementType_VirtualFolder != pElem->type())
- {
- qlSelectedItems << pElem;
- }
-
- if(!pElem->isMoveable())
- {
- bCanDrag = false;
- }
- }
- }
- }
-
- // Check if we are in the trash folder
- bool bInTrash = false;
- if(NULL != mpCrntDir)
- {
- if("Trash" == mpCrntDir->name())
- {
- bInTrash = true;
- }
- }
-
- // Send the signal with these items
- emit itemsSelected(qlSelectedItems, bInTrash);
-}
-
-/**
- * \brief Handle the delete done event
- */
-void UBLibraryWidget::onRefreshCurrentFolder()
-{
- // Refresh the current view
- mCurrentElems = libraryController()->getContent(mpCrntDir);
- refreshView();
-}
-
-/**
- * \brief Handles the drag enter event
- * @param event as the drag enter event
- */
-void UBLibraryWidget::dragEnterEvent(QDragEnterEvent *event)
-{
- event->acceptProposedAction();
-}
-
-/**
- * \brief Handles the drag move event
- * @param event as the drag move event
- */
-void UBLibraryWidget::dragMoveEvent(QDragMoveEvent *event)
-{
- UBLibElement* pElem = elementAt(event->pos());
- if(NULL != pElem)
- {
- // We can only drop an item into a folder
- if(eUBLibElementType_Folder == pElem->type() ||
- eUBLibElementType_VirtualFolder == pElem->type())
- {
- event->acceptProposedAction();
- }
- }
-}
-
-void UBLibraryWidget::onDropMe(const QMimeData *_data)
-{
- Q_UNUSED(_data);
-}
-
-/**
- * \brief Handles the drop event
- * @param event as the drop event
- */
-void UBLibraryWidget::dropEvent(QDropEvent *event)
-{
- const QMimeData* pMimeData = event->mimeData();
- if(event->source() == this)
- {
- event->accept();
-
- // Get the destination item
- UBLibElement* pElem = elementAt(event->pos());
- if(NULL != pElem)
- {
- if(eUBLibElementType_Folder == pElem->type())
- {
- // The drag comes from this application, we have now to get the list of UBLibElements*
- QList qlDroppedElems;
-
- foreach(QUrl url, pMimeData->urls())
- {
- qlDroppedElems << url.toString();
- }
-
- if(!qlDroppedElems.empty())
- onElementsDropped(qlDroppedElems, pElem);
- }
- }
- }
- else
- {
- bool bDropAccepted = false;
- if (pMimeData->hasImage())
- {
- qDebug() << "hasImage";
- QImage image = qvariant_cast(pMimeData->imageData());
- libraryController()->importImageOnLibrary(image);
- bDropAccepted = true;
- }
- else if (pMimeData->hasHtml())
- {
- qDebug() << "hasHtml Unsupported yet";
- }
- else if (pMimeData->hasText())
- {
- // On linux external dragged element are considered as text;
- qDebug() << "hasText: " << pMimeData->text();
- QString filePath = QUrl(pMimeData->text()).toLocalFile();
- libraryController()->importItemOnLibrary(filePath);
- bDropAccepted = true;
- }
- else if (pMimeData->hasUrls())
- {
- qDebug() << "hasUrls";
- QList urlList = pMimeData->urls();
- for (int i = 0; i < urlList.size() && i < 32; ++i)
- {
- QString filePath = QUrl(urlList.at(i).path()).toLocalFile();
- libraryController()->importItemOnLibrary(filePath);
- bDropAccepted = true;
- }
- }
- else
- {
- qWarning() << "Cannot import data";
- }
-
- if(bDropAccepted)
- {
- onRefreshCurrentFolder();
- event->accept();
- }
- else
- {
- event->ignore();
- }
- }
-}
-
-/**
- * \brief Get the element at the given position
- * @param p as the given position
- * @return a pointer on the related element
- */
-UBLibElement* UBLibraryWidget::elementAt(QPoint p)
-{
- QGraphicsItem* pItem = itemAt(p);
- if(NULL != pItem)
- {
- int iItem = mGraphicItems.indexOf(pItem);
- if(-1 != iItem)
- {
- return mCurrentElems.at(iItem);
- }
- }
-
- // If no element is found, return NULL
- return NULL;
-}
-
-
-/**
- * \brief Get the element from the given name
- * @param name as the given element name
- * @return the UBLibElement related to the given name
- */
-UBLibElement* UBLibraryWidget::elementFromFilePath(const QString &filePath)
-{
- UBLibElement* pElem = NULL;
-
- foreach(UBLibElement* elem, mCurrentElems)
- {
- if(elem->path().toLocalFile() == QUrl(filePath).toLocalFile())
- {
- return elem;
- }
-
- }
-
- return pElem;
-}
-
-/**
- * \brief Get a pointer on the library controller
- * @return a pointer on the library controller
- */
-UBLibraryController* UBLibraryWidget::libraryController()
-{
- return UBApplication::boardController->libraryController();
-}
-
-/**
- * \brief Update the thumbnails size
- * @param newSize as the thumbnail size
- */
-void UBLibraryWidget::updateThumbnailsSize(int newSize)
-{
- setThumbnailWidth(newSize);
- refreshView();
-}
-
-/**
- * \brief Handles the element dropped event
- * @param elements as the list of dropped elements
- * @param target as the drop target
- */
-void UBLibraryWidget::onElementsDropped(QList elements, UBLibElement *target)
-{
- if(target != mpCrntDir)
- {
- QList qlElements;
-
- foreach(QString qsElem, elements)
- qlElements << elementFromFilePath(qsElem);
-
- libraryController()->moveContent(qlElements, target);
- mCurrentElems = libraryController()->getContent(mpCrntDir);
- refreshView();
- }
-}
-
-/**
- * \brief Search the element related to the given text
- * @param elem as the searched element name
- */
-void UBLibraryWidget::onSearchElement(QString elem)
-{
- // Store the original list of items
- mOrigCurrentElems = libraryController()->getContent(mpCrntDir);
-
- // Build the filtered list
- mCurrentElems.clear();
- if(elem.isEmpty())
- {
- mCurrentElems = mOrigCurrentElems;
- }
- else
- {
- foreach(UBLibElement* ubLibElem, mOrigCurrentElems)
- {
- if(ubLibElem->name().toLower().contains(elem.toLower()))
- {
- mCurrentElems << ubLibElem;
- }
- }
- }
- refreshView();
-}
-
-/**
- * \brief Create a new folder
- */
-void UBLibraryWidget::onNewFolderToCreate()
-{
- // Create here a dialog asking the name of the new folder
- UBNewFolderDlg dlg;
- if(QDialog::Accepted == dlg.exec())
- {
- libraryController()->createNewFolder(dlg.folderName(), mpCrntElem);
- onRefreshCurrentFolder();
- }
-}
-
-/**
- * \brief Constructor
- * @param parent as the parent widget
- * @param name as the object name
- */
-UBNewFolderDlg::UBNewFolderDlg(QWidget *parent, const char *name):QDialog(parent)
- , mpLabel(NULL)
- , mpLineEdit(NULL)
- , mpButtons(NULL)
- , mpLayout(NULL)
- , mpHLayout(NULL)
-{
- setObjectName(name);
- setWindowTitle(tr("Add new folder"));
-
- mpLabel = new QLabel(tr("New Folder name:"),this);
- mpLineEdit = new QLineEdit(this);
- mpButtons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
- mpLayout = new QVBoxLayout(this);
- mpHLayout = new QHBoxLayout(this);
-
- setLayout(mpLayout);
- mpLayout->addLayout(mpHLayout, 0);
- mpHLayout->addWidget(mpLabel, 0);
- mpHLayout->addWidget(mpLineEdit, 1);
- mpLayout->addWidget(mpButtons);
-
- connect(mpButtons->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept()));
- connect(mpButtons->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
-
- setMaximumHeight(100);
- setMinimumHeight(100);
-}
-
-/**
- * \brief Destructor
- */
-UBNewFolderDlg::~UBNewFolderDlg()
-{
- if(NULL != mpButtons)
- {
- delete mpButtons;
- mpButtons = NULL;
- }
- if(NULL != mpLineEdit)
- {
- delete mpLineEdit;
- mpLineEdit = NULL;
- }
- if(NULL != mpLabel)
- {
- delete mpLabel;
- mpLabel = NULL;
- }
- if(NULL != mpHLayout)
- {
- delete mpHLayout;
- mpHLayout = NULL;
- }
- if(NULL != mpLayout)
- {
- delete mpLayout;
- mpLayout = NULL;
- }
-}
-
-/**
- * \brief Get the folder name
- * @return the entered folder name
- */
-QString UBNewFolderDlg::folderName()
-{
- return mpLineEdit->text();
-}
+#include
+#include
+
+#include "UBLibraryWidget.h"
+#include "core/UBSettings.h"
+#include "core/UBSetting.h"
+#include "core/UBApplication.h"
+
+#include "board/UBBoardController.h"
+#include "board/UBLibraryController.h"
+
+#include "core/memcheck.h"
+
+/**
+ * \brief Constructor
+ * @param parent as the parent widget
+ * @param name as the widget object name
+ */
+UBLibraryWidget::UBLibraryWidget(QWidget *parent, const char *name):UBThumbnailWidget(parent)
+ , chainedElements(NULL)
+ , mpCrntDir(NULL)
+ , mpCrntElem(NULL)
+{
+ setObjectName(name);
+ setSpacing(5);
+ setStyleSheet(QString("background: #EEEEEE; border-radius : 10px; border : 2px solid #999999;"));
+ mLibraryController = new UBLibraryController(parentWidget());
+}
+
+/**
+ * \brief Destructor
+ */
+UBLibraryWidget::~UBLibraryWidget()
+{
+ if(mLibraryController){
+ delete mLibraryController;
+ mLibraryController = NULL;
+ }
+
+// if(NULL != chainedElements)
+// {
+// delete chainedElements;
+// chainedElements = NULL;
+// }
+ if(NULL != mpCrntDir)
+ {
+ delete mpCrntDir;
+ mpCrntDir = NULL;
+ }
+ if(NULL != mpCrntElem)
+ {
+ delete mpCrntElem;
+ mpCrntElem = NULL;
+ }
+}
+
+/**
+ * \brief Initialize the widget content
+ */
+void UBLibraryWidget::init()
+{
+ setAcceptDrops(true);
+ mpCrntElem = new UBLibElement();
+ mpCrntElem->setThumbnail(QImage(":images/libpalette/home.png"));
+ chainedElements = new UBChainedLibElement(mpCrntElem);
+ QList qlElems = mLibraryController->getContent(mpCrntElem);
+ mCurrentElems = qlElems;
+
+ setCurrentElemsAndRefresh(chainedElements);
+
+ connect(this, SIGNAL(mouseClick(QGraphicsItem*,int)), this, SLOT(onItemClicked(QGraphicsItem*,int)));
+ connect(this, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
+}
+
+/**
+ * \brief Refresh the view
+ */
+void UBLibraryWidget::refreshView()
+{
+ // Clear the view
+ mItems.clear();
+ mLabels.clear();
+ mItemsPaths.clear();
+ mGraphicItems.clear();
+
+ // Generate the graphics items
+ generateItems();
+
+ // Set the new items
+ setGraphicsItems(mGraphicItems, mItemsPaths, mLabels);
+
+ // Refresh the view
+ refreshScene();
+
+ emit navigBarUpdate(mpCrntElem);
+
+ bool bFavorite = false;
+ if(NULL != mpCrntDir && mLibraryController->favoritePath() == mpCrntDir->path().toLocalFile())
+ {
+ bFavorite = true;
+ }
+ emit favoritesEntered(bFavorite);
+}
+
+/**
+ * \brief Generate the graphic items related to the current directory
+ */
+void UBLibraryWidget::generateItems()
+{
+ for(int i = 0; i < mCurrentElems.size(); i++)
+ {
+ UBLibElement* pElem = mCurrentElems.at(i);
+ mLabels << pElem->name();
+ mItemsPaths << pElem->path();
+ QGraphicsPixmapItem *pixmapItem = new UBThumbnailPixmap(QPixmap::fromImage(*pElem->thumbnail()));
+ mGraphicItems << pixmapItem;
+ }
+}
+
+/**
+ * \brief Handles the click on an item
+ * @param item as the clicked item
+ * @param index as the given index
+ */
+void UBLibraryWidget::onItemClicked(QGraphicsItem *item, int index)
+{
+ Q_UNUSED(index);
+ if(NULL != item)
+ {
+ int iItem = mGraphicItems.indexOf(item);
+ if(0 <= iItem)
+ {
+ UBLibElement* pElem = mCurrentElems.at(iItem);
+ if(NULL != pElem)
+ {
+ delete mpCrntElem;
+ mpCrntElem = new UBLibElement(pElem);
+ if(eUBLibElementType_Folder == pElem->type() || eUBLibElementType_VirtualFolder == pElem->type()) {
+ // Add the clicked element to the end of the elements list
+ // (at this level, the user can only go down in the path)
+ UBChainedLibElement* pNextElem = new UBChainedLibElement(pElem);
+ appendChainedElement(pNextElem, chainedElements);
+ delete mpCrntDir;
+ mpCrntDir = new UBLibElement(pElem);
+ // Display the content of the folder
+ QList qlElems = mLibraryController->getContent(mpCrntDir);
+ mCurrentElems = qlElems;
+ refreshView();
+ }
+ else
+ {
+ // Display the properties view
+ emit propertiesRequested(pElem);
+ }
+ }
+ }
+ }
+}
+
+/**
+ * \brief Append the given element to the given chain
+ * @param element as the element to append
+ * @param toElem as the given chain
+ */
+void UBLibraryWidget::appendChainedElement(UBChainedLibElement *element, UBChainedLibElement *toElem)
+{
+ if(NULL != toElem)
+ {
+ if(NULL != toElem->nextElement())
+ {
+ appendChainedElement(element, toElem->nextElement());
+ }
+ else
+ {
+ toElem->setNextElement(element);
+ }
+ }
+}
+
+/**
+ * \brief Set the current element and refresh the scene
+ * @param elem as the current element
+ */
+void UBLibraryWidget::setCurrentElemsAndRefresh(UBChainedLibElement *elem)
+{
+ if(NULL != elem)
+ {
+ UBLibElement* pLibElem = elem->element();
+ if(NULL != pLibElem)
+ {
+ if(eUBLibElementType_Item != pLibElem->type())
+ {
+ QList qlElements = mLibraryController->getContent(pLibElem);
+ mCurrentElems = qlElements;
+ delete mpCrntElem;
+ mpCrntElem = new UBLibElement(pLibElem);
+ refreshView();
+ delete mpCrntDir;
+ mpCrntDir = new UBLibElement(pLibElem);
+ bool bFavorite = false;
+ if(NULL != mpCrntDir && mLibraryController->favoritePath() == mpCrntDir->path().toLocalFile())
+ {
+ bFavorite = true;
+ }
+ emit favoritesEntered(bFavorite);
+ }
+ }
+ }
+}
+
+/**
+ * \brief Handles the selection changed event
+ */
+void UBLibraryWidget::onSelectionChanged()
+{
+ // Get the selected items
+ QList qlSelectedItems;
+ QList qlGI = selectedItems();
+
+ bCanDrag = true;
+ foreach(QGraphicsItem* it, qlGI)
+ {
+ int itIndex = mGraphicItems.indexOf(it);
+ if(0 <= itIndex)
+ {
+ UBLibElement* pElem = mCurrentElems.at(itIndex);
+ if(NULL != pElem)
+ {
+ if(eUBLibElementType_Category != pElem->type() && eUBLibElementType_VirtualFolder != pElem->type()) {
+ qlSelectedItems << pElem;
+ }
+
+ if(!pElem->isMoveable())
+ {
+ bCanDrag = false;
+ }
+ }
+ }
+ }
+
+ // Check if we are in the trash folder
+ bool bInTrash = false;
+ if(NULL != mpCrntDir)
+ {
+ if("Trash" == mpCrntDir->name())
+ {
+ bInTrash = true;
+ }
+ }
+
+ // Send the signal with these items
+ emit itemsSelected(qlSelectedItems, bInTrash);
+}
+
+/**
+ * \brief Handle the delete done event
+ */
+void UBLibraryWidget::onRefreshCurrentFolder()
+{
+ // Refresh the current view
+ mCurrentElems = mLibraryController->getContent(mpCrntDir);
+ refreshView();
+}
+
+/**
+ * \brief Handles the drag enter event
+ * @param event as the drag enter event
+ */
+void UBLibraryWidget::dragEnterEvent(QDragEnterEvent *event)
+{
+ event->acceptProposedAction();
+}
+
+/**
+ * \brief Handles the drag move event
+ * @param event as the drag move event
+ */
+void UBLibraryWidget::dragMoveEvent(QDragMoveEvent *event)
+{
+ UBLibElement* pElem = elementAt(event->pos());
+ if(NULL != pElem)
+ {
+ // We can only drop an item into a folder
+ if(eUBLibElementType_Folder == pElem->type() ||
+ eUBLibElementType_VirtualFolder == pElem->type())
+ {
+ event->acceptProposedAction();
+ }
+ }
+}
+
+void UBLibraryWidget::onDropMe(const QMimeData *_data)
+{
+ Q_UNUSED(_data);
+}
+
+/**
+ * \brief Handles the drop event
+ * @param event as the drop event
+ */
+void UBLibraryWidget::dropEvent(QDropEvent *event)
+{
+ const QMimeData* pMimeData = event->mimeData();
+ if(event->source() == this)
+ {
+ event->accept();
+
+ // Get the destination item
+ UBLibElement* pElem = elementAt(event->pos());
+ if(NULL != pElem)
+ {
+ if(eUBLibElementType_Folder == pElem->type())
+ {
+ // The drag comes from this application, we have now to get the list of UBLibElements*
+ QList qlDroppedElems;
+
+ foreach(QUrl url, pMimeData->urls())
+ {
+ qlDroppedElems << url.toString();
+ }
+
+ if(!qlDroppedElems.empty())
+ onElementsDropped(qlDroppedElems, pElem);
+ }
+ }
+ }
+ else
+ {
+ bool bDropAccepted = false;
+ if (pMimeData->hasImage())
+ {
+ qDebug() << "hasImage";
+ QImage image = qvariant_cast(pMimeData->imageData());
+ mLibraryController->importImageOnLibrary(image);
+ bDropAccepted = true;
+ }
+ else if (pMimeData->hasHtml())
+ {
+ qDebug() << "hasHtml Unsupported yet";
+ }
+ else if (pMimeData->hasText())
+ {
+ // On linux external dragged element are considered as text;
+ qDebug() << "hasText: " << pMimeData->text();
+ QString filePath = QUrl(pMimeData->text()).toLocalFile();
+ mLibraryController->importItemOnLibrary(filePath);
+ bDropAccepted = true;
+ }
+ else if (pMimeData->hasUrls())
+ {
+ qDebug() << "hasUrls";
+ QList urlList = pMimeData->urls();
+ for (int i = 0; i < urlList.size() && i < 32; ++i)
+ {
+ QString filePath = QUrl(urlList.at(i).path()).toLocalFile();
+ mLibraryController->importItemOnLibrary(filePath);
+ bDropAccepted = true;
+ }
+ }
+ else
+ {
+ qWarning() << "Cannot import data";
+ }
+
+ if(bDropAccepted)
+ {
+ onRefreshCurrentFolder();
+ event->accept();
+ }
+ else
+ {
+ event->ignore();
+ }
+ }
+}
+
+/**
+ * \brief Get the element at the given position
+ * @param p as the given position
+ * @return a pointer on the related element
+ */
+UBLibElement* UBLibraryWidget::elementAt(QPoint p)
+{
+ QGraphicsItem* pItem = itemAt(p);
+ if(NULL != pItem)
+ {
+ int iItem = mGraphicItems.indexOf(pItem);
+ if(-1 != iItem)
+ {
+ return mCurrentElems.at(iItem);
+ }
+ }
+
+ // If no element is found, return NULL
+ return NULL;
+}
+
+
+/**
+ * \brief Get the element from the given name
+ * @param name as the given element name
+ * @return the UBLibElement related to the given name
+ */
+UBLibElement* UBLibraryWidget::elementFromFilePath(const QString &filePath)
+{
+ UBLibElement* pElem = NULL;
+
+ foreach(UBLibElement* elem, mCurrentElems)
+ {
+ if(elem->path().toLocalFile() == QUrl(filePath).toLocalFile())
+ {
+ return elem;
+ }
+
+ }
+
+ return pElem;
+}
+
+
+/**
+ * \brief Update the thumbnails size
+ * @param newSize as the thumbnail size
+ */
+void UBLibraryWidget::updateThumbnailsSize(int newSize)
+{
+ setThumbnailWidth(newSize);
+ refreshView();
+}
+
+/**
+ * \brief Handles the element dropped event
+ * @param elements as the list of dropped elements
+ * @param target as the drop target
+ */
+void UBLibraryWidget::onElementsDropped(QList elements, UBLibElement *target)
+{
+ if(target != mpCrntDir)
+ {
+ QList qlElements;
+
+ foreach(QString qsElem, elements)
+ qlElements << elementFromFilePath(qsElem);
+
+ mLibraryController->moveContent(qlElements, target);
+ mCurrentElems = mLibraryController->getContent(mpCrntDir);
+ refreshView();
+ }
+}
+
+/**
+ * \brief Search the element related to the given text
+ * @param elem as the searched element name
+ */
+void UBLibraryWidget::onSearchElement(QString elem)
+{
+ // Store the original list of items
+ mOrigCurrentElems = mLibraryController->getContent(mpCrntDir);
+
+ // Build the filtered list
+ mCurrentElems.clear();
+ if(elem.isEmpty())
+ {
+ mCurrentElems = mOrigCurrentElems;
+ }
+ else
+ {
+ foreach(UBLibElement* ubLibElem, mOrigCurrentElems)
+ {
+ if(ubLibElem->name().toLower().contains(elem.toLower()))
+ {
+ mCurrentElems << ubLibElem;
+ }
+ }
+ }
+ refreshView();
+}
+
+/**
+ * \brief Create a new folder
+ */
+void UBLibraryWidget::onNewFolderToCreate()
+{
+ // Create here a dialog asking the name of the new folder
+ UBNewFolderDlg dlg;
+ if(QDialog::Accepted == dlg.exec())
+ {
+ mLibraryController->createNewFolder(dlg.folderName(), mpCrntElem);
+ onRefreshCurrentFolder();
+ }
+}
+
+/**
+ * \brief Constructor
+ * @param parent as the parent widget
+ * @param name as the object name
+ */
+UBNewFolderDlg::UBNewFolderDlg(QWidget *parent, const char *name):QDialog(parent)
+ , mpLabel(NULL)
+ , mpLineEdit(NULL)
+ , mpButtons(NULL)
+ , mpLayout(NULL)
+ , mpHLayout(NULL)
+{
+ setObjectName(name);
+ setWindowTitle(tr("Add new folder"));
+
+ mpLabel = new QLabel(tr("New Folder name:"),this);
+ mpLineEdit = new QLineEdit(this);
+ mpButtons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
+ mpLayout = new QVBoxLayout(this);
+ mpHLayout = new QHBoxLayout(this);
+
+ setLayout(mpLayout);
+ mpLayout->addLayout(mpHLayout, 0);
+ mpHLayout->addWidget(mpLabel, 0);
+ mpHLayout->addWidget(mpLineEdit, 1);
+ mpLayout->addWidget(mpButtons);
+
+ connect(mpButtons->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept()));
+ connect(mpButtons->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
+
+ setMaximumHeight(100);
+ setMinimumHeight(100);
+}
+
+/**
+ * \brief Destructor
+ */
+UBNewFolderDlg::~UBNewFolderDlg()
+{
+ if(NULL != mpButtons)
+ {
+ delete mpButtons;
+ mpButtons = NULL;
+ }
+ if(NULL != mpLineEdit)
+ {
+ delete mpLineEdit;
+ mpLineEdit = NULL;
+ }
+ if(NULL != mpLabel)
+ {
+ delete mpLabel;
+ mpLabel = NULL;
+ }
+ if(NULL != mpHLayout)
+ {
+ delete mpHLayout;
+ mpHLayout = NULL;
+ }
+ if(NULL != mpLayout)
+ {
+ delete mpLayout;
+ mpLayout = NULL;
+ }
+}
+
+/**
+ * \brief Get the folder name
+ * @return the entered folder name
+ */
+QString UBNewFolderDlg::folderName()
+{
+ return mpLineEdit->text();
+}
diff --git a/src/gui/UBLibraryWidget.h b/src/gui/UBLibraryWidget.h
index 42f9aa32..e6fd0fc7 100644
--- a/src/gui/UBLibraryWidget.h
+++ b/src/gui/UBLibraryWidget.h
@@ -29,7 +29,10 @@
#include
#include "UBThumbnailWidget.h"
-#include "board/UBLibraryController.h"
+
+class UBLibraryController;
+class UBChainedLibElement;
+class UBLibElement;
class UBLibraryWidget : public UBThumbnailWidget
{
@@ -44,6 +47,8 @@ public:
void updateThumbnailsSize(int newSize);
void init();
+ UBLibraryController* libraryController() {return mLibraryController;};
+
public slots:
void onRefreshCurrentFolder();
void onElementsDropped(QList elements, UBLibElement* target);
@@ -71,14 +76,13 @@ private:
void appendChainedElement(UBChainedLibElement* element, UBChainedLibElement* toElem);
UBLibElement* elementAt(QPoint p);
UBLibElement* elementFromFilePath(const QString& filePath);
- UBLibraryController* libraryController();
+ UBLibraryController* mLibraryController;
UBLibElement* mpCrntDir;
UBLibElement* mpCrntElem;
QList mCurrentElems;
QList mOrigCurrentElems;
QList mItems;
- QString mCrntPath;
};
diff --git a/src/gui/UBMagnifer.cpp b/src/gui/UBMagnifer.cpp
index 0888522e..e36add3f 100644
--- a/src/gui/UBMagnifer.cpp
+++ b/src/gui/UBMagnifer.cpp
@@ -1,51 +1,124 @@
+
+#include
#include "UBMagnifer.h"
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-UBMagnifer::UBMagnifer(QWidget *parent)
- : QWidget(parent)
+
+#include "core/UBApplication.h"
+#include "board/UBBoardController.h"
+#include "domain/UBGraphicsScene.h"
+
+// #include
+// #include
+// #include
+// #include
+// #include
+// #include
+// #include
+// #include
+
+
+UBMagnifier::UBMagnifier(QWidget *parent, bool isInteractive)
+ : QWidget(parent, parent ? Qt::Widget : Qt::Tool | (Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint))
, gView(0)
, mView(0)
- , sizePercentFromScene(20)
, inTimer(false)
, borderPen(Qt::darkGray)
+ , mShouldMoveWidget(false)
+ , mShouldResizeWidget(false)
+
{
- borderPen.setWidth(2);
+ isCusrsorAlreadyStored = false;
+ setMouseTracking(true);
+
+ //--------------------------------------------------//
+
+ QPixmap pix(":/images/cursors/resize.png");
+ QTransform tr;
+ tr.rotate(45);
+ mResizeCursor = QCursor(pix.transformed(tr, Qt::SmoothTransformation), pix.width() / 2, pix.height() / 2);
+
+ //--------------------------------------------------//
+
+ params.sizePercentFromScene = 20;
+ m_isInteractive = isInteractive;
+ sClosePixmap = new QPixmap(":/images/close.svg");
+ sIncreasePixmap = new QPixmap(":/images/increase.svg");
+ sDecreasePixmap = new QPixmap(":/images/decrease.svg");
+ mResizeItem = new QPixmap(":/images/resize.svg");
+
+ if (parent)
+ {
+ setAttribute(Qt::WA_NoMousePropagation);
+ }
+ else
+ {
+ // standalone window
+ // !!!! Should be included into Windows after QT recompilation
+#ifndef Q_WS_WIN
+ setAttribute(Qt::WA_TranslucentBackground);
+ setAttribute(Qt::WA_MacAlwaysShowToolWindow);
+#endif
+#ifdef Q_WS_MAC
+ setAttribute(Qt::WA_MacAlwaysShowToolWindow);
+ setAttribute(Qt::WA_MacNonActivatingToolWindow);
+ setAttribute(Qt::WA_MacNoShadow);
+#endif
+ }
+
}
-UBMagnifer::~UBMagnifer()
+UBMagnifier::~UBMagnifier()
{
if (timerUpdate != 0)
{
killTimer(timerUpdate);
timerUpdate = 0;
}
+
+ if(sClosePixmap)
+ {
+ delete sClosePixmap;
+ sClosePixmap = NULL;
+ }
+
+ if(sIncreasePixmap)
+ {
+ delete sIncreasePixmap;
+ sIncreasePixmap = NULL;
+ }
+
+ if(sDecreasePixmap)
+ {
+ delete sDecreasePixmap;
+ sDecreasePixmap = NULL;
+ }
+
}
-void UBMagnifer::setSize(int percentFromScene)
+void UBMagnifier::setSize(qreal percentFromScene)
{
- if(gView == NULL) return;
+ if(gView == NULL || mView == NULL) return;
// calculate object size
- sizePercentFromScene = percentFromScene;
- QSize sceneSize = gView->size();
- int size = sizePercentFromScene * sceneSize.width() / 100;
+ params.sizePercentFromScene = percentFromScene;
+ QSize sceneSize = mView->size();
+ qreal size = params.sizePercentFromScene * sceneSize.width() / 100;
- setGeometry(0, 0, size, size);
+ QRect currGeom = geometry();
+ if(currGeom.width() == currGeom.height())
+ {
+ QPoint newPos = mView->mapFromGlobal(updPointMove);
+ setGeometry(newPos.x() - size / 2, newPos.y() - size / 2, size, size);
+ }
+ else
+ setGeometry(0, 0, size, size);
// prepare transparent bit mask
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.drawEllipse(QPoint(size/2, size/2), size/2, size/2);
+ mask_ptr.drawEllipse(QPointF(size/2, size/2), size / 2 - sClosePixmap->width(), size / 2 - sClosePixmap->width());
bmpMask = QBitmap::fromImage(mask_img);
// prepare general image
@@ -54,49 +127,207 @@ void UBMagnifer::setSize(int percentFromScene)
pMap.setMask(bmpMask);
}
-void UBMagnifer::setZoom(int z)
+void UBMagnifier::setZoom(qreal zoom)
+{
+ params.zoom = zoom;
+}
+
+void UBMagnifier::paintEvent(QPaintEvent * event)
+{
+ QPainter painter(this);
+
+// painter.drawRect(0,0,size().width()-1, size().height()-1);
+
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.setPen(Qt::NoPen);
+
+ if (m_isInteractive)
+ {
+ painter.setBrush(QColor(127, 127, 127, 127));
+ painter.drawRoundedRect(QRectF(size().width() / 2, size().height() / 2, ( size().width() - sClosePixmap->width() ) / 2, ( size().height() - sClosePixmap->width() ) / 2), 15, 15);
+
+ painter.setBrush(QColor(190, 190, 190, 255));
+ painter.drawEllipse(QPoint( size().width() / 2, size().height() / 2), ( size().width() - sClosePixmap->width() ) / 2, ( size().height() - sClosePixmap->height() ) / 2);
+
+ painter.drawPixmap(size().width() - sClosePixmap->width(), size().height() / 2 + sClosePixmap->height() * 1, *sClosePixmap);
+ painter.drawPixmap(size().width() - sIncreasePixmap->width(), size().height() / 2 + sIncreasePixmap->height() * 2.5, *sIncreasePixmap);
+ painter.drawPixmap(size().width() - sDecreasePixmap->width(), size().height() / 2 + sDecreasePixmap->height() * 3.6, *sDecreasePixmap);
+
+ painter.drawPixmap(size().width() - mResizeItem->width() - 20, size().height() - mResizeItem->height() - 20, *mResizeItem);
+ }
+ else
+ {
+ painter.setBrush(QColor(127, 127, 127, 127));
+ painter.drawEllipse(QPoint( size().width() / 2, size().height() / 2), ( size().width() - sClosePixmap->width() ) / 2, ( size().height() - sClosePixmap->height() ) / 2);
+ }
+
+ painter.drawPixmap(0, 0, pMap);
+}
+
+void UBMagnifier::mousePressEvent ( QMouseEvent * event )
{
- zoom = z;
+ if(m_isInteractive)
+ {
+
+ QWidget::mousePressEvent(event);
+
+ if (event->pos().x() >= size().width() - mResizeItem->width() - 20 &&
+ event->pos().x() < size().width() - 20 &&
+ event->pos().y() >= size().height() - mResizeItem->height() - 20 &&
+ event->pos().y() < size().height() - - 20)
+ {
+ mShouldResizeWidget = true;
+ }
+ else
+ {
+ mShouldMoveWidget = !event->isAccepted() && (event->buttons() & Qt::LeftButton);
+ }
+
+ mMousePressPos = event->pos();
+ mMousePressDelta = (qreal)updPointGrab.x() + (qreal)size().width() / 2 - (qreal)event->globalPos().x();
+
+ event->accept();
- zWidth = size().width() / zoom;
- zWidthHalf = zWidth / 2;
- zHeight = size().height() / zoom;
- zHeightHalf = zHeight / 2;
+ update();
+ }
+ else
+ event->ignore();
}
-void UBMagnifer::paintEvent(QPaintEvent *)
+void UBMagnifier::mouseMoveEvent ( QMouseEvent * event )
{
- QPainter p(this);
- p.drawPixmap(0, 0, pMap);
-
- // in future replace to image border
- QPen pen(Qt::darkGray);
- pen.setWidth(2);
- p.setPen(borderPen);
- p.drawEllipse(QPoint( size().width() / 2, size().height() / 2), size().width() / 2, size().height() / 2);
+ if(m_isInteractive)
+ {
+ if(mShouldMoveWidget && (event->buttons() & Qt::LeftButton))
+ {
+ QPoint offset = event->pos() - mMousePressPos;
+ move(pos() - mMousePressPos + event->pos());
+ event->accept();
+
+ QWidget::mouseMoveEvent(event);
+ emit magnifierMoved_Signal(QPoint(this->pos().x() + size().width() / 2, this->pos().y() + size().height() / 2 ));
+ return;
+ }
+
+ if(mShouldResizeWidget && (event->buttons() & Qt::LeftButton))
+ {
+
+ QPoint currGlobalPos = event->globalPos();
+ qreal cvW = mView->width();
+
+ qreal newXSize = ( currGlobalPos.x() + mMousePressDelta - updPointGrab.x() ) * 2;
+ qreal newPercentSize = newXSize * 100 / cvW;
+
+ emit magnifierResized_Signal(newPercentSize);
+
+ event->ignore();
+ return;
+ }
+
+ if (event->pos().x() >= size().width() - mResizeItem->width() - 20 &&
+ event->pos().x() < size().width() - 20 &&
+ event->pos().y() >= size().height() - mResizeItem->height() - 20 &&
+ event->pos().y() < size().height() - - 20 &&
+ isCusrsorAlreadyStored == false
+ )
+ {
+ mOldCursor = cursor();
+ isCusrsorAlreadyStored = true;
+ setCursor(mResizeCursor);
+ }
+
+ }
+ else
+ event->ignore();
+}
+
+
+void UBMagnifier::mouseReleaseEvent(QMouseEvent * event)
+{
+ if(m_isInteractive)
+ {
+ mShouldMoveWidget = false;
+ mShouldResizeWidget = false;
+
+ if (event->pos().x() >= size().width() - sClosePixmap->width() &&
+ event->pos().x() < size().width()&&
+ event->pos().y() >= size().height() / 2 + sClosePixmap->height() * 1 &&
+ event->pos().y() < size().height() / 2 + sClosePixmap->height() * 2)
+ {
+ event->accept();
+ emit magnifierClose_Signal();
+ }
+ else
+ if (event->pos().x() >= size().width() - sIncreasePixmap->width() &&
+ event->pos().x() < size().width()&&
+ event->pos().y() >= size().height() / 2 + sIncreasePixmap->height() * 2.5 &&
+ event->pos().y() < size().height() / 2 + sIncreasePixmap->height() * 3.5)
+ {
+ event->accept();
+ emit magnifierZoomIn_Signal();
+ }
+ else
+ if (event->pos().x() >= size().width() - sDecreasePixmap->width() &&
+ event->pos().x() < size().width()&&
+ event->pos().y() >= size().height() / 2 + sDecreasePixmap->height() * 3.6 &&
+ event->pos().y() < size().height() / 2 + sDecreasePixmap->height() * 4.6)
+ {
+ event->accept();
+ emit magnifierZoomOut_Signal();
+ }
+ else
+ QWidget::mouseReleaseEvent(event); // don't propgate to parent, the widget is deleted in UBApplication::boardController->removeTool
+ }
+ else
+ event->ignore();
+
}
-void UBMagnifer::timerEvent(QTimerEvent *e)
+void UBMagnifier::timerEvent(QTimerEvent *e)
{
if(inTimer) return;
if (e->timerId() == timerUpdate)
{
inTimer = true;
- if(!(updPoint.isNull())) grabPoint(updPoint);
- if(!(updPointF.isNull()))grabPoint(updPointF);
+ if(!(updPointGrab.isNull()))
+ grabPoint(updPointGrab);
+
+ if(isCusrsorAlreadyStored)
+ {
+ QPoint globalCursorPos = QCursor::pos();
+ QPoint cursorPos = mapFromGlobal(globalCursorPos);
+ if (cursorPos.x() < size().width() - mResizeItem->width() - 20 ||
+ cursorPos.x() > size().width() - 20 ||
+ cursorPos.y() < size().height() - mResizeItem->height() - 20 ||
+ cursorPos.y() > size().height() - - 20
+ )
+ {
+ isCusrsorAlreadyStored = false;
+ setCursor(mOldCursor);
+ }
+
+ }
+
inTimer = false;
}
}
-void UBMagnifer::grabPoint(const QPoint &point)
+void UBMagnifier::grabPoint()
{
- QPointF itemPos = gView->mapFromGlobal(point);
+ QPointF itemPos = gView->mapFromGlobal(updPointGrab);
+
+ qreal zWidth = size().width() / params.zoom;
+ qreal zWidthHalf = zWidth / 2;
+ qreal zHeight = size().height() / params.zoom;
+ 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();
+
pMap.fill(Qt::transparent);
pMap = newPixMap.scaled(QSize(width(), height()));
pMap.setMask(bmpMask);
@@ -104,15 +335,23 @@ void UBMagnifer::grabPoint(const QPoint &point)
update();
}
-void UBMagnifer::grabPoint(const QPointF &point)
+void UBMagnifier::grabPoint(const QPoint &pGrab)
{
- QPoint itemPos = gView->mapFromScene(point);
+ updPointGrab = pGrab;
+ QPointF itemPos = gView->mapFromGlobal(pGrab);
+
+ qreal zWidth = size().width() / params.zoom;
+ qreal zWidthHalf = zWidth / 2;
+ qreal zHeight = size().height() / params.zoom;
+ 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();
+
pMap.fill(Qt::transparent);
pMap = newPixMap.scaled(QSize(width(), height()));
pMap.setMask(bmpMask);
@@ -120,32 +359,24 @@ void UBMagnifer::grabPoint(const QPointF &point)
update();
}
-
// from global
-void UBMagnifer::grabNMove(const QPoint &point, bool needGrab = true)
+void UBMagnifier::grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needGrab, bool needMove)
{
- updPoint = point;
+ updPointGrab = pGrab;
+ updPointMove = pMove;
if(needGrab)
- grabPoint(point);
- QPoint itemPos = mView->mapFromGlobal(point);
- move(itemPos.x() - width()/2, itemPos.y() - height()/2);
-// move(itemPos.x(), itemPos.y());
-}
+ grabPoint(pGrab);
-// from scene
-void UBMagnifer::grabNMove(const QPointF &point, bool needGrab = true)
-{
- updPointF = point;
-
- if(needGrab)
- grabPoint(point);
- QPoint itemPos = mView->mapFromScene(point);
- move(itemPos.x() - width()/2, itemPos.y() - height()/2);
-// move(itemPos.x(), itemPos.y());
+ if(needMove)
+ {
+ QPoint movePos = mView->mapFromGlobal(pMove);
+ move(movePos.x() - width()/2, movePos.y() - height()/2);
+ // move(itemPos.x(), itemPos.y());
+ }
}
-void UBMagnifer::setGrabView(QGraphicsView *view)
+void UBMagnifier::setGrabView(QWidget *view)
{
if (timerUpdate != 0)
killTimer(timerUpdate);
diff --git a/src/gui/UBMagnifer.h b/src/gui/UBMagnifer.h
index 435775a3..9032a3cd 100644
--- a/src/gui/UBMagnifer.h
+++ b/src/gui/UBMagnifer.h
@@ -1,60 +1,82 @@
-#ifndef UBMAGNIFER_H
-#define UBMAGNIFER_H
+#ifndef UBMAGNIFIER_H
+#define UBMAGNIFIER_H
-#include
-#include
-#include
+#include
-class QPixmap;
-class QBitmap;
-class QPen;
-class QGraphicsView;
+class UBMagnifierParams
+{
+public :
+ int x;
+ int y;
+ qreal zoom;
+ qreal sizePercentFromScene;
+};
-class UBMagnifer : public QWidget
+class UBMagnifier : public QWidget
{
Q_OBJECT
public:
- UBMagnifer(QWidget *parent = 0);
- ~UBMagnifer();
+ UBMagnifier(QWidget *parent = 0, bool isInteractive = false);
+ ~UBMagnifier();
- void setSize(int percentFromScene);
- void setZoom(int z);
+ void setSize(qreal percentFromScene);
+ void setZoom(qreal zoom);
- void setGrabView(QGraphicsView *view);
- void setMoveView(QGraphicsView *view) {mView = view;}
+ void setGrabView(QWidget *view);
+ void setMoveView(QWidget *view) {mView = view;}
+ void grabPoint();
void grabPoint(const QPoint &point);
- void grabPoint(const QPointF &point);
- void grabNMove(const QPoint &point, bool needGrab);
- void grabNMove(const QPointF &point, bool needGrab);
+ void grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needGrab = true, bool needMove = true);
+
+ UBMagnifierParams params;
+
+signals:
+ void magnifierMoved_Signal(QPoint newPos);
+ void magnifierClose_Signal();
+ void magnifierZoomIn_Signal();
+ void magnifierZoomOut_Signal();
+ void magnifierResized_Signal(qreal newPercentSize);
protected:
void paintEvent(QPaintEvent *);
void timerEvent(QTimerEvent *);
- int sizePercentFromScene;
+ virtual void mousePressEvent ( QMouseEvent * event );
+ virtual void mouseMoveEvent ( QMouseEvent * event );
+ virtual void mouseReleaseEvent ( QMouseEvent * event );
+
+ QPoint mMousePressPos;
+ qreal mMousePressDelta;
+ bool mShouldMoveWidget;
+ bool mShouldResizeWidget;
+
+
+ QPixmap *sClosePixmap;
+ QPixmap *sIncreasePixmap;
+ QPixmap *sDecreasePixmap;
+ QPixmap *mResizeItem;
+ bool isCusrsorAlreadyStored;
+ QCursor mOldCursor;
+ QCursor mResizeCursor;
private:
- int zoom;
- int zWidth;
- int zHeight;
- int zWidthHalf;
- int zHeightHalf;
bool inTimer;
+ bool m_isInteractive;
int timerUpdate;
- QPoint updPoint;
- QPointF updPointF;
+ QPoint updPointGrab;
+ QPoint updPointMove;
QPixmap pMap;
QBitmap bmpMask;
QPen borderPen;
- QGraphicsView *gView;
- QGraphicsView *mView;
+ QWidget *gView;
+ QWidget *mView;
};
-#endif // UBMAGNIFER_H
+#endif // UBMAGNIFIER_H
diff --git a/src/gui/UBNavigatorPalette.cpp b/src/gui/UBNavigatorPalette.cpp
index 3e035ae3..4e6eed8b 100644
--- a/src/gui/UBNavigatorPalette.cpp
+++ b/src/gui/UBNavigatorPalette.cpp
@@ -32,9 +32,8 @@ UBNavigatorPalette::UBNavigatorPalette(QWidget *parent, const char *name):UBDock
{
setOrientation(eUBDockOrientation_Left);
setMaximumWidth(300);
- //mIcon = QPixmap(":images/paletteNavigator.png");
- mCollapsedIcon = QPixmap(":images/pages_open.png");
- mIcon = QPixmap(":images/pages_close.png");
+ //mCollapsedIcon = QPixmap(":images/pages_open.png");
+ //mIcon = QPixmap(":images/pages_close.png");
resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), height());
mLastWidth = 300;
diff --git a/src/gui/UBPageNavigationWidget.cpp b/src/gui/UBPageNavigationWidget.cpp
new file mode 100644
index 00000000..8c4c20c6
--- /dev/null
+++ b/src/gui/UBPageNavigationWidget.cpp
@@ -0,0 +1,195 @@
+/*
+ * 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 "UBPageNavigationWidget.h"
+#include "core/UBApplication.h"
+#include "board/UBBoardController.h"
+#include "core/memcheck.h"
+
+/**
+ * \brief Constructor
+ * @param parent as the parent widget
+ * @param name as the object name
+ */
+UBPageNavigationWidget::UBPageNavigationWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent)
+ , mNavigator(NULL)
+ , mLayout(NULL)
+ , mHLayout(NULL)
+ , mPageNbr(NULL)
+ , mClock(NULL)
+{
+ setObjectName(name);
+ mName = "PageNavigator";
+
+ mIconToRight = QPixmap(":images/pages_open.png");
+ mIconToLeft = QPixmap(":images/pages_close.png");
+
+ // Build the gui
+ mLayout = new QVBoxLayout(this);
+ //mLayout->setContentsMargins(customMargin(), customMargin(), 2*border() + customMargin(), customMargin());
+ setLayout(mLayout);
+
+ mNavigator = new UBDocumentNavigator(this);
+ mNavigator->setStyleSheet(QString("background-color : transparent;"));
+ mLayout->addWidget(mNavigator, 1);
+
+ mHLayout = new QHBoxLayout();
+ mLayout->addLayout(mHLayout, 0);
+
+ mPageNbr = new QLabel(this);
+ mClock = new QLabel(this);
+ mHLayout->addWidget(mPageNbr);
+ mHLayout->addWidget(mClock);
+
+ // Configure the page number indicator
+ mPageNbr->setStyleSheet(QString("QLabel { color: white; background-color: transparent; border: none; font-family: Arial; font-weight: bold; font-size: 20px }"));
+ setPageNumber(0, 0);
+ mPageNbr->setAlignment(Qt::AlignHCenter);
+
+ // Configure the clock
+ mClock->setStyleSheet(QString("QLabel {color: white; background-color: transparent; text-align: center; font-family: Arial; font-weight: bold; font-size: 20px}"));
+ mTimeFormat = QLocale::system().timeFormat(QLocale::ShortFormat);
+ mClock->setAlignment(Qt::AlignHCenter);
+
+ //strip seconds
+ mTimeFormat = mTimeFormat.remove(":ss");
+ mTimeFormat = mTimeFormat.remove(":s");
+ mTimerID = startTimer(1000);
+
+ connect(mNavigator, SIGNAL(changeCurrentPage()), this, SLOT(changeCurrentPage()));
+}
+
+/**
+ * \brief Destructor
+ */
+UBPageNavigationWidget::~UBPageNavigationWidget()
+{
+ killTimer(mTimerID);
+
+ if(NULL != mClock)
+ {
+ delete mClock;
+ mClock = NULL;
+ }
+ if(NULL != mPageNbr)
+ {
+ delete mPageNbr;
+ mPageNbr = NULL;
+ }
+ if(NULL != mHLayout)
+ {
+ delete mHLayout;
+ mHLayout = NULL;
+ }
+ if(NULL != mLayout)
+ {
+ delete mLayout;
+ mLayout = NULL;
+ }
+ if(NULL != mNavigator)
+ {
+ delete mNavigator;
+ mNavigator = NULL;
+ }
+}
+
+/**
+ * \brief Set the current document in the navigator
+ * @param document as the given document
+ */
+void UBPageNavigationWidget::setDocument(UBDocumentProxy *document)
+{
+ if(mNavigator->currentDoc() != document)
+ {
+ mNavigator->setDocument(document);
+ }
+}
+
+/**
+ * \brief Change the current page
+ */
+void UBPageNavigationWidget::changeCurrentPage()
+{
+ // Get the index of the page to display
+ int iPage = mNavigator->selectedPageNumber();
+ if(NO_PAGESELECTED != iPage)
+ {
+ // Display the selected page
+ UBApplication::boardController->setActiveDocumentScene(mNavigator->currentDoc(), iPage);
+ }
+}
+
+/**
+ * \brief Refresh the thumbnails widget
+ */
+void UBPageNavigationWidget::refresh()
+{
+ mNavigator->setDocument(UBApplication::boardController->activeDocument());
+}
+
+/**
+ * \brief Handle the resize event
+ * @param event as the resize event
+ */
+void UBPageNavigationWidget::resizeEvent(QResizeEvent *event)
+{
+ emit resizeRequest(event);
+ //UBDockPalette::resizeEvent(event);
+ if(NULL != mNavigator)
+ {
+ mNavigator->setMinimumHeight(height() - 2*border());
+ }
+ UBSettings::settings()->navigPaletteWidth->set(width());
+}
+
+/**
+ * \brief Notify a timer event
+ * @param event as the timer event
+ */
+void UBPageNavigationWidget::timerEvent(QTimerEvent *event)
+{
+ Q_UNUSED(event);
+ updateTime();
+}
+
+/**
+ * \brief Update the current time
+ */
+void UBPageNavigationWidget::updateTime()
+{
+ if (mClock)
+ {
+ mClock->setText(QLocale::system().toString (QTime::currentTime(), mTimeFormat));
+ }
+}
+
+/**
+ * \brief Set the page number
+ * @param current as the current page
+ * @param total as the total number of pages
+ */
+void UBPageNavigationWidget::setPageNumber(int current, int total)
+{
+ mPageNbr->setText(QString("%1 / %2").arg(current).arg(total));
+}
+
+int UBPageNavigationWidget::customMargin()
+{
+ return 5;
+}
+
+int UBPageNavigationWidget::border()
+{
+ return 15;
+}
diff --git a/src/gui/UBPageNavigationWidget.h b/src/gui/UBPageNavigationWidget.h
new file mode 100644
index 00000000..8f1ca723
--- /dev/null
+++ b/src/gui/UBPageNavigationWidget.h
@@ -0,0 +1,68 @@
+/*
+ * 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 UBPAGENAVIGATIONWIDGET_H
+#define UBPAGENAVIGATIONWIDGET_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "UBDocumentNavigator.h"
+#include "UBDockPaletteWidget.h"
+#include "document/UBDocumentProxy.h"
+
+class UBPageNavigationWidget : public UBDockPaletteWidget
+{
+ Q_OBJECT
+public:
+ UBPageNavigationWidget(QWidget* parent=0, const char* name="UBPageNavigationWidget");
+ ~UBPageNavigationWidget();
+ void setDocument(UBDocumentProxy* document);
+ void refresh();
+
+signals:
+ void resizeRequest(QResizeEvent* event);
+
+public slots:
+ void setPageNumber(int current, int total);
+
+protected:
+ virtual void resizeEvent(QResizeEvent *event);
+ virtual void timerEvent(QTimerEvent *event);
+
+private:
+ void updateTime();
+ int customMargin();
+ int border();
+
+ /** The thumbnails navigator widget */
+ UBDocumentNavigator* mNavigator;
+ /** The layout */
+ QVBoxLayout* mLayout;
+ QHBoxLayout* mHLayout;
+ QLabel* mPageNbr;
+ QLabel* mClock;
+ QString mTimeFormat;
+ int mTimerID;
+
+private slots:
+ void changeCurrentPage();
+};
+
+#endif // UBPAGENAVIGATIONWIDGET_H
diff --git a/src/gui/UBRightPalette.cpp b/src/gui/UBRightPalette.cpp
new file mode 100644
index 00000000..c7f8a765
--- /dev/null
+++ b/src/gui/UBRightPalette.cpp
@@ -0,0 +1,73 @@
+/*
+ * 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 "UBRightPalette.h"
+
+UBRightPalette::UBRightPalette(QWidget *parent, const char *name):UBDockPalette(parent)
+ , mpLibWidget(NULL)
+{
+ setObjectName(name);
+ setOrientation(eUBDockOrientation_Right);
+ setOrientation(eUBDockOrientation_Right);
+ mCollapseWidth = 180;
+ mLastWidth = 300;
+ resize(UBSettings::settings()->libPaletteWidth->get().toInt(), parentWidget()->height());
+ mpLayout->setContentsMargins(2*border() + customMargin(), customMargin(), customMargin(), customMargin());
+
+ mpLibWidget = new UBLibWidget(this);
+ addTabWidget(mpLibWidget);
+}
+
+UBRightPalette::~UBRightPalette()
+{
+ if(NULL != mpLibWidget)
+ {
+ delete mpLibWidget;
+ mpLibWidget = NULL;
+ }
+}
+
+UBLibWidget* UBRightPalette::libWidget()
+{
+ return mpLibWidget;
+}
+
+void UBRightPalette::mouseMoveEvent(QMouseEvent *event)
+{
+ if(mCanResize)
+ {
+ UBDockPalette::mouseMoveEvent(event);
+ }
+ else
+ {
+ //qDebug() << "Mouse move event detected!" ;
+ }
+}
+
+void UBRightPalette::resizeEvent(QResizeEvent *event)
+{
+ UBDockPalette::resizeEvent(event);
+ UBSettings::settings()->libPaletteWidth->set(width());
+ emit resized();
+}
+
+/**
+ * \brief Update the maximum width
+ */
+void UBRightPalette::updateMaxWidth()
+{
+ setMaximumWidth((int)((parentWidget()->width() * 2)/3));
+ setMaximumHeight(parentWidget()->height());
+ setMinimumHeight(parentWidget()->height());
+}
diff --git a/src/gui/UBRightPalette.h b/src/gui/UBRightPalette.h
new file mode 100644
index 00000000..7d99cd4c
--- /dev/null
+++ b/src/gui/UBRightPalette.h
@@ -0,0 +1,42 @@
+/*
+ * 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 UBRIGHTPALETTE_H
+#define UBRIGHTPALETTE_H
+
+#include "UBDockPalette.h"
+#include "UBLibWidget.h"
+
+class UBRightPalette : public UBDockPalette
+{
+ Q_OBJECT
+public:
+ UBRightPalette(QWidget* parent=0, const char* name="UBRightPalette");
+ ~UBRightPalette();
+
+ UBLibWidget* libWidget();
+
+signals:
+ void resized();
+
+protected:
+ void updateMaxWidth();
+ void mouseMoveEvent(QMouseEvent *event);
+ void resizeEvent(QResizeEvent *event);
+
+private:
+ UBLibWidget* mpLibWidget;
+};
+
+#endif // UBRIGHTPALETTE_H
diff --git a/src/gui/UBStylusPalette.cpp b/src/gui/UBStylusPalette.cpp
index 4ae06f4c..93073ccd 100644
--- a/src/gui/UBStylusPalette.cpp
+++ b/src/gui/UBStylusPalette.cpp
@@ -37,7 +37,6 @@ UBStylusPalette::UBStylusPalette(QWidget *parent, Qt::Orientation orient)
actions << UBApplication::mainWindow->actionPen;
actions << UBApplication::mainWindow->actionEraser;
- actions << UBApplication::mainWindow->actionMagnifier;
actions << UBApplication::mainWindow->actionMarker;
actions << UBApplication::mainWindow->actionSelector;
diff --git a/src/gui/gui.pri b/src/gui/gui.pri
index e1fa70a4..6d933785 100644
--- a/src/gui/gui.pri
+++ b/src/gui/gui.pri
@@ -29,7 +29,6 @@ HEADERS += src/gui/UBThumbnailView.h \
src/gui/UBFavoriteToolPalette.h \
src/gui/UBKeyboardPalette.h \
src/gui/UBNavigatorPalette.h \
- src/gui/UBLibPalette.h \
src/gui/UBDocumentNavigator.h \
src/gui/UBDockPalette.h \
src/gui/UBPropertyPalette.h \
@@ -39,6 +38,11 @@ HEADERS += src/gui/UBThumbnailView.h \
src/gui/UBLibraryWidget.h \
src/gui/UBLibPathViewer.h \
src/gui/UBUpdateDlg.h \
+ src/gui/UBDockPaletteWidget.h \
+ src/gui/UBLeftPalette.h \
+ src/gui/UBRightPalette.h \
+ src/gui/UBPageNavigationWidget.h \
+ src/gui/UBLibWidget.h \
src/gui/UBMagnifer.h
SOURCES += src/gui/UBThumbnailView.cpp \
@@ -71,7 +75,6 @@ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBFavoriteToolPalette.cpp \
src/gui/UBKeyboardPalette.cpp \
src/gui/UBNavigatorPalette.cpp \
- src/gui/UBLibPalette.cpp \
src/gui/UBDocumentNavigator.cpp \
src/gui/UBDockPalette.cpp \
src/gui/UBPropertyPalette.cpp \
@@ -81,6 +84,11 @@ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBLibraryWidget.cpp \
src/gui/UBLibPathViewer.cpp \
src/gui/UBUpdateDlg.cpp \
+ src/gui/UBDockPaletteWidget.cpp \
+ src/gui/UBLeftPalette.cpp \
+ src/gui/UBRightPalette.cpp \
+ src/gui/UBPageNavigationWidget.cpp \
+ src/gui/UBLibWidget.cpp \
src/gui/UBMagnifer.cpp
win32 {
diff --git a/src/pdf/XPDFRenderer.cpp b/src/pdf/XPDFRenderer.cpp
index 5ef2851b..c77113fd 100644
--- a/src/pdf/XPDFRenderer.cpp
+++ b/src/pdf/XPDFRenderer.cpp
@@ -25,6 +25,8 @@ QAtomicInt XPDFRenderer::sInstancesCount = 0;
XPDFRenderer::XPDFRenderer(const QString &filename, bool importingFile)
: mDocument(0)
+ , mpSplashBitmap(0)
+ , mSplash(0)
{
if (!globalParams)
{
@@ -38,7 +40,6 @@ XPDFRenderer::XPDFRenderer(const QString &filename, bool importingFile)
mDocument = new PDFDoc(new GString(filename.toUtf8().data()), 0, 0, 0); // the filename GString is deleted on PDFDoc desctruction
sInstancesCount.ref();
bThumbGenerated = !importingFile;
- bPagesGenerated = false;
mPagesMap.clear();
mThumbs.clear();
mThumbMap.clear();
@@ -48,6 +49,17 @@ XPDFRenderer::XPDFRenderer(const QString &filename, bool importingFile)
XPDFRenderer::~XPDFRenderer()
{
+ qDeleteAll(mThumbs);
+ mThumbs.clear();
+
+ qDeleteAll(mNumPageToPageMap);
+ mNumPageToPageMap.clear();
+
+ if(mSplash){
+ delete mSplash;
+ mSplash = NULL;
+ }
+
if (mDocument)
{
delete mDocument;
@@ -141,7 +153,6 @@ void XPDFRenderer::render(QPainter *p, int pageNumber, const QRectF &bounds)
qreal xscale = p->worldTransform().m11();
qreal yscale = p->worldTransform().m22();
bool bZoomChanged = false;
- bool bFirstThumbnail = false;
if(fabs(mScaleX - xscale) > 0.1 || fabs(mScaleY - yscale) > 0.1)
{
@@ -150,57 +161,39 @@ void XPDFRenderer::render(QPainter *p, int pageNumber, const QRectF &bounds)
bZoomChanged = true;
}
+ QImage *pdfImage;
+
// First verify if the thumbnails and the pages are generated
if(!bThumbGenerated)
{
- if(pageNumber == 1)
- {
- bFirstThumbnail = true;
- }
-
if(!mThumbMap[pageNumber - 1])
{
-
// Generate the thumbnail
- mThumbs << *createPDFImage(pageNumber, xscale, yscale, bounds);
+ mThumbs << createPDFImage(pageNumber, xscale, yscale, bounds);
mThumbMap[pageNumber - 1] = true;
+ pdfImage = mThumbs.at(pageNumber - 1);
if(pageNumber == mDocument->getNumPages())
{
bThumbGenerated = true;
}
}
}
- else if(!bPagesGenerated || bZoomChanged)
+ else
{
if(!mPagesMap[pageNumber - 1] || bZoomChanged)
{
// Generate the page
- mNumPageToPageMap[pageNumber] = *createPDFImage(pageNumber, xscale, yscale, bounds);
+ if (mPagesMap[pageNumber - 1])
+ delete mNumPageToPageMap[pageNumber];
+ mNumPageToPageMap[pageNumber] = createPDFImage(pageNumber, xscale, yscale, bounds);
mPagesMap[pageNumber - 1] = true;
- if(mPagesMap.size() == mDocument->getNumPages())
- {
- bPagesGenerated = true;
- }
+ pdfImage = mNumPageToPageMap[pageNumber];
}
}
- QImage pdfImage;
-
- if(!bThumbGenerated || bFirstThumbnail)
- {
- pdfImage = mThumbs.at(pageNumber - 1);
- }
- else
- {
- pdfImage = mNumPageToPageMap[pageNumber];
- }
-
QTransform savedTransform = p->worldTransform();
p->resetTransform();
- QTime t;
- t.start();
- p->drawImage(QPointF(savedTransform.dx() + mSliceX, savedTransform.dy() + mSliceY), pdfImage);
- //qDebug() << "XPDFRenderer::render(...) execution time: " << t.elapsed() << "ms";
+ p->drawImage(QPointF(savedTransform.dx() + mSliceX, savedTransform.dy() + mSliceY), *pdfImage);
p->setWorldTransform(savedTransform);
}
}
@@ -211,6 +204,8 @@ QImage* XPDFRenderer::createPDFImage(int pageNumber, const qreal xscale, const q
if (isValid())
{
SplashColor paperColor = {0xFF, 0xFF, 0xFF}; // white
+ if(mSplash)
+ delete mSplash;
mSplash = new SplashOutputDev(splashModeRGB8, 1, gFalse, paperColor);
mSplash->startDoc(mDocument->getXRef());
int hResolution = 72;
@@ -241,6 +236,7 @@ QImage* XPDFRenderer::createPDFImage(int pageNumber, const qreal xscale, const q
}
mpSplashBitmap = mSplash->getBitmap();
+ delete img;
img = new QImage(mpSplashBitmap->getDataPtr(), mpSplashBitmap->getWidth(), mpSplashBitmap->getHeight(), mpSplashBitmap->getWidth() * 3, QImage::Format_RGB888);
}
return img;
diff --git a/src/pdf/XPDFRenderer.h b/src/pdf/XPDFRenderer.h
index 63d4bbd4..27181b80 100644
--- a/src/pdf/XPDFRenderer.h
+++ b/src/pdf/XPDFRenderer.h
@@ -51,10 +51,10 @@ class XPDFRenderer : public PDFRenderer
QImage* createPDFImage(int pageNumber, const qreal xscale = 0.5, const qreal yscale = 0.5, const QRectF &bounds = QRectF());
PDFDoc *mDocument;
- QList mThumbs;
+ QList mThumbs;
QMap mPagesMap;
QMap mThumbMap;
- QMap mNumPageToPageMap;
+ QMap mNumPageToPageMap;
static QAtomicInt sInstancesCount;
qreal mSliceX;
qreal mSliceY;
diff --git a/src/tools/Mask_specification.doc b/src/tools/Mask_specification.doc
new file mode 100644
index 00000000..51be5dc1
Binary files /dev/null and b/src/tools/Mask_specification.doc differ
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..5fb516e8 100644
--- a/src/tools/UBToolsManager.cpp
+++ b/src/tools/UBToolsManager.cpp
@@ -58,9 +58,16 @@ UBToolsManager::UBToolsManager(QObject *parent)
mToolsIcon.insert(triangle.id,":/images/toolPalette/triangleTool.png");
mDescriptors << triangle;
+ magnifier.id = "uniboardTool://uniboard.mnemis.com/magnifier";
+ magnifier.icon = QPixmap(":/images/toolPalette/magnifierTool.png");
+ magnifier.label = tr("Magnifier");
+ magnifier.version = "1.0";
+ mToolsIcon.insert(magnifier.id,":/images/toolPalette/magnifierTool.png");
+ mDescriptors << magnifier;
+
}
UBToolsManager::~UBToolsManager()
{
// NOOP
-}
\ No newline at end of file
+}
diff --git a/src/tools/UBToolsManager.h b/src/tools/UBToolsManager.h
index 8844bdd2..df87db8a 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 magnifier;
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