diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp index 698a9820..145e4035 100755 --- a/src/board/UBBoardPaletteManager.cpp +++ b/src/board/UBBoardPaletteManager.cpp @@ -38,6 +38,9 @@ #include "web/browser/WBTabWidget.h" #include "web/browser/WBWebView.h" +#include "desktop/UBDesktopAnnotationController.h" + + #include "network/UBNetworkAccessManager.h" #include "network/UBServerXMLHttpRequest.h" @@ -76,7 +79,7 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll , mpPageNavigWidget(NULL) , mpLibWidget(NULL) , mpCachePropWidget(NULL) - , mDesktopRightPalette(NULL) +// , mDesktopRightPalette(NULL) , mpTeacherBarWidget(NULL) , mpDesktopLibWidget(NULL) { @@ -131,11 +134,11 @@ UBBoardPaletteManager::~UBBoardPaletteManager() delete mpDesktopLibWidget; mpDesktopLibWidget = NULL; } - if(NULL != mDesktopRightPalette) - { - delete mDesktopRightPalette; - mDesktopRightPalette = NULL; - } +// if(NULL != mDesktopRightPalette) +// { +// delete mDesktopRightPalette; +// mDesktopRightPalette = NULL; +// } } void UBBoardPaletteManager::initPalettesPosAtStartup() @@ -153,34 +156,65 @@ void UBBoardPaletteManager::setupLayout() */ void UBBoardPaletteManager::setupDockPaletteWidgets() { + + //------------------------------------------------// + // Create the widgets for the dock palettes + + mpPageNavigWidget = new UBPageNavigationWidget(); + mpPageNavigWidget->registerMode(eUBDockPaletteWidget_BOARD); + connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpPageNavigWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode))); + + mpLibWidget = new UBLibWidget(); + mpLibWidget ->registerMode(eUBDockPaletteWidget_BOARD); + mpLibWidget ->registerMode(eUBDockPaletteWidget_DESKTOP); + connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpLibWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode))); + +// mpCachePropWidget = new UBCachePropertiesWidget(); +// mpCachePropWidget->registerMode(eUBDockPaletteWidget_BOARD); +// connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpCachePropWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode))); + +// mpTeacherBarWidget = new UBTeacherBarWidget(); +// mpTeacherBarWidget->registerMode(eUBDockPaletteWidget_BOARD); +// connect(this, SIGNAL(signal_changeMode(eUBDockPaletteWidgetMode)), mpTeacherBarWidget, SLOT(slot_changeMode(eUBDockPaletteWidgetMode))); + + //------------------------------------------------// + // Add the dock palettes + mLeftPalette = new UBLeftPalette(mContainer); + // LEFT palette widgets mLeftPalette->registerWidget(mpPageNavigWidget); mLeftPalette->addTabWidget(mpPageNavigWidget); + mLeftPalette->connectSignals(); + //------------------------------------------------// + + mRightPalette = new UBRightPalette(mContainer); + // RIGHT palette widgets mRightPalette->registerWidget(mpLibWidget); - mRightPalette->registerWidget(mpCachePropWidget); mRightPalette->addTabWidget(mpLibWidget); - mRightPalette->registerWidget(mpTeacherBarWidget); - //mRightPalette->addTabWidget(mpTeacherBarWidget); +// // ??? +// mRightPalette->registerWidget(mpCachePropWidget); +// mRightPalette->addTabWidget(mpCachePropWidget); + +// // ??? +// mRightPalette->registerWidget(mpTeacherBarWidget); +// mRightPalette->addTabWidget(mpTeacherBarWidget); + mRightPalette->connectSignals(); + + //------------------------------------------------// + mLeftPalette->showTabWidget(0); mRightPalette->showTabWidget(0); + + //------------------------------------------------// } void UBBoardPaletteManager::setupPalettes() { - // Add the dock palettes - mLeftPalette = new UBLeftPalette(mContainer); - mRightPalette = new UBRightPalette(mContainer); - - // Create the widgets for the dock palettes - mpPageNavigWidget = new UBPageNavigationWidget(); - mpLibWidget = new UBLibWidget(); - mpCachePropWidget = new UBCachePropertiesWidget(); - mpTeacherBarWidget = new UBTeacherBarWidget(); setupDockPaletteWidgets(); @@ -435,6 +469,8 @@ void UBBoardPaletteManager::containerResized() mKeyboardPalette->adjustSizeAndPosition(); } + mLeftPalette->resize(mLeftPalette->width()-1, mContainer->height()); + mRightPalette->resize(mRightPalette->width()-1, mContainer->height()); mLeftPalette->resize(mLeftPalette->width(), mContainer->height()); mRightPalette->resize(mRightPalette->width(), mContainer->height()); } @@ -569,6 +605,53 @@ void UBBoardPaletteManager::addItem(const QUrl& pUrl) } +void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode) +{ + switch( newMode ) + { + case eUBDockPaletteWidget_BOARD: + { + mLeftPalette->setParent(UBApplication::boardController->controlContainer()); + mRightPalette->setParent(UBApplication::boardController->controlContainer()); + + mLeftPalette->setVisible(true); + mRightPalette->setVisible(true); + + containerResized(); + } + break; + + case eUBDockPaletteWidget_DESKTOP: + { + mLeftPalette->setParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView()); + mRightPalette->setParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView()); + + mLeftPalette->setVisible(false); + mRightPalette->setVisible(true); + + UBApplication::applicationController->uninotesController()->TransparentWidgetResized(); + } + break; + + default: + { + mLeftPalette->setVisible(false); + mRightPalette->setVisible(false); + mLeftPalette->setParent(0); + mRightPalette->setParent(0); + } + break; + } + + emit signal_changeMode(newMode); +} + +/* +void UBBoardPaletteManager::slot_changeMode(eUBDockPaletteWidgetMode newMode) +{ + emit signal_changeMode(newMode); +} +*/ void UBBoardPaletteManager::addItem(const QPixmap& pPixmap, const QPointF& pos, qreal scaleFactor, const QUrl& sourceUrl) { @@ -719,6 +802,7 @@ void UBBoardPaletteManager::changeStylusPaletteOrientation(QVariant var) mStylusPalette->setVisible(bVisible); // always show stylus palette at startup } +/* UBRightPalette* UBBoardPaletteManager::createDesktopRightPalette(QWidget* parent) { mpDesktopLibWidget = new UBLibWidget(); @@ -729,6 +813,7 @@ UBRightPalette* UBBoardPaletteManager::createDesktopRightPalette(QWidget* parent return mDesktopRightPalette; } +*/ void UBBoardPaletteManager::connectToDocumentController() { diff --git a/src/board/UBBoardPaletteManager.h b/src/board/UBBoardPaletteManager.h index f2313a71..5fab9c5c 100644 --- a/src/board/UBBoardPaletteManager.h +++ b/src/board/UBBoardPaletteManager.h @@ -48,15 +48,19 @@ class UBBoardPaletteManager : public QObject void setupLayout(); UBLeftPalette* leftPalette(){return mLeftPalette;} + UBRightPalette* rightPalette(){return mRightPalette;} void showVirtualKeyboard(bool show = true); void initPalettesPosAtStartup(); void connectToDocumentController(); UBKeyboardPalette *mKeyboardPalette; - UBRightPalette* createDesktopRightPalette(QWidget* parent); +// UBRightPalette* createDesktopRightPalette(QWidget* parent); + + void changeMode(eUBDockPaletteWidgetMode newMode); signals: void connectToDocController(); + void signal_changeMode(eUBDockPaletteWidgetMode newMode); public slots: @@ -65,6 +69,8 @@ class UBBoardPaletteManager : public QObject void addItem(const QUrl& pUrl); void addItem(const QPixmap& pPixmap, const QPointF& p = QPointF(0.0, 0.0), qreal scale = 1.0, const QUrl& sourceUrl = QUrl()); +// void slot_changeMode(eUBDockPaletteWidgetMode newMode); + private: void setupPalettes(); @@ -84,10 +90,10 @@ class UBBoardPaletteManager : public QObject /** The right dock palette */ UBRightPalette* mRightPalette; - // HACK: here we duplicate the right palette for the desktop mode - // we MUST refactor the architecture in order to use only one - // right palette! - UBRightPalette* mDesktopRightPalette; +// // HACK: here we duplicate the right palette for the desktop mode +// // we MUST refactor the architecture in order to use only one +// // right palette! +// UBRightPalette* mDesktopRightPalette; UBActionPalette *mBackgroundsPalette; UBActionPalette *mToolsPalette; diff --git a/src/board/UBBoardView.cpp b/src/board/UBBoardView.cpp index 2eed5112..2cb28ef9 100644 --- a/src/board/UBBoardView.cpp +++ b/src/board/UBBoardView.cpp @@ -660,8 +660,8 @@ UBBoardView::wheelEvent (QWheelEvent *wheelEvent) QBool isSlectedAndMouseHower = itemsList.contains(selItem); if(isSlectedAndMouseHower) { - wheelEvent->accept(); QGraphicsView::wheelEvent(wheelEvent); + wheelEvent->accept(); } } diff --git a/src/core/UBApplicationController.cpp b/src/core/UBApplicationController.cpp index 4fad106a..f6b002ee 100644 --- a/src/core/UBApplicationController.cpp +++ b/src/core/UBApplicationController.cpp @@ -336,6 +336,7 @@ void UBApplicationController::showBoard() mMainWindow->boardToolBar->show(); mMainMode = Board; + UBApplication::boardController->paletteManager()->changeMode(eUBDockPaletteWidget_BOARD); adaptToolBar(); @@ -352,6 +353,8 @@ void UBApplicationController::showBoard() mUninoteController->hideWindow(); mMainWindow->show(); +// UBApplication::boardController->paletteManager()->changeMode(eUBDockPaletteWidget_BOARD); + emit mainModeChanged(Board); } @@ -365,6 +368,8 @@ void UBApplicationController::showInternet() UBApplication::boardController->hide(); } + UBApplication::boardController->paletteManager()->changeMode(eUBDockPaletteWidget_WEB); + if (UBSettings::settings()->webUseExternalBrowser->get().toBool()) { showDesktop(true); @@ -384,8 +389,10 @@ void UBApplicationController::showInternet() mUninoteController->hideWindow(); emit mainModeChanged(Internet); } - UBApplication::webController->show(UBWebController::WebBrowser); +// UBApplication::boardController->paletteManager()->changeMode(eUBDockPaletteWidget_WEB); + + UBApplication::webController->show(UBWebController::WebBrowser); } @@ -397,6 +404,7 @@ void UBApplicationController::showDocument() mMainWindow->documentToolBar->show(); mMainMode = Document; + UBApplication::boardController->paletteManager()->changeMode(eUBDockPaletteWidget_DOCUMENT); adaptToolBar(); @@ -418,6 +426,8 @@ void UBApplicationController::showDocument() mUninoteController->hideWindow(); +// UBApplication::boardController->paletteManager()->changeMode(eUBDockPaletteWidget_DOCUMENT); + emit mainModeChanged(Document); } @@ -429,6 +439,8 @@ void UBApplicationController::showDesktop(bool dontSwitchFrontProcess) UBApplication::boardController->hide(); mMainWindow->hide(); + UBApplication::boardController->paletteManager()->changeMode(eUBDockPaletteWidget_DESKTOP); + mUninoteController->showWindow(); if (mMirror) @@ -444,6 +456,8 @@ void UBApplicationController::showDesktop(bool dontSwitchFrontProcess) UBPlatformUtils::bringPreviousProcessToFront(); } +// UBApplication::boardController->paletteManager()->changeMode(eUBDockPaletteWidget_DESKTOP); + UBDrawingController::drawingController()->setStylusTool(UBStylusTool::Selector); } diff --git a/src/desktop/UBDesktopAnnotationController.cpp b/src/desktop/UBDesktopAnnotationController.cpp index 458c3534..a4b9c92d 100644 --- a/src/desktop/UBDesktopAnnotationController.cpp +++ b/src/desktop/UBDesktopAnnotationController.cpp @@ -56,7 +56,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) , mDesktopPenPalette(NULL) , mDesktopMarkerPalette(NULL) , mDesktopEraserPalette(NULL) - , mRightPalette(NULL) +// , mRightPalette(NULL) , mWindowPositionInitialized(0) , mIsFullyTransparent(false) , mDesktopToolsPalettePositioned(false) @@ -89,7 +89,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) mTransparentDrawingScene = new UBGraphicsScene(0); mTransparentDrawingView->setScene(mTransparentDrawingScene); - mRightPalette = UBApplication::boardController->paletteManager()->createDesktopRightPalette(mTransparentDrawingView); +// mRightPalette = UBApplication::boardController->paletteManager()->createDesktopRightPalette(mTransparentDrawingView); //mRightPalette = new UBRightPalette(mTransparentDrawingView); mDesktopPalette = new UBDesktopPalette(mTransparentDrawingView); @@ -158,7 +158,8 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) #ifdef Q_WS_X11 connect(mDesktopPalette, SIGNAL(moving()), this, SLOT(refreshMask())); - connect(mRightPalette, SIGNAL(resized()), this, SLOT(refreshMask())); +// connect(mRightPalette, SIGNAL(resized()), this, SLOT(refreshMask())); + connect(UBApplication::boardController->paletteManager()->rightPalette(), SIGNAL(resized()), this, SLOT(refreshMask())); #endif onDesktopPaletteMaximized(); } @@ -859,12 +860,34 @@ void UBDesktopAnnotationController::onDesktopPaletteMinimize() } } +void UBDesktopAnnotationController::TransparentWidgetResized() +{ +/* + int rW = UBApplication::boardController->paletteManager()->rightPalette()->width(); + int rH_ = UBApplication::boardController->paletteManager()->rightPalette()->height(); + int rH = mTransparentDrawingView->height(); + + UBApplication::boardController->paletteManager()->rightPalette()->resize(rW+1, rH); + + // UBApplication::boardController->paletteManager()->rightPalette()->resize(500, 500); +*/ + + onTransparentWidgetResized(); +} + /** * \brief Resize the library palette. */ void UBDesktopAnnotationController::onTransparentWidgetResized() { - mRightPalette->resize(mRightPalette->width(), mTransparentDrawingView->height()); + int rW = UBApplication::boardController->paletteManager()->rightPalette()->width(); + int rH_ = UBApplication::boardController->paletteManager()->rightPalette()->height(); + int rH = mTransparentDrawingView->height(); + + UBApplication::boardController->paletteManager()->rightPalette()->resize(rW+1, rH); + UBApplication::boardController->paletteManager()->rightPalette()->resize(rW, rH); + +// mRightPalette->resize(mRightPalette->width(), mTransparentDrawingView->height()); } void UBDesktopAnnotationController::updateMask(bool bTransparent) @@ -891,10 +914,15 @@ void UBDesktopAnnotationController::updateMask(bool bTransparent) { p.drawRect(mKeyboardPalette->geometry().x(), mKeyboardPalette->geometry().y(), mKeyboardPalette->width(), mKeyboardPalette->height()); } - if(mRightPalette->isVisible()) + +// UBApplication::boardController->paletteManager()->mDesktopRightPalette + if(UBApplication::boardController->paletteManager()->rightPalette()->isVisible()) { qDebug() << ">>>>>> Drawing the mask for the right palette"; - p.drawRect(mRightPalette->geometry().x(), mRightPalette->geometry().y(), mRightPalette->width(), mRightPalette->height()); + p.drawRect(UBApplication::boardController->paletteManager()->rightPalette()->geometry().x(), + UBApplication::boardController->paletteManager()->rightPalette()->geometry().y(), + UBApplication::boardController->paletteManager()->rightPalette()->width(), + UBApplication::boardController->paletteManager()->rightPalette()->height()); } p.end(); diff --git a/src/desktop/UBDesktopAnnotationController.h b/src/desktop/UBDesktopAnnotationController.h index d61d7607..b3a9e37f 100644 --- a/src/desktop/UBDesktopAnnotationController.h +++ b/src/desktop/UBDesktopAnnotationController.h @@ -55,6 +55,9 @@ class UBDesktopAnnotationController : public QObject UBDesktopPalette *desktopPalette(); UBBoardView *drawingView(); + void TransparentWidgetResized(); + + public slots: void screenLayoutChanged(); diff --git a/src/gui/UBDockPalette.h b/src/gui/UBDockPalette.h index 627535da..b69d0653 100644 --- a/src/gui/UBDockPalette.h +++ b/src/gui/UBDockPalette.h @@ -123,6 +123,8 @@ protected: /** The current widget */ QVector mRegisteredWidgets; +// QVector mVisibleWidgets; // ??? + private slots: void onToolbarPosUpdated(); void onResizeRequest(QResizeEvent* event); diff --git a/src/gui/UBDockPaletteWidget.cpp b/src/gui/UBDockPaletteWidget.cpp index d649d9a5..9cd1197c 100644 --- a/src/gui/UBDockPaletteWidget.cpp +++ b/src/gui/UBDockPaletteWidget.cpp @@ -24,3 +24,16 @@ QString UBDockPaletteWidget::name() { return mName; } + +void UBDockPaletteWidget::registerMode(eUBDockPaletteWidgetMode mode) +{ + if(!mRegisteredModes.contains(mode)) + mRegisteredModes.append(mode); +} + +void UBDockPaletteWidget::slot_changeMode(eUBDockPaletteWidgetMode newMode) +{ + this->setVisible(mRegisteredModes.contains(newMode)); +} + + diff --git a/src/gui/UBDockPaletteWidget.h b/src/gui/UBDockPaletteWidget.h index 69a70a8a..aa97a029 100644 --- a/src/gui/UBDockPaletteWidget.h +++ b/src/gui/UBDockPaletteWidget.h @@ -5,8 +5,17 @@ #include #include +typedef enum +{ + eUBDockPaletteWidget_BOARD, + eUBDockPaletteWidget_WEB, + eUBDockPaletteWidget_DOCUMENT, + eUBDockPaletteWidget_DESKTOP, +} eUBDockPaletteWidgetMode; + class UBDockPaletteWidget : public QWidget { + Q_OBJECT public: UBDockPaletteWidget(QWidget* parent=0, const char* name="UBDockPaletteWidget"); @@ -16,10 +25,21 @@ public: QPixmap iconToLeft(); QString name(); + void registerMode(eUBDockPaletteWidgetMode mode); + + /* The current widget available mode list */ + QVector mRegisteredModes; + + + signals: void hideTab(const QString& widgetName); void showTab(const QString& widgetName); +public slots: + void slot_changeMode(eUBDockPaletteWidgetMode newMode); + + protected: QPixmap mIconToRight; // arrow like this: > QPixmap mIconToLeft; // arrow like this: <