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

preferencesAboutTextFull
Anatoly Mihalchenko 14 years ago
commit 4439697b7a
  1. 109
      resources/forms/mainWindow.ui
  2. 3
      resources/images/close.svg
  3. BIN
      resources/images/cursors/magnifier.png
  4. 9
      resources/images/decrease.svg
  5. 9
      resources/images/increase.svg
  6. BIN
      resources/images/stylusPalette/magnifier.png
  7. BIN
      resources/images/stylusPalette/magnifierOn.png
  8. BIN
      resources/images/toolPalette/cacheTool.png
  9. BIN
      resources/images/toolPalette/magnifierTool.png
  10. BIN
      resources/images/toolbar/largeMagnifierSize.png
  11. BIN
      resources/images/toolbar/largeMagnifierZoom.png
  12. BIN
      resources/images/toolbar/mediumMagnifierSize.png
  13. BIN
      resources/images/toolbar/mediumMagnifierZoom.png
  14. BIN
      resources/images/toolbar/smallMagnifierSize.png
  15. BIN
      resources/images/toolbar/smallMagnifierZoom.png
  16. 10
      resources/library/interactive/Graphme.wgt/Grapheur.xhtml
  17. 13
      resources/sankore.qrc
  18. 49
      src/adaptors/UBSvgSubsetAdaptor.cpp
  19. 6
      src/adaptors/UBSvgSubsetAdaptor.h
  20. BIN
      src/adaptors/publishing/Sankore_Document_Web_Publication_Specification.doc
  21. 2
      src/adaptors/publishing/UBDocumentPublisher.cpp
  22. 1
      src/adaptors/publishing/UBDocumentPublisher.h
  23. 55
      src/board/UBBoardController.cpp
  24. 12
      src/board/UBBoardController.h
  25. 55
      src/board/UBBoardPaletteManager.cpp
  26. 15
      src/board/UBBoardPaletteManager.h
  27. 3
      src/board/UBBoardView.cpp
  28. 24
      src/board/UBDrawingController.cpp
  29. 3
      src/board/UBDrawingController.h
  30. 135
      src/board/UBLibraryController.cpp
  31. 11
      src/board/UBLibraryController.h
  32. 3
      src/core/UB.h
  33. 1
      src/core/UBApplication.cpp
  34. 164
      src/core/UBSettings.cpp
  35. 26
      src/core/UBSettings.h
  36. 18
      src/desktop/UBDesktopAnnotationController.cpp
  37. 4
      src/desktop/UBDesktopAnnotationController.h
  38. 153
      src/domain/UBGraphicsScene.cpp
  39. 18
      src/domain/UBGraphicsScene.h
  40. 209
      src/gui/UBDockPalette.cpp
  41. 31
      src/gui/UBDockPalette.h
  42. 26
      src/gui/UBDockPaletteWidget.cpp
  43. 25
      src/gui/UBDockPaletteWidget.h
  44. 44
      src/gui/UBLeftPalette.cpp
  45. 34
      src/gui/UBLeftPalette.h
  46. 5
      src/gui/UBLibActionBar.cpp
  47. 11
      src/gui/UBLibItemProperties.cpp
  48. 32
      src/gui/UBLibNavigatorWidget.cpp
  49. 2
      src/gui/UBLibNavigatorWidget.h
  50. 128
      src/gui/UBLibWidget.cpp
  51. 34
      src/gui/UBLibWidget.h
  52. 84
      src/gui/UBLibraryWidget.cpp
  53. 10
      src/gui/UBLibraryWidget.h
  54. 355
      src/gui/UBMagnifer.cpp
  55. 82
      src/gui/UBMagnifer.h
  56. 5
      src/gui/UBNavigatorPalette.cpp
  57. 195
      src/gui/UBPageNavigationWidget.cpp
  58. 68
      src/gui/UBPageNavigationWidget.h
  59. 73
      src/gui/UBRightPalette.cpp
  60. 42
      src/gui/UBRightPalette.h
  61. 1
      src/gui/UBStylusPalette.cpp
  62. 12
      src/gui/gui.pri
  63. 56
      src/pdf/XPDFRenderer.cpp
  64. 4
      src/pdf/XPDFRenderer.h
  65. BIN
      src/tools/Mask_specification.doc
  66. 142
      src/tools/UBGraphicsCache.cpp
  67. 61
      src/tools/UBGraphicsCache.h
  68. 7
      src/tools/UBToolsManager.cpp
  69. 3
      src/tools/UBToolsManager.h
  70. 6
      src/tools/tools.pri

@ -1638,115 +1638,6 @@
<string>Ctrl+H</string>
</property>
</action>
<action name="actionMagnifier">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../sankore.qrc">
<normaloff>:/images/stylusPalette/magnifier.png</normaloff>
<normalon>:/images/stylusPalette/magnifierOn.png</normalon>:/images/stylusPalette/magnifier.png</iconset>
</property>
<property name="text">
<string>Magnifier</string>
</property>
<property name="toolTip">
<string>Magnifier</string>
</property>
</action>
<action name="actionMagnifierZoomSmall">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../sankore.qrc">
<normaloff>:/images/toolbar/smallMagnifierZoom.png</normaloff>:/images/toolbar/smallMagnifierZoom.png</iconset>
</property>
<property name="text">
<string>Zoom</string>
</property>
<property name="toolTip">
<string>x2 Zoom</string>
</property>
</action>
<action name="actionMagnifierZoomMedium">
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../sankore.qrc">
<normaloff>:/images/toolbar/mediumMagnifierZoom.png</normaloff>:/images/toolbar/mediumMagnifierZoom.png</iconset>
</property>
<property name="text">
<string>Zoom</string>
</property>
<property name="toolTip">
<string>x3 Zoom</string>
</property>
</action>
<action name="actionMagnifierZoomLarge">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../sankore.qrc">
<normaloff>:/images/toolbar/largeMagnifierZoom.png</normaloff>:/images/toolbar/largeMagnifierZoom.png</iconset>
</property>
<property name="text">
<string>Zoom</string>
</property>
<property name="toolTip">
<string>x4 Zoom</string>
</property>
</action>
<action name="actionMagnifierSizeSmall">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../sankore.qrc">
<normaloff>:/images/toolbar/smallMagnifierSize.png</normaloff>:/images/toolbar/smallMagnifierSize.png</iconset>
</property>
<property name="text">
<string>Size</string>
</property>
<property name="toolTip">
<string>10% from scene size</string>
</property>
</action>
<action name="actionMagnifierSizeMedium">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../sankore.qrc">
<normaloff>:/images/toolbar/mediumMagnifierSize.png</normaloff>:/images/toolbar/mediumMagnifierSize.png</iconset>
</property>
<property name="text">
<string>Size</string>
</property>
<property name="toolTip">
<string>20% from scene size</string>
</property>
</action>
<action name="actionMagnifierSizeLarge">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../sankore.qrc">
<normaloff>:/images/toolbar/largeMagnifierSize.png</normaloff>:/images/toolbar/largeMagnifierSize.png</iconset>
</property>
<property name="text">
<string>Size</string>
</property>
<property name="toolTip">
<string>30% from scene size</string>
</property>
</action>
</widget>
<resources>
<include location="../sankore.qrc"/>

@ -5,6 +5,5 @@
width="26px" height="26px" viewBox="0 0 26 26" style="enable-background:new 0 0 26 26;" xml:space="preserve">
<circle style="fill:#CCCCCC;" cx="13" cy="13" r="13"/>
<circle style="fill:#999999;" cx="13" cy="13" r="11"/>
<polygon style="fill:#FFFFFF;" points="20.071,17.242 15.828,13 20.071,8.757 17.242,5.929 13,10.171 8.757,5.929 5.929,8.757
10.171,13 5.929,17.242 8.757,20.071 13,15.828 17.242,20.071 "/>
<polygon style="fill:#FFFFFF;" points="20,17 16,13 20,9 17,6 13,10 9,6 6,9 10,13 6,17 9,20 13,16 17,20 "/>
</svg>

Before

Width:  |  Height:  |  Size: 796 B

After

Width:  |  Height:  |  Size: 713 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 13.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="26px" height="26px" viewBox="0 0 26 26" style="enable-background:new 0 0 26 26;" xml:space="preserve">
<circle style="fill:#CCCCCC;" cx="13" cy="13" r="13"/>
<circle style="fill:#999999;" cx="13" cy="13" r="11"/>
<polygon style="fill:#FFFFFF;" points="20,15 20,11 6,11 6,15 20,15"/>
</svg>

After

Width:  |  Height:  |  Size: 676 B

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 13.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 14948) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="26px" height="26px" viewBox="0 0 26 26" style="enable-background:new 0 0 26 26;" xml:space="preserve">
<circle style="fill:#CCCCCC;" cx="13" cy="13" r="13"/>
<circle style="fill:#999999;" cx="13" cy="13" r="11"/>
<polygon style="fill:#FFFFFF;" points="20,15 20,11 15,11 15,6 11,6 11,11 6,11 6,15 11,15 11,20 15,20 15,15 20,15"/>
</svg>

After

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 300 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 295 B

@ -150,6 +150,13 @@
$("#borneYGauche").val(sankore.preference("yAxisFrom", "-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());
}
});
});

@ -3,6 +3,8 @@
<file>images/uniboard.png</file>
<file>images/bigUniboard.png</file>
<file>images/close.svg</file>
<file>images/increase.svg</file>
<file>images/decrease.svg</file>
<file>images/resize.svg</file>
<file>images/play.svg</file>
<file>images/pause.svg</file>
@ -121,12 +123,6 @@
<file>images/toolbar/eraserTool.png</file>
<file>images/toolbar/lineTool.png</file>
<file>images/toolbar/tools.png</file>
<file>images/toolbar/largeMagnifierSize.png</file>
<file>images/toolbar/mediumMagnifierSize.png</file>
<file>images/toolbar/smallMagnifierSize.png</file>
<file>images/toolbar/largeMagnifierZoom.png</file>
<file>images/toolbar/mediumMagnifierZoom.png</file>
<file>images/toolbar/smallMagnifierZoom.png</file>
<file>images/stylusPalette/arrow.png</file>
<file>images/stylusPalette/arrowOn.png</file>
<file>images/stylusPalette/eraser.png</file>
@ -150,8 +146,6 @@
<file>images/stylusPalette/textOn.png</file>
<file>images/stylusPalette/captureArea.png</file>
<file>images/stylusPalette/captureAreaOn.png</file>
<file>images/stylusPalette/magnifier.png</file>
<file>images/stylusPalette/magnifierOn.png</file>
<file>images/backgroundPalette/background1.svg</file>
<file>images/backgroundPalette/background1On.svg</file>
<file>images/backgroundPalette/background2.svg</file>
@ -167,6 +161,7 @@
<file>images/toolPalette/protractorTool.png</file>
<file>images/toolPalette/compassTool.png</file>
<file>images/toolPalette/maskTool.png</file>
<file>images/toolPalette/magnifierTool.png</file>
<file>images/extraPalette/blackout.png</file>
<file>images/extraPalette/keyboard.png</file>
<file>images/extraPalette/trapFlash.png</file>
@ -185,7 +180,6 @@
<file>images/cursors/resize.png</file>
<file>images/cursors/drawCompass.png</file>
<file>images/cursors/drawRulerLine.png</file>
<file>images/cursors/magnifier.png</file>
<file>images/print/onepage.png</file>
<file>images/print/thumbnails.png</file>
<file>images/print/twopages.png</file>
@ -315,6 +309,7 @@
<file>images/virtual.keyboard/29/backspace.png</file>
<file>images/virtual.keyboard/29/capslock.png</file>
<file>images/virtual.keyboard/29/tab.png</file>
<file>images/toolPalette/cacheTool.png</file>
<file>images/libpalette/FlashCategory.svg</file>
<file>images/libpalette/FlashIcon.svg</file>
<file>images/toolbar/stylusTab.png</file>

@ -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<UBGraphicsCache*>(item);
if(cache && cache->isVisible())
{
cacheToSvg(cache);
continue;
}
UBGraphicsCompass *compass = qgraphicsitem_cast<UBGraphicsCompass*> (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<UBItem*>(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++)

@ -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();

@ -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,*");

@ -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
{

@ -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<QAction *> 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<QAction *> 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();

@ -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;

@ -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();

@ -20,8 +20,8 @@
#include <QtWebKit>
#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();

@ -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;

@ -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)

@ -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);

@ -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<UBLibElement*> UBLibraryController::rootCategoriesList()
QList<UBLibElement*> 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<UBLibElement*> 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<UBLibElement*> 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<UBLibElement*> UBLibraryController::listElementsInPath(const QString& pPat
QList<UBLibElement*> UBLibraryController::listElementsInVirtualForlder(UBLibElement* pElement)
{
Q_UNUSED(pElement);
return mFavoriteList;
QList<UBLibElement*> copyOfTheFavoriteList;
foreach(UBLibElement* eachElement, mFavoriteList)
copyOfTheFavoriteList << new UBLibElement(eachElement);
return copyOfTheFavoriteList;
}
void UBLibraryController::moveContent(QList<UBLibElement*> sourceList, UBLibElement *pDestination)
@ -416,21 +410,31 @@ void UBLibraryController::emptyElementsOnTrash( QList<UBLibElement*> elementsLis
}
}
void UBLibraryController::cleanElementsList()
{
// qDebug() << "cleanElementsList()";
// qDebug() << this;
// foreach(UBLibElement*eachElement, mElementsList)
// qDebug() << eachElement;
qDeleteAll(mElementsList);
mElementsList.clear();
}
QList<UBLibElement*> UBLibraryController::getContent(UBLibElement *element)
{
QList<UBLibElement*> 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<UBLibElement*> 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<UBLibElement*> 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<UBLibElement*> 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<QUrl>& images) {
void UBLibraryController::addImagesToCurrentPage(const QList<QUrl>& images)
{
QPointF pos = visibleSceneRect().topLeft();
foreach(const QUrl url, images)
@ -652,7 +660,8 @@ void UBLibraryController::addImagesToCurrentPage(const QList<QUrl>& images) {
}
}
void UBLibraryController::addVideosToCurrentPage(const QList<QUrl>& videos) {
void UBLibraryController::addVideosToCurrentPage(const QList<QUrl>& videos)
{
QPointF pos = visibleSceneRect().topLeft();
foreach(const QUrl url, videos)
@ -665,7 +674,8 @@ void UBLibraryController::addVideosToCurrentPage(const QList<QUrl>& videos) {
}
}
void UBLibraryController::addAudiosToCurrentPage(const QList<QUrl>& sounds) {
void UBLibraryController::addAudiosToCurrentPage(const QList<QUrl>& sounds)
{
QPointF topLeftPos = visibleSceneRect().topLeft();
QPointF pos = topLeftPos;
@ -680,12 +690,10 @@ void UBLibraryController::addAudiosToCurrentPage(const QList<QUrl>& sounds) {
}
}
void UBLibraryController::addInteractivesToCurrentPage(
const QList<QUrl>& widgets) {
void UBLibraryController::addInteractivesToCurrentPage( const QList<QUrl>& 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;

@ -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<UBLibElement*> getContent(UBLibElement* pElement);
@ -134,14 +135,16 @@ class UBLibraryController : public QObject
void persistFavoriteList();
void readFavoriteList();
QList<UBLibElement*> mInternalLibElements;
QList<UBLibElement*> mElementsList;
void cleanElementsList();
private:
QList<UBLibElement*> rootCategoriesList();
QList<UBLibElement*> listElementsInPath(const QString& pPath);
QList<UBLibElement*> listElementsInVirtualForlder(UBLibElement* pElement);
void userPath(QUrl &pPath);
QImage* thumbnailForFile(UBLibElement* pPath);
QImage* createThumbnail(UBLibElement* pPath);
QImage thumbnailForFile(UBLibElement* pPath);
QImage createThumbnail(UBLibElement* pPath);
QList<UBLibElement*> addVirtualElementsForItemPath(const QString& pPath);
void createInternalWidgetItems();

@ -26,8 +26,7 @@ struct UBStylusTool
{
Pen = 0,
Eraser,
Magnifier,
Marker,
Marker,
Selector,
Hand,
ZoomIn,

@ -38,7 +38,6 @@
#include "board/UBBoardController.h"
#include "board/UBDrawingController.h"
#include "board/UBLibraryController.h"
#include "board/UBBoardView.h"
#include "web/UBWebController.h"

@ -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();

@ -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);

@ -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();

@ -20,7 +20,7 @@
#include <QTime>
#include <QTimer>
#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;

@ -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,12 +347,6 @@ bool UBGraphicsScene::inputDeviceRelease()
{
mCurrentStroke = 0;
}
else
if (currentTool == UBStylusTool::Magnifier)
{
DisposeMagnifierQWidgets();
//qDebug() << "deleted";
}
if (mRemovedItems.size() > 0 || mAddedItems.size() > 0)
{
@ -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)
{

@ -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<QGraphicsItem*> 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_ */

@ -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;
}

@ -24,6 +24,12 @@
#include <QTime>
#include <QPoint>
#include <QPixmap>
#include <QMap>
#include <QStackedWidget>
#include <QVBoxLayout>
#include <QVector>
#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<QString, UBDockPaletteWidget*> mTabWidgets;
/** The stacked widget */
QStackedWidget* mpStackWidget;
/** The layout */
QVBoxLayout* mpLayout;
/** The current tab index */
int mCurrentTab;
/** The tab widgets */
QVector<UBDockPaletteWidget*> 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

@ -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;
}

@ -0,0 +1,25 @@
#ifndef UBDOCKPALETTEWIDGET_H
#define UBDOCKPALETTEWIDGET_H
#include <QWidget>
#include <QPixmap>
#include <QString>
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

@ -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 <http://www.gnu.org/licenses/>.
*/
#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;
}

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

@ -16,9 +16,9 @@
#include <QSize>
#include <QDebug>
#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<UBLibElement *> itemList, bool isI
*/
UBLibraryController* UBLibActionBar::libraryController()
{
return UBApplication::boardController->libraryController();
UBLibWidget* libWidget = dynamic_cast<UBLibWidget*>(parentWidget());
return libWidget->libNavigator()->libraryWidget()->libraryController();
}
/**

@ -12,15 +12,14 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#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<UBLibWidget*>(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<UBLibWidget*>(parentWidget()->parentWidget());
libWidget->libNavigator()->libraryWidget()->libraryController()->setItemAsBackground(mpElement);
}
/**

@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#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<UBLibPalette*>(parentWidget());
UBLibWidget* libWidget = dynamic_cast<UBLibWidget*>(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<QString>,UBLibElement*)), mLibWidget, SLOT(onElementsDropped(QList<QString>,UBLibElement*)));
if(NULL != pLibPalette)
{
connect(mLibWidget, SIGNAL(navigBarUpdate(UBLibElement*)), pLibPalette->actionBar(), SLOT(onNavigbarUpdate(UBLibElement*)));
connect(mLibWidget, SIGNAL(itemsSelected(QList<UBLibElement*>, bool)), pLibPalette->actionBar(), SLOT(onSelectionChanged(QList<UBLibElement*>, 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<UBLibElement*>, bool)), libWidget->actionBar(), SLOT(onSelectionChanged(QList<UBLibElement*>, 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);
}

@ -32,6 +32,8 @@ public:
~UBLibNavigatorWidget();
void dropMe(const QMimeData* _data);
UBLibraryWidget* libraryWidget(){return mLibWidget;};
signals:
void propertiesRequested(UBLibElement* elem);

@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QDebug>
#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;
}

@ -12,8 +12,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBLIBPALETTE_H
#define UBLIBPALETTE_H
#ifndef UBLIBWIDGET_H
#define UBLIBWIDGET_H
#include <QWidget>
#include <QVBoxLayout>
@ -26,46 +26,32 @@
#include <QResizeEvent>
#include <QLabel>
#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

@ -34,11 +34,11 @@ UBLibraryWidget::UBLibraryWidget(QWidget *parent, const char *name):UBThumbnailW
, chainedElements(NULL)
, mpCrntDir(NULL)
, mpCrntElem(NULL)
, mCrntPath("/")
{
setObjectName(name);
setSpacing(5);
setStyleSheet(QString("background: #EEEEEE; border-radius : 10px; border : 2px solid #999999;"));
mLibraryController = new UBLibraryController(parentWidget());
}
/**
@ -46,21 +46,26 @@ UBLibraryWidget::UBLibraryWidget(QWidget *parent, const char *name):UBThumbnailW
*/
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;
// }
if(NULL != mpCrntDir)
{
delete mpCrntDir;
mpCrntDir = NULL;
}
if(NULL != mpCrntElem)
{
delete mpCrntElem;
mpCrntElem = NULL;
}
}
/**
@ -70,9 +75,9 @@ void UBLibraryWidget::init()
{
setAcceptDrops(true);
mpCrntElem = new UBLibElement();
mpCrntElem->setThumbnail(new QImage(":images/libpalette/home.png"));
mpCrntElem->setThumbnail(QImage(":images/libpalette/home.png"));
chainedElements = new UBChainedLibElement(mpCrntElem);
QList<UBLibElement*> qlElems = libraryController()->getContent(mpCrntElem);
QList<UBLibElement*> qlElems = mLibraryController->getContent(mpCrntElem);
mCurrentElems = qlElems;
setCurrentElemsAndRefresh(chainedElements);
@ -104,7 +109,7 @@ void UBLibraryWidget::refreshView()
emit navigBarUpdate(mpCrntElem);
bool bFavorite = false;
if(NULL != mpCrntDir && libraryController()->favoritePath() == mpCrntDir->path().toLocalFile())
if(NULL != mpCrntDir && mLibraryController->favoritePath() == mpCrntDir->path().toLocalFile())
{
bFavorite = true;
}
@ -142,18 +147,17 @@ void UBLibraryWidget::onItemClicked(QGraphicsItem *item, int index)
UBLibElement* pElem = mCurrentElems.at(iItem);
if(NULL != pElem)
{
mpCrntElem = pElem;
if(eUBLibElementType_Folder == pElem->type() ||
eUBLibElementType_VirtualFolder == pElem->type())
{
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);
mpCrntDir = pElem;
delete mpCrntDir;
mpCrntDir = new UBLibElement(pElem);
// Display the content of the folder
QList<UBLibElement*> qlElems = libraryController()->getContent(pElem);
QList<UBLibElement*> qlElems = mLibraryController->getContent(mpCrntDir);
mCurrentElems = qlElems;
refreshView();
}
@ -200,13 +204,15 @@ void UBLibraryWidget::setCurrentElemsAndRefresh(UBChainedLibElement *elem)
{
if(eUBLibElementType_Item != pLibElem->type())
{
QList<UBLibElement*> qlElements = libraryController()->getContent(pLibElem);
QList<UBLibElement*> qlElements = mLibraryController->getContent(pLibElem);
mCurrentElems = qlElements;
mpCrntElem = pLibElem;
delete mpCrntElem;
mpCrntElem = new UBLibElement(pLibElem);
refreshView();
mpCrntDir = pLibElem;
delete mpCrntDir;
mpCrntDir = new UBLibElement(pLibElem);
bool bFavorite = false;
if(NULL != mpCrntDir && libraryController()->favoritePath() == mpCrntDir->path().toLocalFile())
if(NULL != mpCrntDir && mLibraryController->favoritePath() == mpCrntDir->path().toLocalFile())
{
bFavorite = true;
}
@ -234,9 +240,7 @@ void UBLibraryWidget::onSelectionChanged()
UBLibElement* pElem = mCurrentElems.at(itIndex);
if(NULL != pElem)
{
if(eUBLibElementType_Category != pElem->type() &&
eUBLibElementType_VirtualFolder != pElem->type())
{
if(eUBLibElementType_Category != pElem->type() && eUBLibElementType_VirtualFolder != pElem->type()) {
qlSelectedItems << pElem;
}
@ -268,7 +272,7 @@ void UBLibraryWidget::onSelectionChanged()
void UBLibraryWidget::onRefreshCurrentFolder()
{
// Refresh the current view
mCurrentElems = libraryController()->getContent(mpCrntDir);
mCurrentElems = mLibraryController->getContent(mpCrntDir);
refreshView();
}
@ -341,7 +345,7 @@ void UBLibraryWidget::dropEvent(QDropEvent *event)
{
qDebug() << "hasImage";
QImage image = qvariant_cast<QImage>(pMimeData->imageData());
libraryController()->importImageOnLibrary(image);
mLibraryController->importImageOnLibrary(image);
bDropAccepted = true;
}
else if (pMimeData->hasHtml())
@ -353,7 +357,7 @@ void UBLibraryWidget::dropEvent(QDropEvent *event)
// On linux external dragged element are considered as text;
qDebug() << "hasText: " << pMimeData->text();
QString filePath = QUrl(pMimeData->text()).toLocalFile();
libraryController()->importItemOnLibrary(filePath);
mLibraryController->importItemOnLibrary(filePath);
bDropAccepted = true;
}
else if (pMimeData->hasUrls())
@ -363,7 +367,7 @@ void UBLibraryWidget::dropEvent(QDropEvent *event)
for (int i = 0; i < urlList.size() && i < 32; ++i)
{
QString filePath = QUrl(urlList.at(i).path()).toLocalFile();
libraryController()->importItemOnLibrary(filePath);
mLibraryController->importItemOnLibrary(filePath);
bDropAccepted = true;
}
}
@ -427,14 +431,6 @@ UBLibElement* UBLibraryWidget::elementFromFilePath(const QString &filePath)
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
@ -460,8 +456,8 @@ void UBLibraryWidget::onElementsDropped(QList<QString> elements, UBLibElement *t
foreach(QString qsElem, elements)
qlElements << elementFromFilePath(qsElem);
libraryController()->moveContent(qlElements, target);
mCurrentElems = libraryController()->getContent(mpCrntDir);
mLibraryController->moveContent(qlElements, target);
mCurrentElems = mLibraryController->getContent(mpCrntDir);
refreshView();
}
}
@ -473,7 +469,7 @@ void UBLibraryWidget::onElementsDropped(QList<QString> elements, UBLibElement *t
void UBLibraryWidget::onSearchElement(QString elem)
{
// Store the original list of items
mOrigCurrentElems = libraryController()->getContent(mpCrntDir);
mOrigCurrentElems = mLibraryController->getContent(mpCrntDir);
// Build the filtered list
mCurrentElems.clear();
@ -503,7 +499,7 @@ void UBLibraryWidget::onNewFolderToCreate()
UBNewFolderDlg dlg;
if(QDialog::Accepted == dlg.exec())
{
libraryController()->createNewFolder(dlg.folderName(), mpCrntElem);
mLibraryController->createNewFolder(dlg.folderName(), mpCrntElem);
onRefreshCurrentFolder();
}
}

@ -29,7 +29,10 @@
#include <QVBoxLayout>
#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<QString> 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<UBLibElement*> mCurrentElems;
QList<UBLibElement*> mOrigCurrentElems;
QList<QGraphicsItem*> mItems;
QString mCrntPath;
};

@ -1,51 +1,124 @@
#include <QtGui>
#include "UBMagnifer.h"
#include <QPainter>
#include <QPixmap>
#include <QDebug>
#include <QWidget>
#include <QGraphicsView>
#include <QTimerEvent>
#include <QBitmap>
#include <QPen>
UBMagnifer::UBMagnifer(QWidget *parent)
: QWidget(parent)
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "domain/UBGraphicsScene.h"
// #include <QPainter>
// #include <QPixmap>
// #include <QDebug>
// #include <QWidget>
// #include <QGraphicsView>
// #include <QTimerEvent>
// #include <QBitmap>
// #include <QPen>
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)
{
zoom = z;
params.zoom = zoom;
}
void UBMagnifier::paintEvent(QPaintEvent * event)
{
QPainter painter(this);
// painter.drawRect(0,0,size().width()-1, size().height()-1);
zWidth = size().width() / zoom;
zWidthHalf = zWidth / 2;
zHeight = size().height() / zoom;
zHeightHalf = zHeight / 2;
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 UBMagnifer::paintEvent(QPaintEvent *)
void UBMagnifier::mousePressEvent ( 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)
{
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();
update();
}
else
event->ignore();
}
void UBMagnifer::timerEvent(QTimerEvent *e)
void UBMagnifier::mouseMoveEvent ( QMouseEvent * event )
{
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 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);

@ -1,60 +1,82 @@
#ifndef UBMAGNIFER_H
#define UBMAGNIFER_H
#ifndef UBMAGNIFIER_H
#define UBMAGNIFIER_H
#include <QWidget>
#include <QBitmap>
#include <QPen>
#include <QtGui>
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

@ -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;

@ -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 <http://www.gnu.org/licenses/>.
*/
#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;
}

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef UBPAGENAVIGATIONWIDGET_H
#define UBPAGENAVIGATIONWIDGET_H
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QMouseEvent>
#include <QResizeEvent>
#include <QTimerEvent>
#include <QLabel>
#include <QString>
#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

@ -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 <http://www.gnu.org/licenses/>.
*/
#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());
}

@ -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 <http://www.gnu.org/licenses/>.
*/
#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

@ -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;

@ -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 {

@ -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;

@ -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<QImage> mThumbs;
QList<QImage*> mThumbs;
QMap<int, bool> mPagesMap;
QMap<int, bool> mThumbMap;
QMap<int, QImage> mNumPageToPageMap;
QMap<int, QImage*> mNumPageToPageMap;
static QAtomicInt sInstancesCount;
qreal mSliceX;
qreal mSliceY;

Binary file not shown.

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <QDebug>
#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;
}

@ -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 <http://www.gnu.org/licenses/>.
*/
#ifndef UBGRAPHICSCACHE_H
#define UBGRAPHICSCACHE_H
#include <QColor>
#include <QGraphicsSceneMouseEvent>
#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

@ -58,6 +58,13 @@ 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()

@ -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);}

@ -6,7 +6,8 @@ HEADERS += src/tools/UBGraphicsRuler.h \
src/tools/UBToolsManager.h \
src/tools/UBGraphicsCurtainItem.h \
src/tools/UBGraphicsCurtainItemDelegate.h \
src/tools/UBAbstractDrawRuler.h
src/tools/UBAbstractDrawRuler.h \
src/tools/UBGraphicsCache.h
SOURCES += src/tools/UBGraphicsRuler.cpp \
src/tools/UBGraphicsTriangle.cpp \
@ -15,4 +16,5 @@ SOURCES += src/tools/UBGraphicsRuler.cpp \
src/tools/UBToolsManager.cpp \
src/tools/UBGraphicsCurtainItem.cpp \
src/tools/UBGraphicsCurtainItemDelegate.cpp \
src/tools/UBAbstractDrawRuler.cpp
src/tools/UBAbstractDrawRuler.cpp \
src/tools/UBGraphicsCache.cpp

Loading…
Cancel
Save