add support for adding two qgw on the sides of the tabbar

svn path=/trunk/KDE/kdelibs/; revision=1148951
This commit is contained in:
Giulio Camuffo 2010-07-12 08:29:49 +00:00
parent 12a3da4aa4
commit 8002b2415b
2 changed files with 93 additions and 0 deletions

View File

@ -109,6 +109,8 @@ public:
Animation *newPageAnim; Animation *newPageAnim;
QParallelAnimationGroup *animGroup; QParallelAnimationGroup *animGroup;
bool customFont; bool customFont;
QWeakPointer<QGraphicsWidget> firstPositionWidget;
QWeakPointer<QGraphicsWidget> lastPositionWidget;
}; };
void TabBarPrivate::updateTabWidgetMode() void TabBarPrivate::updateTabWidgetMode()
@ -610,6 +612,65 @@ void TabBar::changeEvent(QEvent *event)
QGraphicsWidget::changeEvent(event); QGraphicsWidget::changeEvent(event);
} }
void TabBar::setFirstPositionWidget(QGraphicsWidget *widget)
{
if (d->lastPositionWidget.data() == widget) {
return;
}
if (d->firstPositionWidget) {
QGraphicsWidget *widget = d->firstPositionWidget.data();
d->tabBarLayout->removeItem(widget);
scene()->removeItem(widget);
widget->deleteLater();
}
d->firstPositionWidget = widget;
if (widget) {
widget->setParentItem(this);
if (layoutDirection() == Qt::LeftToRight) {
d->tabBarLayout->insertItem(0, widget);
} else {
d->tabBarLayout->addItem(widget);
}
}
}
QGraphicsWidget *TabBar::firstPositionWidget() const
{
return d->firstPositionWidget.data();
}
void TabBar::setLastPositionWidget(QGraphicsWidget *widget)
{
if (d->lastPositionWidget.data() == widget) {
return;
}
if (d->lastPositionWidget) {
QGraphicsWidget *widget = d->lastPositionWidget.data();
d->tabBarLayout->removeItem(widget);
scene()->removeItem(widget);
widget->deleteLater();
}
d->lastPositionWidget = widget;
if (widget) {
widget->setParentItem(this);
if (layoutDirection() == Qt::LeftToRight) {
d->tabBarLayout->addItem(widget);
} else {
d->tabBarLayout->insertItem(0, widget);
}
}
}
QGraphicsWidget *TabBar::lastPositionWidget() const
{
return d->lastPositionWidget.data();
}
} // namespace Plasma } // namespace Plasma
#include <tabbar.moc> #include <tabbar.moc>

View File

@ -52,6 +52,8 @@ class PLASMA_EXPORT TabBar : public QGraphicsWidget
Q_PROPERTY(int count READ count) Q_PROPERTY(int count READ count)
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet) Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
Q_PROPERTY(bool tabBarShown READ isTabBarShown WRITE setTabBarShown) Q_PROPERTY(bool tabBarShown READ isTabBarShown WRITE setTabBarShown)
Q_PROPERTY(QGraphicsWidget *firstPositionWidget READ firstPositionWidget WRITE setFirstPositionWidget)
Q_PROPERTY(QGraphicsWidget *lastPositionWidget READ lastPositionWidget WRITE setLastPositionWidget)
public: public:
/** /**
@ -207,6 +209,36 @@ public:
*/ */
KTabBar *nativeWidget() const; KTabBar *nativeWidget() const;
/**
* Set a widget to be displayed on one side of the TabBar, depending on the
* LayoutDirection and the Shape.
* @param widget the widget to be displayed. Passing 0 will show nothing.
* Any previous widget will be deleted.
* @since 4.6
*/
void setFirstPositionWidget(QGraphicsWidget *widget);
/**
* @return the widget in the first position
* @since 4.6
*/
QGraphicsWidget *firstPositionWidget() const;
/**
* Set a widget to be displayed on one side of the TabBar, depending on the
* LayoutDirection and the Shape.
* @param widget the widget to be displayed. Passing 0 will show nothing.
* Any previous widget will be deleted.
* @since 4.6
*/
void setLastPositionWidget(QGraphicsWidget *widget);
/**
* @return the widget in the last position
* @since 4.6
*/
QGraphicsWidget *lastPositionWidget() const;
public Q_SLOTS: public Q_SLOTS:
/** /**
* Activate a given tab * Activate a given tab