• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

Plasma

  • sources
  • kde-4.12
  • kdelibs
  • plasma
  • widgets
tabbar.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Marco Martin <notmart@gmail.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Library General Public License as
6  * published by the Free Software Foundation; either version 2, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 #include "tabbar.h"
21 
22 #include <QGraphicsLinearLayout>
23 #include <QGraphicsLayoutItem>
24 #include <QGraphicsProxyWidget>
25 #include <QGraphicsScene>
26 #include <QGraphicsSceneWheelEvent>
27 #include <QIcon>
28 #include <QMenu>
29 #include <QPainter>
30 #include <QParallelAnimationGroup>
31 #include <QString>
32 #include <QStyleOption>
33 
34 #include <kdebug.h>
35 
36 #include "animator.h"
37 #include "animations/animation.h"
38 #include "private/nativetabbar_p.h"
39 #include "private/themedwidgetinterface_p.h"
40 #include "theme.h"
41 
42 namespace Plasma
43 {
44 
45 class TabBarProxy : public QGraphicsProxyWidget
46 {
47 public:
48  TabBarProxy(QGraphicsWidget *parent)
49  : QGraphicsProxyWidget(parent)
50  {
51  native = new NativeTabBar();
52  native->setAttribute(Qt::WA_NoSystemBackground);
53  setWidget(native);
54  setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
55  }
56 
57  void paint(QPainter *painter,
58  const QStyleOptionGraphicsItem *option,
59  QWidget *widget)
60  {
61  Q_UNUSED(option);
62  Q_UNUSED(widget);
63  //Don't paint the child widgets
64  static_cast<NativeTabBar *>(QGraphicsProxyWidget::widget())->render(
65  painter, QPoint(0, 0), QRegion(), 0);
66  }
67 
68  NativeTabBar *native;
69 };
70 
71 class TabBarPrivate : public ThemedWidgetInterface<TabBar>
72 {
73 public:
74  TabBarPrivate(TabBar *parent)
75  : ThemedWidgetInterface<TabBar>(parent),
76  tabProxy(0),
77  currentIndex(0),
78  tabWidgetMode(true),
79  oldPageAnimId(-1),
80  newPageAnimId(-1),
81  tabBarShown(true)
82  {
83  }
84 
85  ~TabBarPrivate()
86  {
87  }
88 
89  void updateTabWidgetMode();
90  void slidingCompleted(QGraphicsItem *item);
91  void slidingNewPageCompleted();
92  void slidingOldPageCompleted();
93  void shapeChanged(const KTabBar::Shape shape);
94 
95  TabBarProxy *tabProxy;
96  QList<QGraphicsWidget *> pages;
97  QGraphicsWidget *emptyTabBarSpacer;
98  QGraphicsLinearLayout *mainLayout;
99  QGraphicsLinearLayout *tabWidgetLayout;
100  QGraphicsLinearLayout *tabBarLayout;
101  int currentIndex;
102  bool tabWidgetMode;
103 
104  QWeakPointer<QGraphicsWidget> oldPage;
105  QWeakPointer<QGraphicsWidget> newPage;
106  int oldPageAnimId;
107  int newPageAnimId;
108  Animation *oldPageAnim;
109  Animation *newPageAnim;
110  QParallelAnimationGroup *animGroup;
111  bool tabBarShown;
112  QWeakPointer<QGraphicsWidget> firstPositionWidget;
113  QWeakPointer<QGraphicsWidget> lastPositionWidget;
114 };
115 
116 void TabBarPrivate::updateTabWidgetMode()
117 {
118  if (!tabBarShown) {
119  return;
120  }
121 
122  bool tabWidget = false;
123 
124  foreach (QGraphicsWidget *page, pages) {
125  if (page->preferredSize() != QSize(0, 0)) {
126  tabWidget = true;
127  break;
128  }
129  }
130 
131  if (tabWidget != tabWidgetMode) {
132  if (tabWidget) {
133  mainLayout->removeAt(0);
134  tabBarLayout->insertItem(1, tabProxy);
135  mainLayout->addItem(tabWidgetLayout);
136  } else {
137  mainLayout->removeAt(0);
138  tabBarLayout->removeAt(1);
139  mainLayout->addItem(tabProxy);
140  }
141  }
142 
143  //always show the tabbar
144  //FIXME: Qt BUG: calling show on a child of an hidden item it shows it anyways
145  //so we avoid to call it if the parent is hidden
146  if (!tabWidget && q->isVisible()) {
147  q->setTabBarShown(true);
148  }
149 
150  tabWidgetMode = tabWidget;
151  if (!tabWidgetMode) {
152  q->setMinimumSize(QSize(0, 0));
153  q->setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
154  } else {
155  tabProxy->native->setMinimumSize(QSize(0,0));
156  tabProxy->setMinimumSize(QSize(0,0));
157  }
158 }
159 
160 void TabBarPrivate::slidingNewPageCompleted()
161 {
162  if (newPage) {
163  tabWidgetLayout->addItem(newPage.data());
164  }
165  newPageAnimId = -1;
166  mainLayout->invalidate();
167  emit q->currentChanged(currentIndex);
168 
169  q->setFlags(0);
170 }
171 
172 void TabBarPrivate::slidingOldPageCompleted()
173 {
174  QGraphicsWidget *item = oldPageAnim->targetWidget();
175 
176  oldPageAnimId = -1;
177  if (item) {
178  item->hide();
179  }
180  q->setFlags(0);
181 }
182 
183 void TabBarPrivate::shapeChanged(const QTabBar::Shape shape)
184 {
185  //FIXME: QGraphicsLinearLayout doesn't have setDirection, so for now
186  // North is equal to south and East is equal to West
187  switch (shape) {
188  case QTabBar::RoundedWest:
189  case QTabBar::TriangularWest:
190 
191  case QTabBar::RoundedEast:
192  case QTabBar::TriangularEast:
193  q->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
194  tabBarLayout->setOrientation(Qt::Vertical);
195  tabWidgetLayout->setOrientation(Qt::Horizontal);
196  tabWidgetLayout->itemAt(0)->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
197  if (tabWidgetLayout->count() > 1) {
198  tabWidgetLayout->itemAt(1)->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
199  }
200  tabProxy->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
201  break;
202 
203  case QTabBar::RoundedSouth:
204  case QTabBar::TriangularSouth:
205 
206  case QTabBar::RoundedNorth:
207  case QTabBar::TriangularNorth:
208  default:
209  q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
210  tabBarLayout->setOrientation(Qt::Horizontal);
211  tabWidgetLayout->setOrientation(Qt::Vertical);
212  tabWidgetLayout->itemAt(0)->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
213  if (tabWidgetLayout->count() > 1) {
214  tabWidgetLayout->itemAt(1)->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
215  }
216  tabProxy->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
217  }
218  tabProxy->setPreferredSize(tabProxy->native->sizeHint());
219 }
220 
221 TabBar::TabBar(QGraphicsWidget *parent)
222  : QGraphicsWidget(parent),
223  d(new TabBarPrivate(this))
224 {
225  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
226  setContentsMargins(0,0,0,0);
227  d->tabProxy = new TabBarProxy(this);
228  d->tabWidgetLayout = new QGraphicsLinearLayout(Qt::Vertical);
229  d->tabBarLayout = new QGraphicsLinearLayout(Qt::Horizontal);
230  d->tabWidgetLayout->setContentsMargins(0,0,0,0);
231 
232  d->mainLayout = new QGraphicsLinearLayout(Qt::Horizontal);
233  d->mainLayout->addItem(d->tabWidgetLayout);
234 
235  setLayout(d->mainLayout);
236  d->mainLayout->setContentsMargins(0,0,0,0);
237 
238  //simulate a page until there isn't one
239  //needed to make the widget resize well when there are no tab added
240  d->emptyTabBarSpacer = new QGraphicsWidget(this);
241 
242  d->tabWidgetLayout->addItem(d->tabBarLayout);
243  d->tabWidgetLayout->addItem(d->emptyTabBarSpacer);
244 
245  //tabBar is centered, so a stretch at begin one at the end
246  d->tabBarLayout->addStretch();
247  d->tabBarLayout->addItem(d->tabProxy);
248  d->tabBarLayout->addStretch();
249  d->tabBarLayout->setContentsMargins(0,0,0,0);
250  //d->tabBarLayout->setStretchFactor(d->tabProxy, 2);
251 
252 
253  d->newPageAnim = Animator::create(Animator::SlideAnimation);
254  d->oldPageAnim = Animator::create(Animator::SlideAnimation);
255  d->animGroup = new QParallelAnimationGroup(this);
256 
257  d->animGroup->addAnimation(d->newPageAnim);
258  d->animGroup->addAnimation(d->oldPageAnim);
259 
260  connect(d->tabProxy->native, SIGNAL(currentChanged(int)),
261  this, SLOT(setCurrentIndex(int)));
262  connect(d->tabProxy->native, SIGNAL(shapeChanged(QTabBar::Shape)),
263  this, SLOT(shapeChanged(QTabBar::Shape)));
264  connect(d->newPageAnim, SIGNAL(finished()), this, SLOT(slidingNewPageCompleted()));
265  connect(d->oldPageAnim, SIGNAL(finished()), this, SLOT(slidingOldPageCompleted()));
266  d->initTheming();
267 }
268 
269 TabBar::~TabBar()
270 {
271  delete d;
272 }
273 
274 
275 int TabBar::insertTab(int index, const QIcon &icon, const QString &label,
276  QGraphicsLayoutItem *content)
277 {
278  QGraphicsWidget *page = new QGraphicsWidget(this);
279  page->setContentsMargins(0,0,0,0);
280  page->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
281  if (content) {
282  if (content->isLayout()) {
283  page->setLayout(static_cast<QGraphicsLayout *>(content));
284  } else {
285  QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical, page);
286  layout->setContentsMargins(0,0,0,0);
287  layout->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
288  layout->addItem(content);
289  page->setLayout(layout);
290  }
291  } else {
292  page->setPreferredSize(0, 0);
293  }
294 
295  d->pages.insert(qBound(0, index, d->pages.count()), page);
296 
297  if (d->pages.count() == 1) {
298  d->tabWidgetLayout->removeItem(d->emptyTabBarSpacer);
299  d->tabWidgetLayout->addItem(page);
300  page->setVisible(true);
301  page->setEnabled(true);
302  } else {
303  page->setVisible(false);
304  page->setEnabled(false);
305  }
306 
307  d->tabProxy->setPreferredSize(d->tabProxy->native->sizeHint());
308  d->updateTabWidgetMode();
309 
310  int actualIndex = d->tabProxy->native->insertTab(index, icon, label);
311  d->currentIndex = d->tabProxy->native->currentIndex();
312  d->tabProxy->setPreferredSize(d->tabProxy->native->sizeHint());
313  d->updateTabWidgetMode();
314  return actualIndex;
315 }
316 
317 int TabBar::insertTab(int index, const QString &label, QGraphicsLayoutItem *content)
318 {
319  return insertTab(index, QIcon(), label, content);
320 }
321 
322 int TabBar::addTab(const QIcon &icon, const QString &label, QGraphicsLayoutItem *content)
323 {
324  return insertTab(d->pages.count(), icon, label, content);
325 }
326 
327 int TabBar::addTab(const QString &label, QGraphicsLayoutItem *content)
328 {
329  return insertTab(d->pages.count(), QIcon(), label, content);
330 }
331 
332 int TabBar::currentIndex() const
333 {
334  return d->tabProxy->native->currentIndex();
335 }
336 
337 void TabBar::resizeEvent(QGraphicsSceneResizeEvent * event)
338 {
339  if (!d->tabWidgetMode) {
340  d->tabProxy->setMinimumSize(event->newSize().toSize());
341  setMinimumSize(QSize(0, 0));
342  setMinimumHeight(d->tabProxy->widget()->minimumSizeHint().height());
343  setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
344  } else {
345  setMinimumSize(QSize(-1, -1));
346  d->tabProxy->native->setMinimumSize(QSize(0,0));
347  }
348 }
349 
350 void TabBar::setCurrentIndex(int index)
351 {
352  if (index >= d->pages.count() ||
353  d->pages.count() < 2 ||
354  d->currentIndex == index) {
355  return;
356  }
357 
358  d->oldPage = d->pages.value(d->currentIndex);
359 
360  if (d->oldPage) {
361  d->tabWidgetLayout->removeItem(d->oldPage.data());
362  }
363 
364  if (index >= 0) {
365  d->newPage = d->pages.value(index);
366  }
367 
368  setFlags(QGraphicsItem::ItemClipsChildrenToShape);
369 
370  //if an animation was in rogress hide everything to avoid an inconsistent state
371 
372  if (d->animGroup->state() != QAbstractAnimation::Stopped) {
373  foreach (QGraphicsWidget *page, d->pages) {
374  page->hide();
375  }
376  d->animGroup->stop();
377  }
378 
379  if (d->newPage) {
380  d->newPage.data()->show();
381  d->newPage.data()->setEnabled(true);
382  }
383 
384  if (d->oldPage) {
385  d->oldPage.data()->show();
386  d->oldPage.data()->setEnabled(false);
387  }
388 
389  if (d->newPage && d->oldPage) {
390  //FIXME: it seems necessary to resiz the thing 2 times to have effect
391  d->newPage.data()->resize(1,1);
392  d->newPage.data()->resize(d->oldPage.data()->size());
393 
394  QRect beforeCurrentGeom(d->oldPage.data()->geometry().toRect());
395  beforeCurrentGeom.moveTopRight(beforeCurrentGeom.topLeft());
396 
397  if (index > d->currentIndex) {
398  d->newPage.data()->setPos(d->oldPage.data()->geometry().topRight());
399  d->newPageAnim->setProperty("movementDirection", Animation::MoveLeft);
400  d->newPageAnim->setProperty("distancePointF", QPointF(d->oldPage.data()->size().width(), 0));
401  d->newPageAnim->setTargetWidget(d->newPage.data());
402 
403  d->oldPageAnim->setProperty("movementDirection", Animation::MoveLeft);
404  d->oldPageAnim->setProperty("distancePointF", QPointF(beforeCurrentGeom.width(), 0));
405  d->oldPageAnim->setTargetWidget(d->oldPage.data());
406 
407  d->animGroup->start();
408  } else {
409  d->newPage.data()->setPos(beforeCurrentGeom.topLeft());
410  d->newPageAnim->setProperty("movementDirection", Animation::MoveRight);
411  d->newPageAnim->setProperty("distancePointF", QPointF(d->oldPage.data()->size().width(), 0));
412  d->newPageAnim->setTargetWidget(d->newPage.data());
413 
414  d->oldPageAnim->setProperty("movementDirection", Animation::MoveRight);
415  d->oldPageAnim->setProperty("distancePointF",
416  QPointF(d->oldPage.data()->size().width(), 0));
417  d->oldPageAnim->setTargetWidget(d->oldPage.data());
418 
419  d->animGroup->start();
420  }
421  } else if (d->newPage) {
422  d->tabWidgetLayout->addItem(d->newPage.data());
423  }
424 
425  d->currentIndex = index;
426  d->tabProxy->native->setCurrentIndex(index);
427 }
428 
429 int TabBar::count() const
430 {
431  return d->pages.count();
432 }
433 
434 void TabBar::removeTab(int index)
435 {
436  if (index >= d->pages.count() || index < 0) {
437  return;
438  }
439 
440  d->newPageAnim->stop();
441  d->oldPageAnim->stop();
442 
443  int oldCurrentIndex = d->tabProxy->native->currentIndex();
444  d->tabProxy->native->removeTab(index);
445 
446  d->currentIndex = oldCurrentIndex;
447  int currentIndex = d->tabProxy->native->currentIndex();
448 
449  if (oldCurrentIndex == index) {
450  d->tabWidgetLayout->removeAt(1);
451  if (d->tabProxy->native->count() > 0) {
452  setCurrentIndex(currentIndex >= oldCurrentIndex ? currentIndex + 1 : currentIndex);
453  }
454  }
455 
456  QGraphicsWidget *page = d->pages.takeAt(index);
457  scene()->removeItem(page);
458  page->deleteLater();
459 
460  if (d->pages.count() > 0) {
461  d->updateTabWidgetMode();
462  } else {
463  d->tabWidgetLayout->addItem(d->emptyTabBarSpacer);
464  }
465 }
466 
467 QGraphicsLayoutItem *TabBar::takeTab(int index)
468 {
469  if (index >= d->pages.count()) {
470  return 0;
471  }
472 
473  int oldCurrentIndex = d->tabProxy->native->currentIndex();
474  d->tabProxy->native->removeTab(index);
475 
476  int currentIndex = d->tabProxy->native->currentIndex();
477 
478  if (oldCurrentIndex == index) {
479  d->tabWidgetLayout->removeAt(1);
480  if (d->tabProxy->native->count() > 0) {
481  setCurrentIndex(currentIndex >= oldCurrentIndex ? currentIndex + 1 : currentIndex);
482  }
483  }
484 
485  QGraphicsWidget *page = d->pages.takeAt(index);
486  QGraphicsLayoutItem *returnItem = 0;
487  QGraphicsLayout *lay = page->layout();
488  if (lay && lay->count() == 1) {
489  returnItem = lay->itemAt(0);
490  lay->removeAt(0);
491  } else {
492  returnItem = lay;
493  }
494 
495  if (returnItem) {
496  returnItem->setParentLayoutItem(0);
497  if (QGraphicsItem *item = returnItem->graphicsItem()) {
498  item->setParentItem(0);
499  }
500  }
501 
502  page->setLayout(0);
503  scene()->removeItem(page);
504  page->deleteLater();
505 
506  if (oldCurrentIndex != currentIndex) {
507  setCurrentIndex(currentIndex);
508  }
509 
510  d->updateTabWidgetMode();
511  d->tabProxy->setPreferredSize(d->tabProxy->native->sizeHint());
512 
513  return returnItem;
514 }
515 
516 QGraphicsLayoutItem *TabBar::tabAt(int index)
517 {
518  if (index >= d->pages.count()) {
519  return 0;
520  }
521 
522  QGraphicsWidget *page = d->pages.value(index);
523 
524  QGraphicsLayoutItem *returnItem = 0;
525  QGraphicsLayout *lay = page->layout();
526  if (lay && lay->count() == 1) {
527  returnItem = lay->itemAt(0);
528  } else {
529  returnItem = lay;
530  }
531 
532  return returnItem;
533 }
534 
535 void TabBar::setTabText(int index, const QString &label)
536 {
537  if (index >= d->pages.count()) {
538  return;
539  }
540 
541  d->tabProxy->native->setTabText(index, label);
542 }
543 
544 QString TabBar::tabText(int index) const
545 {
546  return d->tabProxy->native->tabText(index);
547 }
548 
549 void TabBar::setTabIcon(int index, const QIcon &icon)
550 {
551  d->tabProxy->native->setTabIcon(index, icon);
552 }
553 
554 QIcon TabBar::tabIcon(int index) const
555 {
556  return d->tabProxy->native->tabIcon(index);
557 }
558 
559 void TabBar::setTabBarShown(bool show)
560 {
561  if (!show && !d->tabWidgetMode) {
562  return;
563  }
564  if (d->tabBarShown == show) {
565  return;
566  }
567  d->tabBarShown = show;
568 
569  if (!show) {
570  d->tabProxy->hide();
571  d->tabWidgetLayout->removeItem(d->tabBarLayout);
572  } else {
573  d->tabProxy->show();
574  d->tabWidgetLayout->insertItem(0, d->tabBarLayout);
575  }
576 }
577 
578 bool TabBar::isTabBarShown() const
579 {
580  return d->tabBarShown;
581 }
582 
583 void TabBar::setStyleSheet(const QString &stylesheet)
584 {
585  d->tabProxy->native->setStyleSheet(stylesheet);
586 }
587 
588 QString TabBar::styleSheet() const
589 {
590  return d->tabProxy->native->styleSheet();
591 }
592 
593 void TabBar::setTabHighlighted(int index, bool highlight)
594 {
595  d->tabProxy->native->setTabHighlighted(index, highlight);
596 }
597 
598 bool TabBar::isTabHighlighted(int index) const
599 {
600  return d->tabProxy->native->isTabHighlighted(index);
601 }
602 
603 KTabBar *TabBar::nativeWidget() const
604 {
605  return d->tabProxy->native;
606 }
607 
608 void TabBar::wheelEvent(QGraphicsSceneWheelEvent * event)
609 {
610  Q_UNUSED(event)
611  //Still here for binary compatibility
612 }
613 
614 void TabBar::changeEvent(QEvent *event)
615 {
616  d->changeEvent(event);
617  QGraphicsWidget::changeEvent(event);
618 }
619 
620 void TabBar::setFirstPositionWidget(QGraphicsWidget *widget)
621 {
622  if (d->lastPositionWidget.data() == widget) {
623  return;
624  }
625 
626  if (d->firstPositionWidget) {
627  QGraphicsWidget *widget = d->firstPositionWidget.data();
628  d->tabBarLayout->removeItem(widget);
629  scene()->removeItem(widget);
630  widget->deleteLater();
631  }
632 
633  d->firstPositionWidget = widget;
634  if (widget) {
635  widget->setParentItem(this);
636  if (layoutDirection() == Qt::LeftToRight) {
637  d->tabBarLayout->insertItem(0, widget);
638  } else {
639  d->tabBarLayout->addItem(widget);
640  }
641  }
642 }
643 
644 
645 QGraphicsWidget *TabBar::firstPositionWidget() const
646 {
647  return d->firstPositionWidget.data();
648 }
649 
650 void TabBar::setLastPositionWidget(QGraphicsWidget *widget)
651 {
652  if (d->lastPositionWidget.data() == widget) {
653  return;
654  }
655 
656  if (d->lastPositionWidget) {
657  QGraphicsWidget *widget = d->lastPositionWidget.data();
658  d->tabBarLayout->removeItem(widget);
659  scene()->removeItem(widget);
660  widget->deleteLater();
661  }
662 
663  d->lastPositionWidget = widget;
664  if (widget) {
665  widget->setParentItem(this);
666  if (layoutDirection() == Qt::LeftToRight) {
667  d->tabBarLayout->addItem(widget);
668  } else {
669  d->tabBarLayout->insertItem(0, widget);
670  }
671  }
672 }
673 
674 QGraphicsWidget *TabBar::lastPositionWidget() const
675 {
676  return d->lastPositionWidget.data();
677 }
678 
679 } // namespace Plasma
680 
681 #include <tabbar.moc>
682 
Plasma::TabBar::setLastPositionWidget
void setLastPositionWidget(QGraphicsWidget *widget)
Set a widget to be displayed on one side of the TabBar, depending on the LayoutDirection and the Shap...
Definition: tabbar.cpp:650
Plasma::Animator::SlideAnimation
Definition: animator.h:65
Plasma::TabBar::setFirstPositionWidget
void setFirstPositionWidget(QGraphicsWidget *widget)
Set a widget to be displayed on one side of the TabBar, depending on the LayoutDirection and the Shap...
Definition: tabbar.cpp:620
Plasma::Vertical
The applet is constrained horizontally, but can expand vertically.
Definition: plasma.h:77
animation.h
Plasma::TabBar::setTabText
Q_INVOKABLE void setTabText(int index, const QString &label)
Sets the text label of the given tab.
Definition: tabbar.cpp:535
Plasma::TabBar::setTabIcon
Q_INVOKABLE void setTabIcon(int index, const QIcon &icon)
Sets an icon for a given tab.
Definition: tabbar.cpp:549
QWidget
Plasma::TabBar::setStyleSheet
void setStyleSheet(const QString &stylesheet)
Sets the stylesheet used to control the visual display of this TabBar.
Definition: tabbar.cpp:583
Plasma::TabBar::styleSheet
QString styleSheet() const
Plasma::TabBar::currentChanged
void currentChanged(int index)
Emitted when the active tab changes.
Plasma::TabBar::addTab
Q_INVOKABLE int addTab(const QIcon &icon, const QString &label, QGraphicsLayoutItem *content=0)
Adds a new tab in the last position.
Definition: tabbar.cpp:322
theme.h
Plasma::TabBar::setTabHighlighted
Q_INVOKABLE void setTabHighlighted(int index, bool highlight)
Highlight the specified tab.
Definition: tabbar.cpp:593
Plasma::TabBar::setTabBarShown
void setTabBarShown(bool show)
shows or hides the tabbar, used if you just want to display the pages, when the tabbar doesn't have c...
Definition: tabbar.cpp:559
Plasma::Horizontal
The applet is constrained vertically, but can expand horizontally.
Definition: plasma.h:75
Plasma::TabBar::setCurrentIndex
void setCurrentIndex(int index)
Activate a given tab.
Definition: tabbar.cpp:350
Plasma::TabBar::takeTab
Q_INVOKABLE QGraphicsLayoutItem * takeTab(int index)
Removes a tab, the page is reparented to 0 and is returned.
Definition: tabbar.cpp:467
Plasma::TabBar::tabText
Q_INVOKABLE QString tabText(int index) const
Definition: tabbar.cpp:544
Plasma::TabBar::insertTab
Q_INVOKABLE int insertTab(int index, const QIcon &icon, const QString &label, QGraphicsLayoutItem *content=0)
Adds a new tab in the desired position.
Definition: tabbar.cpp:275
Plasma::TabBar::nativeWidget
KTabBar * nativeWidget() const
Plasma::TabBar::count
int count() const
Plasma::TabBar::isTabHighlighted
Q_INVOKABLE bool isTabHighlighted(int index) const
Definition: tabbar.cpp:598
Plasma::TabBar::removeTab
Q_INVOKABLE void removeTab(int index)
Removes a tab, contents are deleted.
Definition: tabbar.cpp:434
Plasma::Animation::MoveRight
Definition: animation.h:82
Plasma::TabBar::currentIndex
int currentIndex() const
Plasma::TabBar::tabIcon
Q_INVOKABLE QIcon tabIcon(int index) const
Definition: tabbar.cpp:554
Plasma::TabBar::wheelEvent
void wheelEvent(QGraphicsSceneWheelEvent *event)
Definition: tabbar.cpp:608
QGraphicsProxyWidget
Plasma::TabBar::~TabBar
~TabBar()
Definition: tabbar.cpp:269
Plasma::TabBar::resizeEvent
void resizeEvent(QGraphicsSceneResizeEvent *event)
Definition: tabbar.cpp:337
QGraphicsLayout
Plasma::TabBar::lastPositionWidget
QGraphicsWidget * lastPositionWidget() const
Plasma::Animator::create
static Plasma::Animation * create(Animator::Animation type, QObject *parent=0)
Factory to build new animation objects.
Definition: animator.cpp:61
Plasma::TabBar::TabBar
TabBar(QGraphicsWidget *parent=0)
Constructs a new TabBar.
Definition: tabbar.cpp:221
Plasma::TabBar::changeEvent
void changeEvent(QEvent *event)
Definition: tabbar.cpp:614
Plasma::TabBar::firstPositionWidget
QGraphicsWidget * firstPositionWidget() const
Plasma::Animation::MoveLeft
Definition: animation.h:84
animator.h
Plasma::TabBar::tabAt
Q_INVOKABLE QGraphicsLayoutItem * tabAt(int index)
Returns the contents of a page.
Definition: tabbar.cpp:516
QStyleOptionGraphicsItem
Plasma::TabBar::isTabBarShown
bool isTabBarShown() const
Definition: tabbar.cpp:578
tabbar.h
QGraphicsWidget
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:34 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Plasma

Skip menu "Plasma"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal