Added backup of the cache widget

preferencesAboutTextFull
shibakaneki 13 years ago
parent 424dc1d89d
commit 00088f0b0b
  1. BIN
      resources/images/cache_circle.png
  2. BIN
      resources/images/cache_close.png
  3. BIN
      resources/images/cache_open.png
  4. BIN
      resources/images/cache_square.png
  5. 5
      resources/sankore.qrc
  6. 52
      resources/style.qss
  7. 25
      src/adaptors/UBSvgSubsetAdaptor.cpp
  8. 30
      src/board/UBBoardController.cpp
  9. 6
      src/board/UBBoardController.h
  10. 16
      src/core/UBApplication.cpp
  11. 1
      src/core/UBApplication.h
  12. 20
      src/domain/UBGraphicsScene.cpp
  13. 4
      src/domain/UBGraphicsScene.h
  14. 317
      src/gui/UBCachePropertiesWidget.cpp
  15. 60
      src/gui/UBCachePropertiesWidget.h
  16. 9
      src/gui/UBDockPalette.cpp
  17. 3
      src/gui/UBDockPalette.h
  18. 3
      src/gui/UBPageNavigationWidget.cpp
  19. 50
      src/gui/UBRightPalette.cpp
  20. 6
      src/gui/UBRightPalette.h
  21. 6
      src/gui/gui.pri
  22. 4
      src/tools/UBGraphicsCache.cpp
  23. 11
      src/tools/UBToolsManager.cpp
  24. 1
      src/tools/UBToolsManager.h

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 689 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 681 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

@ -317,5 +317,10 @@
<file>images/library_open.png</file> <file>images/library_open.png</file>
<file>images/pages_close.png</file> <file>images/pages_close.png</file>
<file>images/pages_open.png</file> <file>images/pages_open.png</file>
<file>images/cache_close.png</file>
<file>images/cache_open.png</file>
<file>style.qss</file>
<file>images/cache_circle.png</file>
<file>images/cache_square.png</file>
</qresource> </qresource>
</RCC> </RCC>

@ -0,0 +1,52 @@
QWidget#DockPaletteWidgetBox
{
background: #EEEEEE;
border-radius: 10px;
border: 2px solid #999999;
}
QColorDialog
{
background: #EEEEEE;
}
QLabel#DockPaletteWidgetTitle
{
color: #FFFFFF;
font-size : 18px;
font-weight:bold;
}
QPushButton#DockPaletteWidgetButton
{
background-color : #DDDDDD;
color : #555555;
border-radius : 6px;
padding : 5px;
font-weight : bold;
font-size : 12px;
}
QPushButton#DockPaletteWidgetButton::checked
{
background-color: #BBBBBB;
}
QSlider::handle::horizontal
{
background-color:#EEEEEE;
margin-top:-5px;
margin-bottom:-5px;
height:20px;
width:18px;
border-radius:10px;
border:1px solid #555555;
}
QSlider::groove::horizontal
{
background-color:#999999;
height:10px;
border-radius:5px;
border:1px solid #555555;
}

@ -48,6 +48,7 @@
#include "core/UBSettings.h" #include "core/UBSettings.h"
#include "core/UBSetting.h" #include "core/UBSetting.h"
#include "core/UBPersistenceManager.h" #include "core/UBPersistenceManager.h"
#include "core/UBApplication.h"
#include "pdf/PDFRenderer.h" #include "pdf/PDFRenderer.h"
@ -672,6 +673,7 @@ UBGraphicsScene* UBSvgSubsetAdaptor::UBSvgSubsetReader::loadScene()
{ {
scene->addItem(cache); scene->addItem(cache);
scene->registerTool(cache); scene->registerTool(cache);
UBApplication::boardController->notifyCache(true);
} }
} }
else if (mXmlReader.name() == "foreignObject") else if (mXmlReader.name() == "foreignObject")
@ -2680,7 +2682,24 @@ UBGraphicsTriangle* UBSvgSubsetAdaptor::UBSvgSubsetReader::triangleFromSvg()
UBGraphicsCache* UBSvgSubsetAdaptor::UBSvgSubsetReader::cacheFromSvg() UBGraphicsCache* UBSvgSubsetAdaptor::UBSvgSubsetReader::cacheFromSvg()
{ {
UBGraphicsCache* pCache = new UBGraphicsCache(); UBGraphicsCache* pCache = new UBGraphicsCache();
//pCache->setZValue(UBGraphicsScene::toolLayerStart + UBGraphicsScene::toolOffsetCache);
pCache->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool)); pCache->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Tool));
graphicsItemFromSvg(pCache);
QStringRef colorR = mXmlReader.attributes().value("colorR");
QStringRef colorG = mXmlReader.attributes().value("colorG");
QStringRef colorB = mXmlReader.attributes().value("colorB");
QStringRef colorA = mXmlReader.attributes().value("colorA");
QStringRef shape = mXmlReader.attributes().value("shape");
QStringRef shapeSize = mXmlReader.attributes().value("shapeSize");
QColor color(colorR.toString().toInt(), colorG.toString().toInt(), colorB.toString().toInt(), colorA.toString().toInt());
pCache->setMaskColor(color);
pCache->setShapeWidth(shapeSize.toString().toInt());
pCache->setMaskShape(static_cast<eMaskShape>(shape.toString().toInt()));
pCache->setVisible(true); pCache->setVisible(true);
return pCache; return pCache;
@ -2694,6 +2713,12 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::cacheToSvg(UBGraphicsCache* item)
mXmlWriter.writeAttribute("y", QString("%1").arg(item->rect().y())); mXmlWriter.writeAttribute("y", QString("%1").arg(item->rect().y()));
mXmlWriter.writeAttribute("width", QString("%1").arg(item->rect().width())); mXmlWriter.writeAttribute("width", QString("%1").arg(item->rect().width()));
mXmlWriter.writeAttribute("height", QString("%1").arg(item->rect().height())); mXmlWriter.writeAttribute("height", QString("%1").arg(item->rect().height()));
mXmlWriter.writeAttribute("colorR", QString("%1").arg(item->maskColor().red()));
mXmlWriter.writeAttribute("colorG", QString("%1").arg(item->maskColor().green()));
mXmlWriter.writeAttribute("colorB", QString("%1").arg(item->maskColor().blue()));
mXmlWriter.writeAttribute("colorA", QString("%1").arg(item->maskColor().alpha()));
mXmlWriter.writeAttribute("shape", QString("%1").arg(item->maskshape()));
mXmlWriter.writeAttribute("shapeSize", QString("%1").arg(item->shapeWidth()));
QString zs; QString zs;
zs.setNum(item->zValue(), 'f'); // 'f' keeps precision zs.setNum(item->zValue(), 'f'); // 'f' keeps precision

@ -484,6 +484,7 @@ void UBBoardController::addScene(UBDocumentProxy* proxy, int sceneIndex, bool re
if (scene) if (scene)
{ {
addScene(scene, replaceActiveIfEmpty); addScene(scene, replaceActiveIfEmpty);
emit pageChanged();
} }
} }
@ -501,6 +502,8 @@ void UBBoardController::duplicateScene()
setActiveDocumentScene(mActiveDocument, mActiveSceneIndex + 1); setActiveDocumentScene(mActiveDocument, mActiveSceneIndex + 1);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
emit pageChanged();
} }
@ -669,6 +672,7 @@ void UBBoardController::previousScene()
} }
updateActionStates(); updateActionStates();
emit pageChanged();
} }
@ -683,7 +687,7 @@ void UBBoardController::nextScene()
} }
updateActionStates(); updateActionStates();
emit pageChanged();
} }
@ -698,6 +702,7 @@ void UBBoardController::firstScene()
} }
updateActionStates(); updateActionStates();
emit pageChanged();
} }
@ -712,6 +717,7 @@ void UBBoardController::lastScene()
} }
updateActionStates(); updateActionStates();
emit pageChanged();
} }
@ -1017,6 +1023,11 @@ 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()->cache.id)
{
mActiveScene->addCache();
UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector);
}
else if (sourceUrl.toString() == UBToolsManager::manager()->magnifier.id) else if (sourceUrl.toString() == UBToolsManager::manager()->magnifier.id)
{ {
UBMagnifierParams params; UBMagnifierParams params;
@ -1516,6 +1527,17 @@ void UBBoardController::setPageSize(QSize newSize)
} }
} }
void UBBoardController::notifyCache(bool visible)
{
if(visible)
{
emit cacheEnabled();
}
else
{
emit cacheDisabled();
}
}
void UBBoardController::updatePageSizeState() void UBBoardController::updatePageSizeState()
{ {
@ -1928,7 +1950,6 @@ void UBBoardController::addItem()
} }
} }
void UBBoardController::importPage() void UBBoardController::importPage()
{ {
int pageCount = mActiveDocument->pageCount(); int pageCount = mActiveDocument->pageCount();
@ -1939,7 +1960,10 @@ void UBBoardController::importPage()
} }
} }
void UBBoardController::notifyPageChanged()
{
emit pageChanged();
}

@ -157,6 +157,9 @@ class UBBoardController : public QObject
return mPaletteManager; return mPaletteManager;
} }
void notifyCache(bool visible);
void notifyPageChanged();
public slots: public slots:
void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0); void setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, int pSceneIndex = 0);
@ -255,6 +258,9 @@ class UBBoardController : public QObject
void controlViewportChanged(); void controlViewportChanged();
void backgroundChanged(); void backgroundChanged();
void cacheEnabled();
void cacheDisabled();
void pageChanged();
protected: protected:

@ -600,3 +600,19 @@ void UBStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment,
if (textRole != QPalette::NoRole) if (textRole != QPalette::NoRole)
painter->setPen(savedPen); painter->setPen(savedPen);
} }
QString UBApplication::globalStyleSheet()
{
QString style;
QFile f(":style.qss");
if(f.exists())
{
if(f.open(QIODevice::ReadOnly))
{
style = QString(f.readAll());
}
}
return style;
}

@ -78,6 +78,7 @@ class UBApplication : public QtSingleApplication
static void setDisabled(bool disable); static void setDisabled(bool disable);
static QObject* staticMemoryCleaner; static QObject* staticMemoryCleaner;
static QString globalStyleSheet();
void decorateActionMenu(QAction* action); void decorateActionMenu(QAction* action);
void insertSpaceToToolbarBeforeAction(QToolBar* toolbar, QAction* action, int width = -1); void insertSpaceToToolbarBeforeAction(QToolBar* toolbar, QAction* action, int width = -1);

@ -36,6 +36,7 @@
#include "tools/UBGraphicsCompass.h" #include "tools/UBGraphicsCompass.h"
#include "tools/UBGraphicsTriangle.h" #include "tools/UBGraphicsTriangle.h"
#include "tools/UBGraphicsCurtainItem.h" #include "tools/UBGraphicsCurtainItem.h"
#include "tools/UBGraphicsCache.h"
#include "document/UBDocumentProxy.h" #include "document/UBDocumentProxy.h"
@ -1626,6 +1627,25 @@ void UBGraphicsScene::addCompass(QPointF center)
setModified(true); setModified(true);
} }
void UBGraphicsScene::addCache()
{
UBGraphicsCache* cache = new UBGraphicsCache();
mTools << cache;
QGraphicsView* view;
if(UBApplication::applicationController->displayManager()->hasDisplay())
{
view = (QGraphicsView*)(UBApplication::boardController->displayView());
}
else
{
view = (QGraphicsView*)(UBApplication::boardController->controlView());
}
addItem(cache);
cache->setVisible(true);
cache->setSelected(true);
UBApplication::boardController->notifyCache(true);
}
void UBGraphicsScene::addMask() void UBGraphicsScene::addMask()
{ {

@ -46,6 +46,7 @@ class UBGraphicsCurtainItem;
class UBGraphicsStroke; class UBGraphicsStroke;
class UBMagnifierParams; class UBMagnifierParams;
class UBMagnifier; class UBMagnifier;
class UBGraphicsCache;
const double PI = 4.0 * atan(1.0); const double PI = 4.0 * atan(1.0);
@ -172,6 +173,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
void addMagnifier(UBMagnifierParams params); void addMagnifier(UBMagnifierParams params);
void addMask(); void addMask();
void addCache();
class SceneViewState class SceneViewState
{ {
@ -247,6 +249,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
static qreal toolOffsetCompass; static qreal toolOffsetCompass;
static qreal toolOffsetCurtain; static qreal toolOffsetCurtain;
static qreal toolOffsetTriangle; static qreal toolOffsetTriangle;
static qreal toolOffsetCache;
QSet<QGraphicsItem*> tools(){ return mTools;} QSet<QGraphicsItem*> tools(){ return mTools;}
@ -358,6 +361,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem
//int mMesure1Ms, mMesure2Ms; //int mMesure1Ms, mMesure2Ms;
bool mHasCache;
UBMagnifier *magniferControlViewWidget; UBMagnifier *magniferControlViewWidget;
UBMagnifier *magniferDisplayViewWidget; UBMagnifier *magniferDisplayViewWidget;
}; };

@ -0,0 +1,317 @@
#include <QColor>
#include <QPainter>
#include <QPixmap>
#include <QColorDialog>
#include "UBCachePropertiesWidget.h"
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "domain/UBGraphicsScene.h"
static QVector<UBGraphicsCache*> mCaches;
UBCachePropertiesWidget::UBCachePropertiesWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent)
, mpLayout(NULL)
, mpCachePropertiesLabel(NULL)
, mpColorLabel(NULL)
, mpShapeLabel(NULL)
, mpSizeLabel(NULL)
, mpColor(NULL)
, mpSquareButton(NULL)
, mpCircleButton(NULL)
, mpCloseButton(NULL)
, mpSizeSlider(NULL)
, mpColorLayout(NULL)
, mpShapeLayout(NULL)
, mpSizeLayout(NULL)
, mpCloseLayout(NULL)
, mpProperties(NULL)
, mpPropertiesLayout(NULL)
, mpCurrentCache(NULL)
{
setObjectName(name);
setAttribute(Qt::WA_StyledBackground, true);
setStyleSheet(UBApplication::globalStyleSheet());
mName = "CachePropWidget";
mIconToLeft = QPixmap(":images/cache_open.png");
mIconToRight = QPixmap(":images/cache_close.png");
setContentsMargins(10, 10, 10, 10);
// Build the UI
mpLayout = new QVBoxLayout();
setLayout(mpLayout);
// Title
mpCachePropertiesLabel = new QLabel(tr("Cache Properties"), this);
mpCachePropertiesLabel->setObjectName("DockPaletteWidgetTitle");
mpLayout->addWidget(mpCachePropertiesLabel, 0);
// Properties Box
mpProperties = new QWidget(this);
mpProperties->setObjectName("DockPaletteWidgetBox");
mpLayout->addWidget(mpProperties, 1);
mpPropertiesLayout = new QVBoxLayout();
mpProperties->setLayout(mpPropertiesLayout);
// Color
mpColorLayout = new QHBoxLayout();
mpColorLabel = new QLabel(tr("Color:"), mpProperties);
mpColor = new QPushButton(mpProperties);
mpColor->setObjectName("DockPaletteWidgetButton");
// TODO: Check in the document if the page has a color and assign it to this cache
// else set the black color by default
updateCacheColor(Qt::black);
mpColorLayout->addWidget(mpColorLabel, 0);
mpColorLayout->addWidget(mpColor, 0);
mpColorLayout->addStretch(1);
mpPropertiesLayout->addLayout(mpColorLayout, 0);
// Shape
mpShapeLayout = new QHBoxLayout();
mpShapeLabel = new QLabel(tr("Shape:"), mpProperties);
mpSquareButton = new QPushButton(mpProperties);
mpSquareButton->setIcon(QIcon(":images/cache_square.png"));
mpSquareButton->setObjectName("DockPaletteWidgetButton");
mpSquareButton->setCheckable(true);
mpCircleButton = new QPushButton(mpProperties);
mpCircleButton->setIcon(QIcon(":images/cache_circle.png"));
mpCircleButton->setObjectName("DockPaletteWidgetButton");
mpCircleButton->setCheckable(true);
mpShapeLayout->addWidget(mpShapeLabel, 0);
mpShapeLayout->addWidget(mpSquareButton, 0);
mpShapeLayout->addWidget(mpCircleButton, 0);
mpShapeLayout->addStretch(1);
mpPropertiesLayout->addLayout(mpShapeLayout, 0);
// TODO: Check in the document which shape is saved and check the corresponding button
mpCircleButton->setChecked(true);
// Shape Size
mpSizeLayout = new QHBoxLayout();
mpSizeLabel = new QLabel(tr("Size:"), mpProperties);
mpSizeSlider = new QSlider(Qt::Horizontal, mpProperties);
mpSizeSlider->setMinimumHeight(20);
mpSizeSlider->setMinimum(0);
mpSizeSlider->setMaximum(MAX_SHAPE_WIDTH);
mpSizeLayout->addWidget(mpSizeLabel, 0);
mpSizeLayout->addWidget(mpSizeSlider, 1);
mpPropertiesLayout->addLayout(mpSizeLayout, 0);
// Close
mpCloseLayout = new QHBoxLayout();
mpCloseButton = new QPushButton(tr("Close"), mpProperties);
mpCloseButton->setObjectName("DockPaletteWidgetButton");
mpCloseLayout->addWidget(mpCloseButton, 0);
mpCloseLayout->addStretch(1);
mpPropertiesLayout->addLayout(mpCloseLayout, 0);
// Fill the empty space
mpPropertiesLayout->addStretch(1);
// Connect signals / slots
connect(mpCloseButton, SIGNAL(clicked()), this, SLOT(onCloseClicked()));
connect(mpColor, SIGNAL(clicked()), this, SLOT(onColorClicked()));
connect(mpCircleButton, SIGNAL(clicked()), this, SLOT(updateShapeButtons()));
connect(mpSquareButton, SIGNAL(clicked()), this, SLOT(updateShapeButtons()));
connect(mpSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(onSizeChanged(int)));
connect(UBApplication::boardController, SIGNAL(pageChanged()), this, SLOT(updateCurrentCache()));
}
UBCachePropertiesWidget::~UBCachePropertiesWidget()
{
if(NULL != mpCachePropertiesLabel)
{
delete mpCachePropertiesLabel;
mpCachePropertiesLabel = NULL;
}
if(NULL != mpColorLabel)
{
delete mpColorLabel;
mpColorLabel = NULL;
}
if(NULL != mpShapeLabel)
{
delete mpShapeLabel;
mpShapeLabel = NULL;
}
if(NULL != mpSizeLabel)
{
delete mpSizeLabel;
mpSizeLabel = NULL;
}
if(NULL != mpColor)
{
delete mpColor;
mpColor = NULL;
}
if(NULL != mpSquareButton)
{
delete mpSquareButton;
mpSquareButton = NULL;
}
if(NULL != mpCircleButton)
{
delete mpCircleButton;
mpCircleButton = NULL;
}
if(NULL != mpCloseButton)
{
delete mpCloseButton;
mpCloseButton = NULL;
}
if(NULL != mpSizeSlider)
{
delete mpSizeSlider;
mpSizeSlider = NULL;
}
if(NULL != mpColorLayout)
{
delete mpColorLayout;
mpColorLayout = NULL;
}
if(NULL != mpShapeLayout)
{
delete mpShapeLayout;
mpShapeLayout = NULL;
}
if(NULL != mpSizeLayout)
{
delete mpSizeLayout;
mpSizeLayout = NULL;
}
if(NULL != mpCloseLayout)
{
delete mpCloseLayout;
mpCloseLayout = NULL;
}
if(NULL != mpPropertiesLayout)
{
delete mpPropertiesLayout;
mpPropertiesLayout = NULL;
}
if(NULL != mpProperties)
{
delete mpProperties;
mpProperties = NULL;
}
if(NULL != mpLayout)
{
delete mpLayout;
mpLayout = NULL;
}
}
void UBCachePropertiesWidget::onCloseClicked()
{
// Remove the current cache from the list
mCaches.remove(mCaches.indexOf(mpCurrentCache));
// Remove the cache from the board
UBApplication::boardController->activeScene()->removeItem(mpCurrentCache);
mpCurrentCache = NULL;
if(mCaches.empty())
{
emit cacheListEmpty();
}
}
void UBCachePropertiesWidget::updateCacheColor(QColor color)
{
mActualColor = color;
// Update the color on the color button
QPixmap pix(32, 32);
QPainter p;
p.begin(&pix);
p.setBackground(Qt::transparent);
p.setBrush(color); // The current color
p.drawRect(0, 0, 32, 32);
p.end();
mpColor->setIcon(QIcon(pix));
if(NULL != mpCurrentCache)
{
mpCurrentCache->setMaskColor(mActualColor);
}
}
void UBCachePropertiesWidget::onColorClicked()
{
// Show the color picker
QColor newColor = QColorDialog::getColor(mActualColor,this);
updateCacheColor(newColor);
}
void UBCachePropertiesWidget::updateShapeButtons()
{
if(mpCircleButton->hasFocus())
{
mActualShape = eMaskShape_Circle;
mpSquareButton->setChecked(false);
}
else if(mpSquareButton->hasFocus())
{
mActualShape = eMaskShap_Rectangle;
mpCircleButton->setChecked(false);
}
if(NULL != mpCurrentCache)
{
mpCurrentCache->setMaskShape(mActualShape);
}
}
void UBCachePropertiesWidget::updateCurrentCache()
{
// Get the current page cache
QList<QGraphicsItem*> items = UBApplication::boardController->activeScene()->items();
foreach(QGraphicsItem* it, items)
{
if("Cache" == it->data(Qt::UserRole).toString())
{
setEnabled(true);
mpCurrentCache = dynamic_cast<UBGraphicsCache*>(it);
if((NULL != mpCurrentCache) && (!mCaches.contains(mpCurrentCache)))
{
mCaches.append(mpCurrentCache);
}
// Update the values of the cache properties
mpSizeSlider->setValue(mpCurrentCache->shapeWidth());
updateCacheColor(mpCurrentCache->maskColor());
switch(mpCurrentCache->maskshape())
{
case eMaskShape_Circle:
mpCircleButton->setChecked(true);
mpSquareButton->setChecked(false);
break;
case eMaskShap_Rectangle:
mpCircleButton->setChecked(false);
mpSquareButton->setChecked(true);
break;
}
return;
}
}
// If we fall here, that means that this page has no cache
mpCurrentCache = NULL;
setDisabled(true);
}
void UBCachePropertiesWidget::onSizeChanged(int newSize)
{
if(NULL != mpCurrentCache)
{
mpCurrentCache->setShapeWidth(newSize);
}
}

@ -0,0 +1,60 @@
#ifndef UBCACHEPROPERTIESWIDGET_H
#define UBCACHEPROPERTIESWIDGET_H
#include <QWidget>
#include <QVBoxLayout>
#include <QLabel>
#include <QHBoxLayout>
#include <QPushButton>
#include <QSlider>
#include <QVector>
#include "UBDockPaletteWidget.h"
#include "tools/UBGraphicsCache.h"
#define MAX_SHAPE_WIDTH 200
class UBCachePropertiesWidget : public UBDockPaletteWidget
{
Q_OBJECT
public:
UBCachePropertiesWidget(QWidget* parent=0, const char* name="UBCachePropertiesWidget");
~UBCachePropertiesWidget();
public slots:
void updateCurrentCache();
signals:
void cacheListEmpty();
private slots:
void onCloseClicked();
void updateCacheColor(QColor color);
void onColorClicked();
void updateShapeButtons();
void onSizeChanged(int newSize);
private:
QVBoxLayout* mpLayout;
QLabel* mpCachePropertiesLabel;
QLabel* mpColorLabel;
QLabel* mpShapeLabel;
QLabel* mpSizeLabel;
QPushButton* mpColor;
QPushButton* mpSquareButton;
QPushButton* mpCircleButton;
QPushButton* mpCloseButton;
QSlider* mpSizeSlider;
QHBoxLayout* mpColorLayout;
QHBoxLayout* mpShapeLayout;
QHBoxLayout* mpSizeLayout;
QHBoxLayout* mpCloseLayout;
QWidget* mpProperties;
QVBoxLayout* mpPropertiesLayout;
QColor mActualColor;
eMaskShape mActualShape;
UBGraphicsCache* mpCurrentCache;
};
#endif // UBCACHEPROPERTIESWIDGET_H

@ -515,9 +515,12 @@ int UBDockPalette::customMargin()
void UBDockPalette::addTabWidget(UBDockPaletteWidget *widget) void UBDockPalette::addTabWidget(UBDockPaletteWidget *widget)
{ {
mTabWidgets.append(widget); if(!mTabWidgets.contains(widget))
mpStackWidget->addWidget(widget); {
update(); mTabWidgets.append(widget);
mpStackWidget->addWidget(widget);
update();
}
} }
void UBDockPalette::removeTab(const QString &widgetName) void UBDockPalette::removeTab(const QString &widgetName)

@ -61,6 +61,7 @@ public:
eUBDockOrientation orientation(); eUBDockOrientation orientation();
void setOrientation(eUBDockOrientation orientation); void setOrientation(eUBDockOrientation orientation);
void setTabsOrientation(eUBDockTabOrientation orientation); void setTabsOrientation(eUBDockTabOrientation orientation);
void showTabWidget(int tabIndex);
virtual void mouseMoveEvent(QMouseEvent *event); virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent *event); virtual void mousePressEvent(QMouseEvent *event);
@ -127,7 +128,7 @@ private slots:
private: private:
void tabClicked(int tabIndex); void tabClicked(int tabIndex);
int tabSpacing(); int tabSpacing();
void showTabWidget(int tabIndex);
void toggleCollapseExpand(); void toggleCollapseExpand();
}; };

@ -127,6 +127,9 @@ void UBPageNavigationWidget::changeCurrentPage()
{ {
// Display the selected page // Display the selected page
UBApplication::boardController->setActiveDocumentScene(mNavigator->currentDoc(), iPage); UBApplication::boardController->setActiveDocumentScene(mNavigator->currentDoc(), iPage);
// emit here the signal to indicate that page change
UBApplication::boardController->notifyPageChanged();
} }
} }

@ -12,8 +12,12 @@
* 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 "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "UBRightPalette.h" #include "UBRightPalette.h"
UBRightPalette::UBRightPalette(QWidget *parent, const char *name):UBDockPalette(parent) UBRightPalette::UBRightPalette(QWidget *parent, const char *name):UBDockPalette(parent)
, mpLibWidget(NULL) , mpLibWidget(NULL)
{ {
@ -25,8 +29,16 @@ UBRightPalette::UBRightPalette(QWidget *parent, const char *name):UBDockPalette(
resize(UBSettings::settings()->libPaletteWidth->get().toInt(), parentWidget()->height()); resize(UBSettings::settings()->libPaletteWidth->get().toInt(), parentWidget()->height());
mpLayout->setContentsMargins(2*border() + customMargin(), customMargin(), customMargin(), customMargin()); mpLayout->setContentsMargins(2*border() + customMargin(), customMargin(), customMargin(), customMargin());
// Add the tab widgets
mpLibWidget = new UBLibWidget(this); mpLibWidget = new UBLibWidget(this);
addTabWidget(mpLibWidget); addTabWidget(mpLibWidget);
mpCachePropWidget = new UBCachePropertiesWidget(this);
mpCachePropWidget->hide();
// Connect signals/slots
connect(UBApplication::boardController, SIGNAL(cacheEnabled()), this, SLOT(onCacheEnabled()));
connect(mpCachePropWidget, SIGNAL(cacheListEmpty()), this, SLOT(onCacheDisabled()));
} }
UBRightPalette::~UBRightPalette() UBRightPalette::~UBRightPalette()
@ -36,6 +48,11 @@ UBRightPalette::~UBRightPalette()
delete mpLibWidget; delete mpLibWidget;
mpLibWidget = NULL; mpLibWidget = NULL;
} }
if(NULL != mpCachePropWidget)
{
delete mpCachePropWidget;
mpCachePropWidget = NULL;
}
} }
UBLibWidget* UBRightPalette::libWidget() UBLibWidget* UBRightPalette::libWidget()
@ -62,12 +79,39 @@ void UBRightPalette::resizeEvent(QResizeEvent *event)
emit resized(); emit resized();
} }
/**
* \brief Update the maximum width
*/
void UBRightPalette::updateMaxWidth() void UBRightPalette::updateMaxWidth()
{ {
setMaximumWidth((int)((parentWidget()->width() * 2)/3)); setMaximumWidth((int)((parentWidget()->width() * 2)/3));
setMaximumHeight(parentWidget()->height()); setMaximumHeight(parentWidget()->height());
setMinimumHeight(parentWidget()->height()); setMinimumHeight(parentWidget()->height());
} }
void UBRightPalette::onCacheEnabled()
{
if(mpCachePropWidget->isHidden())
{
mpCachePropWidget->setVisible(true);
// Add the cache tab
addTabWidget(mpCachePropWidget);
}
// Set the cache of the current page as the active one for the properties widget
mpCachePropWidget->updateCurrentCache();
// Show the cache properties widget
for(int i = 0; i < mTabWidgets.size(); i++)
{
if((NULL != mTabWidgets.at(i)) && ("CachePropWidget" == mTabWidgets.at(i)->name()))
{
showTabWidget(i);
break;
}
}
}
void UBRightPalette::onCacheDisabled()
{
removeTab(mpCachePropWidget->name());
mpCachePropWidget->hide();
}

@ -17,6 +17,7 @@
#include "UBDockPalette.h" #include "UBDockPalette.h"
#include "UBLibWidget.h" #include "UBLibWidget.h"
#include "UBCachePropertiesWidget.h"
class UBRightPalette : public UBDockPalette class UBRightPalette : public UBDockPalette
{ {
@ -35,8 +36,13 @@ protected:
void mouseMoveEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event);
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event);
private slots:
void onCacheEnabled();
void onCacheDisabled();
private: private:
UBLibWidget* mpLibWidget; UBLibWidget* mpLibWidget;
UBCachePropertiesWidget* mpCachePropWidget;
}; };
#endif // UBRIGHTPALETTE_H #endif // UBRIGHTPALETTE_H

@ -41,7 +41,8 @@ HEADERS += src/gui/UBThumbnailView.h \
src/gui/UBRightPalette.h \ src/gui/UBRightPalette.h \
src/gui/UBPageNavigationWidget.h \ src/gui/UBPageNavigationWidget.h \
src/gui/UBLibWidget.h \ src/gui/UBLibWidget.h \
src/gui/UBMagnifer.h src/gui/UBMagnifer.h \
src/gui/UBCachePropertiesWidget.h
SOURCES += src/gui/UBThumbnailView.cpp \ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBFloatingPalette.cpp \ src/gui/UBFloatingPalette.cpp \
@ -85,7 +86,8 @@ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBRightPalette.cpp \ src/gui/UBRightPalette.cpp \
src/gui/UBPageNavigationWidget.cpp \ src/gui/UBPageNavigationWidget.cpp \
src/gui/UBLibWidget.cpp \ src/gui/UBLibWidget.cpp \
src/gui/UBMagnifer.cpp src/gui/UBMagnifer.cpp \
src/gui/UBCachePropertiesWidget.cpp
win32 { win32 {

@ -33,6 +33,7 @@ UBGraphicsCache::UBGraphicsCache():QGraphicsRectItem()
QRect boardRect = UBApplication::boardController->displayView()->rect(); QRect boardRect = UBApplication::boardController->displayView()->rect();
setRect(-15*boardRect.width(), -15*boardRect.height(), 30*boardRect.width(), 30*boardRect.height()); setRect(-15*boardRect.width(), -15*boardRect.height(), 30*boardRect.width(), 30*boardRect.height());
setZValue(CACHE_ZVALUE); setZValue(CACHE_ZVALUE);
setData(Qt::UserRole, QVariant("Cache"));
} }
UBGraphicsCache::~UBGraphicsCache() UBGraphicsCache::~UBGraphicsCache()
@ -62,6 +63,7 @@ QColor UBGraphicsCache::maskColor()
void UBGraphicsCache::setMaskColor(QColor color) void UBGraphicsCache::setMaskColor(QColor color)
{ {
mMaskColor = color; mMaskColor = color;
update();
} }
eMaskShape UBGraphicsCache::maskshape() eMaskShape UBGraphicsCache::maskshape()
@ -72,6 +74,7 @@ eMaskShape UBGraphicsCache::maskshape()
void UBGraphicsCache::setMaskShape(eMaskShape shape) void UBGraphicsCache::setMaskShape(eMaskShape shape)
{ {
mMaskShape = shape; mMaskShape = shape;
update();
} }
void UBGraphicsCache::init() void UBGraphicsCache::init()
@ -139,4 +142,5 @@ int UBGraphicsCache::shapeWidth()
void UBGraphicsCache::setShapeWidth(int width) void UBGraphicsCache::setShapeWidth(int width)
{ {
mShapeWidth = width; mShapeWidth = width;
update();
} }

@ -65,6 +65,17 @@ UBToolsManager::UBToolsManager(QObject *parent)
mToolsIcon.insert(magnifier.id,":/images/toolPalette/magnifierTool.png"); mToolsIcon.insert(magnifier.id,":/images/toolPalette/magnifierTool.png");
mDescriptors << magnifier; mDescriptors << magnifier;
// --------------------------------------------------------------------------------
// DO NOT ERASE THIS COMMENTED CODE! IT WILL BE UNCOMMENTED DURING THE NEXT DAYS!!!
// --------------------------------------------------------------------------------
cache.id = "uniboardTool://uniboard.mnemis.com/cache";
cache.icon = QPixmap(":/images/toolPalette/cacheTool.png");
cache.label = tr("Cache");
cache.version = "1.0";
mToolsIcon.insert(cache.id, ":/images/toolPalette/cacheTool.png");
mDescriptors << cache;
// --------------------------------------------------------------------------------
} }
UBToolsManager::~UBToolsManager() UBToolsManager::~UBToolsManager()

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

Loading…
Cancel
Save