Commit 4439697b authored by Anatoly Mihalchenko's avatar Anatoly Mihalchenko

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

parents 4b7b8917 60eacbf1
...@@ -1638,115 +1638,6 @@ ...@@ -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 @@ ...@@ -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>
<?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>
<?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>
...@@ -150,6 +150,13 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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() ...@@ -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() ...@@ -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() ...@@ -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; ...@@ -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 ...@@ -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 ...@@ -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) ...@@ -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 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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) ...@@ -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) ...@@ -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() ...@@ -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 ...@@ -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, ...@@ -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; ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 @@ ...@@ -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 ...@@ -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 ...@@ -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() ...@@ -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() ...@@ -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() ...@@ -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() ...@@ -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() ...@@ -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 @@ ...@@ -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 ...@@ -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 ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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 ...@@ -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 ...@@ -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);
......
This diff is collapsed.
...@@ -42,6 +42,7 @@ class UBLibElement ...@@ -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: ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -26,7 +26,6 @@ struct UBStylusTool
{ {
Pen = 0, Pen = 0,
Eraser, Eraser,
Magnifier,
Marker, Marker,
Selector, Selector,
Hand, Hand,
......
...@@ -38,7 +38,6 @@ ...@@ -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() ...@@ -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 ...@@ -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 ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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() ...@@ -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() ...@@ -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) ...@@ -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 @@ ...@@ -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 ...@@ -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) ...@@ -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 ...@@ -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 ...@@ -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() ...@@ -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) ...@@ -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) ...@@ -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; ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 @@ ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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() ...@@ -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() ...@@ -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 @@ ...@@ -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: ...@@ -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: ...@@ -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
#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;
}
#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
/*
* 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;
}
/*
* 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 @@ ...@@ -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 ...@@ -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 @@ ...@@ -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() ...@@ -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() ...@@ -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 @@ ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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: ...@@ -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 @@ ...@@ -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 @@ ...@@ -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 ...@@ -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 ...@@ -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() ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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 @@ ...@@ -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 @@ ...@@ -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: ...@@ -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: ...@@ -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 ...@@ -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 ...@@ -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() ...@@ -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() ...@@ -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) ...@@ -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) ...@@ -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() ...@@ -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() ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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 ...@@ -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 ...@@ -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() ...@@ -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 @@ ...@@ -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: ...@@ -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: ...@@ -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;
}; };
......
This diff is collapsed.
#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 ...@@ -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;
......
/*
* 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;
}
/*
* 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
/*
* 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());
}
/*
* 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) ...@@ -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 \ ...@@ -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 \ ...@@ -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 \ ...@@ -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 \ ...@@ -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; ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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;
......
/*
* 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;
}
/*
* 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) ...@@ -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 ...@@ -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 \ ...@@ -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 \ ...@@ -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 \
\ No newline at end of file src/tools/UBGraphicsCache.cpp
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment