diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index 782cf085..8199900e 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -1137,7 +1137,7 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, } // Notify the navigator palette that the document has changed - mPaletteManager->navigatorPalette()->setDocument(pDocumentProxy); + mPaletteManager->leftPalette()->pageNavigator()->setDocument(pDocumentProxy); if (sceneChange) emit activeSceneChanged(); diff --git a/src/board/UBBoardPaletteManager.cpp b/src/board/UBBoardPaletteManager.cpp index 5392cc28..2e9efabb 100755 --- a/src/board/UBBoardPaletteManager.cpp +++ b/src/board/UBBoardPaletteManager.cpp @@ -65,8 +65,8 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll , mBoardControler(pBoardController) , mStylusPalette(0) , mZoomPalette(0) - , mNavigPalette(NULL) - , mLibPalette(NULL) + , mLeftPalette(NULL) + , mRightPalette(NULL) , mBackgroundsPalette(0) , mToolsPalette(0) , mAddItemPalette(0) @@ -86,16 +86,16 @@ UBBoardPaletteManager::UBBoardPaletteManager(QWidget* container, UBBoardControll UBBoardPaletteManager::~UBBoardPaletteManager() { delete mAddItemPalette; - if(NULL != mNavigPalette) + if(NULL != mLeftPalette) { - delete mNavigPalette; - mNavigPalette = NULL; + delete mLeftPalette; + mLeftPalette = NULL; } - if(NULL != mLibPalette) + if(NULL != mRightPalette) { - delete mLibPalette; - mLibPalette = NULL; + delete mRightPalette; + mRightPalette = NULL; } if(NULL != mStylusPalette) @@ -119,10 +119,10 @@ void UBBoardPaletteManager::setupLayout() void UBBoardPaletteManager::setupPalettes() { // 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 - mLibPalette = new UBLibPalette(mContainer); + mRightPalette = new UBRightPalette(mContainer); // Add the other palettes mStylusPalette = new UBStylusPalette(mContainer, UBSettings::settings()->appToolBarOrientationVertical->get().toBool() ? Qt::Vertical : Qt::Horizontal); @@ -375,8 +375,8 @@ void UBBoardPaletteManager::containerResized() mKeyboardPalette->adjustSizeAndPosition(); } - mNavigPalette->resize(mNavigPalette->width(), mContainer->height()); - mLibPalette->resize(mLibPalette->width(), mContainer->height()); + mLeftPalette->resize(mLeftPalette->width(), mContainer->height()); + mRightPalette->resize(mRightPalette->width(), mContainer->height()); } @@ -403,9 +403,9 @@ void UBBoardPaletteManager::activeSceneChanged() if (mStylusPalette) 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) diff --git a/src/board/UBBoardPaletteManager.h b/src/board/UBBoardPaletteManager.h index e440f5f7..187f0736 100644 --- a/src/board/UBBoardPaletteManager.h +++ b/src/board/UBBoardPaletteManager.h @@ -20,8 +20,8 @@ #include #include "web/UBRoutedMouseEventWebView.h" -#include "gui/UBNavigatorPalette.h" -#include "gui/UBLibPalette.h" +#include "gui/UBLeftPalette.h" +#include "gui/UBRightPalette.h" class UBStylusPalette; class UBClockPalette; @@ -43,8 +43,8 @@ class UBBoardPaletteManager : public QObject virtual ~UBBoardPaletteManager(); void setupLayout(); - UBNavigatorPalette* navigatorPalette(){return mNavigPalette;} - void showVirtualKeyboard(bool show = true); + UBLeftPalette* leftPalette(){return mLeftPalette;} + void showVirtualKeyboard(bool show = true); void initPalettesPosAtStartup(); UBKeyboardPalette *mKeyboardPalette; @@ -68,8 +68,9 @@ class UBBoardPaletteManager : public QObject UBStylusPalette *mStylusPalette; UBZoomPalette *mZoomPalette; - UBNavigatorPalette* mNavigPalette; - UBLibPalette* mLibPalette; + + UBLeftPalette* mLeftPalette; + UBRightPalette* mRightPalette; UBActionPalette *mBackgroundsPalette; UBActionPalette *mToolsPalette; @@ -113,7 +114,7 @@ class UBBoardPaletteManager : public QObject void togglePagePalette(bool ckecked); void pagePaletteClosed(); - void pagePaletteButtonPressed(); + void pagePaletteButtonPressed(); void pagePaletteButtonReleased(); void addItemToCurrentPage(); diff --git a/src/desktop/UBDesktopAnnotationController.cpp b/src/desktop/UBDesktopAnnotationController.cpp index 5d6b3b34..cb44c140 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) - , mLibPalette(NULL) + , mRightPalette(NULL) , mWindowPositionInitialized(0) , mIsFullyTransparent(false) , mDesktopToolsPalettePositioned(false) @@ -89,7 +89,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) mTransparentDrawingScene = new UBGraphicsScene(0); mTransparentDrawingView->setScene(mTransparentDrawingScene); - mLibPalette = new UBLibPalette(mTransparentDrawingView); + mRightPalette = new UBRightPalette(mTransparentDrawingView); mDesktopPalette = new UBDesktopPalette(mTransparentDrawingView); @@ -160,7 +160,7 @@ UBDesktopAnnotationController::UBDesktopAnnotationController(QObject *parent) #ifdef Q_WS_X11 connect(mDesktopPalette, SIGNAL(moving()), this, SLOT(refreshMask())); - connect(mLibPalette, SIGNAL(resized()), this, SLOT(refreshMask())); + connect(mRightPalette, SIGNAL(resized()), this, SLOT(refreshMask())); #endif onDesktopPaletteMaximized(); } @@ -212,10 +212,10 @@ UBDesktopAnnotationController::~UBDesktopAnnotationController() delete mDesktopEraserPalette; mDesktopEraserPalette = NULL; } - if(NULL != mLibPalette) + if(NULL != mRightPalette) { - delete mLibPalette; - mLibPalette = NULL; + delete mRightPalette; + mRightPalette = NULL; } */ } @@ -800,7 +800,7 @@ void UBDesktopAnnotationController::onDesktopPaletteMinimize() */ void UBDesktopAnnotationController::onTransparentWidgetResized() { - mLibPalette->resize(mLibPalette->width(), mTransparentDrawingView->height()); + mRightPalette->resize(mRightPalette->width(), mTransparentDrawingView->height()); } 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()); } - 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(); diff --git a/src/desktop/UBDesktopAnnotationController.h b/src/desktop/UBDesktopAnnotationController.h index c4e9fea3..f569332a 100644 --- a/src/desktop/UBDesktopAnnotationController.h +++ b/src/desktop/UBDesktopAnnotationController.h @@ -20,7 +20,7 @@ #include #include -#include "gui/UBLibPalette.h" +#include "gui/UBRightPalette.h" class UBDesktopPalette; class UBDesktopToolsPalette; @@ -117,7 +117,7 @@ class UBDesktopAnnotationController : public QObject UBDesktopMarkerPalette* mDesktopMarkerPalette; UBDesktopEraserPalette* mDesktopEraserPalette; - UBLibPalette* mLibPalette; + UBRightPalette* mRightPalette; QTime mPenHoldTimer; QTime mMarkerHoldTimer; diff --git a/src/gui/UBDockPalette.cpp b/src/gui/UBDockPalette.cpp index e1e44528..b342bc6a 100644 --- a/src/gui/UBDockPalette.cpp +++ b/src/gui/UBDockPalette.cpp @@ -24,22 +24,6 @@ #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 */ @@ -54,9 +38,17 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name) , mLastWidth(-1) , mHTab(0) , mpStackWidget(NULL) + , mpLayout(NULL) + , mCurrentTab(0) { setObjectName(name); + mpLayout = new QVBoxLayout(); + setLayout(mpLayout); + + mpStackWidget = new QStackedWidget(this); + mpLayout->addWidget(mpStackWidget); + // clear the tab widgets mTabWidgets.clear(); @@ -100,6 +92,11 @@ UBDockPalette::~UBDockPalette() delete mpStackWidget; mpStackWidget = NULL; } + if(NULL != mpLayout) + { + delete mpLayout; + mpLayout = NULL; + } } /** @@ -202,13 +199,13 @@ void UBDockPalette::mousePressEvent(QMouseEvent *event) switch(mOrientation) { case eUBDockOrientation_Left: - if((p.x() >= width() - border()) && (p.x() <= width())) + if((p.x() >= width() - 2 * border()) && (p.x() <= width())) { mCanResize = true; } break; case eUBDockOrientation_Right: - if((p.x() >= 0) && (p.x() <= border())) + if((p.x() >= 0) && (p.x() <= 2 * border())) { mCanResize = true; } @@ -233,15 +230,18 @@ void UBDockPalette::mouseReleaseEvent(QMouseEvent *event) Q_UNUSED(event); 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(eUBDockOrientation_Left == mOrientation) { if(mMousePressPos.x() >= width() - 2*border() && mMousePressPos.y() >= mHTab && 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) @@ -249,9 +249,10 @@ void UBDockPalette::mouseReleaseEvent(QMouseEvent *event) if(mMousePressPos.x() >= 0 && mMousePressPos.x() <= 2*border() && 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.setPen(Qt::NoPen); 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) - { - mHTab = border(); - } - else - { - mHTab = height() - border() - i*TABSIZE; - } - + // First draw the BIG RECTANGLE (I write it big because the rectangle is big...) if(mOrientation == eUBDockOrientation_Left) { - QPainterPath path; - path.setFillRule(Qt::WindingFill); path.addRect(0.0, 0.0, width()-2*border(), height()); - path.addRoundedRect(width()-4*border(), mHTab, 4*border(), TABSIZE, radius(), radius()); - painter.drawPath(path); - //painter.drawPixmap(width() - border() + 1, mHTab + 1 , border() - 4, TABSIZE - 2, mIcon); } else if(mOrientation == eUBDockOrientation_Right) { - QPainterPath path; - path.setFillRule(Qt::WindingFill); path.addRect(2*border(), 0.0, width()-2*border(), height()); - path.addRoundedRect(0.0, mHTab, 4*border(), TABSIZE, radius(), radius()); - painter.drawPath(path); - //painter.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 { - 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 */ -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) { @@ -449,12 +513,34 @@ int UBDockPalette::customMargin() 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) { - 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; } diff --git a/src/gui/UBDockPalette.h b/src/gui/UBDockPalette.h index c2e68b4a..34c3ee2b 100644 --- a/src/gui/UBDockPalette.h +++ b/src/gui/UBDockPalette.h @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include "UBDockPaletteWidget.h" @@ -68,10 +70,11 @@ public: virtual void leaveEvent(QEvent *); void setBackgroundBrush(const QBrush& brush); - void addTabWidget(const QString& widgetName, UBDockPaletteWidget* widget); - void removeTab(const QString& widgetName); protected: + void addTabWidget(UBDockPaletteWidget* widget); + void removeTab(const QString& widgetName); + virtual int border(); virtual int radius(); virtual int customMargin(); @@ -107,15 +110,25 @@ protected: /** The h position of the tab */ int mHTab; /** The tab widgets */ - QMap mTabWidgets; + //QMap mTabWidgets; /** The stacked widget */ QStackedWidget* mpStackWidget; + /** The layout */ + QVBoxLayout* mpLayout; + /** The current tab index */ + int mCurrentTab; + /** The tab widgets */ + QVector mTabWidgets; private slots: void onToolbarPosUpdated(); + void onResizeRequest(QResizeEvent* event); private: - void tabClicked(); + void tabClicked(int tabIndex); + int tabSpacing(); + void showTabWidget(int tabIndex); + void toggleCollapseExpand(); }; #endif // UBDOCKPALETTE_H diff --git a/src/gui/UBDockPaletteWidget.cpp b/src/gui/UBDockPaletteWidget.cpp index bf8e51c7..d649d9a5 100644 --- a/src/gui/UBDockPaletteWidget.cpp +++ b/src/gui/UBDockPaletteWidget.cpp @@ -1,36 +1,26 @@ #include "UBDockPaletteWidget.h" -UBDockPaletteWidget::UBDockPaletteWidget(const char *name, QWidget *parent):QWidget(parent) - , mpWidget(NULL) +UBDockPaletteWidget::UBDockPaletteWidget(QWidget *parent, const char *name):QWidget(parent) { setObjectName(name); - } 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; - } diff --git a/src/gui/UBDockPaletteWidget.h b/src/gui/UBDockPaletteWidget.h index 6d21a15a..1158a858 100644 --- a/src/gui/UBDockPaletteWidget.h +++ b/src/gui/UBDockPaletteWidget.h @@ -2,24 +2,22 @@ #define UBDOCKPALETTEWIDGET_H #include -#include +#include #include class UBDockPaletteWidget : public QWidget { public: - UBDockPaletteWidget(const char* name="UBDockPaletteWidget", QWidget* parent=0); + UBDockPaletteWidget(QWidget* parent=0, const char* name="UBDockPaletteWidget"); ~UBDockPaletteWidget(); - QWidget* widget(); - QIcon icon(); - QIcon collapsedIcon(); + QPixmap iconToRight(); + QPixmap iconToLeft(); QString name(); protected: - QWidget* mpWidget; - QIcon mIcon; - QIcon mCollapsedIcon; + QPixmap mIconToRight; // arrow like this: > + QPixmap mIconToLeft; // arrow like this: < QString mName; }; diff --git a/src/gui/UBLeftPalette.cpp b/src/gui/UBLeftPalette.cpp new file mode 100644 index 00000000..299e8494 --- /dev/null +++ b/src/gui/UBLeftPalette.cpp @@ -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 . + */ +#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; +} diff --git a/src/gui/UBLeftPalette.h b/src/gui/UBLeftPalette.h new file mode 100644 index 00000000..61e0e1ce --- /dev/null +++ b/src/gui/UBLeftPalette.h @@ -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 . + */ +#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 diff --git a/src/gui/UBLibNavigatorWidget.cpp b/src/gui/UBLibNavigatorWidget.cpp index adefdd1e..8edaf447 100644 --- a/src/gui/UBLibNavigatorWidget.cpp +++ b/src/gui/UBLibNavigatorWidget.cpp @@ -13,7 +13,7 @@ * along with this program. If not, see . */ #include "UBLibNavigatorWidget.h" -#include "UBLibPalette.h" +#include "UBRightPalette.h" #include "core/memcheck.h" @@ -36,7 +36,7 @@ UBLibNavigatorWidget::UBLibNavigatorWidget(QWidget *parent, const char *name):QW setObjectName(name); setAcceptDrops(true); - UBLibPalette* pLibPalette = dynamic_cast(parentWidget()); + UBRightPalette* pRightPalette = dynamic_cast(parentWidget()); mLayout = new QVBoxLayout(this); // 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(mPathViewer, SIGNAL(elementsDropped(QList,UBLibElement*)), mLibWidget, SLOT(onElementsDropped(QList,UBLibElement*))); - if(NULL != pLibPalette) + if(NULL != pRightPalette) { - connect(mLibWidget, SIGNAL(navigBarUpdate(UBLibElement*)), pLibPalette->actionBar(), SLOT(onNavigbarUpdate(UBLibElement*))); - connect(mLibWidget, SIGNAL(itemsSelected(QList, bool)), pLibPalette->actionBar(), SLOT(onSelectionChanged(QList, bool))); - connect(pLibPalette->actionBar(), SIGNAL(deleteDone()), mLibWidget, SLOT(onRefreshCurrentFolder())); - connect(mLibWidget, SIGNAL(favoritesEntered(bool)), pLibPalette->actionBar(), SLOT(onFavoritesEntered(bool))); - connect(pLibPalette->actionBar(), SIGNAL(searchElement(QString)), mLibWidget, SLOT(onSearchElement(QString))); - connect(pLibPalette->actionBar(), SIGNAL(newFolderToCreate()), mLibWidget, SLOT(onNewFolderToCreate())); + connect(mLibWidget, SIGNAL(navigBarUpdate(UBLibElement*)), pRightPalette->libWidget()->actionBar(), SLOT(onNavigbarUpdate(UBLibElement*))); + connect(mLibWidget, SIGNAL(itemsSelected(QList, bool)), pRightPalette->libWidget()->actionBar(), SLOT(onSelectionChanged(QList, bool))); + connect(pRightPalette->libWidget()->actionBar(), SIGNAL(deleteDone()), mLibWidget, SLOT(onRefreshCurrentFolder())); + connect(mLibWidget, SIGNAL(favoritesEntered(bool)), pRightPalette->libWidget()->actionBar(), SLOT(onFavoritesEntered(bool))); + connect(pRightPalette->libWidget()->actionBar(), SIGNAL(searchElement(QString)), mLibWidget, SLOT(onSearchElement(QString))); + connect(pRightPalette->libWidget()->actionBar(), SIGNAL(newFolderToCreate()), mLibWidget, SLOT(onNewFolderToCreate())); } mLibWidget->init(); diff --git a/src/gui/UBLibPalette.cpp b/src/gui/UBLibPalette.cpp index 1970adeb..597a99a0 100644 --- a/src/gui/UBLibPalette.cpp +++ b/src/gui/UBLibPalette.cpp @@ -28,11 +28,8 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare , mNavigator(NULL) , mProperties(NULL) , mActionBar(NULL) - , mDropWidget(NULL) { setOrientation(eUBDockOrientation_Right); - //mCollapsedIcon = QPixmap(":images/library_open.png"); - //mIcon = QPixmap(":images/library_close.png"); setAcceptDrops(true); @@ -50,14 +47,12 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare mActionBar = new UBLibActionBar(this); mNavigator = new UBLibNavigatorWidget(this); mProperties = new UBLibItemProperties(this); - //mDropWidget = new UBDropMeWidget(this); mLayout->addWidget(mStackedWidget, 1); mLayout->addWidget(mActionBar, 0); mStackedWidget->addWidget(mNavigator); mStackedWidget->addWidget(mProperties); - //mStackedWidget->addWidget(mDropWidget); mStackedWidget->setCurrentIndex(ID_NAVIGATOR); miCrntStackWidget = ID_NAVIGATOR; @@ -71,18 +66,7 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare */ UBLibPalette::~UBLibPalette() { - //if(NULL != mStackedWidget) - //{ - // delete mStackedWidget; - // mStackedWidget = NULL; - //} - //if(NULL != mNavigator) - //{ - // delete mNavigator; - // mNavigator = NULL; - //} - - if(NULL != mProperties) + if(NULL != mProperties) { delete mProperties; mProperties = NULL; @@ -92,16 +76,6 @@ UBLibPalette::~UBLibPalette() delete mActionBar; 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) { setBackgroundRole(QPalette::Highlight); - //mStackedWidget->setCurrentIndex(ID_DROPME); pEvent->acceptProposedAction(); } void UBLibPalette::dragLeaveEvent(QDragLeaveEvent *pEvent) { - //mStackedWidget->setCurrentIndex(miCrntStackWidget); pEvent->accept(); } @@ -164,8 +136,6 @@ void UBLibPalette::processMimeData(const QMimeData *pData) { qDebug() << "Dropped element format " << i << " = "<< qslFormats.at(i); } - // mNavigator->dropMe(pData); - } void UBLibPalette::mouseMoveEvent(QMouseEvent *event) @@ -205,30 +175,3 @@ void UBLibPalette::resizeEvent(QResizeEvent *event) UBSettings::settings()->libPaletteWidth->set(width()); 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; - } -} diff --git a/src/gui/UBLibPalette.h b/src/gui/UBLibPalette.h index afbe8ff9..ca6d6890 100644 --- a/src/gui/UBLibPalette.h +++ b/src/gui/UBLibPalette.h @@ -33,18 +33,6 @@ #define ID_NAVIGATOR 0 #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 { @@ -84,8 +72,6 @@ private: UBLibItemProperties* mProperties; /** UBLibActionBar */ UBLibActionBar* mActionBar; - /** The 'drop here' indicator */ - UBDropMeWidget* mDropWidget; /** The current stack widget index*/ int miCrntStackWidget; }; diff --git a/src/gui/UBLibWidget.cpp b/src/gui/UBLibWidget.cpp new file mode 100644 index 00000000..de9cf34d --- /dev/null +++ b/src/gui/UBLibWidget.cpp @@ -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 . + */ +#include + +#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; +} diff --git a/src/gui/UBLibWidget.h b/src/gui/UBLibWidget.h new file mode 100644 index 00000000..09896ae4 --- /dev/null +++ b/src/gui/UBLibWidget.h @@ -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 . + */ +#ifndef UBLIBWIDGET_H +#define UBLIBWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 diff --git a/src/gui/UBPageNavigationWidget.cpp b/src/gui/UBPageNavigationWidget.cpp new file mode 100644 index 00000000..8c4c20c6 --- /dev/null +++ b/src/gui/UBPageNavigationWidget.cpp @@ -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 . + */ +#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; +} diff --git a/src/gui/UBPageNavigationWidget.h b/src/gui/UBPageNavigationWidget.h new file mode 100644 index 00000000..8f1ca723 --- /dev/null +++ b/src/gui/UBPageNavigationWidget.h @@ -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 . + */ +#ifndef UBPAGENAVIGATIONWIDGET_H +#define UBPAGENAVIGATIONWIDGET_H + +#include +#include +#include +#include +#include +#include +#include + +#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 diff --git a/src/gui/UBRightPalette.cpp b/src/gui/UBRightPalette.cpp new file mode 100644 index 00000000..c7f8a765 --- /dev/null +++ b/src/gui/UBRightPalette.cpp @@ -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 . + */ +#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()); +} diff --git a/src/gui/UBRightPalette.h b/src/gui/UBRightPalette.h new file mode 100644 index 00000000..7d99cd4c --- /dev/null +++ b/src/gui/UBRightPalette.h @@ -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 . + */ +#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 diff --git a/src/gui/gui.pri b/src/gui/gui.pri index 67bab1be..2afdd343 100644 --- a/src/gui/gui.pri +++ b/src/gui/gui.pri @@ -39,7 +39,11 @@ HEADERS += src/gui/UBThumbnailView.h \ src/gui/UBLibraryWidget.h \ src/gui/UBLibPathViewer.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 \ src/gui/UBFloatingPalette.cpp \ @@ -81,7 +85,11 @@ SOURCES += src/gui/UBThumbnailView.cpp \ src/gui/UBLibraryWidget.cpp \ src/gui/UBLibPathViewer.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 {