diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index 6a07e994..7dd647c6 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -1155,7 +1155,7 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, } // Notify the navigator palette that the document has changed - mPaletteManager->leftPalette()->pageNavigator()->setDocument(pDocumentProxy); + emit setDocOnPageNavigator(pDocumentProxy); if (sceneChange) { diff --git a/src/board/UBBoardController.h b/src/board/UBBoardController.h index 0ddb0412..1fdeb6b3 100644 --- a/src/board/UBBoardController.h +++ b/src/board/UBBoardController.h @@ -261,6 +261,7 @@ class UBBoardController : public QObject void cacheEnabled(); void cacheDisabled(); void pageChanged(); + void setDocOnPageNavigator(UBDocumentProxy* doc); protected: diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp index 7762cd1b..e3abfc04 100755 --- a/src/board/UBBoardPaletteManager.cpp +++ b/src/board/UBBoardPaletteManager.cpp @@ -73,7 +73,9 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll , mPendingZoomButtonPressed(false) , mPendingPanButtonPressed(false) , mPendingEraseButtonPressed(false) - + , mpPageNavigWidget(NULL) + , mpLibWidget(NULL) + , mpCachePropWidget(NULL) { setupPalettes(); connectPalettes(); @@ -82,6 +84,21 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll UBBoardPaletteManager::~UBBoardPaletteManager() { + if(NULL != mpPageNavigWidget) + { + delete mpPageNavigWidget; + mpPageNavigWidget = NULL; + } + if(NULL != mpLibWidget) + { + delete mpLibWidget; + mpLibWidget = NULL; + } + if(NULL != mpCachePropWidget) + { + delete mpCachePropWidget; + mpCachePropWidget = NULL; + } delete mAddItemPalette; if(NULL != mLeftPalette) { @@ -112,15 +129,37 @@ void UBBoardPaletteManager::setupLayout() } +/** + * \brief Set up the dock palette widgets + */ +void UBBoardPaletteManager::setupDockPaletteWidgets() +{ + // LEFT palette widgets + mLeftPalette->registerWidget(mpPageNavigWidget); + mLeftPalette->addTabWidget(mpPageNavigWidget); + mLeftPalette->connectSignals(); + + // RIGHT palette widgets + mRightPalette->registerWidget(mpLibWidget); + mRightPalette->registerWidget(mpCachePropWidget); + mRightPalette->addTabWidget(mpLibWidget); + mRightPalette->connectSignals(); +} void UBBoardPaletteManager::setupPalettes() { // Add the dock palettes mLeftPalette = new UBLeftPalette(mContainer); - - // We disable the lib palette for the moment because it is not yet available mRightPalette = new UBRightPalette(mContainer); + // Create the widgets for the dock palettes + mpPageNavigWidget = new UBPageNavigationWidget(); + mpLibWidget = new UBLibWidget(); + mpCachePropWidget = new UBCachePropertiesWidget(); + + setupDockPaletteWidgets(); + + // Add the other palettes mStylusPalette = new UBStylusPalette(mContainer, UBSettings::settings()->appToolBarOrientationVertical->get().toBool() ? Qt::Vertical : Qt::Horizontal); connect(mStylusPalette, SIGNAL(stylusToolDoubleClicked(int)), UBApplication::boardController, SLOT(stylusToolDoubleClicked(int))); @@ -396,9 +435,9 @@ void UBBoardPaletteManager::activeSceneChanged() if (mStylusPalette) connect(mStylusPalette, SIGNAL(mouseEntered()), activeScene, SLOT(hideEraser())); - if (mLeftPalette) + if (mpPageNavigWidget) { - mLeftPalette->pageNavigator()->setPageNumber(pageIndex + 1, activeScene->document()->pageCount()); + mpPageNavigWidget->setPageNumber(pageIndex + 1, activeScene->document()->pageCount()); } if (mZoomPalette) @@ -562,10 +601,11 @@ void UBBoardPaletteManager::addItemToLibrary() , Qt::KeepAspectRatio, Qt::SmoothTransformation); } QImage image = mPixmap.toImage(); - // TODO:Claudio - // This is a wrong way of calling importImageOnLibrary but for the moment it works because element on mRightPalette are predefined. - mRightPalette->libWidget()->libNavigator()->libraryWidget()->libraryController()->importImageOnLibrary(image); + if(NULL != mpLibWidget) + { + mpLibWidget->libNavigator()->libraryWidget()->libraryController()->importImageOnLibrary(image); + } } else { diff --git a/src/board/UBBoardPaletteManager.h b/src/board/UBBoardPaletteManager.h index 1432ad0e..a4d0e08e 100644 --- a/src/board/UBBoardPaletteManager.h +++ b/src/board/UBBoardPaletteManager.h @@ -22,6 +22,9 @@ #include "web/UBRoutedMouseEventWebView.h" #include "gui/UBLeftPalette.h" #include "gui/UBRightPalette.h" +#include "gui/UBPageNavigationWidget.h" +#include "gui/UBLibWidget.h" +#include "gui/UBCachePropertiesWidget.h" class UBStylusPalette; class UBClockPalette; @@ -61,6 +64,7 @@ class UBBoardPaletteManager : public QObject void setupPalettes(); void connectPalettes(); void positionFreeDisplayPalette(); + void setupDockPaletteWidgets(); QWidget* mContainer; UBBoardController *mBoardControler; @@ -69,7 +73,9 @@ class UBBoardPaletteManager : public QObject UBZoomPalette *mZoomPalette; + /** The left dock palette */ UBLeftPalette* mLeftPalette; + /** The right dock palette */ UBRightPalette* mRightPalette; UBActionPalette *mBackgroundsPalette; @@ -95,6 +101,13 @@ class UBBoardPaletteManager : public QObject QTime mEraseButtonPressedTime; bool mPendingEraseButtonPressed; + /** The page navigator widget */ + UBPageNavigationWidget* mpPageNavigWidget; + /** The library widget */ + UBLibWidget* mpLibWidget; + /** The cache properties widget */ + UBCachePropertiesWidget* mpCachePropWidget; + private slots: void changeBackground(); diff --git a/src/gui/UBDockPalette.cpp b/src/gui/UBDockPalette.cpp index 2d54f017..7e0e49fe 100644 --- a/src/gui/UBDockPalette.cpp +++ b/src/gui/UBDockPalette.cpp @@ -260,6 +260,10 @@ void UBDockPalette::mouseReleaseEvent(QMouseEvent *event) mCanResize = false; } +/** + * \brief Handle the resize event + * @param event as the resize event + */ void UBDockPalette::resizeEvent(QResizeEvent *event) { Q_UNUSED(event); @@ -461,6 +465,10 @@ void UBDockPalette::tabClicked(int tabIndex) } } +/** + * \brief Show the tab widget related to the given index + * @param tabIndex as the given index + */ void UBDockPalette::showTabWidget(int tabIndex) { mpStackWidget->setCurrentIndex(tabIndex); @@ -473,6 +481,9 @@ void UBDockPalette::showTabWidget(int tabIndex) } } +/** + * \brief Toggle the collapse / expand state + */ void UBDockPalette::toggleCollapseExpand() { if(mLastWidth == -1) @@ -489,11 +500,18 @@ void UBDockPalette::toggleCollapseExpand() } } +/** + * \brief Set the tabs orientation + * @param orientation as the given tabs orientation + */ void UBDockPalette::setTabsOrientation(eUBDockTabOrientation orientation) { mTabsOrientation = orientation; } +/** + * \brief Update the tab position regarding the toolbar position (up or down) + */ void UBDockPalette::onToolbarPosUpdated() { // Get the position of the tab @@ -508,11 +526,19 @@ void UBDockPalette::onToolbarPosUpdated() update(); } +/** + * \brief Get the custom margin + * @return the custom margin value + */ int UBDockPalette::customMargin() { return 5; } +/** + * \brief Add the given tab widget + * @param widget as the given widget + */ void UBDockPalette::addTabWidget(UBDockPaletteWidget *widget) { if(!mTabWidgets.contains(widget)) @@ -525,6 +551,10 @@ void UBDockPalette::addTabWidget(UBDockPaletteWidget *widget) } } +/** + * \brief Remove the given tab + * @param widgetName as the tab widget name + */ void UBDockPalette::removeTab(const QString &widgetName) { for(int i = 0; i < mTabWidgets.size(); i++) @@ -541,17 +571,28 @@ void UBDockPalette::removeTab(const QString &widgetName) } } +/** + * \brief Handle the resize request + * @param event as the given resize request + */ void UBDockPalette::onResizeRequest(QResizeEvent *event) { resizeEvent(event); } +/** + * \brief Get the tab spacing + * @return the tab spacing + */ int UBDockPalette::tabSpacing() { return 2; } -// This method is used to show the tab widget +/** + * \brief Show the given widget + * @param widgetName as the given widget name + */ void UBDockPalette::onShowTabWidget(const QString &widgetName) { for(int i = 0; i < mRegisteredWidgets.size(); i++) @@ -565,12 +606,18 @@ void UBDockPalette::onShowTabWidget(const QString &widgetName) } } -// This method is used to hide the tab widget +/** + * \brief Hide the given widget + * @param widgetName as the given widget name + */ void UBDockPalette::onHideTabWidget(const QString &widgetName) { removeTab(widgetName); } +/** + * \brief Connect the show / hide signals of the widget related to this dock palette + */ void UBDockPalette::connectSignals() { for(int i=0; i < mRegisteredWidgets.size(); i++) @@ -580,10 +627,16 @@ void UBDockPalette::connectSignals() } } +/** + * \brief Register the given widget + * @param widget as the given widget + */ void UBDockPalette::registerWidget(UBDockPaletteWidget *widget) { if(!mRegisteredWidgets.contains(widget)) { + // Update the parent of this widget + widget->setParent(this); mRegisteredWidgets.append(widget); // By default, the widget is hidden diff --git a/src/gui/UBDockPalette.h b/src/gui/UBDockPalette.h index 3854eb53..627535da 100644 --- a/src/gui/UBDockPalette.h +++ b/src/gui/UBDockPalette.h @@ -72,16 +72,15 @@ public: void setBackgroundBrush(const QBrush& brush); void registerWidget(UBDockPaletteWidget* widget); + void addTabWidget(UBDockPaletteWidget* widget); + void removeTab(const QString& widgetName); + void connectSignals(); public slots: void onShowTabWidget(const QString& widgetName); void onHideTabWidget(const QString& widgetName); protected: - void addTabWidget(UBDockPaletteWidget* widget); - void removeTab(const QString& widgetName); - void connectSignals(); - virtual int border(); virtual int radius(); virtual int customMargin(); @@ -109,15 +108,10 @@ protected: QTime mClickTime; /** The mouse pressed position */ QPoint mMousePressPos; -// /** The palette icon */ -// QPixmap mIcon; -// QPixmap mCollapsedIcon; /** The tab orientation */ eUBDockTabOrientation mTabsOrientation; /** The h position of the tab */ int mHTab; - /** The tab widgets */ - //QMap mTabWidgets; /** The stacked widget */ QStackedWidget* mpStackWidget; /** The layout */ @@ -136,7 +130,6 @@ private slots: private: void tabClicked(int tabIndex); int tabSpacing(); - void toggleCollapseExpand(); }; diff --git a/src/gui/UBLeftPalette.cpp b/src/gui/UBLeftPalette.cpp index 2172eb2b..c5debaa6 100644 --- a/src/gui/UBLeftPalette.cpp +++ b/src/gui/UBLeftPalette.cpp @@ -13,52 +13,45 @@ * along with this program. If not, see . */ #include "UBLeftPalette.h" +#include "core/UBSettings.h" +/** + * \brief The constructor + */ UBLeftPalette::UBLeftPalette(QWidget *parent, const char *name):UBDockPalette(parent) - , mpPageNavigator(NULL) { setObjectName(name); setOrientation(eUBDockOrientation_Left); mLastWidth = 300; mCollapseWidth = 180; -/* - resize(UBSettings::settings()->libPaletteWidth->get().toInt(), parentWidget()->height()); - mpLayout->setContentsMargins(2*border() + customMargin(), customMargin(), customMargin(), customMargin()); -*/ resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), parentWidget()->height()); mpLayout->setContentsMargins(customMargin(), customMargin(), 2*border() + customMargin(), customMargin()); - // Add the widgets here - mpPageNavigator = new UBPageNavigationWidget(this); - addTabWidget(mpPageNavigator); } +/** + * \brief The destructor + */ UBLeftPalette::~UBLeftPalette() { - if(NULL != mpPageNavigator) - { - delete mpPageNavigator; - mpPageNavigator = NULL; - } + } +/** + * \brief Update the maximum width + */ void UBLeftPalette::updateMaxWidth() { setMaximumWidth(300); } +/** + * \brief Handle the resize event + * @param event as the resize event + */ void UBLeftPalette::resizeEvent(QResizeEvent *event) { UBDockPalette::resizeEvent(event); - if(NULL != mpPageNavigator) - { - mpPageNavigator->setMinimumHeight(height() - 2*border()); - } UBSettings::settings()->navigPaletteWidth->set(width()); } - -UBPageNavigationWidget* UBLeftPalette::pageNavigator() -{ - return mpPageNavigator; -} diff --git a/src/gui/UBLeftPalette.h b/src/gui/UBLeftPalette.h index a2f549ec..cdb49330 100644 --- a/src/gui/UBLeftPalette.h +++ b/src/gui/UBLeftPalette.h @@ -16,7 +16,6 @@ #define UBLEFTPALETTE_H #include "UBDockPalette.h" -#include "UBPageNavigationWidget.h" class UBLeftPalette : public UBDockPalette { @@ -24,15 +23,9 @@ public: UBLeftPalette(QWidget* parent=0, const char* name="UBLeftPalette"); ~UBLeftPalette(); - UBPageNavigationWidget* pageNavigator(); - protected: void updateMaxWidth(); void resizeEvent(QResizeEvent *event); - -private: - UBPageNavigationWidget* mpPageNavigator; - }; #endif // UBLEFTPALETTE_H diff --git a/src/gui/UBPageNavigationWidget.cpp b/src/gui/UBPageNavigationWidget.cpp index 557f86b0..a5fd7ed3 100644 --- a/src/gui/UBPageNavigationWidget.cpp +++ b/src/gui/UBPageNavigationWidget.cpp @@ -68,6 +68,7 @@ UBPageNavigationWidget::UBPageNavigationWidget(QWidget *parent, const char *name mTimerID = startTimer(1000); connect(mNavigator, SIGNAL(changeCurrentPage()), this, SLOT(changeCurrentPage())); + connect(UBApplication::boardController, SIGNAL(setDocOnPageNavigator(UBDocumentProxy*)), this, SLOT(onSetDocOnPageNavigator(UBDocumentProxy*))); } /** @@ -173,12 +174,29 @@ void UBPageNavigationWidget::setPageNumber(int current, int total) mPageNbr->setText(QString("%1 / %2").arg(current).arg(total)); } +/** + * \brief Get the custom margin value + * @return the custom margin value + */ int UBPageNavigationWidget::customMargin() { return 5; } +/** + * \brief Get the border value + * @return the border value + */ int UBPageNavigationWidget::border() { return 15; } + +/** + * \brief Set the current document + * @param doc as the current document + */ +void UBPageNavigationWidget::onSetDocOnPageNavigator(UBDocumentProxy *doc) +{ + setDocument(doc); +} diff --git a/src/gui/UBPageNavigationWidget.h b/src/gui/UBPageNavigationWidget.h index ce4993bb..bd54e10b 100644 --- a/src/gui/UBPageNavigationWidget.h +++ b/src/gui/UBPageNavigationWidget.h @@ -45,6 +45,9 @@ public slots: protected: virtual void timerEvent(QTimerEvent *event); +private slots: + void onSetDocOnPageNavigator(UBDocumentProxy* doc); + private: void updateTime(); int customMargin(); diff --git a/src/gui/UBRightPalette.cpp b/src/gui/UBRightPalette.cpp index c48cdc92..ee54b4e7 100644 --- a/src/gui/UBRightPalette.cpp +++ b/src/gui/UBRightPalette.cpp @@ -17,9 +17,10 @@ #include "UBRightPalette.h" - +/** + * \brief The constructor + */ UBRightPalette::UBRightPalette(QWidget *parent, const char *name):UBDockPalette(parent) - , mpLibWidget(NULL) { setObjectName(name); setOrientation(eUBDockOrientation_Right); @@ -27,50 +28,32 @@ UBRightPalette::UBRightPalette(QWidget *parent, const char *name):UBDockPalette( mLastWidth = 300; resize(UBSettings::settings()->libPaletteWidth->get().toInt(), parentWidget()->height()); mpLayout->setContentsMargins(2*border() + customMargin(), customMargin(), customMargin(), customMargin()); - - // Create and register the widgets - mpLibWidget = new UBLibWidget(this); - mpCachePropWidget = new UBCachePropertiesWidget(this); - registerWidget(mpLibWidget); - registerWidget(mpCachePropWidget); - - // Add the visible widgets - addTabWidget(mpLibWidget); - - connectSignals(); } +/** + * \brief The destructor + */ UBRightPalette::~UBRightPalette() { - if(NULL != mpLibWidget) - { - delete mpLibWidget; - mpLibWidget = NULL; - } - if(NULL != mpCachePropWidget) - { - delete mpCachePropWidget; - mpCachePropWidget = NULL; - } -} -UBLibWidget* UBRightPalette::libWidget() -{ - return mpLibWidget; } +/** + * \brief Handle the mouse move event + * @event as the mouse move event + */ void UBRightPalette::mouseMoveEvent(QMouseEvent *event) { if(mCanResize) { UBDockPalette::mouseMoveEvent(event); } - else - { - //qDebug() << "Mouse move event detected!" ; - } } +/** + * \brief Handle the resize event + * @param event as the resize event + */ void UBRightPalette::resizeEvent(QResizeEvent *event) { UBDockPalette::resizeEvent(event); @@ -78,39 +61,12 @@ void UBRightPalette::resizeEvent(QResizeEvent *event) emit resized(); } +/** + * \brief Update the maximum width + */ void UBRightPalette::updateMaxWidth() { setMaximumWidth((int)((parentWidget()->width() * 2)/3)); setMaximumHeight(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(); -//} diff --git a/src/gui/UBRightPalette.h b/src/gui/UBRightPalette.h index 2181a8a4..df0e82e5 100644 --- a/src/gui/UBRightPalette.h +++ b/src/gui/UBRightPalette.h @@ -16,8 +16,6 @@ #define UBRIGHTPALETTE_H #include "UBDockPalette.h" -#include "UBLibWidget.h" -#include "UBCachePropertiesWidget.h" class UBRightPalette : public UBDockPalette { @@ -26,8 +24,6 @@ public: UBRightPalette(QWidget* parent=0, const char* name="UBRightPalette"); ~UBRightPalette(); - UBLibWidget* libWidget(); - signals: void resized(); @@ -35,14 +31,6 @@ protected: void updateMaxWidth(); void mouseMoveEvent(QMouseEvent *event); void resizeEvent(QResizeEvent *event); - -private slots: -// void onCacheEnabled(); -// void onCacheDisabled(); - -private: - UBLibWidget* mpLibWidget; - UBCachePropertiesWidget* mpCachePropWidget; }; #endif // UBRIGHTPALETTE_H