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. 4
      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. 53
      src/board/UBBoardController.cpp
  24. 12
      src/board/UBBoardController.h
  25. 55
      src/board/UBBoardPaletteManager.cpp
  26. 11
      src/board/UBBoardPaletteManager.h
  27. 3
      src/board/UBBoardView.cpp
  28. 24
      src/board/UBDrawingController.cpp
  29. 3
      src/board/UBDrawingController.h
  30. 133
      src/board/UBLibraryController.cpp
  31. 11
      src/board/UBLibraryController.h
  32. 1
      src/core/UB.h
  33. 1
      src/core/UBApplication.cpp
  34. 164
      src/core/UBSettings.cpp
  35. 24
      src/core/UBSettings.h
  36. 18
      src/desktop/UBDesktopAnnotationController.cpp
  37. 4
      src/desktop/UBDesktopAnnotationController.h
  38. 153
      src/domain/UBGraphicsScene.cpp
  39. 16
      src/domain/UBGraphicsScene.h
  40. 169
      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. 22
      src/gui/UBLibNavigatorWidget.cpp
  49. 2
      src/gui/UBLibNavigatorWidget.h
  50. 116
      src/gui/UBLibWidget.cpp
  51. 34
      src/gui/UBLibWidget.h
  52. 84
      src/gui/UBLibraryWidget.cpp
  53. 10
      src/gui/UBLibraryWidget.h
  54. 353
      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. 1
      src/tools/UBToolsManager.h
  70. 6
      src/tools/tools.pri

@ -1638,115 +1638,6 @@
<string>Ctrl+H</string> <string>Ctrl+H</string>
</property> </property>
</action> </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> </widget>
<resources> <resources>
<include location="../sankore.qrc"/> <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"> 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:#CCCCCC;" cx="13" cy="13" r="13"/>
<circle style="fill:#999999;" cx="13" cy="13" r="11"/> <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 <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 "/>
10.171,13 5.929,17.242 8.757,20.071 13,15.828 17.242,20.071 "/>
</svg> </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")); $("#borneYGauche").val(sankore.preference("yAxisFrom", "-5"));
$("#borneYDroite").val(sankore.preference("yAxisTo", "5")); $("#borneYDroite").val(sankore.preference("yAxisTo", "5"));
var tempArray;
if(sankore.preference("graphmeHistory",""))
tempArray = sankore.preference("graphmeHistory","").split(",");
if(sankore.preference("graphmeHistory","")){
for(i in tempArray)
evaluer(tempArray[i]);
}
actualiserGraph(); actualiserGraph();
loadingFlag = true; loadingFlag = true;
} }
@ -225,6 +232,9 @@
sankore.setPreference("offsetDiagrammX", $("#inputDecalageX").val()); sankore.setPreference("offsetDiagrammX", $("#inputDecalageX").val());
sankore.setPreference("offsetDiagrammY", $("#inputDecalageY").val()); sankore.setPreference("offsetDiagrammY", $("#inputDecalageY").val());
sankore.setPreference("accuracyGraph", $("#inputPrecision").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/uniboard.png</file>
<file>images/bigUniboard.png</file> <file>images/bigUniboard.png</file>
<file>images/close.svg</file> <file>images/close.svg</file>
<file>images/increase.svg</file>
<file>images/decrease.svg</file>
<file>images/resize.svg</file> <file>images/resize.svg</file>
<file>images/play.svg</file> <file>images/play.svg</file>
<file>images/pause.svg</file> <file>images/pause.svg</file>
@ -121,12 +123,6 @@
<file>images/toolbar/eraserTool.png</file> <file>images/toolbar/eraserTool.png</file>
<file>images/toolbar/lineTool.png</file> <file>images/toolbar/lineTool.png</file>
<file>images/toolbar/tools.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/arrow.png</file>
<file>images/stylusPalette/arrowOn.png</file> <file>images/stylusPalette/arrowOn.png</file>
<file>images/stylusPalette/eraser.png</file> <file>images/stylusPalette/eraser.png</file>
@ -150,8 +146,6 @@
<file>images/stylusPalette/textOn.png</file> <file>images/stylusPalette/textOn.png</file>
<file>images/stylusPalette/captureArea.png</file> <file>images/stylusPalette/captureArea.png</file>
<file>images/stylusPalette/captureAreaOn.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/background1.svg</file>
<file>images/backgroundPalette/background1On.svg</file> <file>images/backgroundPalette/background1On.svg</file>
<file>images/backgroundPalette/background2.svg</file> <file>images/backgroundPalette/background2.svg</file>
@ -167,6 +161,7 @@
<file>images/toolPalette/protractorTool.png</file> <file>images/toolPalette/protractorTool.png</file>
<file>images/toolPalette/compassTool.png</file> <file>images/toolPalette/compassTool.png</file>
<file>images/toolPalette/maskTool.png</file> <file>images/toolPalette/maskTool.png</file>
<file>images/toolPalette/magnifierTool.png</file>
<file>images/extraPalette/blackout.png</file> <file>images/extraPalette/blackout.png</file>
<file>images/extraPalette/keyboard.png</file> <file>images/extraPalette/keyboard.png</file>
<file>images/extraPalette/trapFlash.png</file> <file>images/extraPalette/trapFlash.png</file>
@ -185,7 +180,6 @@
<file>images/cursors/resize.png</file> <file>images/cursors/resize.png</file>
<file>images/cursors/drawCompass.png</file> <file>images/cursors/drawCompass.png</file>
<file>images/cursors/drawRulerLine.png</file> <file>images/cursors/drawRulerLine.png</file>
<file>images/cursors/magnifier.png</file>
<file>images/print/onepage.png</file> <file>images/print/onepage.png</file>
<file>images/print/thumbnails.png</file> <file>images/print/thumbnails.png</file>
<file>images/print/twopages.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/backspace.png</file>
<file>images/virtual.keyboard/29/capslock.png</file> <file>images/virtual.keyboard/29/capslock.png</file>
<file>images/virtual.keyboard/29/tab.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/FlashCategory.svg</file>
<file>images/libpalette/FlashIcon.svg</file> <file>images/libpalette/FlashIcon.svg</file>
<file>images/toolbar/stylusTab.png</file> <file>images/toolbar/stylusTab.png</file>

@ -35,6 +35,7 @@
#include "tools/UBGraphicsProtractor.h" #include "tools/UBGraphicsProtractor.h"
#include "tools/UBGraphicsCurtainItem.h" #include "tools/UBGraphicsCurtainItem.h"
#include "tools/UBGraphicsTriangle.h" #include "tools/UBGraphicsTriangle.h"
#include "tools/UBGraphicsCache.h"
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
@ -664,6 +665,15 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
scene->registerTool(triangle); scene->registerTool(triangle);
} }
} }
else if(mXmlReader.name() == "cache")
{
UBGraphicsCache* cache = cacheFromSvg();
if(cache)
{
scene->addItem(cache);
scene->registerTool(cache);
}
}
else if (mXmlReader.name() == "foreignObject") else if (mXmlReader.name() == "foreignObject")
{ {
QString href = mXmlReader.attributes().value(nsXLink, "href").toString(); QString href = mXmlReader.attributes().value(nsXLink, "href").toString();
@ -1046,6 +1056,13 @@ bool UBSvgSubsetAdaptor::UBSvgSubsetWriter::persistScene()
continue; continue;
} }
UBGraphicsCache* cache = qgraphicsitem_cast<UBGraphicsCache*>(item);
if(cache && cache->isVisible())
{
cacheToSvg(cache);
continue;
}
UBGraphicsCompass *compass = qgraphicsitem_cast<UBGraphicsCompass*> (item); UBGraphicsCompass *compass = qgraphicsitem_cast<UBGraphicsCompass*> (item);
if (compass && compass->isVisible()) if (compass && compass->isVisible())
@ -2660,6 +2677,38 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg()
return triangle; 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) void UBSvgSubsetAdaptor::convertPDFObjectsToImages(UBDocumentProxy* proxy)
{ {
for (int i = 0; i < proxy->pageCount(); i++) for (int i = 0; i < proxy->pageCount(); i++)

@ -40,6 +40,7 @@ class UBDocumentProxy;
class UBGraphicsStroke; class UBGraphicsStroke;
class UBPersistenceManager; class UBPersistenceManager;
class UBGraphicsTriangle; class UBGraphicsTriangle;
class UBGraphicsCache;
class UBSvgSubsetAdaptor class UBSvgSubsetAdaptor
{ {
@ -129,6 +130,8 @@ class UBSvgSubsetAdaptor
UBGraphicsTriangle* triangleFromSvg(); UBGraphicsTriangle* triangleFromSvg();
UBGraphicsCache* cacheFromSvg();
void graphicsItemFromSvg(QGraphicsItem* gItem); void graphicsItemFromSvg(QGraphicsItem* gItem);
QXmlStreamReader mXmlReader; QXmlStreamReader mXmlReader;
@ -210,6 +213,7 @@ class UBSvgSubsetAdaptor
void rulerToSvg(UBGraphicsRuler *item); void rulerToSvg(UBGraphicsRuler *item);
void compassToSvg(UBGraphicsCompass *item); void compassToSvg(UBGraphicsCompass *item);
void protractorToSvg(UBGraphicsProtractor *item); void protractorToSvg(UBGraphicsProtractor *item);
void cacheToSvg(UBGraphicsCache* item);
void triangleToSvg(UBGraphicsTriangle *item); void triangleToSvg(UBGraphicsTriangle *item);
void writeSvgElement(); void writeSvgElement();

@ -635,7 +635,7 @@ void UBDocumentPublisher::sendUbw(QString username, QString password)
request.setHeader(QNetworkRequest::ContentLengthHeader,datatoSend.size()); request.setHeader(QNetworkRequest::ContentLengthHeader,datatoSend.size());
QString b64Auth = getBase64Of(QString("%0:%1").arg(username).arg(password)); QString b64Auth = getBase64Of(QString("%0:%1").arg(username).arg(password));
request.setRawHeader("Authorization", QString("Basic %0").arg(b64Auth).toAscii().constData()); 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", "*/*");
request.setRawHeader("Accept-Language", "en-US,*"); request.setRawHeader("Accept-Language", "en-US,*");

@ -22,7 +22,6 @@
#include "UBAbstractPublisher.h" #include "UBAbstractPublisher.h"
#define DOCPUBLICATION_URL "http://planete.sankore.org/xwiki/bin/view/CreateResources/UniboardUpload?xpage=plain&outputSyntax=plain" #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 typedef struct
{ {

@ -36,6 +36,7 @@
#include "gui/UBMainWindow.h" #include "gui/UBMainWindow.h"
#include "gui/UBToolWidget.h" #include "gui/UBToolWidget.h"
#include "gui/UBKeyboardPalette.h" #include "gui/UBKeyboardPalette.h"
#include "gui/UBMagnifer.h"
#include "domain/UBGraphicsPixmapItem.h" #include "domain/UBGraphicsPixmapItem.h"
#include "domain/UBGraphicsItemUndoCommand.h" #include "domain/UBGraphicsItemUndoCommand.h"
@ -54,7 +55,6 @@
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
#include "document/UBDocumentController.h" #include "document/UBDocumentController.h"
#include "board/UBLibraryController.h"
#include "board/UBDrawingController.h" #include "board/UBDrawingController.h"
#include "board/UBBoardView.h" #include "board/UBBoardView.h"
@ -72,7 +72,6 @@ UBBoardController::UBBoardController(UBMainWindow* mainWindow)
, mActiveDocument(0) , mActiveDocument(0)
, mActiveScene(0) , mActiveScene(0)
, mActiveSceneIndex(-1) , mActiveSceneIndex(-1)
, mLibraryController(0)
, mPaletteManager(0) , mPaletteManager(0)
, mSoftwareUpdateDialog(0) , mSoftwareUpdateDialog(0)
, mMessageWindow(0) , mMessageWindow(0)
@ -85,8 +84,6 @@ UBBoardController::UBBoardController(UBMainWindow* mainWindow)
, mSystemScaleFactor(1.0) , mSystemScaleFactor(1.0)
, mCleanupDone(false) , mCleanupDone(false)
{ {
mLibraryController = new UBLibraryController(mMainWindow->centralWidget(), this);
mZoomFactor = UBSettings::settings()->boardZoomFactor->get().toDouble(); mZoomFactor = UBSettings::settings()->boardZoomFactor->get().toDouble();
int penColorIndex = UBSettings::settings()->penColorIndex(); 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->boardToolBar, mMainWindow->actionBoard);
UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->tutorialToolBar, mMainWindow->actionBoard); UBApplication::app()->insertSpaceToToolbarBeforeAction(mMainWindow->tutorialToolBar, mMainWindow->actionBoard);
@ -1056,6 +1017,16 @@ void UBBoardController::downloadFinished(bool pSuccess, QUrl sourceUrl, QString
mActiveScene->addTriangle(pPos); mActiveScene->addTriangle(pPos);
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); 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) else if (sourceUrl.toString() == UBToolsManager::manager()->mask.id)
{ {
mActiveScene->addMask(); mActiveScene->addMask();
@ -1174,7 +1145,7 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy,
} }
// Notify the navigator palette that the document has changed // Notify the navigator palette that the document has changed
mPaletteManager->navigatorPalette()->setDocument(pDocumentProxy); mPaletteManager->leftPalette()->pageNavigator()->setDocument(pDocumentProxy);
if (sceneChange) if (sceneChange)
emit activeSceneChanged(); emit activeSceneChanged();

@ -25,7 +25,6 @@ class UBApplication;
class UBBoardView; class UBBoardView;
class UBDocumentController; class UBDocumentController;
class UBLibraryController;
class UBMessageWindow; class UBMessageWindow;
class UBGraphicsScene; class UBGraphicsScene;
class UBDocumentProxy; class UBDocumentProxy;
@ -81,6 +80,11 @@ class UBBoardController : public QObject
return mDisplayView; return mDisplayView;
} }
UBGraphicsScene* activeScene()
{
return mActiveScene;
}
void setPenColorOnDarkBackground(const QColor& pColor) void setPenColorOnDarkBackground(const QColor& pColor)
{ {
if (mPenColorOnDarkBackground == pColor) if (mPenColorOnDarkBackground == pColor)
@ -129,11 +133,6 @@ class UBBoardController : public QObject
return mMarkerColorOnLightBackground; return mMarkerColorOnLightBackground;
} }
UBLibraryController* libraryController()
{
return mLibraryController;
}
qreal systemScaleFactor() qreal systemScaleFactor()
{ {
return mSystemScaleFactor; return mSystemScaleFactor;
@ -285,7 +284,6 @@ class UBBoardController : public QObject
UBGraphicsScene* mActiveScene; UBGraphicsScene* mActiveScene;
int mActiveSceneIndex; int mActiveSceneIndex;
UBLibraryController* mLibraryController;
UBBoardPaletteManager *mPaletteManager; UBBoardPaletteManager *mPaletteManager;
UBSoftwareUpdateDialog *mSoftwareUpdateDialog; UBSoftwareUpdateDialog *mSoftwareUpdateDialog;

@ -49,7 +49,6 @@
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
#include "podcast/UBPodcastController.h" #include "podcast/UBPodcastController.h"
#include "board/UBLibraryController.h"
#include "board/UBDrawingController.h" #include "board/UBDrawingController.h"
#include "tools/UBToolsManager.h" #include "tools/UBToolsManager.h"
@ -65,8 +64,8 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll
, mBoardControler(pBoardController) , mBoardControler(pBoardController)
, mStylusPalette(0) , mStylusPalette(0)
, mZoomPalette(0) , mZoomPalette(0)
, mNavigPalette(NULL) , mLeftPalette(NULL)
, mLibPalette(NULL) , mRightPalette(NULL)
, mBackgroundsPalette(0) , mBackgroundsPalette(0)
, mToolsPalette(0) , mToolsPalette(0)
, mAddItemPalette(0) , mAddItemPalette(0)
@ -86,16 +85,16 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll
UBBoardPaletteManager::~UBBoardPaletteManager() UBBoardPaletteManager::~UBBoardPaletteManager()
{ {
delete mAddItemPalette; delete mAddItemPalette;
if(NULL != mNavigPalette) if(NULL != mLeftPalette)
{ {
delete mNavigPalette; delete mLeftPalette;
mNavigPalette = NULL; mLeftPalette = NULL;
} }
if(NULL != mLibPalette) if(NULL != mRightPalette)
{ {
delete mLibPalette; delete mRightPalette;
mLibPalette = NULL; mRightPalette = NULL;
} }
if(NULL != mStylusPalette) if(NULL != mStylusPalette)
@ -119,10 +118,10 @@ void UBBoardPaletteManager::setupLayout()
void UBBoardPaletteManager::setupPalettes() void UBBoardPaletteManager::setupPalettes()
{ {
// Add the dock palettes // 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 // 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 // Add the other palettes
mStylusPalette = new UBStylusPalette(mContainer, UBSettings::settings()->appToolBarOrientationVertical->get().toBool() ? Qt::Vertical : Qt::Horizontal); mStylusPalette = new UBStylusPalette(mContainer, UBSettings::settings()->appToolBarOrientationVertical->get().toBool() ? Qt::Vertical : Qt::Horizontal);
@ -375,8 +374,8 @@ void UBBoardPaletteManager::containerResized()
mKeyboardPalette->adjustSizeAndPosition(); mKeyboardPalette->adjustSizeAndPosition();
} }
mNavigPalette->resize(mNavigPalette->width(), mContainer->height()); mLeftPalette->resize(mLeftPalette->width(), mContainer->height());
mLibPalette->resize(mLibPalette->width(), mContainer->height()); mRightPalette->resize(mRightPalette->width(), mContainer->height());
} }
@ -403,9 +402,9 @@ void UBBoardPaletteManager::activeSceneChanged()
if (mStylusPalette) if (mStylusPalette)
connect(mStylusPalette, SIGNAL(mouseEntered()), activeScene, SLOT(hideEraser())); 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) if (mZoomPalette)
@ -569,7 +568,8 @@ void UBBoardPaletteManager::addItemToLibrary()
, Qt::KeepAspectRatio, Qt::SmoothTransformation); , Qt::KeepAspectRatio, Qt::SmoothTransformation);
} }
QImage image = mPixmap.toImage(); QImage image = mPixmap.toImage();
UBApplication::boardController->libraryController()->importImageOnLibrary(image); //UBApplication::boardController->libraryController()->importImageOnLibrary(image);
} }
else else
{ {
@ -579,29 +579,6 @@ void UBBoardPaletteManager::addItemToLibrary()
mAddItemPalette->hide(); 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() void UBBoardPaletteManager::zoomButtonPressed()
{ {
mZoomButtonPressedTime = QTime::currentTime(); mZoomButtonPressedTime = QTime::currentTime();

@ -20,8 +20,8 @@
#include <QtWebKit> #include <QtWebKit>
#include "web/UBRoutedMouseEventWebView.h" #include "web/UBRoutedMouseEventWebView.h"
#include "gui/UBNavigatorPalette.h" #include "gui/UBLeftPalette.h"
#include "gui/UBLibPalette.h" #include "gui/UBRightPalette.h"
class UBStylusPalette; class UBStylusPalette;
class UBClockPalette; class UBClockPalette;
@ -43,7 +43,7 @@ class UBBoardPaletteManager : public QObject
virtual ~UBBoardPaletteManager(); virtual ~UBBoardPaletteManager();
void setupLayout(); void setupLayout();
UBNavigatorPalette* navigatorPalette(){return mNavigPalette;} UBLeftPalette* leftPalette(){return mLeftPalette;}
void showVirtualKeyboard(bool show = true); void showVirtualKeyboard(bool show = true);
void initPalettesPosAtStartup(); void initPalettesPosAtStartup();
@ -68,8 +68,9 @@ class UBBoardPaletteManager : public QObject
UBStylusPalette *mStylusPalette; UBStylusPalette *mStylusPalette;
UBZoomPalette *mZoomPalette; UBZoomPalette *mZoomPalette;
UBNavigatorPalette* mNavigPalette;
UBLibPalette* mLibPalette; UBLeftPalette* mLeftPalette;
UBRightPalette* mRightPalette;
UBActionPalette *mBackgroundsPalette; UBActionPalette *mBackgroundsPalette;
UBActionPalette *mToolsPalette; UBActionPalette *mToolsPalette;

@ -857,9 +857,6 @@ UBBoardView::setToolCursor (int tool)
case UBStylusTool::Eraser: case UBStylusTool::Eraser:
controlViewport->setCursor (UBResources::resources ()->eraserCursor); controlViewport->setCursor (UBResources::resources ()->eraserCursor);
break; break;
case UBStylusTool::Magnifier:
controlViewport->setCursor (UBResources::resources ()->magnifierCursor);
break;
case UBStylusTool::Marker: case UBStylusTool::Marker:
controlViewport->setCursor (UBResources::resources ()->markerCursor); controlViewport->setCursor (UBResources::resources ()->markerCursor);
break; break;

@ -44,7 +44,6 @@ UBDrawingController::UBDrawingController(QObject * parent)
connect(UBApplication::mainWindow->actionPen, SIGNAL(triggered(bool)), this, SLOT(penToolSelected(bool))); 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->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->actionMarker, SIGNAL(triggered(bool)), this, SLOT(markerToolSelected(bool)));
connect(UBApplication::mainWindow->actionSelector, SIGNAL(triggered(bool)), this, SLOT(selectorToolSelected(bool))); connect(UBApplication::mainWindow->actionSelector, SIGNAL(triggered(bool)), this, SLOT(selectorToolSelected(bool)));
connect(UBApplication::mainWindow->actionHand, SIGNAL(triggered(bool)), this, SLOT(handToolSelected(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); UBApplication::mainWindow->actionPen->setChecked(true);
else if (mStylusTool == UBStylusTool::Eraser) else if (mStylusTool == UBStylusTool::Eraser)
UBApplication::mainWindow->actionEraser->setChecked(true); UBApplication::mainWindow->actionEraser->setChecked(true);
else if (mStylusTool == UBStylusTool::Magnifier)
UBApplication::mainWindow->actionMagnifier->setChecked(true);
else if (mStylusTool == UBStylusTool::Marker) else if (mStylusTool == UBStylusTool::Marker)
UBApplication::mainWindow->actionMarker->setChecked(true); UBApplication::mainWindow->actionMarker->setChecked(true);
else if (mStylusTool == UBStylusTool::Selector) else if (mStylusTool == UBStylusTool::Selector)
@ -265,21 +262,6 @@ void UBDrawingController::setEraserWidthIndex(int index)
UBSettings::settings()->setEraserWidthIndex(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) void UBDrawingController::setPenColor(bool onDarkBackground, const QColor& color, int pIndex)
{ {
if (onDarkBackground) if (onDarkBackground)
@ -340,12 +322,6 @@ void UBDrawingController::eraserToolSelected(bool checked)
setStylusTool(UBStylusTool::Eraser); setStylusTool(UBStylusTool::Eraser);
} }
void UBDrawingController::magnifierToolSelected(bool checked)
{
if (checked)
setStylusTool(UBStylusTool::Magnifier);
}
void UBDrawingController::markerToolSelected(bool checked) void UBDrawingController::markerToolSelected(bool checked)
{ {
if (checked) if (checked)

@ -57,8 +57,6 @@ class UBDrawingController : public QObject
void setLineWidthIndex(int index); void setLineWidthIndex(int index);
void setColorIndex(int index); void setColorIndex(int index);
void setEraserWidthIndex(int index); void setEraserWidthIndex(int index);
void setMagnifierZoomIndex(int index);
void setMagnifierSizeIndex(int index);
signals: signals:
void stylusToolChanged(int tool); void stylusToolChanged(int tool);
@ -77,7 +75,6 @@ class UBDrawingController : public QObject
void penToolSelected(bool checked); void penToolSelected(bool checked);
void eraserToolSelected(bool checked); void eraserToolSelected(bool checked);
void magnifierToolSelected(bool checked);
void markerToolSelected(bool checked); void markerToolSelected(bool checked);
void selectorToolSelected(bool checked); void selectorToolSelected(bool checked);
void handToolSelected(bool checked); void handToolSelected(bool checked);

@ -45,10 +45,10 @@
static quint32 magicNumber = 0xACDCAFE0; static quint32 magicNumber = 0xACDCAFE0;
static QString favoriteVirtualPath = "$favorite$"; static QString favoriteVirtualPath = "$favorite$";
UBLibraryController::UBLibraryController(QWidget *pParentWidget, UBBoardController *pBoardController) : UBLibraryController::UBLibraryController(QWidget *pParentWidget) :
QObject(pParentWidget), QObject(pParentWidget),
mParentWidget(pParentWidget), mParentWidget(pParentWidget),
mBoardController(pBoardController), mBoardController(UBApplication::boardController),
mLastItemOffsetIndex(0) mLastItemOffsetIndex(0)
{ {
readFavoriteList(); readFavoriteList();
@ -84,7 +84,7 @@ void UBLibraryController::createInternalWidgetItems()
UBToolsManager::UBToolDescriptor tool = UBToolsManager::manager()->toolByID(toolUri); UBToolsManager::UBToolDescriptor tool = UBToolsManager::manager()->toolByID(toolUri);
UBLibElement *newTool = new UBLibElement(eUBLibElementType_InteractiveItem, QUrl(tool.id), tool.label); UBLibElement *newTool = new UBLibElement(eUBLibElementType_InteractiveItem, QUrl(tool.id), tool.label);
QImage toolImage = tool.icon.toImage(); QImage toolImage = tool.icon.toImage();
newTool->setThumbnail(&toolImage); newTool->setThumbnail(toolImage);
newTool->setInformation(tool.label + " " + tool.version); newTool->setInformation(tool.label + " " + tool.version);
mInternalLibElements << newTool; mInternalLibElements << newTool;
@ -201,64 +201,54 @@ QList<UBLibElement*> UBLibraryController::rootCategoriesList()
QList<UBLibElement*> categories; QList<UBLibElement*> categories;
UBLibElement* element = new UBLibElement(eUBLibElementType_Folder, mAudioStandardDirectoryPath, tr("Audios", "Audio category element")); UBLibElement* element = new UBLibElement(eUBLibElementType_Folder, mAudioStandardDirectoryPath, tr("Audios", "Audio category element"));
QImage* categoryImage = new QImage(":images/libpalette/AudiosCategory.svg"); element->setThumbnail(QImage(":images/libpalette/AudiosCategory.svg"));
element->setThumbnail(categoryImage);
element->setMoveable(false); element->setMoveable(false);
categories << element; categories << element;
element = new UBLibElement(eUBLibElementType_Folder, mVideoStandardDirectoryPath, tr("Movies", "Movies category element")); element = new UBLibElement(eUBLibElementType_Folder, mVideoStandardDirectoryPath, tr("Movies", "Movies category element"));
categoryImage = new QImage(":images/libpalette/MoviesCategory.svg"); element->setThumbnail(QImage(":images/libpalette/MoviesCategory.svg"));
element->setThumbnail(categoryImage);
element->setMoveable(false); element->setMoveable(false);
categories << element; categories << element;
element = new UBLibElement(eUBLibElementType_Folder, mPicturesStandardDirectoryPath, tr("Pictures", "Pictures category element")); element = new UBLibElement(eUBLibElementType_Folder, mPicturesStandardDirectoryPath, tr("Pictures", "Pictures category element"));
categoryImage = new QImage(":images/libpalette/PicturesCategory.svg"); element->setThumbnail(QImage(":images/libpalette/PicturesCategory.svg"));
element->setThumbnail(categoryImage);
element->setMoveable(false); element->setMoveable(false);
categories << element; categories << element;
QString path = UBSettings::settings()->uniboardShapeLibraryDirectory(); 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 = 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); element->setMoveable(false);
categories << element; categories << element;
categoryImage = new QImage(":images/libpalette/ApplicationsCategory.svg");
element = new UBLibElement(eUBLibElementType_Folder, mInteractiveUserDirectoryPath, tr("Applications", "Applications category element")); element = new UBLibElement(eUBLibElementType_Folder, mInteractiveUserDirectoryPath, tr("Applications", "Applications category element"));
element->setThumbnail(categoryImage); element->setThumbnail(QImage(":images/libpalette/ApplicationsCategory.svg"));
element->setMoveable(false); element->setMoveable(false);
categories << element; categories << element;
categoryImage = new QImage(":images/libpalette/FavoritesCategory.svg");
element = new UBLibElement(eUBLibElementType_VirtualFolder, favoriteVirtualPath, tr("Favorite", "Favorite category element")); element = new UBLibElement(eUBLibElementType_VirtualFolder, favoriteVirtualPath, tr("Favorite", "Favorite category element"));
element->setThumbnail(categoryImage); element->setThumbnail(QImage(":images/libpalette/FavoritesCategory.svg"));
element->setMoveable(false); element->setMoveable(false);
categories << element; categories << element;
categoryImage = new QImage(":images/libpalette/InteractivesCategory.svg");
mInteractiveCategoryPath = QUrl::fromLocalFile(UBSettings::settings()->uniboardGipLibraryDirectory()); mInteractiveCategoryPath = QUrl::fromLocalFile(UBSettings::settings()->uniboardGipLibraryDirectory());
element = new UBLibElement(eUBLibElementType_Folder, mInteractiveCategoryPath, tr("Interactivities", "Interactives category element")); element = new UBLibElement(eUBLibElementType_Folder, mInteractiveCategoryPath, tr("Interactivities", "Interactives category element"));
element->setThumbnail(categoryImage); element->setThumbnail(QImage(":images/libpalette/InteractivesCategory.svg"));
element->setMoveable(false); element->setMoveable(false);
categories << element; categories << element;
categoryImage = new QImage(":images/libpalette/FlashCategory.svg");
element = new UBLibElement(eUBLibElementType_Folder, mAnimationUserDirectoryPath, tr("Animations", "Animations category element")); element = new UBLibElement(eUBLibElementType_Folder, mAnimationUserDirectoryPath, tr("Animations", "Animations category element"));
element->setThumbnail(categoryImage); element->setThumbnail(QImage(":images/libpalette/FlashCategory.svg"));
element->setMoveable(false); element->setMoveable(false);
categories << element; categories << element;
categories << UBLibElement::trashElement(); categories << UBLibElement::trashElement();
return categories; return categories;
} }
QImage* UBLibraryController::createThumbnail(UBLibElement* pElement) QImage UBLibraryController::createThumbnail(UBLibElement* pElement)
{ {
QString thumbnailPath = UBFileSystemUtils::thumbnailPath(pElement->path().toLocalFile()); QString thumbnailPath = UBFileSystemUtils::thumbnailPath(pElement->path().toLocalFile());
QString mimetype = UBFileSystemUtils::mimeTypeFromFileName(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://")){ 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; return image;
} }
if (pElement->type() == eUBLibElementType_InteractiveItem){ if (pElement->type() == eUBLibElementType_InteractiveItem){
QImage* image = new QImage(UBAbstractWidget::iconFilePath(pElement->path())); QImage image = QImage(UBAbstractWidget::iconFilePath(pElement->path()));
return image; return image;
} }
@ -307,7 +297,7 @@ QImage* UBLibraryController::thumbnailForFile(UBLibElement* pElement)
qWarning() << "thumbnailForFile impossible to create thumbnail path for the element " + pElement->path().toLocalFile(); qWarning() << "thumbnailForFile impossible to create thumbnail path for the element " + pElement->path().toLocalFile();
if (QFileInfo(thumbnailPath).exists()) if (QFileInfo(thumbnailPath).exists())
return new QImage(thumbnailPath); return QImage(thumbnailPath);
else else
return createThumbnail(pElement); return createThumbnail(pElement);
} }
@ -318,7 +308,8 @@ QList<UBLibElement*> UBLibraryController::addVirtualElementsForItemPath(const QS
if (pPath == mInteractiveUserDirectoryPath.toLocalFile()){ if (pPath == mInteractiveUserDirectoryPath.toLocalFile()){
content << listElementsInPath(UBSettings::settings()->uniboardInteractiveLibraryDirectory()); content << listElementsInPath(UBSettings::settings()->uniboardInteractiveLibraryDirectory());
content << listElementsInPath(UBSettings::settings()->uniboardInteractiveFavoritesDirectory()); content << listElementsInPath(UBSettings::settings()->uniboardInteractiveFavoritesDirectory());
content << mInternalLibElements; foreach(UBLibElement* eachElement, mInternalLibElements)
content << new UBLibElement(eachElement);
} }
else if (pPath == mPicturesStandardDirectoryPath.toLocalFile()){ else if (pPath == mPicturesStandardDirectoryPath.toLocalFile()){
QUrl path = QUrl::fromLocalFile(UBSettings::settings()->uniboardImageLibraryDirectory()); 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); UBLibElement *element = new UBLibElement(fileType, QUrl::fromLocalFile(fileInfo->absoluteFilePath()), itemName);
if (fileType == eUBLibElementType_Folder) { if (fileType == eUBLibElementType_Folder) {
QImage* directoryImage = new QImage(":images/libpalette/folder.svg"); // QImage* directoryImage = new QImage(":images/libpalette/folder.svg");
element->setThumbnail(directoryImage); element->setThumbnail(QImage(":images/libpalette/folder.svg"));
} }
else if (fileType == eUBLibElementType_Item) { else if (fileType == eUBLibElementType_Item) {
if (element->path().toLocalFile().contains(".thumbnail.")) if (element->path().toLocalFile().contains(".thumbnail."))
@ -373,7 +364,10 @@ QList<UBLibElement*> UBLibraryController::listElementsInPath(const QString& pPat
QList<UBLibElement*> UBLibraryController::listElementsInVirtualForlder(UBLibElement* pElement) QList<UBLibElement*> UBLibraryController::listElementsInVirtualForlder(UBLibElement* pElement)
{ {
Q_UNUSED(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) 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*> UBLibraryController::getContent(UBLibElement *element)
{ {
QList<UBLibElement*> elementsList; cleanElementsList();
switch (element->type()) { switch (element->type()) {
case eUBLibElementType_Category: { case eUBLibElementType_Category: {
elementsList = rootCategoriesList(); mElementsList = rootCategoriesList();
break; break;
} }
case eUBLibElementType_VirtualFolder: { case eUBLibElementType_VirtualFolder: {
elementsList = listElementsInVirtualForlder(element); mElementsList = listElementsInVirtualForlder(element);
break; break;
} }
case eUBLibElementType_Folder: { case eUBLibElementType_Folder: {
elementsList = listElementsInPath(element->path().toLocalFile()); mElementsList = listElementsInPath(element->path().toLocalFile());
break; break;
} }
case eUBLibElementType_Item: { case eUBLibElementType_Item: {
@ -443,16 +447,20 @@ QList<UBLibElement*> UBLibraryController::getContent(UBLibElement *element)
break; break;
} }
return elementsList; // qDebug() << "getContent()";
// qDebug() << this;
// foreach(UBLibElement*eachElement, mElementsList)
// qDebug() << eachElement;
return mElementsList;
} }
UBLibraryController::~UBLibraryController() UBLibraryController::~UBLibraryController()
{ {
cleanElementsList();
//NOOP //NOOP
} }
void UBLibraryController::setItemAsBackground(UBLibElement* image) void UBLibraryController::setItemAsBackground(UBLibElement* image)
{ {
if (!activeScene()){ if (!activeScene()){
@ -501,9 +509,6 @@ void UBLibraryController::addItemToPage(UBLibElement* item)
else{ else{
UBApplication::showMessage(tr("Adding to page failed for item %1.").arg(item->name())); UBApplication::showMessage(tr("Adding to page failed for item %1.").arg(item->name()));
} }
} }
void UBLibraryController::removeBackground() void UBLibraryController::removeBackground()
@ -564,6 +569,7 @@ void UBLibraryController::readFavoriteList()
eachElement->setInformation(info); eachElement->setInformation(info);
eachElement->setExtension(extension); eachElement->setExtension(extension);
eachElement->setThumbnail(thumbnailForFile(eachElement)); eachElement->setThumbnail(thumbnailForFile(eachElement));
if(!isOnFavoriteList(eachElement))
mFavoriteList << eachElement; mFavoriteList << eachElement;
} }
@ -582,10 +588,10 @@ UBLibElement* UBLibraryController::isOnFavoriteList(UBLibElement * element)
void UBLibraryController::addToFavorite(QList<UBLibElement*> elementList) void UBLibraryController::addToFavorite(QList<UBLibElement*> elementList)
{ {
foreach(UBLibElement* eachElement, elementList){ foreach(UBLibElement* eachElement, elementList)
if(!isOnFavoriteList(eachElement)) if(!isOnFavoriteList(eachElement))
mFavoriteList << eachElement; mFavoriteList << new UBLibElement(eachElement);
}
persistFavoriteList(); persistFavoriteList();
} }
@ -601,7 +607,8 @@ void UBLibraryController::removeFromFavorite(QList<UBLibElement*> elementList)
persistFavoriteList(); persistFavoriteList();
} }
QRectF UBLibraryController::visibleSceneRect() { QRectF UBLibraryController::visibleSceneRect()
{
QRectF visibleSceneRect(0, 0, 0, 0); QRectF visibleSceneRect(0, 0, 0, 0);
if (activeScene() && mBoardController && mBoardController->controlView()) { if (activeScene() && mBoardController && mBoardController->controlView()) {
@ -621,7 +628,8 @@ QRectF UBLibraryController::visibleSceneRect() {
return visibleSceneRect; return visibleSceneRect;
} }
void UBLibraryController::addImagesToCurrentPage(const QList<QUrl>& images) { void UBLibraryController::addImagesToCurrentPage(const QList<QUrl>& images)
{
QPointF pos = visibleSceneRect().topLeft(); QPointF pos = visibleSceneRect().topLeft();
foreach(const QUrl url, images) 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(); QPointF pos = visibleSceneRect().topLeft();
foreach(const QUrl url, videos) 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 topLeftPos = visibleSceneRect().topLeft();
QPointF pos = topLeftPos; QPointF pos = topLeftPos;
@ -680,12 +690,10 @@ void UBLibraryController::addAudiosToCurrentPage(const QList<QUrl>& sounds) {
} }
} }
void UBLibraryController::addInteractivesToCurrentPage( void UBLibraryController::addInteractivesToCurrentPage( const QList<QUrl>& widgets)
const QList<QUrl>& widgets) { {
foreach(const QUrl url, widgets) foreach(const QUrl url, widgets)
{
mBoardController->downloadURL(url, QPointF(0, 0)); mBoardController->downloadURL(url, QPointF(0, 0));
}
} }
QString UBLibraryController::favoritePath() QString UBLibraryController::favoritePath()
@ -699,6 +707,17 @@ UBLibElement::UBLibElement() {
mbMoveable = false; 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) UBLibElement::UBLibElement(eUBLibElementType type, const QUrl &path, const QString &name)
{ {
@ -728,7 +747,7 @@ UBLibElement::~UBLibElement()
UBChainedLibElement::UBChainedLibElement(UBLibElement *pElem, UBChainedLibElement *pNextElem) UBChainedLibElement::UBChainedLibElement(UBLibElement *pElem, UBChainedLibElement *pNextElem)
{ {
mpElem = pElem; mpElem = new UBLibElement(pElem);
mpNextElem = pNextElem; mpNextElem = pNextElem;
} }
@ -747,13 +766,9 @@ void UBChainedLibElement::setNextElement(UBChainedLibElement *nextElem)
UBLibElement* UBLibElement::trashElement() UBLibElement* UBLibElement::trashElement()
{ {
static UBLibElement *trashElement; UBLibElement *trashElement;
if (trashElement)
return trashElement;
trashElement = new UBLibElement(eUBLibElementType_Folder, QUrl::fromLocalFile(UBSettings::trashLibraryPaletteDirPath()), QObject::tr("Trash", "Pictures category element")); 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(QImage(":images/libpalette/TrashCategory.svg"));
trashElement->setThumbnail(categoryImage);
trashElement->setMoveable(false); trashElement->setMoveable(false);
return trashElement; return trashElement;

@ -42,6 +42,7 @@ class UBLibElement
public: public:
UBLibElement(); UBLibElement();
UBLibElement(eUBLibElementType type, const QUrl& path, const QString& name); UBLibElement(eUBLibElementType type, const QUrl& path, const QString& name);
UBLibElement(UBLibElement* element);
~UBLibElement(); ~UBLibElement();
static UBLibElement* trashElement(); static UBLibElement* trashElement();
@ -51,7 +52,7 @@ public:
QUrl path(){return mPath;} QUrl path(){return mPath;}
void setPath(QUrl path){mPath = path;} void setPath(QUrl path){mPath = path;}
QImage* thumbnail(){return &mThumbnail;} QImage* thumbnail(){return &mThumbnail;}
void setThumbnail(QImage* pThumb){mThumbnail = *pThumb;} void setThumbnail(QImage pThumb){mThumbnail = pThumb;}
QString information(){return mInfo;} QString information(){return mInfo;}
void setInformation(QString info){mInfo = info;} void setInformation(QString info){mInfo = info;}
QString name(){return mName;} QString name(){return mName;}
@ -91,7 +92,7 @@ class UBLibraryController : public QObject
Q_OBJECT; Q_OBJECT;
public: public:
UBLibraryController(QWidget *parentWidget, UBBoardController *boardController); UBLibraryController(QWidget *parentWidget);
virtual ~UBLibraryController(); virtual ~UBLibraryController();
QList<UBLibElement*> getContent(UBLibElement* pElement); QList<UBLibElement*> getContent(UBLibElement* pElement);
@ -134,14 +135,16 @@ class UBLibraryController : public QObject
void persistFavoriteList(); void persistFavoriteList();
void readFavoriteList(); void readFavoriteList();
QList<UBLibElement*> mInternalLibElements; QList<UBLibElement*> mInternalLibElements;
QList<UBLibElement*> mElementsList;
void cleanElementsList();
private: private:
QList<UBLibElement*> rootCategoriesList(); QList<UBLibElement*> rootCategoriesList();
QList<UBLibElement*> listElementsInPath(const QString& pPath); QList<UBLibElement*> listElementsInPath(const QString& pPath);
QList<UBLibElement*> listElementsInVirtualForlder(UBLibElement* pElement); QList<UBLibElement*> listElementsInVirtualForlder(UBLibElement* pElement);
void userPath(QUrl &pPath); void userPath(QUrl &pPath);
QImage* thumbnailForFile(UBLibElement* pPath); QImage thumbnailForFile(UBLibElement* pPath);
QImage* createThumbnail(UBLibElement* pPath); QImage createThumbnail(UBLibElement* pPath);
QList<UBLibElement*> addVirtualElementsForItemPath(const QString& pPath); QList<UBLibElement*> addVirtualElementsForItemPath(const QString& pPath);
void createInternalWidgetItems(); void createInternalWidgetItems();

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

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

@ -624,170 +624,6 @@ qreal UBSettings::currentEraserWidth()
return width; 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() bool UBSettings::isDarkBackground()
{ {
return value("Board/DarkBackground", 0).toBool(); return value("Board/DarkBackground", 0).toBool();

@ -66,19 +66,6 @@ class UBSettings : public QObject
qreal eraserStrongWidth(); qreal eraserStrongWidth();
qreal currentEraserWidth(); 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 // Background related
bool isDarkBackground(); bool isDarkBackground();
bool isCrossedBackground(); bool isCrossedBackground();
@ -360,17 +347,6 @@ class UBSettings : public QObject
void setEraserMediumWidth(qreal width); void setEraserMediumWidth(qreal width);
void setEraserStrongWidth(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 setPenPressureSensitive(bool sensitive);

@ -56,7 +56,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
, mDesktopPenPalette(NULL) , mDesktopPenPalette(NULL)
, mDesktopMarkerPalette(NULL) , mDesktopMarkerPalette(NULL)
, mDesktopEraserPalette(NULL) , mDesktopEraserPalette(NULL)
, mLibPalette(NULL) , mRightPalette(NULL)
, mWindowPositionInitialized(0) , mWindowPositionInitialized(0)
, mIsFullyTransparent(false) , mIsFullyTransparent(false)
, mDesktopToolsPalettePositioned(false) , mDesktopToolsPalettePositioned(false)
@ -89,7 +89,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
mTransparentDrawingScene = new UBGraphicsScene(0); mTransparentDrawingScene = new UBGraphicsScene(0);
mTransparentDrawingView->setScene(mTransparentDrawingScene); mTransparentDrawingView->setScene(mTransparentDrawingScene);
mLibPalette = new UBLibPalette(mTransparentDrawingView); mRightPalette = new UBRightPalette(mTransparentDrawingView);
mDesktopPalette = new UBDesktopPalette(mTransparentDrawingView); mDesktopPalette = new UBDesktopPalette(mTransparentDrawingView);
@ -160,7 +160,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent)
#ifdef Q_WS_X11 #ifdef Q_WS_X11
connect(mDesktopPalette, SIGNAL(moving()), this, SLOT(refreshMask())); connect(mDesktopPalette, SIGNAL(moving()), this, SLOT(refreshMask()));
connect(mLibPalette, SIGNAL(resized()), this, SLOT(refreshMask())); connect(mRightPalette, SIGNAL(resized()), this, SLOT(refreshMask()));
#endif #endif
onDesktopPaletteMaximized(); onDesktopPaletteMaximized();
} }
@ -212,10 +212,10 @@ UBDesktopAnnotationController::~UBDesktopAnnotationController()
delete mDesktopEraserPalette; delete mDesktopEraserPalette;
mDesktopEraserPalette = NULL; mDesktopEraserPalette = NULL;
} }
if(NULL != mLibPalette) if(NULL != mRightPalette)
{ {
delete mLibPalette; delete mRightPalette;
mLibPalette = NULL; mRightPalette = NULL;
} }
*/ */
} }
@ -800,7 +800,7 @@ void UBDesktopAnnotationController::onDesktopPaletteMinimize()
*/ */
void UBDesktopAnnotationController::onTransparentWidgetResized() void UBDesktopAnnotationController::onTransparentWidgetResized()
{ {
mLibPalette->resize(mLibPalette->width(), mTransparentDrawingView->height()); mRightPalette->resize(mRightPalette->width(), mTransparentDrawingView->height());
} }
void UBDesktopAnnotationController::updateMask(bool bTransparent) 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()); 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(); p.end();

@ -20,7 +20,7 @@
#include <QTime> #include <QTime>
#include <QTimer> #include <QTimer>
#include "gui/UBLibPalette.h" #include "gui/UBRightPalette.h"
class UBDesktopPalette; class UBDesktopPalette;
class UBDesktopToolsPalette; class UBDesktopToolsPalette;
@ -117,7 +117,7 @@ class UBDesktopAnnotationController : public QObject
UBDesktopMarkerPalette* mDesktopMarkerPalette; UBDesktopMarkerPalette* mDesktopMarkerPalette;
UBDesktopEraserPalette* mDesktopEraserPalette; UBDesktopEraserPalette* mDesktopEraserPalette;
UBLibPalette* mLibPalette; UBRightPalette* mRightPalette;
QTime mPenHoldTimer; QTime mPenHoldTimer;
QTime mMarkerHoldTimer; QTime mMarkerHoldTimer;

@ -136,13 +136,13 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
} }
connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing())); connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing()));
} }
UBGraphicsScene::~UBGraphicsScene() UBGraphicsScene::~UBGraphicsScene()
{ {
// NOOP // NOOP
DisposeMagnifierQWidgets();
} }
void UBGraphicsScene::selectionChangedProcessing() void UBGraphicsScene::selectionChangedProcessing()
@ -236,15 +236,6 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
drawPointer(scenePos); drawPointer(scenePos);
accepted = true; 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; return accepted;
@ -318,11 +309,6 @@ bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pres
{ {
drawPointer(position); drawPointer(position);
} }
else if (currentTool == UBStylusTool::Magnifier)
{
magniferControlViewWidget->grabNMove(QCursor::pos(), false);
magniferDisplayViewWidget->grabNMove(position, false);
}
accepted = true; accepted = true;
} }
@ -361,12 +347,6 @@ bool UBGraphicsScene::inputDeviceRelease()
{ {
mCurrentStroke = 0; mCurrentStroke = 0;
} }
else
if (currentTool == UBStylusTool::Magnifier)
{
DisposeMagnifierQWidgets();
//qDebug() << "deleted";
}
if (mRemovedItems.size() > 0 || mAddedItems.size() > 0) 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 // call this function when user release mouse button in Magnifier mode
void UBGraphicsScene::DisposeMagnifierQWidgets() void UBGraphicsScene::DisposeMagnifierQWidgets()
{ {
@ -1534,6 +1496,119 @@ void UBGraphicsScene::addTriangle(QPointF center)
setModified(true); 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) void UBGraphicsScene::addCompass(QPointF center)
{ {

@ -44,7 +44,8 @@ class UBAbstractWidget;
class UBDocumentProxy; class UBDocumentProxy;
class UBGraphicsCurtainItem; class UBGraphicsCurtainItem;
class UBGraphicsStroke; class UBGraphicsStroke;
class UBMagnifer; class UBMagnifierParams;
class UBMagnifier;
const double PI = 4.0 * atan(1.0); const double PI = 4.0 * atan(1.0);
@ -165,9 +166,10 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
qreal getNextObjectZIndex(); qreal getNextObjectZIndex();
void addRuler(QPointF center); void addRuler(QPointF center);
void addTriangle(QPointF center);
void addProtractor(QPointF center); void addProtractor(QPointF center);
void addCompass(QPointF center); void addCompass(QPointF center);
void addTriangle(QPointF center);
void addMagnifier(UBMagnifierParams params);
void addMask(); void addMask();
@ -274,6 +276,11 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void selectionChangedProcessing(); void selectionChangedProcessing();
void moveMagnifier(QPoint newPos);
void closeMagnifier();
void zoomInMagnifier();
void zoomOutMagnifier();
void resizedMagnifier(qreal newPercent);
signals: signals:
@ -289,7 +296,6 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void drawEraser(const QPointF& pEndPoint); void drawEraser(const QPointF& pEndPoint);
void drawPointer(const QPointF& pEndPoint); void drawPointer(const QPointF& pEndPoint);
void CreateMagnifierQWidgets();
void DisposeMagnifierQWidgets(); void DisposeMagnifierQWidgets();
@ -352,8 +358,8 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
//int mMesure1Ms, mMesure2Ms; //int mMesure1Ms, mMesure2Ms;
UBMagnifer *magniferControlViewWidget; UBMagnifier *magniferControlViewWidget;
UBMagnifer *magniferDisplayViewWidget; UBMagnifier *magniferDisplayViewWidget;
}; };
#endif /* UBGRAPHICSSCENE_H_ */ #endif /* UBGRAPHICSSCENE_H_ */

@ -24,22 +24,6 @@
#include "core/memcheck.h" #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 * \brief The constructor
*/ */
@ -53,9 +37,21 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
, mCollapseWidth(150) , mCollapseWidth(150)
, mLastWidth(-1) , mLastWidth(-1)
, mHTab(0) , mHTab(0)
, mpStackWidget(NULL)
, mpLayout(NULL)
, mCurrentTab(0)
{ {
setObjectName(name); 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 // We let 2 pixels in order to keep a small border for the resizing
setMinimumWidth(2*border() + 2); setMinimumWidth(2*border() + 2);
@ -91,7 +87,16 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
*/ */
UBDockPalette::~UBDockPalette() 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) switch(mOrientation)
{ {
case eUBDockOrientation_Left: case eUBDockOrientation_Left:
if((p.x() >= width() - border()) && (p.x() <= width())) if((p.x() >= width() - 2 * border()) && (p.x() <= width()))
{ {
mCanResize = true; mCanResize = true;
} }
break; break;
case eUBDockOrientation_Right: case eUBDockOrientation_Right:
if((p.x() >= 0) && (p.x() <= border())) if((p.x() >= 0) && (p.x() <= 2 * border()))
{ {
mCanResize = true; mCanResize = true;
} }
@ -225,15 +230,18 @@ void UBDockPalette::mouseReleaseEvent(QMouseEvent *event)
Q_UNUSED(event); Q_UNUSED(event);
if(!mResized && mClickTime.elapsed() < CLICKTIME) 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 the clicked position is in the tab, perform the related action
if(eUBDockOrientation_Left == mOrientation) if(eUBDockOrientation_Left == mOrientation)
{ {
if(mMousePressPos.x() >= width() - 2*border() && if(mMousePressPos.x() >= width() - 2*border() &&
mMousePressPos.y() >= mHTab && mMousePressPos.y() >= mHTab &&
mMousePressPos.x() <= width() && 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) else if(eUBDockOrientation_Right == mOrientation)
@ -241,9 +249,10 @@ void UBDockPalette::mouseReleaseEvent(QMouseEvent *event)
if(mMousePressPos.x() >= 0 && if(mMousePressPos.x() >= 0 &&
mMousePressPos.x() <= 2*border() && mMousePressPos.x() <= 2*border() &&
mMousePressPos.y() >= mHTab && 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,52 +322,78 @@ void UBDockPalette::paintEvent(QPaintEvent *event)
painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);
painter.setBrush(mBackgroundBrush); painter.setBrush(mBackgroundBrush);
QPainterPath path;
path.setFillRule(Qt::WindingFill);
int nbTabs = mTabWidgets.size();
if(0 < nbTabs)
{
// First draw the BIG RECTANGLE (I write it big because the rectangle is big...)
if(mOrientation == eUBDockOrientation_Left)
{
path.addRect(0.0, 0.0, width()-2*border(), height());
}
else if(mOrientation == eUBDockOrientation_Right)
{
path.addRect(2*border(), 0.0, width()-2*border(), height());
}
// THEN DRAW THE small tabs (yes, the tabs are small...)
if(eUBDockTabOrientation_Up == mTabsOrientation) if(eUBDockTabOrientation_Up == mTabsOrientation)
{ {
mHTab = border(); mHTab = border();
} }
else else
{ {
mHTab = height() - border() - TABSIZE; 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) if(mOrientation == eUBDockOrientation_Left)
{ {
QPainterPath path; path.addRoundedRect(width()-4*border(), mHTab + i*TABSIZE + i*tabSpacing(), 4*border(), TABSIZE, radius(), radius());
path.setFillRule(Qt::WindingFill);
path.addRect(0.0, 0.0, width()-2*border(), height());
path.addRoundedRect(width()-4*border(), mHTab, 4*border(), TABSIZE, radius(), radius());
painter.drawPath(path); painter.drawPath(path);
QPixmap iconPixmap;
if(mCollapseWidth >= width()) if(mCollapseWidth >= width())
{ {
painter.drawPixmap(width() - 2*border() + 1, mHTab + 1 , 2*border() - 4, TABSIZE - 2, mCollapsedIcon); // Get the collapsed icon
iconPixmap = pCrntWidget->iconToRight();
} }
else else
{ {
painter.drawPixmap(width() - 2*border() + 1, mHTab + 1 , 2*border() - 4, TABSIZE - 2, mIcon); // 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) else if(mOrientation == eUBDockOrientation_Right)
{ {
QPainterPath path; path.addRoundedRect(0.0, mHTab + i*TABSIZE + i*tabSpacing(), 4*border(), TABSIZE, radius(), radius());
path.setFillRule(Qt::WindingFill);
path.addRect(2*border(), 0.0, width()-2*border(), height());
path.addRoundedRect(0.0, mHTab, 4*border(), TABSIZE, radius(), radius());
painter.drawPath(path); painter.drawPath(path);
if(width() <= mCollapseWidth) QPixmap iconPixmap;
if(mCollapseWidth >= width())
{ {
painter.drawPixmap(2, mHTab + 1, 2*border() - 3, TABSIZE - 2, mCollapsedIcon); // Get the collapsed icon
iconPixmap = pCrntWidget->iconToLeft();
} }
else else
{ {
painter.drawPixmap(2, mHTab + 1, 2*border() - 3, TABSIZE - 2, mIcon); // Get the expanded icon
iconPixmap = pCrntWidget->iconToRight();
} }
painter.drawPixmap(2, mHTab + i*TABSIZE + i*tabSpacing() + 1, 2*border() - 4, TABSIZE - 2, iconPixmap);
} }
else else
{ {
painter.drawRoundedRect(border(), border(), width() - 2 * border(), height() - 2 * border(), radius(), radius()); 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 * \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) if(mLastWidth == -1)
{ {
@ -451,3 +512,35 @@ int UBDockPalette::customMargin()
{ {
return 5; 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 <QTime>
#include <QPoint> #include <QPoint>
#include <QPixmap> #include <QPixmap>
#include <QMap>
#include <QStackedWidget>
#include <QVBoxLayout>
#include <QVector>
#include "UBDockPaletteWidget.h"
#define TABSIZE 50 #define TABSIZE 50
#define CLICKTIME 1000000 #define CLICKTIME 1000000
@ -66,6 +72,9 @@ public:
void setBackgroundBrush(const QBrush& brush); void setBackgroundBrush(const QBrush& brush);
protected: protected:
void addTabWidget(UBDockPaletteWidget* widget);
void removeTab(const QString& widgetName);
virtual int border(); virtual int border();
virtual int radius(); virtual int radius();
virtual int customMargin(); virtual int customMargin();
@ -93,19 +102,33 @@ protected:
QTime mClickTime; QTime mClickTime;
/** The mouse pressed position */ /** The mouse pressed position */
QPoint mMousePressPos; QPoint mMousePressPos;
/** The palette icon */ // /** The palette icon */
QPixmap mIcon; // QPixmap mIcon;
QPixmap mCollapsedIcon; // QPixmap mCollapsedIcon;
/** The tab orientation */ /** The tab orientation */
eUBDockTabOrientation mTabsOrientation; eUBDockTabOrientation mTabsOrientation;
/** The h position of the tab */ /** The h position of the tab */
int mHTab; 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: private slots:
void onToolbarPosUpdated(); void onToolbarPosUpdated();
void onResizeRequest(QResizeEvent* event);
private: private:
void tabClicked(); void tabClicked(int tabIndex);
int tabSpacing();
void showTabWidget(int tabIndex);
void toggleCollapseExpand();
}; };
#endif // UBDOCKPALETTE_H #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 <QSize>
#include <QDebug> #include <QDebug>
#include "UBLibWidget.h"
#include "UBLibActionBar.h" #include "UBLibActionBar.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "core/memcheck.h" #include "core/memcheck.h"
@ -361,7 +361,8 @@ void UBLibActionBar::onSelectionChanged(QList<UBLibElement *> itemList, bool isI
*/ */
UBLibraryController* UBLibActionBar::libraryController() 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 * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "UBLibWidget.h"
#include "UBLibItemProperties.h" #include "UBLibItemProperties.h"
#include "core/UBApplication.h" #include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "frameworks/UBFileSystemUtils.h" #include "frameworks/UBFileSystemUtils.h"
#include "core/memcheck.h" #include "core/memcheck.h"
/** /**
@ -223,7 +222,8 @@ void UBLibItemProperties::adaptSize()
*/ */
void UBLibItemProperties::onAddToPage() 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() 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/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "UBLibNavigatorWidget.h" #include "UBLibNavigatorWidget.h"
#include "UBLibPalette.h" #include "UBLibWidget.h"
#include "core/memcheck.h" #include "core/memcheck.h"
@ -36,10 +36,9 @@ UBLibNavigatorWidget::UBLibNavigatorWidget(QWidget *parent, const char *name):QW
setObjectName(name); setObjectName(name);
setAcceptDrops(true); setAcceptDrops(true);
UBLibPalette* pLibPalette = dynamic_cast<UBLibPalette*>(parentWidget()); UBLibWidget* libWidget = dynamic_cast<UBLibWidget*>(parentWidget());
mLayout = new QVBoxLayout(this); mLayout = new QVBoxLayout(this);
// mLayout->setContentsMargins(20, 5, 5, 5);
setLayout(mLayout); setLayout(mLayout);
mPathViewer = new UBLibPathViewer(this); 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(mSlider,SIGNAL(valueChanged(int)),this,SLOT(updateThumbnailsSize(int)));
connect(mPathViewer, SIGNAL(elementsDropped(QList<QString>,UBLibElement*)), mLibWidget, SLOT(onElementsDropped(QList<QString>,UBLibElement*))); connect(mPathViewer, SIGNAL(elementsDropped(QList<QString>,UBLibElement*)), mLibWidget, SLOT(onElementsDropped(QList<QString>,UBLibElement*)));
if(NULL != pLibPalette)
{ connect(mLibWidget, SIGNAL(navigBarUpdate(UBLibElement*)), libWidget->actionBar(), SLOT(onNavigbarUpdate(UBLibElement*)));
connect(mLibWidget, SIGNAL(navigBarUpdate(UBLibElement*)), pLibPalette->actionBar(), SLOT(onNavigbarUpdate(UBLibElement*))); connect(mLibWidget, SIGNAL(itemsSelected(QList<UBLibElement*>, bool)), libWidget->actionBar(), SLOT(onSelectionChanged(QList<UBLibElement*>, bool)));
connect(mLibWidget, SIGNAL(itemsSelected(QList<UBLibElement*>, bool)), pLibPalette->actionBar(), SLOT(onSelectionChanged(QList<UBLibElement*>, bool))); connect(libWidget->actionBar(), SIGNAL(deleteDone()), mLibWidget, SLOT(onRefreshCurrentFolder()));
connect(pLibPalette->actionBar(), SIGNAL(deleteDone()), mLibWidget, SLOT(onRefreshCurrentFolder())); connect(mLibWidget, SIGNAL(favoritesEntered(bool)), libWidget->actionBar(), SLOT(onFavoritesEntered(bool)));
connect(mLibWidget, SIGNAL(favoritesEntered(bool)), pLibPalette->actionBar(), SLOT(onFavoritesEntered(bool))); connect(libWidget->actionBar(), SIGNAL(searchElement(QString)), mLibWidget, SLOT(onSearchElement(QString)));
connect(pLibPalette->actionBar(), SIGNAL(searchElement(QString)), mLibWidget, SLOT(onSearchElement(QString))); connect(libWidget->actionBar(), SIGNAL(newFolderToCreate()), mLibWidget, SLOT(onNewFolderToCreate()));
connect(pLibPalette->actionBar(), SIGNAL(newFolderToCreate()), mLibWidget, SLOT(onNewFolderToCreate()));
}
mLibWidget->init(); mLibWidget->init();
} }
@ -147,6 +144,7 @@ void UBLibNavigatorWidget::removeNextChainedElements(UBChainedLibElement *fromEl
if(NULL != fromElem->nextElement()) if(NULL != fromElem->nextElement())
{ {
removeNextChainedElements(fromElem->nextElement()); removeNextChainedElements(fromElem->nextElement());
delete fromElem->nextElement()->element();
delete fromElem->nextElement(); delete fromElem->nextElement();
fromElem->setNextElement(NULL); fromElem->setNextElement(NULL);
} }

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

@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <QDebug> #include <QDebug>
#include "UBLibPalette.h"
#include "UBLibWidget.h"
#include "core/memcheck.h" #include "core/memcheck.h"
/** /**
@ -22,27 +22,20 @@
* @param parent as the parent widget * @param parent as the parent widget
* @param name as the object name * @param name as the object name
*/ */
UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(parent, name) UBLibWidget::UBLibWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent)
, mLayout(NULL) , mLayout(NULL)
, mStackedWidget(NULL) , mStackedWidget(NULL)
, mNavigator(NULL) , mNavigator(NULL)
, mProperties(NULL) , mProperties(NULL)
, mActionBar(NULL) , mActionBar(NULL)
, mDropWidget(NULL)
{ {
setOrientation(eUBDockOrientation_Right); setObjectName(name);
//mIcon = QPixmap(":images/paletteLibrary.png"); mName = "LibWidget";
mCollapsedIcon = QPixmap(":images/library_open.png"); mIconToLeft = QPixmap(":images/library_open.png");
mIcon = QPixmap(":images/library_close.png"); mIconToRight = QPixmap(":images/library_close.png");
setAcceptDrops(true); setAcceptDrops(true);
resize(UBSettings::settings()->libPaletteWidth->get().toInt(), parentWidget()->height());
setContentsMargins(border(), 0, 0, 0);
mCollapseWidth = 180;
mLastWidth = 300;
mLayout = new QVBoxLayout(this); mLayout = new QVBoxLayout(this);
mLayout->setContentsMargins(20, customMargin(), customMargin(), customMargin());
setLayout(mLayout); setLayout(mLayout);
// Build the GUI // Build the GUI
@ -50,14 +43,12 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare
mActionBar = new UBLibActionBar(this); mActionBar = new UBLibActionBar(this);
mNavigator = new UBLibNavigatorWidget(this); mNavigator = new UBLibNavigatorWidget(this);
mProperties = new UBLibItemProperties(this); mProperties = new UBLibItemProperties(this);
//mDropWidget = new UBDropMeWidget(this);
mLayout->addWidget(mStackedWidget, 1); mLayout->addWidget(mStackedWidget, 1);
mLayout->addWidget(mActionBar, 0); mLayout->addWidget(mActionBar, 0);
mStackedWidget->addWidget(mNavigator); mStackedWidget->addWidget(mNavigator);
mStackedWidget->addWidget(mProperties); mStackedWidget->addWidget(mProperties);
//mStackedWidget->addWidget(mDropWidget);
mStackedWidget->setCurrentIndex(ID_NAVIGATOR); mStackedWidget->setCurrentIndex(ID_NAVIGATOR);
miCrntStackWidget = ID_NAVIGATOR; miCrntStackWidget = ID_NAVIGATOR;
@ -69,19 +60,8 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare
/** /**
* \brief Destructor * \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; delete mProperties;
@ -92,42 +72,20 @@ UBLibPalette::~UBLibPalette()
delete mActionBar; delete mActionBar;
mActionBar = NULL; 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 * \brief Handles the drag enter event
* @param pEvent as the drag enter event * @param pEvent as the drag enter event
*/ */
void UBLibPalette::dragEnterEvent(QDragEnterEvent *pEvent) void UBLibWidget::dragEnterEvent(QDragEnterEvent *pEvent)
{ {
setBackgroundRole(QPalette::Highlight); setBackgroundRole(QPalette::Highlight);
//mStackedWidget->setCurrentIndex(ID_DROPME);
pEvent->acceptProposedAction(); pEvent->acceptProposedAction();
} }
void UBLibPalette::dragLeaveEvent(QDragLeaveEvent *pEvent) void UBLibWidget::dragLeaveEvent(QDragLeaveEvent *pEvent)
{ {
//mStackedWidget->setCurrentIndex(miCrntStackWidget);
pEvent->accept(); pEvent->accept();
} }
@ -135,7 +93,7 @@ void UBLibPalette::dragLeaveEvent(QDragLeaveEvent *pEvent)
* \brief Handles the drop event * \brief Handles the drop event
* @param pEvent as the drop event * @param pEvent as the drop event
*/ */
void UBLibPalette::dropEvent(QDropEvent *pEvent) void UBLibWidget::dropEvent(QDropEvent *pEvent)
{ {
processMimeData(pEvent->mimeData()); processMimeData(pEvent->mimeData());
setBackgroundRole(QPalette::Dark); setBackgroundRole(QPalette::Dark);
@ -147,7 +105,7 @@ void UBLibPalette::dropEvent(QDropEvent *pEvent)
* \brief Handles the drag move event * \brief Handles the drag move event
* @param pEvent as the drag move event * @param pEvent as the drag move event
*/ */
void UBLibPalette::dragMoveEvent(QDragMoveEvent *pEvent) void UBLibWidget::dragMoveEvent(QDragMoveEvent *pEvent)
{ {
pEvent->acceptProposedAction(); pEvent->acceptProposedAction();
} }
@ -156,7 +114,7 @@ void UBLibPalette::dragMoveEvent(QDragMoveEvent *pEvent)
* \brief Process the dropped MIME data * \brief Process the dropped MIME data
* @param pData as the mime dropped 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 // Display the different mime types contained in the mime data
QStringList qslFormats = pData->formats(); QStringList qslFormats = pData->formats();
@ -164,23 +122,9 @@ void UBLibPalette::processMimeData(const QMimeData *pData)
{ {
qDebug() << "Dropped element format " << i << " = "<< qslFormats.at(i); qDebug() << "Dropped element format " << i << " = "<< qslFormats.at(i);
} }
// mNavigator->dropMe(pData);
} }
void UBLibPalette::mouseMoveEvent(QMouseEvent *event) void UBLibWidget::showProperties(UBLibElement *elem)
{
if(mCanResize)
{
UBDockPalette::mouseMoveEvent(event);
}
else
{
//qDebug() << "Mouse move event detected!" ;
}
}
void UBLibPalette::showProperties(UBLibElement *elem)
{ {
if(NULL != elem) if(NULL != elem)
{ {
@ -192,43 +136,19 @@ void UBLibPalette::showProperties(UBLibElement *elem)
} }
} }
void UBLibPalette::showFolder() void UBLibWidget::showFolder()
{ {
mActionBar->setButtons(mActionBar->previousButtonSet()); mActionBar->setButtons(mActionBar->previousButtonSet());
mStackedWidget->setCurrentIndex(ID_NAVIGATOR); mStackedWidget->setCurrentIndex(ID_NAVIGATOR);
miCrntStackWidget = ID_NAVIGATOR; miCrntStackWidget = ID_NAVIGATOR;
} }
void UBLibPalette::resizeEvent(QResizeEvent *event) int UBLibWidget::customMargin()
{ {
UBDockPalette::resizeEvent(event); return 5;
UBSettings::settings()->libPaletteWidth->set(width());
emit resized();
} }
// -------------------------------------------------------------------------- int UBLibWidget::border()
UBDropMeWidget::UBDropMeWidget(QWidget *parent, const char *name):QWidget(parent)
, mpLabel(NULL)
, mpLayout(NULL)
{ {
setObjectName(name); return 15;
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;
}
} }

@ -12,8 +12,8 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef UBLIBPALETTE_H #ifndef UBLIBWIDGET_H
#define UBLIBPALETTE_H #define UBLIBWIDGET_H
#include <QWidget> #include <QWidget>
#include <QVBoxLayout> #include <QVBoxLayout>
@ -26,46 +26,32 @@
#include <QResizeEvent> #include <QResizeEvent>
#include <QLabel> #include <QLabel>
#include "UBDockPalette.h" #include "UBDockPaletteWidget.h"
#include "UBLibNavigatorWidget.h" #include "UBLibNavigatorWidget.h"
#include "UBLibItemProperties.h" #include "UBLibItemProperties.h"
#include "UBLibActionBar.h" #include "UBLibActionBar.h"
#define ID_NAVIGATOR 0 #define ID_NAVIGATOR 0
#define ID_PROPERTIES 1 #define ID_PROPERTIES 1
#define ID_DROPME 2
class UBDropMeWidget : public QWidget class UBLibWidget : public UBDockPaletteWidget
{
public:
UBDropMeWidget(QWidget* parent=0, const char* name="dropMeWidget");
~UBDropMeWidget();
private:
QLabel* mpLabel;
QVBoxLayout* mpLayout;
};
class UBLibPalette : public UBDockPalette
{ {
Q_OBJECT Q_OBJECT
public: public:
UBLibPalette(QWidget* parent=0, const char* name="libPalette"); UBLibWidget(QWidget* parent=0, const char* name="UBLibWidget");
~UBLibPalette(); ~UBLibWidget();
UBLibActionBar* actionBar(){return mActionBar;} UBLibActionBar* actionBar(){return mActionBar;}
UBLibNavigatorWidget* libNavigator() {return mNavigator;};
signals: signals:
void resized(); void resized();
protected: protected:
void updateMaxWidth();
void dragEnterEvent(QDragEnterEvent* pEvent); void dragEnterEvent(QDragEnterEvent* pEvent);
void dropEvent(QDropEvent *pEvent); void dropEvent(QDropEvent *pEvent);
void dragMoveEvent(QDragMoveEvent* pEvent); void dragMoveEvent(QDragMoveEvent* pEvent);
void dragLeaveEvent(QDragLeaveEvent* pEvent); void dragLeaveEvent(QDragLeaveEvent* pEvent);
void mouseMoveEvent(QMouseEvent *event);
void resizeEvent(QResizeEvent *event);
private slots: private slots:
void showProperties(UBLibElement* elem); void showProperties(UBLibElement* elem);
@ -73,6 +59,8 @@ private slots:
private: private:
void processMimeData(const QMimeData* pData); void processMimeData(const QMimeData* pData);
int customMargin();
int border();
/** The layout */ /** The layout */
QVBoxLayout* mLayout; QVBoxLayout* mLayout;
@ -84,10 +72,8 @@ private:
UBLibItemProperties* mProperties; UBLibItemProperties* mProperties;
/** UBLibActionBar */ /** UBLibActionBar */
UBLibActionBar* mActionBar; UBLibActionBar* mActionBar;
/** The 'drop here' indicator */
UBDropMeWidget* mDropWidget;
/** The current stack widget index*/ /** The current stack widget index*/
int miCrntStackWidget; int miCrntStackWidget;
}; };
#endif // UBLIBPALETTE_H #endif // UBLIBWIDGET_H

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

@ -29,7 +29,10 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include "UBThumbnailWidget.h" #include "UBThumbnailWidget.h"
#include "board/UBLibraryController.h"
class UBLibraryController;
class UBChainedLibElement;
class UBLibElement;
class UBLibraryWidget : public UBThumbnailWidget class UBLibraryWidget : public UBThumbnailWidget
{ {
@ -44,6 +47,8 @@ public:
void updateThumbnailsSize(int newSize); void updateThumbnailsSize(int newSize);
void init(); void init();
UBLibraryController* libraryController() {return mLibraryController;};
public slots: public slots:
void onRefreshCurrentFolder(); void onRefreshCurrentFolder();
void onElementsDropped(QList<QString> elements, UBLibElement* target); void onElementsDropped(QList<QString> elements, UBLibElement* target);
@ -71,14 +76,13 @@ private:
void appendChainedElement(UBChainedLibElement* element, UBChainedLibElement* toElem); void appendChainedElement(UBChainedLibElement* element, UBChainedLibElement* toElem);
UBLibElement* elementAt(QPoint p); UBLibElement* elementAt(QPoint p);
UBLibElement* elementFromFilePath(const QString& filePath); UBLibElement* elementFromFilePath(const QString& filePath);
UBLibraryController* libraryController(); UBLibraryController* mLibraryController;
UBLibElement* mpCrntDir; UBLibElement* mpCrntDir;
UBLibElement* mpCrntElem; UBLibElement* mpCrntElem;
QList<UBLibElement*> mCurrentElems; QList<UBLibElement*> mCurrentElems;
QList<UBLibElement*> mOrigCurrentElems; QList<UBLibElement*> mOrigCurrentElems;
QList<QGraphicsItem*> mItems; QList<QGraphicsItem*> mItems;
QString mCrntPath;
}; };

@ -1,43 +1,116 @@
#include <QtGui>
#include "UBMagnifer.h" #include "UBMagnifer.h"
#include <QPainter>
#include <QPixmap> #include "core/UBApplication.h"
#include <QDebug> #include "board/UBBoardController.h"
#include <QWidget> #include "domain/UBGraphicsScene.h"
#include <QGraphicsView>
#include <QTimerEvent> // #include <QPainter>
#include <QBitmap> // #include <QPixmap>
#include <QPen> // #include <QDebug>
// #include <QWidget>
UBMagnifer::UBMagnifer(QWidget *parent) // #include <QGraphicsView>
: QWidget(parent) // #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) , gView(0)
, mView(0) , mView(0)
, sizePercentFromScene(20)
, inTimer(false) , inTimer(false)
, borderPen(Qt::darkGray) , 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) if (timerUpdate != 0)
{ {
killTimer(timerUpdate); killTimer(timerUpdate);
timerUpdate = 0; 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 // calculate object size
sizePercentFromScene = percentFromScene; params.sizePercentFromScene = percentFromScene;
QSize sceneSize = gView->size(); QSize sceneSize = mView->size();
int size = sizePercentFromScene * sceneSize.width() / 100; qreal size = params.sizePercentFromScene * sceneSize.width() / 100;
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); setGeometry(0, 0, size, size);
// prepare transparent bit mask // prepare transparent bit mask
@ -45,7 +118,7 @@ void UBMagnifer::setSize(int percentFromScene)
mask_img.fill(0xff); mask_img.fill(0xff);
QPainter mask_ptr(&mask_img); QPainter mask_ptr(&mask_img);
mask_ptr.setBrush( QBrush( QColor(0, 0, 0) ) ); 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); bmpMask = QBitmap::fromImage(mask_img);
// prepare general image // prepare general image
@ -54,49 +127,207 @@ void UBMagnifer::setSize(int percentFromScene)
pMap.setMask(bmpMask); pMap.setMask(bmpMask);
} }
void UBMagnifer::setZoom(int z) void UBMagnifier::setZoom(qreal zoom)
{
params.zoom = zoom;
}
void UBMagnifier::paintEvent(QPaintEvent * event)
{
QPainter painter(this);
// painter.drawRect(0,0,size().width()-1, size().height()-1);
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(Qt::NoPen);
if (m_isInteractive)
{
painter.setBrush(QColor(127, 127, 127, 127));
painter.drawRoundedRect(QRectF(size().width() / 2, size().height() / 2, ( size().width() - sClosePixmap->width() ) / 2, ( size().height() - sClosePixmap->width() ) / 2), 15, 15);
painter.setBrush(QColor(190, 190, 190, 255));
painter.drawEllipse(QPoint( size().width() / 2, size().height() / 2), ( size().width() - sClosePixmap->width() ) / 2, ( size().height() - sClosePixmap->height() ) / 2);
painter.drawPixmap(size().width() - sClosePixmap->width(), size().height() / 2 + sClosePixmap->height() * 1, *sClosePixmap);
painter.drawPixmap(size().width() - sIncreasePixmap->width(), size().height() / 2 + sIncreasePixmap->height() * 2.5, *sIncreasePixmap);
painter.drawPixmap(size().width() - sDecreasePixmap->width(), size().height() / 2 + sDecreasePixmap->height() * 3.6, *sDecreasePixmap);
painter.drawPixmap(size().width() - mResizeItem->width() - 20, size().height() - mResizeItem->height() - 20, *mResizeItem);
}
else
{
painter.setBrush(QColor(127, 127, 127, 127));
painter.drawEllipse(QPoint( size().width() / 2, size().height() / 2), ( size().width() - sClosePixmap->width() ) / 2, ( size().height() - sClosePixmap->height() ) / 2);
}
painter.drawPixmap(0, 0, pMap);
}
void UBMagnifier::mousePressEvent ( QMouseEvent * event )
{
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 UBMagnifier::mouseMoveEvent ( QMouseEvent * event )
{ {
zoom = z; 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);
zWidth = size().width() / zoom; event->ignore();
zWidthHalf = zWidth / 2; return;
zHeight = size().height() / zoom; }
zHeightHalf = zHeight / 2;
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 UBMagnifer::paintEvent(QPaintEvent *)
void UBMagnifier::mouseReleaseEvent(QMouseEvent * event)
{ {
QPainter p(this); if(m_isInteractive)
p.drawPixmap(0, 0, pMap); {
mShouldMoveWidget = false;
// in future replace to image border mShouldResizeWidget = false;
QPen pen(Qt::darkGray);
pen.setWidth(2); if (event->pos().x() >= size().width() - sClosePixmap->width() &&
p.setPen(borderPen); event->pos().x() < size().width()&&
p.drawEllipse(QPoint( size().width() / 2, size().height() / 2), size().width() / 2, size().height() / 2); event->pos().y() >= size().height() / 2 + sClosePixmap->height() * 1 &&
event->pos().y() < size().height() / 2 + sClosePixmap->height() * 2)
{
event->accept();
emit magnifierClose_Signal();
}
else
if (event->pos().x() >= size().width() - sIncreasePixmap->width() &&
event->pos().x() < size().width()&&
event->pos().y() >= size().height() / 2 + sIncreasePixmap->height() * 2.5 &&
event->pos().y() < size().height() / 2 + sIncreasePixmap->height() * 3.5)
{
event->accept();
emit magnifierZoomIn_Signal();
}
else
if (event->pos().x() >= size().width() - sDecreasePixmap->width() &&
event->pos().x() < size().width()&&
event->pos().y() >= size().height() / 2 + sDecreasePixmap->height() * 3.6 &&
event->pos().y() < size().height() / 2 + sDecreasePixmap->height() * 4.6)
{
event->accept();
emit magnifierZoomOut_Signal();
}
else
QWidget::mouseReleaseEvent(event); // don't propgate to parent, the widget is deleted in UBApplication::boardController->removeTool
}
else
event->ignore();
} }
void UBMagnifer::timerEvent(QTimerEvent *e) void UBMagnifier::timerEvent(QTimerEvent *e)
{ {
if(inTimer) return; if(inTimer) return;
if (e->timerId() == timerUpdate) if (e->timerId() == timerUpdate)
{ {
inTimer = true; inTimer = true;
if(!(updPoint.isNull())) grabPoint(updPoint); if(!(updPointGrab.isNull()))
if(!(updPointF.isNull()))grabPoint(updPointF); 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; 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 x = itemPos.x() - zWidthHalf;
int y = itemPos.y() - zHeightHalf; int y = itemPos.y() - zHeightHalf;
QPixmap newPixMap(QSize(zWidth,zHeight)); QPixmap newPixMap(QSize(zWidth,zHeight));
((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight)); ((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight));
UBApplication::boardController->activeScene()->update();
pMap.fill(Qt::transparent); pMap.fill(Qt::transparent);
pMap = newPixMap.scaled(QSize(width(), height())); pMap = newPixMap.scaled(QSize(width(), height()));
pMap.setMask(bmpMask); pMap.setMask(bmpMask);
@ -104,15 +335,23 @@ void UBMagnifer::grabPoint(const QPoint &point)
update(); 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 x = itemPos.x() - zWidthHalf;
int y = itemPos.y() - zHeightHalf; int y = itemPos.y() - zHeightHalf;
QPixmap newPixMap(QSize(zWidth,zHeight)); QPixmap newPixMap(QSize(zWidth,zHeight));
((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight)); ((QWidget*)gView)->render(&newPixMap, QPoint(0, 0), QRegion(x, y, zWidth, zHeight));
UBApplication::boardController->activeScene()->update();
pMap.fill(Qt::transparent); pMap.fill(Qt::transparent);
pMap = newPixMap.scaled(QSize(width(), height())); pMap = newPixMap.scaled(QSize(width(), height()));
pMap.setMask(bmpMask); pMap.setMask(bmpMask);
@ -120,32 +359,24 @@ void UBMagnifer::grabPoint(const QPointF &point)
update(); update();
} }
// from global // 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) if(needGrab)
grabPoint(point); grabPoint(pGrab);
QPoint itemPos = mView->mapFromGlobal(point);
move(itemPos.x() - width()/2, itemPos.y() - height()/2);
// move(itemPos.x(), itemPos.y());
}
// from scene
void UBMagnifer::grabNMove(const QPointF &point, bool needGrab = true)
{
updPointF = point;
if(needGrab) if(needMove)
grabPoint(point); {
QPoint itemPos = mView->mapFromScene(point); QPoint movePos = mView->mapFromGlobal(pMove);
move(itemPos.x() - width()/2, itemPos.y() - height()/2); move(movePos.x() - width()/2, movePos.y() - height()/2);
// move(itemPos.x(), itemPos.y()); // move(itemPos.x(), itemPos.y());
}
} }
void UBMagnifer::setGrabView(QGraphicsView *view) void UBMagnifier::setGrabView(QWidget *view)
{ {
if (timerUpdate != 0) if (timerUpdate != 0)
killTimer(timerUpdate); killTimer(timerUpdate);

@ -1,60 +1,82 @@
#ifndef UBMAGNIFER_H #ifndef UBMAGNIFIER_H
#define UBMAGNIFER_H #define UBMAGNIFIER_H
#include <QWidget> #include <QtGui>
#include <QBitmap>
#include <QPen>
class QPixmap; class UBMagnifierParams
class QBitmap; {
class QPen; public :
class QGraphicsView; int x;
int y;
qreal zoom;
qreal sizePercentFromScene;
};
class UBMagnifer : public QWidget class UBMagnifier : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
UBMagnifer(QWidget *parent = 0); UBMagnifier(QWidget *parent = 0, bool isInteractive = false);
~UBMagnifer(); ~UBMagnifier();
void setSize(int percentFromScene); void setSize(qreal percentFromScene);
void setZoom(int z); void setZoom(qreal zoom);
void setGrabView(QGraphicsView *view); void setGrabView(QWidget *view);
void setMoveView(QGraphicsView *view) {mView = view;} void setMoveView(QWidget *view) {mView = view;}
void grabPoint();
void grabPoint(const QPoint &point); void grabPoint(const QPoint &point);
void grabPoint(const QPointF &point); void grabNMove(const QPoint &pGrab, const QPoint &pMove, bool needGrab = true, bool needMove = true);
void grabNMove(const QPoint &point, bool needGrab);
void grabNMove(const QPointF &point, bool needGrab); UBMagnifierParams params;
signals:
void magnifierMoved_Signal(QPoint newPos);
void magnifierClose_Signal();
void magnifierZoomIn_Signal();
void magnifierZoomOut_Signal();
void magnifierResized_Signal(qreal newPercentSize);
protected: protected:
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *);
void timerEvent(QTimerEvent *); 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: private:
int zoom;
int zWidth;
int zHeight;
int zWidthHalf;
int zHeightHalf;
bool inTimer; bool inTimer;
bool m_isInteractive;
int timerUpdate; int timerUpdate;
QPoint updPoint; QPoint updPointGrab;
QPointF updPointF; QPoint updPointMove;
QPixmap pMap; QPixmap pMap;
QBitmap bmpMask; QBitmap bmpMask;
QPen borderPen; QPen borderPen;
QGraphicsView *gView; QWidget *gView;
QGraphicsView *mView; QWidget *mView;
}; };
#endif // UBMAGNIFER_H #endif // UBMAGNIFIER_H

@ -32,9 +32,8 @@ UBNavigatorPalette::UBNavigatorPalette(QWidget *parent, const char *name):UBDock
{ {
setOrientation(eUBDockOrientation_Left); setOrientation(eUBDockOrientation_Left);
setMaximumWidth(300); setMaximumWidth(300);
//mIcon = QPixmap(":images/paletteNavigator.png"); //mCollapsedIcon = QPixmap(":images/pages_open.png");
mCollapsedIcon = QPixmap(":images/pages_open.png"); //mIcon = QPixmap(":images/pages_close.png");
mIcon = QPixmap(":images/pages_close.png");
resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), height()); resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), height());
mLastWidth = 300; 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->actionPen;
actions << UBApplication::mainWindow->actionEraser; actions << UBApplication::mainWindow->actionEraser;
actions << UBApplication::mainWindow->actionMagnifier;
actions << UBApplication::mainWindow->actionMarker; actions << UBApplication::mainWindow->actionMarker;
actions << UBApplication::mainWindow->actionSelector; actions << UBApplication::mainWindow->actionSelector;

@ -29,7 +29,6 @@ HEADERS += src/gui/UBThumbnailView.h \
src/gui/UBFavoriteToolPalette.h \ src/gui/UBFavoriteToolPalette.h \
src/gui/UBKeyboardPalette.h \ src/gui/UBKeyboardPalette.h \
src/gui/UBNavigatorPalette.h \ src/gui/UBNavigatorPalette.h \
src/gui/UBLibPalette.h \
src/gui/UBDocumentNavigator.h \ src/gui/UBDocumentNavigator.h \
src/gui/UBDockPalette.h \ src/gui/UBDockPalette.h \
src/gui/UBPropertyPalette.h \ src/gui/UBPropertyPalette.h \
@ -39,6 +38,11 @@ HEADERS += src/gui/UBThumbnailView.h \
src/gui/UBLibraryWidget.h \ src/gui/UBLibraryWidget.h \
src/gui/UBLibPathViewer.h \ src/gui/UBLibPathViewer.h \
src/gui/UBUpdateDlg.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 src/gui/UBMagnifer.h
SOURCES += src/gui/UBThumbnailView.cpp \ SOURCES += src/gui/UBThumbnailView.cpp \
@ -71,7 +75,6 @@ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBFavoriteToolPalette.cpp \ src/gui/UBFavoriteToolPalette.cpp \
src/gui/UBKeyboardPalette.cpp \ src/gui/UBKeyboardPalette.cpp \
src/gui/UBNavigatorPalette.cpp \ src/gui/UBNavigatorPalette.cpp \
src/gui/UBLibPalette.cpp \
src/gui/UBDocumentNavigator.cpp \ src/gui/UBDocumentNavigator.cpp \
src/gui/UBDockPalette.cpp \ src/gui/UBDockPalette.cpp \
src/gui/UBPropertyPalette.cpp \ src/gui/UBPropertyPalette.cpp \
@ -81,6 +84,11 @@ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBLibraryWidget.cpp \ src/gui/UBLibraryWidget.cpp \
src/gui/UBLibPathViewer.cpp \ src/gui/UBLibPathViewer.cpp \
src/gui/UBUpdateDlg.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 src/gui/UBMagnifer.cpp
win32 { win32 {

@ -25,6 +25,8 @@ QAtomicInt XPDFRenderer::sInstancesCount = 0;
XPDFRenderer::XPDFRenderer(const QString &filename, bool importingFile) XPDFRenderer::XPDFRenderer(const QString &filename, bool importingFile)
: mDocument(0) : mDocument(0)
, mpSplashBitmap(0)
, mSplash(0)
{ {
if (!globalParams) 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 mDocument = new PDFDoc(new GString(filename.toUtf8().data()), 0, 0, 0); // the filename GString is deleted on PDFDoc desctruction
sInstancesCount.ref(); sInstancesCount.ref();
bThumbGenerated = !importingFile; bThumbGenerated = !importingFile;
bPagesGenerated = false;
mPagesMap.clear(); mPagesMap.clear();
mThumbs.clear(); mThumbs.clear();
mThumbMap.clear(); mThumbMap.clear();
@ -48,6 +49,17 @@ XPDFRenderer::XPDFRenderer(const QString &filename, bool importingFile)
XPDFRenderer::~XPDFRenderer() XPDFRenderer::~XPDFRenderer()
{ {
qDeleteAll(mThumbs);
mThumbs.clear();
qDeleteAll(mNumPageToPageMap);
mNumPageToPageMap.clear();
if(mSplash){
delete mSplash;
mSplash = NULL;
}
if (mDocument) if (mDocument)
{ {
delete mDocument; delete mDocument;
@ -141,7 +153,6 @@ void XPDFRenderer::render(QPainter *p, int pageNumber, const QRectF &bounds)
qreal xscale = p->worldTransform().m11(); qreal xscale = p->worldTransform().m11();
qreal yscale = p->worldTransform().m22(); qreal yscale = p->worldTransform().m22();
bool bZoomChanged = false; bool bZoomChanged = false;
bool bFirstThumbnail = false;
if(fabs(mScaleX - xscale) > 0.1 || fabs(mScaleY - yscale) > 0.1) 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; bZoomChanged = true;
} }
QImage *pdfImage;
// First verify if the thumbnails and the pages are generated // First verify if the thumbnails and the pages are generated
if(!bThumbGenerated) if(!bThumbGenerated)
{ {
if(pageNumber == 1)
{
bFirstThumbnail = true;
}
if(!mThumbMap[pageNumber - 1]) if(!mThumbMap[pageNumber - 1])
{ {
// Generate the thumbnail // Generate the thumbnail
mThumbs << *createPDFImage(pageNumber, xscale, yscale, bounds); mThumbs << createPDFImage(pageNumber, xscale, yscale, bounds);
mThumbMap[pageNumber - 1] = true; mThumbMap[pageNumber - 1] = true;
pdfImage = mThumbs.at(pageNumber - 1);
if(pageNumber == mDocument->getNumPages()) if(pageNumber == mDocument->getNumPages())
{ {
bThumbGenerated = true; bThumbGenerated = true;
} }
} }
} }
else if(!bPagesGenerated || bZoomChanged) else
{ {
if(!mPagesMap[pageNumber - 1] || bZoomChanged) if(!mPagesMap[pageNumber - 1] || bZoomChanged)
{ {
// Generate the page // 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; mPagesMap[pageNumber - 1] = true;
if(mPagesMap.size() == mDocument->getNumPages())
{
bPagesGenerated = true;
}
}
}
QImage pdfImage;
if(!bThumbGenerated || bFirstThumbnail)
{
pdfImage = mThumbs.at(pageNumber - 1);
}
else
{
pdfImage = mNumPageToPageMap[pageNumber]; pdfImage = mNumPageToPageMap[pageNumber];
} }
}
QTransform savedTransform = p->worldTransform(); QTransform savedTransform = p->worldTransform();
p->resetTransform(); p->resetTransform();
QTime t; p->drawImage(QPointF(savedTransform.dx() + mSliceX, savedTransform.dy() + mSliceY), *pdfImage);
t.start();
p->drawImage(QPointF(savedTransform.dx() + mSliceX, savedTransform.dy() + mSliceY), pdfImage);
//qDebug() << "XPDFRenderer::render(...) execution time: " << t.elapsed() << "ms";
p->setWorldTransform(savedTransform); p->setWorldTransform(savedTransform);
} }
} }
@ -211,6 +204,8 @@ QImage* XPDFRenderer::createPDFImage(int pageNumber, const qreal xscale, const q
if (isValid()) if (isValid())
{ {
SplashColor paperColor = {0xFF, 0xFF, 0xFF}; // white SplashColor paperColor = {0xFF, 0xFF, 0xFF}; // white
if(mSplash)
delete mSplash;
mSplash = new SplashOutputDev(splashModeRGB8, 1, gFalse, paperColor); mSplash = new SplashOutputDev(splashModeRGB8, 1, gFalse, paperColor);
mSplash->startDoc(mDocument->getXRef()); mSplash->startDoc(mDocument->getXRef());
int hResolution = 72; int hResolution = 72;
@ -241,6 +236,7 @@ QImage* XPDFRenderer::createPDFImage(int pageNumber, const qreal xscale, const q
} }
mpSplashBitmap = mSplash->getBitmap(); mpSplashBitmap = mSplash->getBitmap();
delete img;
img = new QImage(mpSplashBitmap->getDataPtr(), mpSplashBitmap->getWidth(), mpSplashBitmap->getHeight(), mpSplashBitmap->getWidth() * 3, QImage::Format_RGB888); img = new QImage(mpSplashBitmap->getDataPtr(), mpSplashBitmap->getWidth(), mpSplashBitmap->getHeight(), mpSplashBitmap->getWidth() * 3, QImage::Format_RGB888);
} }
return img; 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()); QImage* createPDFImage(int pageNumber, const qreal xscale = 0.5, const qreal yscale = 0.5, const QRectF &bounds = QRectF());
PDFDoc *mDocument; PDFDoc *mDocument;
QList<QImage> mThumbs; QList<QImage*> mThumbs;
QMap<int, bool> mPagesMap; QMap<int, bool> mPagesMap;
QMap<int, bool> mThumbMap; QMap<int, bool> mThumbMap;
QMap<int, QImage> mNumPageToPageMap; QMap<int, QImage*> mNumPageToPageMap;
static QAtomicInt sInstancesCount; static QAtomicInt sInstancesCount;
qreal mSliceX; qreal mSliceX;
qreal mSliceY; 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"); mToolsIcon.insert(triangle.id,":/images/toolPalette/triangleTool.png");
mDescriptors << triangle; 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() UBToolsManager::~UBToolsManager()

@ -78,6 +78,7 @@ class UBToolsManager : public QObject
UBToolDescriptor compass; UBToolDescriptor compass;
UBToolDescriptor mask; UBToolDescriptor mask;
UBToolDescriptor triangle; UBToolDescriptor triangle;
UBToolDescriptor magnifier;
QString iconFromToolId(QString id) { return mToolsIcon.value(id);} QString iconFromToolId(QString id) { return mToolsIcon.value(id);}

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

Loading…
Cancel
Save