Sankore 396 444-446

preferencesAboutTextFull
Ivan Ilin 13 years ago
parent 45ec8db85e
commit 1fc6a86b4a
  1. 3
      Sankore_3.1.pro
  2. BIN
      resources/images/tab_mask.png
  3. 1
      resources/sankore.qrc
  4. 6
      src/board/UBBoardPaletteManager.cpp
  5. 4
      src/core/UBSettings.cpp
  6. 10
      src/desktop/UBDesktopAnnotationController.cpp
  7. 1
      src/desktop/UBDesktopPalette.cpp
  8. 2
      src/document/UBDocumentController.cpp
  9. 585
      src/gui/UBDockPalette.cpp
  10. 45
      src/gui/UBDockPalette.h
  11. 10
      src/gui/UBLeftPalette.cpp
  12. 7
      src/gui/UBRightPalette.cpp
  13. 1
      src/web/browser/WBBrowserWindow.cpp

@ -4,7 +4,8 @@ TEMPLATE = app
THIRD_PARTY_PATH=../Sankore-ThirdParty THIRD_PARTY_PATH=../Sankore-ThirdParty
CONFIG += debug_and_release \ CONFIG += debug_and_release \
no_include_pwd no_include_pwd \
link_prl
VERSION_MAJ = 1 VERSION_MAJ = 1
VERSION_MIN = 40 VERSION_MIN = 40

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

@ -337,5 +337,6 @@
<file>images/libpalette/WebSearchCategory.svg</file> <file>images/libpalette/WebSearchCategory.svg</file>
<file>images/download_close.png</file> <file>images/download_close.png</file>
<file>images/download_open.png</file> <file>images/download_open.png</file>
<file>images/tab_mask.png</file>
</qresource> </qresource>
</RCC> </RCC>

@ -727,7 +727,7 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
case eUBDockPaletteWidget_BOARD: case eUBDockPaletteWidget_BOARD:
{ {
mLeftPalette->setParent(UBApplication::boardController->controlContainer()); mLeftPalette->setParent(UBApplication::boardController->controlContainer());
mRightPalette->setParent(UBApplication::boardController->controlContainer()); mRightPalette->assignParent(UBApplication::boardController->controlContainer());
if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL) if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL)
{ {
@ -752,7 +752,7 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
case eUBDockPaletteWidget_DESKTOP: case eUBDockPaletteWidget_DESKTOP:
{ {
mLeftPalette->setParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView()); mLeftPalette->setParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView());
mRightPalette->setParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView()); mRightPalette->assignParent((QWidget*)UBApplication::applicationController->uninotesController()->drawingView());
if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL) if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL)
{ {
@ -802,7 +802,7 @@ void UBBoardPaletteManager::changeMode(eUBDockPaletteWidgetMode newMode, bool is
mLeftPalette->setVisible(false); mLeftPalette->setVisible(false);
mRightPalette->setVisible(false); mRightPalette->setVisible(false);
mLeftPalette->setParent(0); mLeftPalette->setParent(0);
mRightPalette->setParent(0); mRightPalette->assignParent(0);
if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL) if (UBPlatformUtils::hasVirtualKeyboard() && mKeyboardPalette != NULL)
{ {

@ -194,8 +194,8 @@ void UBSettings::init()
appEnableAutomaticSoftwareUpdates = new UBSetting(this, "App", "EnableAutomaticSoftwareUpdates", true); appEnableAutomaticSoftwareUpdates = new UBSetting(this, "App", "EnableAutomaticSoftwareUpdates", true);
appEnableSoftwareUpdates = new UBSetting(this, "App", "EnableSoftwareUpdates", true); appEnableSoftwareUpdates = new UBSetting(this, "App", "EnableSoftwareUpdates", true);
appToolBarOrientationVertical = new UBSetting(this, "App", "ToolBarOrientationVertical", false); appToolBarOrientationVertical = new UBSetting(this, "App", "ToolBarOrientationVertical", false);
navigPaletteWidth = new UBSetting(this, "Board", "NavigPaletteWidth", 300); navigPaletteWidth = new UBSetting(this, "Board", "NavigPaletteWidth", 270);
libPaletteWidth = new UBSetting(this, "Board", "LibPaletteWidth", 300); libPaletteWidth = new UBSetting(this, "Board", "LibPaletteWidth", 270);
appIsInSoftwareUpdateProcess = new UBSetting(this, "App", "IsInSoftwareUpdateProcess", false); appIsInSoftwareUpdateProcess = new UBSetting(this, "App", "IsInSoftwareUpdateProcess", false);
appLastSessionDocumentUUID = new UBSetting(this, "App", "LastSessionDocumentUUID", ""); appLastSessionDocumentUUID = new UBSetting(this, "App", "LastSessionDocumentUUID", "");

@ -900,7 +900,7 @@ void UBDesktopAnnotationController::updateMask(bool bTransparent)
{ {
if(bTransparent) if(bTransparent)
{ {
// Here we have to generate a new mask. This method is certainly resource // Here we have to generate a new mask This method is certainly resource
// consuming but for the moment this is the only solution that I found. // consuming but for the moment this is the only solution that I found.
mMask = QPixmap(mTransparentDrawingView->width(), mTransparentDrawingView->height()); mMask = QPixmap(mTransparentDrawingView->width(), mTransparentDrawingView->height());
@ -922,13 +922,17 @@ void UBDesktopAnnotationController::updateMask(bool bTransparent)
UBApplication::boardController->paletteManager()->mKeyboardPalette->width(), UBApplication::boardController->paletteManager()->mKeyboardPalette->height()); UBApplication::boardController->paletteManager()->mKeyboardPalette->width(), UBApplication::boardController->paletteManager()->mKeyboardPalette->height());
} }
// UBApplication::boardController->paletteManager()->mDesktopRightPalette
if(UBApplication::boardController->paletteManager()->rightPalette()->isVisible()) if(UBApplication::boardController->paletteManager()->rightPalette()->isVisible())
{ {
p.drawRect(UBApplication::boardController->paletteManager()->rightPalette()->geometry().x(), QRect rightPalette(UBApplication::boardController->paletteManager()->rightPalette()->geometry().x(),
UBApplication::boardController->paletteManager()->rightPalette()->geometry().y(), UBApplication::boardController->paletteManager()->rightPalette()->geometry().y(),
UBApplication::boardController->paletteManager()->rightPalette()->width(), UBApplication::boardController->paletteManager()->rightPalette()->width(),
UBApplication::boardController->paletteManager()->rightPalette()->height()); UBApplication::boardController->paletteManager()->rightPalette()->height());
QRect tabsPalette(UBApplication::boardController->paletteManager()->rightPalette()->getTabPaletteRect());
p.drawRect(rightPalette);
p.drawRect(tabsPalette);
} }
p.end(); p.end();

@ -111,7 +111,6 @@ void UBDesktopPalette::updateShowHideState(bool pShowEnabled)
mShowHideAction->setToolTip(tr("Show Board on Secondary Screen")); mShowHideAction->setToolTip(tr("Show Board on Secondary Screen"));
else else
mShowHideAction->setToolTip(tr("Show Desktop on Secondary Screen")); mShowHideAction->setToolTip(tr("Show Desktop on Secondary Screen"));
} }

@ -1455,7 +1455,7 @@ bool UBDocumentController::isOKToOpenDocument(UBDocumentProxy* proxy)
QString docVersion = proxy->metaData(UBSettings::documentVersion).toString(); QString docVersion = proxy->metaData(UBSettings::documentVersion).toString();
if (docVersion.isEmpty() || docVersion.startsWith("4.1") || docVersion.startsWith("4.2") if (docVersion.isEmpty() || docVersion.startsWith("4.1") || docVersion.startsWith("4.2")
|| docVersion.startsWith("4.3") || docVersion.startsWith("4.4")) // TODO UB 4.7 update if necessary || docVersion.startsWith("4.3") || docVersion.startsWith("4.4") || docVersion.startsWith("4.5")) // TODO UB 4.7 update if necessary
{ {
return true; return true;
} }

@ -41,6 +41,7 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
, mpStackWidget(NULL) , mpStackWidget(NULL)
, mpLayout(NULL) , mpLayout(NULL)
, mCurrentTab(0) , mCurrentTab(0)
, mTabPalette(new UBTabDockPalete(this, parent))
{ {
setObjectName(name); setObjectName(name);
@ -54,7 +55,7 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
mTabWidgets.clear(); mTabWidgets.clear();
// We let 2 pixels in order to keep a small border for the resizing // We let 2 pixels in order to keep a small border for the resizing
setMinimumWidth(2*border() + 2); setMinimumWidth(/*2*border() + 2*/0);
if (parent) if (parent)
{ {
@ -93,6 +94,10 @@ UBDockPalette::~UBDockPalette()
delete mpLayout; delete mpLayout;
mpLayout = NULL; mpLayout = NULL;
} }
if (NULL != mTabPalette) {
delete mTabPalette;
mTabPalette = NULL;
}
} }
/** /**
@ -123,139 +128,139 @@ void UBDockPalette::setOrientation(eUBDockOrientation orientation)
setMaximumWidth(parentWidget()->width()); setMaximumWidth(parentWidget()->width());
setMinimumWidth(maximumWidth()); setMinimumWidth(maximumWidth());
} }
} }
/** /**
* \brief Handle the mouse move event * \brief Handle the mouse move event
* @param as the mouse event * @param as the mouse event
*/ */
void UBDockPalette::mouseMoveEvent(QMouseEvent *event) //void UBDockPalette::mouseMoveEvent(QMouseEvent *event)
{ //{
QPoint p = event->pos();
// QPoint p = event->pos();
if(mCanResize && ((mMousePressPos - p).manhattanLength() > QApplication::startDragDistance()))
{ // if(mCanResize && ((mMousePressPos - p).manhattanLength() > QApplication::startDragDistance()))
switch(mOrientation) // {
{ // switch(mOrientation)
case eUBDockOrientation_Left: // {
if(p.x() < collapseWidth() && p.x() >= minimumWidth()) // case eUBDockOrientation_Left:
{ // if(p.x() < collapseWidth() && p.x() >= minimumWidth())
resize(border(), height()); // {
mLastWidth = collapseWidth() + 1; // resize(border(), height());
mResized = true; // mLastWidth = collapseWidth() + 1;
} // mResized = true;
else if(p.x() <= maximumWidth() && p.x() >= minimumWidth()) // }
{ // else if(p.x() <= maximumWidth() && p.x() >= minimumWidth())
resize(p.x(), height()); // {
mResized = true; // resize(p.x(), height());
} // mResized = true;
break; // }
case eUBDockOrientation_Right: // break;
if((this->x() + p.x() > parentWidget()->width() - collapseWidth()) && (this->x() + p.x() < parentWidget()->width())) // case eUBDockOrientation_Right:
{ // if((this->x() + p.x() > parentWidget()->width() - collapseWidth()) && (this->x() + p.x() < parentWidget()->width()))
resize(border(), height()); // {
mLastWidth = collapseWidth() + 1; // resize(border(), height());
mResized = true; // mLastWidth = collapseWidth() + 1;
} // mResized = true;
else if((this->x() + p.x() >= parentWidget()->width() - maximumWidth()) && (this->x() + p.x() <= parentWidget()->width() - this->minimumWidth())) // }
{ // else if((this->x() + p.x() >= parentWidget()->width() - maximumWidth()) && (this->x() + p.x() <= parentWidget()->width() - this->minimumWidth()))
resize(parentWidget()->width() - (this->x() + p.x()), height()); // {
mResized = true; // resize(parentWidget()->width() - (this->x() + p.x()), height());
} // mResized = true;
// }
break;
case eUBDockOrientation_Top: // break;
case eUBDockOrientation_Bottom: // case eUBDockOrientation_Top:
if(p.y() <= maximumHeight()) // case eUBDockOrientation_Bottom:
{ // if(p.y() <= maximumHeight())
resize(width(), p.y()); // {
mResized = true; // resize(width(), p.y());
} // mResized = true;
break; // }
// break;
default:
break; // default:
} // break;
} // }
} // }
//}
/** /**
* \brief Handle the mouse press event * \brief Handle the mouse press event
* @param as the mouse event * @param as the mouse event
*/ */
void UBDockPalette::mousePressEvent(QMouseEvent *event) //void UBDockPalette::mousePressEvent(QMouseEvent *event)
{ //{
mClickTime = QTime::currentTime(); // mClickTime = QTime::currentTime();
// The goal here is to verify if the user can resize the widget. // // The goal here is to verify if the user can resize the widget.
// It is only possible to resize it if the border is selected // // It is only possible to resize it if the border is selected
QPoint p = event->pos(); // QPoint p = event->pos();
mMousePressPos = p; // mMousePressPos = p;
mResized = false; // mResized = false;
switch(mOrientation) // switch(mOrientation)
{ // {
case eUBDockOrientation_Left: // case eUBDockOrientation_Left:
if((p.x() >= width() - 2 * 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() <= 2 * border())) // if((p.x() >= 0) && (p.x() <= 2 * border()))
{ // {
mCanResize = true; // mCanResize = true;
} // }
break; // break;
case eUBDockOrientation_Top: // case eUBDockOrientation_Top:
// Not supported yet // // Not supported yet
break; // break;
case eUBDockOrientation_Bottom: // case eUBDockOrientation_Bottom:
// Not supported yet // // Not supported yet
break; // break;
default: // default:
break; // break;
} // }
} //}
/** /**
* \brief Handle the mouse release event * \brief Handle the mouse release event
* @param event as the mouse event * @param event as the mouse event
*/ */
void UBDockPalette::mouseReleaseEvent(QMouseEvent *event) //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 nbTabs = mTabWidgets.size();
int clickedTab = 0; // 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 + nbTabs*TABSIZE + (nbTabs -1)*tabSpacing()) // mMousePressPos.y() <= mHTab + nbTabs*TABSIZE + (nbTabs -1)*tabSpacing())
{ // {
clickedTab = (mMousePressPos.y() - mHTab)/(TABSIZE+tabSpacing()); // clickedTab = (mMousePressPos.y() - mHTab)/(TABSIZE+tabSpacing());
tabClicked(clickedTab); // tabClicked(clickedTab);
} // }
} // }
else if(eUBDockOrientation_Right == mOrientation) // else if(eUBDockOrientation_Right == mOrientation)
{ // {
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 + nbTabs*TABSIZE + (nbTabs -1)*tabSpacing()) // mMousePressPos.y() <= mHTab + nbTabs*TABSIZE + (nbTabs -1)*tabSpacing())
{ // {
clickedTab = (mMousePressPos.y() - mHTab)/(TABSIZE+tabSpacing()); // clickedTab = (mMousePressPos.y() - mHTab)/(TABSIZE+tabSpacing());
tabClicked(clickedTab); // tabClicked(clickedTab);
} // }
} // }
} // }
mCanResize = false; // mCanResize = false;
} //}
/** /**
* \brief Handle the resize event * \brief Handle the resize event
@ -288,6 +293,7 @@ void UBDockPalette::resizeEvent(QResizeEvent *event)
break; break;
} }
move(origin.x(), origin.y()); move(origin.x(), origin.y());
moveTabs();
} }
/** /**
@ -332,11 +338,11 @@ void UBDockPalette::paintEvent(QPaintEvent *event)
// First draw the BIG RECTANGLE (I write it big because the rectangle is big...) // First draw the BIG RECTANGLE (I write it big because the rectangle is big...)
if(mOrientation == eUBDockOrientation_Left) if(mOrientation == eUBDockOrientation_Left)
{ {
path.addRect(0.0, 0.0, width()-2*border(), height()); path.addRect(0.0, 0.0, width(), height());
} }
else if(mOrientation == eUBDockOrientation_Right) else if(mOrientation == eUBDockOrientation_Right)
{ {
path.addRect(2*border(), 0.0, width()-2*border(), height()); path.addRect(0.0, 0.0, width(), height());
} }
// THEN DRAW THE small tabs (yes, the tabs are small...) // THEN DRAW THE small tabs (yes, the tabs are small...)
@ -348,52 +354,53 @@ void UBDockPalette::paintEvent(QPaintEvent *event)
{ {
mHTab = height() - border() - nbTabs*TABSIZE - (nbTabs-1)*tabSpacing(); 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); painter.drawPath(path);
QPixmap iconPixmap;
if(mCollapseWidth >= width()) // for(int i = 0; i < mTabWidgets.size(); i++)
{ // {
// Get the collapsed icon // UBDockPaletteWidget* pCrntWidget = mTabWidgets.at(i);
iconPixmap = pCrntWidget->iconToRight(); // if(NULL != pCrntWidget)
} // {
else // if(mOrientation == eUBDockOrientation_Left)
{ // {
// Get the expanded icon // path.addRoundedRect(width()-4*border(), mHTab + i*TABSIZE + i*tabSpacing(), 4*border(), TABSIZE, radius(), radius());
iconPixmap = pCrntWidget->iconToLeft(); // painter.drawPath(path);
} // QPixmap iconPixmap;
painter.drawPixmap(width() - 2*border() + 1, mHTab + i*TABSIZE + i*tabSpacing() + 1 , 2*border() - 4, TABSIZE - 2, iconPixmap); // if(mCollapseWidth >= width())
} // {
else if(mOrientation == eUBDockOrientation_Right) // // Get the collapsed icon
{ // iconPixmap = pCrntWidget->iconToRight();
path.addRoundedRect(0.0, mHTab + i*TABSIZE + i*tabSpacing(), 4*border(), TABSIZE, radius(), radius()); // }
painter.drawPath(path); // else
QPixmap iconPixmap; // {
if(mCollapseWidth >= width()) // // Get the expanded icon
{ // iconPixmap = pCrntWidget->iconToLeft();
// Get the collapsed icon // }
iconPixmap = pCrntWidget->iconToLeft(); // painter.drawPixmap(width() - 2*border() + 1, mHTab + i*TABSIZE + i*tabSpacing() + 1 , 2*border() - 4, TABSIZE - 2, iconPixmap);
} // }
else // else if(mOrientation == eUBDockOrientation_Right)
{ // {
// Get the expanded icon // path.addRoundedRect(0.0, mHTab + i*TABSIZE + i*tabSpacing(), 4*border(), TABSIZE, radius(), radius());
iconPixmap = pCrntWidget->iconToRight(); // painter.drawPath(path);
} // QPixmap iconPixmap;
painter.drawPixmap(2, mHTab + i*TABSIZE + i*tabSpacing() + 1, 2*border() - 4, TABSIZE - 2, iconPixmap); // if(mCollapseWidth >= width())
} // {
else // // Get the collapsed icon
{ // iconPixmap = pCrntWidget->iconToLeft();
painter.drawRoundedRect(border(), border(), width() - 2 * border(), height() - 2 * border(), radius(), radius()); // }
} // 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());
// }
// }
// }
} }
} }
@ -460,6 +467,7 @@ void UBDockPalette::tabClicked(int tabIndex)
{ {
toggleCollapseExpand(); toggleCollapseExpand();
} }
mTabPalette->update();
} }
/** /**
@ -493,7 +501,7 @@ void UBDockPalette::toggleCollapseExpand()
{ {
// The palette must be collapsed // The palette must be collapsed
mLastWidth = width(); mLastWidth = width();
resize(2*border(), height()); resize(0, height());
} }
else else
{ {
@ -550,6 +558,7 @@ void UBDockPalette::addTab(UBDockPaletteWidget *widget)
mTabWidgets.append(widget); mTabWidgets.append(widget);
mpStackWidget->addWidget(widget); mpStackWidget->addWidget(widget);
mpStackWidget->setCurrentWidget(widget); mpStackWidget->setCurrentWidget(widget);
resizeTabs();
update(); update();
} }
} }
@ -571,6 +580,8 @@ void UBDockPalette::removeTab(const QString &widgetName)
break; break;
} }
} }
resizeTabs();
mCurrentTab = qMax(mCurrentTab - 1, 0);
} }
/** /**
@ -666,3 +677,245 @@ void UBDockPalette::onAllDownloadsFinished()
} }
} }
} }
void UBDockPalette::moveTabs()
{
if (!mHTab) {
if(eUBDockTabOrientation_Up == mTabsOrientation) {
mHTab = border();
} else {
mHTab = height() - border() - mTabWidgets.size() * TABSIZE - (mTabWidgets.size() - 1) * tabSpacing();
}
}
QPoint origin(width(), mHTab);
switch (mOrientation) {
case eUBDockOrientation_Left:
origin.setX(width());
break;
case eUBDockOrientation_Right:
if (parentWidget()) {
origin.setX(parentWidget()->width() - width() - mTabPalette->width());
}
break;
case eUBDockOrientation_Top: ;
case eUBDockOrientation_Bottom: ;
}
mTabPalette->move(origin.x(), origin.y());
}
void UBDockPalette::resizeTabs()
{
int numTabs = mTabWidgets.size();
mTabPalette->resize(2 * border(), (numTabs * TABSIZE) + qMax(numTabs - 1, 0) * tabSpacing());
}
QRect UBDockPalette::getTabPaletteRect()
{
QRect tabsRect = mTabPalette->rect();
QPoint topLeft = mTabPalette->mapToParent(tabsRect.topLeft());
QPoint bottomRight = mTabPalette->mapToParent(tabsRect.bottomRight());
return QRect(topLeft, bottomRight);
}
void UBDockPalette::assignParent(QWidget *widget)
{
setParent(widget);
mTabPalette->setParent(widget);
}
void UBDockPalette::setVisible(bool visible)
{
QWidget::setVisible(visible);
mTabPalette->setVisible(visible);
}
UBTabDockPalete::UBTabDockPalete(UBDockPalette *dockPalette, QWidget *parent) :
QWidget(parent)
, dock(dockPalette)
{
int numTabs = dock->mTabWidgets.size();
resize(2 * dock->border(), (numTabs * TABSIZE) + qMax(numTabs - 1, 0) * dock->tabSpacing());
// move(dock->width(), 20);
setAttribute(Qt::WA_TranslucentBackground);
}
void UBTabDockPalete::paintEvent(QPaintEvent */*event*/)
{
int nTabs = dock->mTabWidgets.size();
if (nTabs <= 0) {
qDebug() << "not enough tabs";
return;
}
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(Qt::NoPen);
painter.setBrush(dock->mBackgroundBrush);
int yFrom = 0;
for (int i = 0; i < nTabs; i++) {
UBDockPaletteWidget* pCrntWidget = dock->mTabWidgets.at(i);
QPainterPath path;
path.setFillRule(Qt::WindingFill);
QPixmap iconPixmap;
switch (dock->mOrientation) {
case eUBDockOrientation_Left:
path.addRect(0, yFrom, width() / 2, TABSIZE);
path.addRoundedRect(0, yFrom, width(), TABSIZE, dock->radius(), dock->radius());
if (pCrntWidget) {
if(dock->mCollapseWidth >= dock->width()) {
// Get the collapsed icon
iconPixmap = pCrntWidget->iconToRight();
} else {
// Get the expanded icon
iconPixmap = pCrntWidget->iconToLeft();
}
}
break;
case eUBDockOrientation_Right:
path.addRect(width() /2, yFrom, width() / 2, TABSIZE);
path.addRoundedRect(0, yFrom, width(), TABSIZE, dock->radius(), dock->radius());
if (pCrntWidget) {
if(dock->mCollapseWidth >= dock->width()) {
// Get the collapsed icon
iconPixmap = pCrntWidget->iconToLeft();
} else {
// Get the expanded icon
iconPixmap = pCrntWidget->iconToRight();
}
}
break;
case eUBDockOrientation_Top: ;
case eUBDockOrientation_Bottom: ;
default:
break;
}
painter.save();
QPixmap transparencyPix(":/images/tab_mask.png");
if (dock->mCurrentTab != i) {
iconPixmap.setAlphaChannel(transparencyPix);
QColor color(0x7F, 0x7F, 0x7F, 0x3F);
painter.setBrush(QBrush(color));
}
painter.drawPath(path);
painter.drawPixmap(2, yFrom + 2, width() - 4, TABSIZE - 4, iconPixmap);
yFrom += (TABSIZE + dock->tabSpacing());
painter.restore();
}
}
UBTabDockPalete::~UBTabDockPalete()
{
}
void UBTabDockPalete::mousePressEvent(QMouseEvent *event)
{
dock->mClickTime = QTime::currentTime();
// The goal here is to verify if the user can resize the widget.
// It is only possible to resize it if the border is selected
QPoint p = event->pos();
dock->mMousePressPos = p;
dock->mResized = false;
switch(dock->mOrientation) {
case eUBDockOrientation_Left:
dock->mCanResize = true;
break;
case eUBDockOrientation_Right:
dock->mCanResize = true;
break;
case eUBDockOrientation_Top:
// Not supported yet
break;
case eUBDockOrientation_Bottom:
// Not supported yet
break;
default:
break;
}
}
void UBTabDockPalete::mouseMoveEvent(QMouseEvent *event)
{
QPoint p = event->pos();
if(dock->mCanResize && ((dock->mMousePressPos - p).manhattanLength() > QApplication::startDragDistance()))
{
switch(dock->mOrientation) {
case eUBDockOrientation_Left:
p.setX(p.x() + dock->width());
if(p.x() < dock->collapseWidth() && p.x() >= dock->minimumWidth()) {
dock->resize(0, dock->height());
dock->mLastWidth = dock->collapseWidth() + 1;
dock->mResized = true;
} else if (p.x() <= dock->maximumWidth() && p.x() >= dock->minimumWidth()) {
dock->resize(p.x(), dock->height());
dock->mResized = true;
}
break;
case eUBDockOrientation_Right:
p.setX(p.x() - 2 * dock->border());
if((dock->x() + p.x() > dock->parentWidget()->width() - dock->collapseWidth()) && (dock->x() + p.x() < dock->parentWidget()->width())) {
dock->resize(0, dock->height());
dock->mLastWidth = dock->collapseWidth() + 1;
dock->mResized = true;
} else if((dock->x() + p.x() >= dock->parentWidget()->width() - dock->maximumWidth()) && (dock->x() + p.x() <= dock->parentWidget()->width() - dock->minimumWidth())) {
dock->resize(dock->parentWidget()->width() - (dock->x() + p.x()), dock->height());
dock->mResized = true;
}
break;
case eUBDockOrientation_Top:
case eUBDockOrientation_Bottom:
if(p.y() <= dock->maximumHeight()) {
dock->resize(width(), p.y());
dock->mResized = true;
}
break;
default:
break;
}
}
}
void UBTabDockPalete::mouseReleaseEvent(QMouseEvent *event)
{
Q_UNUSED(event);
if(!dock->mResized && dock->mClickTime.elapsed() < CLICKTIME) {
int nbTabs = dock->mTabWidgets.size();
int clickedTab = 0;
// If the clicked position is in the tab, perform the related action
if(eUBDockOrientation_Left == dock->mOrientation) {
if(dock->mMousePressPos.y() >= dock->mHTab &&
dock->mMousePressPos.x() <= width() &&
dock->mMousePressPos.y() <= dock->mHTab + nbTabs * TABSIZE + (nbTabs -1)*dock->tabSpacing()) {
clickedTab = (dock->mMousePressPos.y() - dock->mHTab) / (TABSIZE + dock->tabSpacing());
dock->tabClicked(clickedTab);
}
} else if (eUBDockOrientation_Right == dock->mOrientation) {
if(dock->mMousePressPos.x() >= 0 &&
dock->mMousePressPos.x() <= width() &&
dock->mMousePressPos.y() >= 0 &&
dock->mMousePressPos.y() <= nbTabs * TABSIZE + (nbTabs -1) * dock->tabSpacing()) {
clickedTab = (dock->mMousePressPos.y())/(TABSIZE+dock->tabSpacing());
dock->tabClicked(clickedTab);
}
}
}
dock->mCanResize = false;
}

@ -31,8 +31,8 @@
#include "UBDockPaletteWidget.h" #include "UBDockPaletteWidget.h"
#define TABSIZE 50 #define TABSIZE 50 //Height of the tab of the palette
#define CLICKTIME 1000000 #define CLICKTIME 1000000 //Clicktime to expand or collapse paltte
/** /**
* \brief The dock positions * \brief The dock positions
@ -51,9 +51,33 @@ typedef enum
eUBDockTabOrientation_Down /** Down tabs */ eUBDockTabOrientation_Down /** Down tabs */
}eUBDockTabOrientation; }eUBDockTabOrientation;
class UBDockPalette;
class UBTabDockPalete : public QWidget
{
Q_OBJECT
friend class UBDockPalette;
public:
UBTabDockPalete(UBDockPalette *dockPalette, QWidget *parent = 0);
~UBTabDockPalete();
protected:
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
virtual void paintEvent(QPaintEvent *event);
private:
UBDockPalette *dock;
};
class UBDockPalette : public QWidget class UBDockPalette : public QWidget
{ {
Q_OBJECT Q_OBJECT
friend class UBTabDockPalete;
public: public:
UBDockPalette(QWidget* parent=0, const char* name="UBDockPalette"); UBDockPalette(QWidget* parent=0, const char* name="UBDockPalette");
~UBDockPalette(); ~UBDockPalette();
@ -62,10 +86,14 @@ public:
void setOrientation(eUBDockOrientation orientation); void setOrientation(eUBDockOrientation orientation);
void setTabsOrientation(eUBDockTabOrientation orientation); void setTabsOrientation(eUBDockTabOrientation orientation);
void showTabWidget(int tabIndex); void showTabWidget(int tabIndex);
QRect getTabPaletteRect();
virtual void mouseMoveEvent(QMouseEvent *event); virtual void assignParent(QWidget *widget);
virtual void mousePressEvent(QMouseEvent *event); virtual void setVisible(bool visible);
virtual void mouseReleaseEvent(QMouseEvent *event);
// virtual void mouseMoveEvent(QMouseEvent *event);
// virtual void mousePressEvent(QMouseEvent *event);
// virtual void mouseReleaseEvent(QMouseEvent *event);
virtual void paintEvent(QPaintEvent *event); virtual void paintEvent(QPaintEvent *event);
virtual void enterEvent(QEvent *); virtual void enterEvent(QEvent *);
virtual void leaveEvent(QEvent *); virtual void leaveEvent(QEvent *);
@ -77,7 +105,7 @@ public:
void connectSignals(); void connectSignals();
QVector<UBDockPaletteWidget*> GetWidgetsList() { return mRegisteredWidgets; }; QVector<UBDockPaletteWidget*> GetWidgetsList() { return mRegisteredWidgets; }
public slots: public slots:
void onShowTabWidget(const QString& widgetName); void onShowTabWidget(const QString& widgetName);
@ -137,6 +165,11 @@ private:
void tabClicked(int tabIndex); void tabClicked(int tabIndex);
int tabSpacing(); int tabSpacing();
void toggleCollapseExpand(); void toggleCollapseExpand();
void moveTabs();
void resizeTabs();
private:
UBTabDockPalete *mTabPalette;
}; };

@ -24,11 +24,11 @@ UBLeftPalette::UBLeftPalette(QWidget *parent, const char *name):UBDockPalette(pa
{ {
setObjectName(name); setObjectName(name);
setOrientation(eUBDockOrientation_Left); setOrientation(eUBDockOrientation_Left);
mLastWidth = 300; mLastWidth = 270;
mCollapseWidth = 180; mCollapseWidth = 150;
resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), parentWidget()->height()); resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), parentWidget()->height());
mpLayout->setContentsMargins(customMargin(), customMargin(), 2*border() + customMargin(), customMargin()); // mpLayout->setContentsMargins(customMargin(), customMargin(), 2*border() + customMargin(), customMargin());
} }
@ -45,7 +45,7 @@ UBLeftPalette::~UBLeftPalette()
*/ */
void UBLeftPalette::updateMaxWidth() void UBLeftPalette::updateMaxWidth()
{ {
setMaximumWidth(300); setMaximumWidth(270);
} }
/** /**
@ -55,5 +55,5 @@ void UBLeftPalette::updateMaxWidth()
void UBLeftPalette::resizeEvent(QResizeEvent *event) void UBLeftPalette::resizeEvent(QResizeEvent *event)
{ {
UBDockPalette::resizeEvent(event); UBDockPalette::resizeEvent(event);
UBSettings::settings()->navigPaletteWidth->set(width()); // UBSettings::settings()->navigPaletteWidth->set(width());
} }

@ -26,10 +26,10 @@ UBRightPalette::UBRightPalette(QWidget *parent, const char *name):UBDockPalette(
{ {
setObjectName(name); setObjectName(name);
setOrientation(eUBDockOrientation_Right); setOrientation(eUBDockOrientation_Right);
mCollapseWidth = 180; mCollapseWidth = 150;
mLastWidth = 300; mLastWidth = 270;
resize(UBSettings::settings()->libPaletteWidth->get().toInt(), parentWidget()->height()); resize(UBSettings::settings()->libPaletteWidth->get().toInt(), parentWidget()->height());
mpLayout->setContentsMargins(2*border() + customMargin(), customMargin(), customMargin(), customMargin()); // mpLayout->setContentsMargins(2*border() + customMargin(), customMargin(), customMargin(), customMargin());
} }
/** /**
@ -37,7 +37,6 @@ UBRightPalette::UBRightPalette(QWidget *parent, const char *name):UBDockPalette(
*/ */
UBRightPalette::~UBRightPalette() UBRightPalette::~UBRightPalette()
{ {
} }
/** /**

@ -205,6 +205,7 @@ void WBBrowserWindow::setupToolBar()
connect(mSearchToolBar, SIGNAL(search(const QUrl&)), SLOT(loadUrl(const QUrl&))); connect(mSearchToolBar, SIGNAL(search(const QUrl&)), SLOT(loadUrl(const QUrl&)));
mChaseWidget = new WBChaseWidget(this); mChaseWidget = new WBChaseWidget(this);
mWebToolBar->insertWidget(mUniboardMainWindow->actionWebBigger, mChaseWidget);
mWebToolBar->insertSeparator(mUniboardMainWindow->actionWebBigger); mWebToolBar->insertSeparator(mUniboardMainWindow->actionWebBigger);
connect(mUniboardMainWindow->actionHome, SIGNAL(triggered()), this , SLOT(slotHome())); connect(mUniboardMainWindow->actionHome, SIGNAL(triggered()), this , SLOT(slotHome()));

Loading…
Cancel
Save