Reworked the dock palettes to support multitab

preferencesAboutTextFull
shibakaneki 13 years ago
parent bb6a1ebf5c
commit 11f8c6b5a5
  1. 2
      src/board/UBBoardController.cpp
  2. 28
      src/board/UBBoardPaletteManager.cpp
  3. 15
      src/board/UBBoardPaletteManager.h
  4. 18
      src/desktop/UBDesktopAnnotationController.cpp
  5. 4
      src/desktop/UBDesktopAnnotationController.h
  6. 180
      src/gui/UBDockPalette.cpp
  7. 21
      src/gui/UBDockPalette.h
  8. 26
      src/gui/UBDockPaletteWidget.cpp
  9. 14
      src/gui/UBDockPaletteWidget.h
  10. 44
      src/gui/UBLeftPalette.cpp
  11. 34
      src/gui/UBLeftPalette.h
  12. 18
      src/gui/UBLibNavigatorWidget.cpp
  13. 59
      src/gui/UBLibPalette.cpp
  14. 14
      src/gui/UBLibPalette.h
  15. 154
      src/gui/UBLibWidget.cpp
  16. 78
      src/gui/UBLibWidget.h
  17. 195
      src/gui/UBPageNavigationWidget.cpp
  18. 68
      src/gui/UBPageNavigationWidget.h
  19. 73
      src/gui/UBRightPalette.cpp
  20. 42
      src/gui/UBRightPalette.h
  21. 12
      src/gui/gui.pri

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

@ -65,8 +65,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 +86,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 +119,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 +375,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 +403,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)

@ -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,8 +43,8 @@ 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();
UBKeyboardPalette *mKeyboardPalette; UBKeyboardPalette *mKeyboardPalette;
@ -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;
@ -113,7 +114,7 @@ class UBBoardPaletteManager : public QObject
void togglePagePalette(bool ckecked); void togglePagePalette(bool ckecked);
void pagePaletteClosed(); void pagePaletteClosed();
void pagePaletteButtonPressed(); void pagePaletteButtonPressed();
void pagePaletteButtonReleased(); void pagePaletteButtonReleased();
void addItemToCurrentPage(); void addItemToCurrentPage();

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

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

@ -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
*/ */
@ -54,9 +38,17 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
, mLastWidth(-1) , mLastWidth(-1)
, mHTab(0) , mHTab(0)
, mpStackWidget(NULL) , 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 // clear the tab widgets
mTabWidgets.clear(); mTabWidgets.clear();
@ -100,6 +92,11 @@ UBDockPalette::~UBDockPalette()
delete mpStackWidget; delete mpStackWidget;
mpStackWidget = NULL; mpStackWidget = NULL;
} }
if(NULL != mpLayout)
{
delete mpLayout;
mpLayout = NULL;
}
} }
/** /**
@ -202,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;
} }
@ -233,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)
@ -249,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);
} }
} }
} }
@ -321,39 +322,76 @@ 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);
for(int i = 0; i < mTabWidgets.size(); i++) int nbTabs = mTabWidgets.size();
if(0 < nbTabs)
{ {
if(eUBDockTabOrientation_Up == mTabsOrientation) // First draw the BIG RECTANGLE (I write it big because the rectangle is big...)
{
mHTab = border();
}
else
{
mHTab = height() - border() - i*TABSIZE;
}
if(mOrientation == eUBDockOrientation_Left) if(mOrientation == eUBDockOrientation_Left)
{ {
QPainterPath path;
path.setFillRule(Qt::WindingFill);
path.addRect(0.0, 0.0, width()-2*border(), height()); 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.drawPixmap(width() - border() + 1, mHTab + 1 , border() - 4, TABSIZE - 2, mIcon);
} }
else if(mOrientation == eUBDockOrientation_Right) else if(mOrientation == eUBDockOrientation_Right)
{ {
QPainterPath path;
path.setFillRule(Qt::WindingFill);
path.addRect(2*border(), 0.0, width()-2*border(), height()); path.addRect(2*border(), 0.0, width()-2*border(), height());
path.addRoundedRect(0.0, mHTab, 4*border(), TABSIZE, radius(), radius()); }
painter.drawPath(path);
//painter.drawPixmap(2, mHTab + 1, border() - 3, TABSIZE - 2, mIcon); // THEN DRAW THE small tabs (yes, the tabs are small...)
if(eUBDockTabOrientation_Up == mTabsOrientation)
{
mHTab = border();
} }
else else
{ {
painter.drawRoundedRect(border(), border(), width() - 2 * border(), height() - 2 * border(), radius(), radius()); mHTab = height() - border() - nbTabs*TABSIZE - (nbTabs-1)*tabSpacing();
}
for(int i = 0; i < mTabWidgets.size(); i++)
{
UBDockPaletteWidget* pCrntWidget = mTabWidgets.at(i);
if(NULL != pCrntWidget)
{
if(mOrientation == eUBDockOrientation_Left)
{
path.addRoundedRect(width()-4*border(), mHTab + i*TABSIZE + i*tabSpacing(), 4*border(), TABSIZE, radius(), radius());
painter.drawPath(path);
QPixmap iconPixmap;
if(mCollapseWidth >= width())
{
// Get the collapsed icon
iconPixmap = pCrntWidget->iconToRight();
}
else
{
// Get the expanded icon
iconPixmap = pCrntWidget->iconToLeft();
}
painter.drawPixmap(width() - 2*border() + 1, mHTab + i*TABSIZE + i*tabSpacing() + 1 , 2*border() - 4, TABSIZE - 2, iconPixmap);
}
else if(mOrientation == eUBDockOrientation_Right)
{
path.addRoundedRect(0.0, mHTab + i*TABSIZE + i*tabSpacing(), 4*border(), TABSIZE, radius(), radius());
painter.drawPath(path);
QPixmap iconPixmap;
if(mCollapseWidth >= width())
{
// Get the collapsed icon
iconPixmap = pCrntWidget->iconToLeft();
}
else
{
// Get the expanded icon
iconPixmap = pCrntWidget->iconToRight();
}
painter.drawPixmap(2, mHTab + i*TABSIZE + i*tabSpacing() + 1, 2*border() - 4, TABSIZE - 2, iconPixmap);
}
else
{
painter.drawRoundedRect(border(), border(), width() - 2 * border(), height() - 2 * border(), radius(), radius());
}
}
} }
} }
} }
@ -409,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)
{ {
@ -449,12 +513,34 @@ int UBDockPalette::customMargin()
return 5; return 5;
} }
void UBDockPalette::addTabWidget(const QString &widgetName, UBDockPaletteWidget *widget) void UBDockPalette::addTabWidget(UBDockPaletteWidget *widget)
{ {
mTabWidgets[widgetName] = widget; mTabWidgets.append(widget);
mpStackWidget->addWidget(widget);
update();
} }
void UBDockPalette::removeTab(const QString &widgetName) void UBDockPalette::removeTab(const QString &widgetName)
{ {
mTabWidgets.remove(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;
} }

@ -26,6 +26,8 @@
#include <QPixmap> #include <QPixmap>
#include <QMap> #include <QMap>
#include <QStackedWidget> #include <QStackedWidget>
#include <QVBoxLayout>
#include <QVector>
#include "UBDockPaletteWidget.h" #include "UBDockPaletteWidget.h"
@ -68,10 +70,11 @@ public:
virtual void leaveEvent(QEvent *); virtual void leaveEvent(QEvent *);
void setBackgroundBrush(const QBrush& brush); void setBackgroundBrush(const QBrush& brush);
void addTabWidget(const QString& widgetName, UBDockPaletteWidget* widget);
void removeTab(const QString& widgetName);
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();
@ -107,15 +110,25 @@ protected:
/** The h position of the tab */ /** The h position of the tab */
int mHTab; int mHTab;
/** The tab widgets */ /** The tab widgets */
QMap<QString, UBDockPaletteWidget*> mTabWidgets; //QMap<QString, UBDockPaletteWidget*> mTabWidgets;
/** The stacked widget */ /** The stacked widget */
QStackedWidget* mpStackWidget; 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

@ -1,36 +1,26 @@
#include "UBDockPaletteWidget.h" #include "UBDockPaletteWidget.h"
UBDockPaletteWidget::UBDockPaletteWidget(const char *name, QWidget *parent):QWidget(parent) UBDockPaletteWidget::UBDockPaletteWidget(QWidget *parent, const char *name):QWidget(parent)
, mpWidget(NULL)
{ {
setObjectName(name); setObjectName(name);
} }
UBDockPaletteWidget::~UBDockPaletteWidget() UBDockPaletteWidget::~UBDockPaletteWidget()
{ {
if(NULL != mpWidget)
{
delete mpWidget;
mpWidget = NULL;
}
} }
QWidget* UBDockPaletteWidget::widget() QPixmap UBDockPaletteWidget::iconToRight()
{ {
return mpWidget; return mIconToRight;
} }
QIcon UBDockPaletteWidget::icon() QPixmap UBDockPaletteWidget::iconToLeft()
{ {
return mIcon; return mIconToLeft;
} }
QIcon UBDockPaletteWidget::collapsedIcon() QString UBDockPaletteWidget::name()
{ {
return mCollapsedIcon; return mName;
} }
QString UBDockPaletteWidget::name()
{
return mName;
}

@ -2,24 +2,22 @@
#define UBDOCKPALETTEWIDGET_H #define UBDOCKPALETTEWIDGET_H
#include <QWidget> #include <QWidget>
#include <QIcon> #include <QPixmap>
#include <QString> #include <QString>
class UBDockPaletteWidget : public QWidget class UBDockPaletteWidget : public QWidget
{ {
public: public:
UBDockPaletteWidget(const char* name="UBDockPaletteWidget", QWidget* parent=0); UBDockPaletteWidget(QWidget* parent=0, const char* name="UBDockPaletteWidget");
~UBDockPaletteWidget(); ~UBDockPaletteWidget();
QWidget* widget(); QPixmap iconToRight();
QIcon icon(); QPixmap iconToLeft();
QIcon collapsedIcon();
QString name(); QString name();
protected: protected:
QWidget* mpWidget; QPixmap mIconToRight; // arrow like this: >
QIcon mIcon; QPixmap mIconToLeft; // arrow like this: <
QIcon mCollapsedIcon;
QString mName; QString mName;
}; };

@ -0,0 +1,44 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "UBLeftPalette.h"
UBLeftPalette::UBLeftPalette(QWidget *parent, const char *name):UBDockPalette(parent)
, mpPageNavigator(NULL)
{
setObjectName(name);
setOrientation(eUBDockOrientation_Left);
mLastWidth = 300;
setMaximumWidth(300);
resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), height());
mpLayout->setContentsMargins(customMargin(), customMargin(), 2*border() + customMargin(), customMargin());
mpPageNavigator = new UBPageNavigationWidget(this);
addTabWidget(mpPageNavigator);
}
UBLeftPalette::~UBLeftPalette()
{
if(NULL != mpPageNavigator)
{
delete mpPageNavigator;
mpPageNavigator = NULL;
}
}
UBPageNavigationWidget* UBLeftPalette::pageNavigator()
{
return mpPageNavigator;
}

@ -0,0 +1,34 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBLEFTPALETTE_H
#define UBLEFTPALETTE_H
#include "UBDockPalette.h"
#include "UBPageNavigationWidget.h"
class UBLeftPalette : public UBDockPalette
{
public:
UBLeftPalette(QWidget* parent=0, const char* name="UBLeftPalette");
~UBLeftPalette();
UBPageNavigationWidget* pageNavigator();
private:
UBPageNavigationWidget* mpPageNavigator;
};
#endif // UBLEFTPALETTE_H

@ -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 "UBRightPalette.h"
#include "core/memcheck.h" #include "core/memcheck.h"
@ -36,7 +36,7 @@ UBLibNavigatorWidget::UBLibNavigatorWidget(QWidget *parent, const char *name):QW
setObjectName(name); setObjectName(name);
setAcceptDrops(true); setAcceptDrops(true);
UBLibPalette* pLibPalette = dynamic_cast<UBLibPalette*>(parentWidget()); UBRightPalette* pRightPalette = dynamic_cast<UBRightPalette*>(parentWidget());
mLayout = new QVBoxLayout(this); mLayout = new QVBoxLayout(this);
// mLayout->setContentsMargins(20, 5, 5, 5); // mLayout->setContentsMargins(20, 5, 5, 5);
@ -66,14 +66,14 @@ 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) if(NULL != pRightPalette)
{ {
connect(mLibWidget, SIGNAL(navigBarUpdate(UBLibElement*)), pLibPalette->actionBar(), SLOT(onNavigbarUpdate(UBLibElement*))); connect(mLibWidget, SIGNAL(navigBarUpdate(UBLibElement*)), pRightPalette->libWidget()->actionBar(), SLOT(onNavigbarUpdate(UBLibElement*)));
connect(mLibWidget, SIGNAL(itemsSelected(QList<UBLibElement*>, bool)), pLibPalette->actionBar(), SLOT(onSelectionChanged(QList<UBLibElement*>, bool))); connect(mLibWidget, SIGNAL(itemsSelected(QList<UBLibElement*>, bool)), pRightPalette->libWidget()->actionBar(), SLOT(onSelectionChanged(QList<UBLibElement*>, bool)));
connect(pLibPalette->actionBar(), SIGNAL(deleteDone()), mLibWidget, SLOT(onRefreshCurrentFolder())); connect(pRightPalette->libWidget()->actionBar(), SIGNAL(deleteDone()), mLibWidget, SLOT(onRefreshCurrentFolder()));
connect(mLibWidget, SIGNAL(favoritesEntered(bool)), pLibPalette->actionBar(), SLOT(onFavoritesEntered(bool))); connect(mLibWidget, SIGNAL(favoritesEntered(bool)), pRightPalette->libWidget()->actionBar(), SLOT(onFavoritesEntered(bool)));
connect(pLibPalette->actionBar(), SIGNAL(searchElement(QString)), mLibWidget, SLOT(onSearchElement(QString))); connect(pRightPalette->libWidget()->actionBar(), SIGNAL(searchElement(QString)), mLibWidget, SLOT(onSearchElement(QString)));
connect(pLibPalette->actionBar(), SIGNAL(newFolderToCreate()), mLibWidget, SLOT(onNewFolderToCreate())); connect(pRightPalette->libWidget()->actionBar(), SIGNAL(newFolderToCreate()), mLibWidget, SLOT(onNewFolderToCreate()));
} }
mLibWidget->init(); mLibWidget->init();

@ -28,11 +28,8 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare
, mNavigator(NULL) , mNavigator(NULL)
, mProperties(NULL) , mProperties(NULL)
, mActionBar(NULL) , mActionBar(NULL)
, mDropWidget(NULL)
{ {
setOrientation(eUBDockOrientation_Right); setOrientation(eUBDockOrientation_Right);
//mCollapsedIcon = QPixmap(":images/library_open.png");
//mIcon = QPixmap(":images/library_close.png");
setAcceptDrops(true); setAcceptDrops(true);
@ -50,14 +47,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;
@ -71,18 +66,7 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare
*/ */
UBLibPalette::~UBLibPalette() UBLibPalette::~UBLibPalette()
{ {
//if(NULL != mStackedWidget) if(NULL != mProperties)
//{
// delete mStackedWidget;
// mStackedWidget = NULL;
//}
//if(NULL != mNavigator)
//{
// delete mNavigator;
// mNavigator = NULL;
//}
if(NULL != mProperties)
{ {
delete mProperties; delete mProperties;
mProperties = NULL; mProperties = NULL;
@ -92,16 +76,6 @@ UBLibPalette::~UBLibPalette()
delete mActionBar; delete mActionBar;
mActionBar = NULL; mActionBar = NULL;
} }
if(NULL != mDropWidget)
{
delete mDropWidget;
mDropWidget = NULL;
}
//if(NULL != mLayout)
//{
//delete mLayout;
//mLayout = NULL;
//}
} }
/** /**
@ -121,13 +95,11 @@ void UBLibPalette::updateMaxWidth()
void UBLibPalette::dragEnterEvent(QDragEnterEvent *pEvent) void UBLibPalette::dragEnterEvent(QDragEnterEvent *pEvent)
{ {
setBackgroundRole(QPalette::Highlight); setBackgroundRole(QPalette::Highlight);
//mStackedWidget->setCurrentIndex(ID_DROPME);
pEvent->acceptProposedAction(); pEvent->acceptProposedAction();
} }
void UBLibPalette::dragLeaveEvent(QDragLeaveEvent *pEvent) void UBLibPalette::dragLeaveEvent(QDragLeaveEvent *pEvent)
{ {
//mStackedWidget->setCurrentIndex(miCrntStackWidget);
pEvent->accept(); pEvent->accept();
} }
@ -164,8 +136,6 @@ 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 UBLibPalette::mouseMoveEvent(QMouseEvent *event)
@ -205,30 +175,3 @@ void UBLibPalette::resizeEvent(QResizeEvent *event)
UBSettings::settings()->libPaletteWidth->set(width()); UBSettings::settings()->libPaletteWidth->set(width());
emit resized(); emit resized();
} }
// --------------------------------------------------------------------------
UBDropMeWidget::UBDropMeWidget(QWidget *parent, const char *name):QWidget(parent)
, mpLabel(NULL)
, mpLayout(NULL)
{
setObjectName(name);
mpLayout = new QVBoxLayout(this);
setLayout(mpLayout);
mpLabel = new QLabel(tr("Drop here"), this);
mpLayout->addWidget(mpLabel);
}
UBDropMeWidget::~UBDropMeWidget()
{
if(NULL != mpLabel)
{
delete mpLabel;
mpLabel = NULL;
}
if(NULL != mpLayout)
{
delete mpLayout;
mpLayout = NULL;
}
}

@ -33,18 +33,6 @@
#define ID_NAVIGATOR 0 #define ID_NAVIGATOR 0
#define ID_PROPERTIES 1 #define ID_PROPERTIES 1
#define ID_DROPME 2
class UBDropMeWidget : public QWidget
{
public:
UBDropMeWidget(QWidget* parent=0, const char* name="dropMeWidget");
~UBDropMeWidget();
private:
QLabel* mpLabel;
QVBoxLayout* mpLayout;
};
class UBLibPalette : public UBDockPalette class UBLibPalette : public UBDockPalette
{ {
@ -84,8 +72,6 @@ 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;
}; };

@ -0,0 +1,154 @@
/*
* 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 "UBLibWidget.h"
#include "core/memcheck.h"
/**
* \brief Constructor
* @param parent as the parent widget
* @param name as the object name
*/
UBLibWidget::UBLibWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent)
, mLayout(NULL)
, mStackedWidget(NULL)
, mNavigator(NULL)
, mProperties(NULL)
, mActionBar(NULL)
{
setObjectName(name);
mName = "LibWidget";
mIconToLeft = QPixmap(":images/library_open.png");
mIconToRight = QPixmap(":images/library_close.png");
setAcceptDrops(true);
mLayout = new QVBoxLayout(this);
setLayout(mLayout);
// Build the GUI
mStackedWidget = new QStackedWidget(this);
mActionBar = new UBLibActionBar(this);
mNavigator = new UBLibNavigatorWidget(this);
mProperties = new UBLibItemProperties(this);
mLayout->addWidget(mStackedWidget, 1);
mLayout->addWidget(mActionBar, 0);
mStackedWidget->addWidget(mNavigator);
mStackedWidget->addWidget(mProperties);
mStackedWidget->setCurrentIndex(ID_NAVIGATOR);
miCrntStackWidget = ID_NAVIGATOR;
connect(mNavigator, SIGNAL(propertiesRequested(UBLibElement*)), this, SLOT(showProperties(UBLibElement*)));
connect(mProperties, SIGNAL(showFolderContent()), this, SLOT(showFolder()));
}
/**
* \brief Destructor
*/
UBLibWidget::~UBLibWidget()
{
if(NULL != mProperties)
{
delete mProperties;
mProperties = NULL;
}
if(NULL != mActionBar)
{
delete mActionBar;
mActionBar = NULL;
}
}
/**
* \brief Handles the drag enter event
* @param pEvent as the drag enter event
*/
void UBLibWidget::dragEnterEvent(QDragEnterEvent *pEvent)
{
setBackgroundRole(QPalette::Highlight);
pEvent->acceptProposedAction();
}
void UBLibWidget::dragLeaveEvent(QDragLeaveEvent *pEvent)
{
pEvent->accept();
}
/**
* \brief Handles the drop event
* @param pEvent as the drop event
*/
void UBLibWidget::dropEvent(QDropEvent *pEvent)
{
processMimeData(pEvent->mimeData());
setBackgroundRole(QPalette::Dark);
mStackedWidget->setCurrentIndex(miCrntStackWidget);
pEvent->acceptProposedAction();
}
/**
* \brief Handles the drag move event
* @param pEvent as the drag move event
*/
void UBLibWidget::dragMoveEvent(QDragMoveEvent *pEvent)
{
pEvent->acceptProposedAction();
}
/**
* \brief Process the dropped MIME data
* @param pData as the mime dropped data
*/
void UBLibWidget::processMimeData(const QMimeData *pData)
{
// Display the different mime types contained in the mime data
QStringList qslFormats = pData->formats();
for(int i = 0; i < qslFormats.size(); i++)
{
qDebug() << "Dropped element format " << i << " = "<< qslFormats.at(i);
}
}
void UBLibWidget::showProperties(UBLibElement *elem)
{
if(NULL != elem)
{
mActionBar->setButtons(eButtonSet_Properties);
// Show the properties of this object
mProperties->showElement(elem);
mStackedWidget->setCurrentIndex(ID_PROPERTIES);
miCrntStackWidget = ID_PROPERTIES;
}
}
void UBLibWidget::showFolder()
{
mActionBar->setButtons(mActionBar->previousButtonSet());
mStackedWidget->setCurrentIndex(ID_NAVIGATOR);
miCrntStackWidget = ID_NAVIGATOR;
}
int UBLibWidget::customMargin()
{
return 5;
}
int UBLibWidget::border()
{
return 15;
}

@ -0,0 +1,78 @@
/*
* 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 UBLIBWIDGET_H
#define UBLIBWIDGET_H
#include <QWidget>
#include <QVBoxLayout>
#include <QStackedWidget>
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QDragMoveEvent>
#include <QMimeData>
#include <QMouseEvent>
#include <QResizeEvent>
#include <QLabel>
#include "UBDockPaletteWidget.h"
#include "UBLibNavigatorWidget.h"
#include "UBLibItemProperties.h"
#include "UBLibActionBar.h"
#define ID_NAVIGATOR 0
#define ID_PROPERTIES 1
class UBLibWidget : public UBDockPaletteWidget
{
Q_OBJECT
public:
UBLibWidget(QWidget* parent=0, const char* name="UBLibWidget");
~UBLibWidget();
UBLibActionBar* actionBar(){return mActionBar;}
signals:
void resized();
protected:
void dragEnterEvent(QDragEnterEvent* pEvent);
void dropEvent(QDropEvent *pEvent);
void dragMoveEvent(QDragMoveEvent* pEvent);
void dragLeaveEvent(QDragLeaveEvent* pEvent);
private slots:
void showProperties(UBLibElement* elem);
void showFolder();
private:
void processMimeData(const QMimeData* pData);
int customMargin();
int border();
/** The layout */
QVBoxLayout* mLayout;
/** The stacked layout */
QStackedWidget* mStackedWidget;
/** The Navigator widget */
UBLibNavigatorWidget* mNavigator;
/** The Properties widget */
UBLibItemProperties* mProperties;
/** UBLibActionBar */
UBLibActionBar* mActionBar;
/** The current stack widget index*/
int miCrntStackWidget;
};
#endif // UBLIBWIDGET_H

@ -0,0 +1,195 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "UBPageNavigationWidget.h"
#include "core/UBApplication.h"
#include "board/UBBoardController.h"
#include "core/memcheck.h"
/**
* \brief Constructor
* @param parent as the parent widget
* @param name as the object name
*/
UBPageNavigationWidget::UBPageNavigationWidget(QWidget *parent, const char *name):UBDockPaletteWidget(parent)
, mNavigator(NULL)
, mLayout(NULL)
, mHLayout(NULL)
, mPageNbr(NULL)
, mClock(NULL)
{
setObjectName(name);
mName = "PageNavigator";
mIconToRight = QPixmap(":images/pages_open.png");
mIconToLeft = QPixmap(":images/pages_close.png");
// Build the gui
mLayout = new QVBoxLayout(this);
//mLayout->setContentsMargins(customMargin(), customMargin(), 2*border() + customMargin(), customMargin());
setLayout(mLayout);
mNavigator = new UBDocumentNavigator(this);
mNavigator->setStyleSheet(QString("background-color : transparent;"));
mLayout->addWidget(mNavigator, 1);
mHLayout = new QHBoxLayout();
mLayout->addLayout(mHLayout, 0);
mPageNbr = new QLabel(this);
mClock = new QLabel(this);
mHLayout->addWidget(mPageNbr);
mHLayout->addWidget(mClock);
// Configure the page number indicator
mPageNbr->setStyleSheet(QString("QLabel { color: white; background-color: transparent; border: none; font-family: Arial; font-weight: bold; font-size: 20px }"));
setPageNumber(0, 0);
mPageNbr->setAlignment(Qt::AlignHCenter);
// Configure the clock
mClock->setStyleSheet(QString("QLabel {color: white; background-color: transparent; text-align: center; font-family: Arial; font-weight: bold; font-size: 20px}"));
mTimeFormat = QLocale::system().timeFormat(QLocale::ShortFormat);
mClock->setAlignment(Qt::AlignHCenter);
//strip seconds
mTimeFormat = mTimeFormat.remove(":ss");
mTimeFormat = mTimeFormat.remove(":s");
mTimerID = startTimer(1000);
connect(mNavigator, SIGNAL(changeCurrentPage()), this, SLOT(changeCurrentPage()));
}
/**
* \brief Destructor
*/
UBPageNavigationWidget::~UBPageNavigationWidget()
{
killTimer(mTimerID);
if(NULL != mClock)
{
delete mClock;
mClock = NULL;
}
if(NULL != mPageNbr)
{
delete mPageNbr;
mPageNbr = NULL;
}
if(NULL != mHLayout)
{
delete mHLayout;
mHLayout = NULL;
}
if(NULL != mLayout)
{
delete mLayout;
mLayout = NULL;
}
if(NULL != mNavigator)
{
delete mNavigator;
mNavigator = NULL;
}
}
/**
* \brief Set the current document in the navigator
* @param document as the given document
*/
void UBPageNavigationWidget::setDocument(UBDocumentProxy *document)
{
if(mNavigator->currentDoc() != document)
{
mNavigator->setDocument(document);
}
}
/**
* \brief Change the current page
*/
void UBPageNavigationWidget::changeCurrentPage()
{
// Get the index of the page to display
int iPage = mNavigator->selectedPageNumber();
if(NO_PAGESELECTED != iPage)
{
// Display the selected page
UBApplication::boardController->setActiveDocumentScene(mNavigator->currentDoc(), iPage);
}
}
/**
* \brief Refresh the thumbnails widget
*/
void UBPageNavigationWidget::refresh()
{
mNavigator->setDocument(UBApplication::boardController->activeDocument());
}
/**
* \brief Handle the resize event
* @param event as the resize event
*/
void UBPageNavigationWidget::resizeEvent(QResizeEvent *event)
{
emit resizeRequest(event);
//UBDockPalette::resizeEvent(event);
if(NULL != mNavigator)
{
mNavigator->setMinimumHeight(height() - 2*border());
}
UBSettings::settings()->navigPaletteWidth->set(width());
}
/**
* \brief Notify a timer event
* @param event as the timer event
*/
void UBPageNavigationWidget::timerEvent(QTimerEvent *event)
{
Q_UNUSED(event);
updateTime();
}
/**
* \brief Update the current time
*/
void UBPageNavigationWidget::updateTime()
{
if (mClock)
{
mClock->setText(QLocale::system().toString (QTime::currentTime(), mTimeFormat));
}
}
/**
* \brief Set the page number
* @param current as the current page
* @param total as the total number of pages
*/
void UBPageNavigationWidget::setPageNumber(int current, int total)
{
mPageNbr->setText(QString("%1 / %2").arg(current).arg(total));
}
int UBPageNavigationWidget::customMargin()
{
return 5;
}
int UBPageNavigationWidget::border()
{
return 15;
}

@ -0,0 +1,68 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBPAGENAVIGATIONWIDGET_H
#define UBPAGENAVIGATIONWIDGET_H
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QMouseEvent>
#include <QResizeEvent>
#include <QTimerEvent>
#include <QLabel>
#include <QString>
#include "UBDocumentNavigator.h"
#include "UBDockPaletteWidget.h"
#include "document/UBDocumentProxy.h"
class UBPageNavigationWidget : public UBDockPaletteWidget
{
Q_OBJECT
public:
UBPageNavigationWidget(QWidget* parent=0, const char* name="UBPageNavigationWidget");
~UBPageNavigationWidget();
void setDocument(UBDocumentProxy* document);
void refresh();
signals:
void resizeRequest(QResizeEvent* event);
public slots:
void setPageNumber(int current, int total);
protected:
virtual void resizeEvent(QResizeEvent *event);
virtual void timerEvent(QTimerEvent *event);
private:
void updateTime();
int customMargin();
int border();
/** The thumbnails navigator widget */
UBDocumentNavigator* mNavigator;
/** The layout */
QVBoxLayout* mLayout;
QHBoxLayout* mHLayout;
QLabel* mPageNbr;
QLabel* mClock;
QString mTimeFormat;
int mTimerID;
private slots:
void changeCurrentPage();
};
#endif // UBPAGENAVIGATIONWIDGET_H

@ -0,0 +1,73 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "UBRightPalette.h"
UBRightPalette::UBRightPalette(QWidget *parent, const char *name):UBDockPalette(parent)
, mpLibWidget(NULL)
{
setObjectName(name);
setOrientation(eUBDockOrientation_Right);
setOrientation(eUBDockOrientation_Right);
mCollapseWidth = 180;
mLastWidth = 300;
resize(UBSettings::settings()->libPaletteWidth->get().toInt(), parentWidget()->height());
mpLayout->setContentsMargins(2*border() + customMargin(), customMargin(), customMargin(), customMargin());
mpLibWidget = new UBLibWidget(this);
addTabWidget(mpLibWidget);
}
UBRightPalette::~UBRightPalette()
{
if(NULL != mpLibWidget)
{
delete mpLibWidget;
mpLibWidget = NULL;
}
}
UBLibWidget* UBRightPalette::libWidget()
{
return mpLibWidget;
}
void UBRightPalette::mouseMoveEvent(QMouseEvent *event)
{
if(mCanResize)
{
UBDockPalette::mouseMoveEvent(event);
}
else
{
//qDebug() << "Mouse move event detected!" ;
}
}
void UBRightPalette::resizeEvent(QResizeEvent *event)
{
UBDockPalette::resizeEvent(event);
UBSettings::settings()->libPaletteWidth->set(width());
emit resized();
}
/**
* \brief Update the maximum width
*/
void UBRightPalette::updateMaxWidth()
{
setMaximumWidth((int)((parentWidget()->width() * 2)/3));
setMaximumHeight(parentWidget()->height());
setMinimumHeight(parentWidget()->height());
}

@ -0,0 +1,42 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UBRIGHTPALETTE_H
#define UBRIGHTPALETTE_H
#include "UBDockPalette.h"
#include "UBLibWidget.h"
class UBRightPalette : public UBDockPalette
{
Q_OBJECT
public:
UBRightPalette(QWidget* parent=0, const char* name="UBRightPalette");
~UBRightPalette();
UBLibWidget* libWidget();
signals:
void resized();
protected:
void updateMaxWidth();
void mouseMoveEvent(QMouseEvent *event);
void resizeEvent(QResizeEvent *event);
private:
UBLibWidget* mpLibWidget;
};
#endif // UBRIGHTPALETTE_H

@ -39,7 +39,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/UBDockPaletteWidget.h \
src/gui/UBLeftPalette.h \
src/gui/UBRightPalette.h \
src/gui/UBPageNavigationWidget.h \
src/gui/UBLibWidget.h
SOURCES += src/gui/UBThumbnailView.cpp \ SOURCES += src/gui/UBThumbnailView.cpp \
src/gui/UBFloatingPalette.cpp \ src/gui/UBFloatingPalette.cpp \
@ -81,7 +85,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/UBDockPaletteWidget.cpp \
src/gui/UBLeftPalette.cpp \
src/gui/UBRightPalette.cpp \
src/gui/UBPageNavigationWidget.cpp \
src/gui/UBLibWidget.cpp
win32 { win32 {

Loading…
Cancel
Save