|
|
@ -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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|