Implemented dock palette tab position related to the toolbar position

preferencesAboutTextFull
shibakaneki 13 years ago
parent 2e64955612
commit e812ebb92e
  1. 1
      src/core/UBPreferencesController.cpp
  2. 80
      src/gui/UBDockPalette.cpp
  3. 16
      src/gui/UBDockPalette.h
  4. 1
      src/gui/UBLibNavigatorWidget.cpp
  5. 2
      src/gui/UBLibPalette.cpp
  6. 3
      src/gui/UBNavigatorPalette.cpp

@ -451,6 +451,7 @@ void UBPreferencesController::toolbarPositionChanged(bool checked)
UBSettings* settings = UBSettings::settings();
settings->appToolBarPositionedAtTop->set(mPreferencesUI->toolbarAtTopRadioButton->isChecked());
}
void UBPreferencesController::toolbarOrientationVertical(bool checked)

@ -19,9 +19,27 @@
#include "UBDockPalette.h"
#include "core/UBSettings.h"
#include "frameworks/UBPlatformUtils.h"
#include "core/UBApplication.h"
#include "core/UBPreferencesController.h"
#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
*/
@ -34,11 +52,12 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
, mResized(false)
, mCollapseWidth(150)
, mLastWidth(-1)
, mHTab(0)
{
setObjectName(name);
// We let 2 pixels in order to keep a small border for the resizing
setMinimumWidth(border() + 2);
setMinimumWidth(2*border() + 2);
if (parent)
{
@ -61,6 +80,10 @@ UBDockPalette::UBDockPalette(QWidget *parent, const char *name)
// This is the only way to set the background as transparent!
setStyleSheet("QWidget {background-color: transparent}");
// Set the position of the tab
onToolbarPosUpdated();
connect(UBSettings::settings()->appToolBarPositionedAtTop, SIGNAL(changed(QVariant)), this, SLOT(onToolbarPosUpdated()));
}
/**
@ -206,9 +229,9 @@ void UBDockPalette::mouseReleaseEvent(QMouseEvent *event)
if(eUBDockOrientation_Left == mOrientation)
{
if(mMousePressPos.x() >= width() - 2*border() &&
mMousePressPos.y() >= border() &&
mMousePressPos.y() >= mHTab &&
mMousePressPos.x() <= width() &&
mMousePressPos.y() <= border() + TABSIZE)
mMousePressPos.y() <= mHTab + TABSIZE)
{
tabClicked();
}
@ -217,8 +240,8 @@ void UBDockPalette::mouseReleaseEvent(QMouseEvent *event)
{
if(mMousePressPos.x() >= 0 &&
mMousePressPos.x() <= 2*border() &&
mMousePressPos.y() >= border() &&
mMousePressPos.y() <= border() + TABSIZE)
mMousePressPos.y() >= mHTab &&
mMousePressPos.y() <= mHTab + TABSIZE)
{
tabClicked();
}
@ -291,23 +314,32 @@ void UBDockPalette::paintEvent(QPaintEvent *event)
painter.setPen(Qt::NoPen);
painter.setBrush(mBackgroundBrush);
if(eUBDockTabOrientation_Up == mTabsOrientation)
{
mHTab = border();
}
else
{
mHTab = height() - border() - TABSIZE;
}
if(mOrientation == eUBDockOrientation_Left)
{
QPainterPath path;
path.setFillRule(Qt::WindingFill);
path.addRect(0.0, 0.0, width()-border(), height());
path.addRoundedRect(width()-2*border(), border(), 2*border(), TABSIZE, radius(), radius());
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, border() + 1 , border() - 4, TABSIZE - 2, mIcon);
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(border(), 0.0, width()-border(), height());
path.addRoundedRect(0.0, border(), 2*border(), TABSIZE, radius(), radius());
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, border() + 1, border() - 3, TABSIZE - 2, mIcon);
painter.drawPixmap(2, mHTab + 1, border() - 3, TABSIZE - 2, mIcon);
}
else
{
@ -372,7 +404,7 @@ void UBDockPalette::tabClicked()
{
// The palette must be collapsed
mLastWidth = width();
resize(border(), height());
resize(2*border(), height());
}
else
{
@ -381,3 +413,27 @@ void UBDockPalette::tabClicked()
mLastWidth = -1;
}
}
void UBDockPalette::setTabsOrientation(eUBDockTabOrientation orientation)
{
mTabsOrientation = orientation;
}
void UBDockPalette::onToolbarPosUpdated()
{
// Get the position of the tab
if(UBSettings::settings()->appToolBarPositionedAtTop->get().toBool())
{
setTabsOrientation(eUBDockTabOrientation_Up);
}
else
{
setTabsOrientation(eUBDockTabOrientation_Down);
}
update();
}
int UBDockPalette::customMargin()
{
return 5;
}

@ -39,14 +39,22 @@ typedef enum
eUBDockOrientation_Bottom /** [to be implemented]Bottom dock */
}eUBDockOrientation;
typedef enum
{
eUBDockTabOrientation_Up, /** Up tabs */
eUBDockTabOrientation_Down /** Down tabs */
}eUBDockTabOrientation;
class UBDockPalette : public QWidget
{
Q_OBJECT
public:
UBDockPalette(QWidget* parent=0, const char* name="UBDockPalette");
~UBDockPalette();
eUBDockOrientation orientation();
void setOrientation(eUBDockOrientation orientation);
void setTabsOrientation(eUBDockTabOrientation orientation);
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent *event);
@ -60,6 +68,7 @@ public:
protected:
virtual int border();
virtual int radius();
virtual int customMargin();
virtual void updateMaxWidth();
virtual void resizeEvent(QResizeEvent *event);
virtual int collapseWidth();
@ -86,6 +95,13 @@ protected:
QPoint mMousePressPos;
/** The palette icon */
QPixmap mIcon;
/** The tab orientation */
eUBDockTabOrientation mTabsOrientation;
/** The h position of the tab */
int mHTab;
private slots:
void onToolbarPosUpdated();
private:
void tabClicked();

@ -39,6 +39,7 @@ UBLibNavigatorWidget::UBLibNavigatorWidget(QWidget *parent, const char *name):QW
UBLibPalette* pLibPalette = dynamic_cast<UBLibPalette*>(parentWidget());
mLayout = new QVBoxLayout(this);
// mLayout->setContentsMargins(20, 5, 5, 5);
setLayout(mLayout);
mPathViewer = new UBLibPathViewer(this);

@ -40,7 +40,7 @@ UBLibPalette::UBLibPalette(QWidget *parent, const char *name):UBDockPalette(pare
mLastWidth = 300;
mLayout = new QVBoxLayout(this);
mLayout->setMargin(3);
mLayout->setContentsMargins(20, customMargin(), customMargin(), customMargin());
setLayout(mLayout);
// Build the GUI

@ -35,11 +35,10 @@ UBNavigatorPalette::UBNavigatorPalette(QWidget *parent, const char *name):UBDock
mIcon = QPixmap(":images/paletteNavigator.png");
resize(UBSettings::settings()->navigPaletteWidth->get().toInt(), height());
mLastWidth = 300;
setContentsMargins(0, 0, border(), 0);
// Build the gui
mLayout = new QVBoxLayout(this);
mLayout->setMargin(3);
mLayout->setContentsMargins(customMargin(), customMargin(), 2*border() + customMargin(), customMargin());
setLayout(mLayout);
mNavigator = new UBDocumentNavigator(this);

Loading…
Cancel
Save