311 case QTabWidget::East: |
311 case QTabWidget::East: |
312 option->shape = d->shape == QTabWidget::Rounded ? QTabBar::RoundedEast |
312 option->shape = d->shape == QTabWidget::Rounded ? QTabBar::RoundedEast |
313 : QTabBar::TriangularEast; |
313 : QTabBar::TriangularEast; |
314 break; |
314 break; |
315 } |
315 } |
|
316 |
316 option->tabBarSize = t; |
317 option->tabBarSize = t; |
|
318 |
|
319 if (QStyleOptionTabWidgetFrameV2 *tabframe = qstyleoption_cast<QStyleOptionTabWidgetFrameV2*>(option)) { |
|
320 QRect tbRect = tabBar()->geometry(); |
|
321 QRect selectedTabRect = tabBar()->tabRect(tabBar()->currentIndex()); |
|
322 tabframe->tabBarRect = tbRect; |
|
323 selectedTabRect.moveTopLeft(selectedTabRect.topLeft() + tbRect.topLeft()); |
|
324 tabframe->selectedTabRect = selectedTabRect; |
|
325 } |
317 } |
326 } |
318 |
327 |
319 /*! |
328 /*! |
320 Constructs a tabbed widget with parent \a parent. |
329 Constructs a tabbed widget with parent \a parent. |
321 */ |
330 */ |
688 delete d->tabs; |
697 delete d->tabs; |
689 d->tabs = tb; |
698 d->tabs = tb; |
690 setFocusProxy(d->tabs); |
699 setFocusProxy(d->tabs); |
691 connect(d->tabs, SIGNAL(currentChanged(int)), |
700 connect(d->tabs, SIGNAL(currentChanged(int)), |
692 this, SLOT(_q_showTab(int))); |
701 this, SLOT(_q_showTab(int))); |
693 connect(d->tabs, SIGNAL(tabMoved(int, int)), |
702 connect(d->tabs, SIGNAL(tabMoved(int,int)), |
694 this, SLOT(_q_tabMoved(int, int))); |
703 this, SLOT(_q_tabMoved(int,int))); |
695 if (d->tabs->tabsClosable()) |
704 if (d->tabs->tabsClosable()) |
696 connect(d->tabs, SIGNAL(tabCloseRequested(int)), |
705 connect(d->tabs, SIGNAL(tabCloseRequested(int)), |
697 this, SIGNAL(tabCloseRequested(int))); |
706 this, SIGNAL(tabCloseRequested(int))); |
698 tb->setExpanding(!documentMode()); |
707 tb->setExpanding(!documentMode()); |
699 setUpLayout(); |
708 setUpLayout(); |
754 { |
763 { |
755 Q_D(QTabWidget); |
764 Q_D(QTabWidget); |
756 if (onlyCheck && !d->dirty) |
765 if (onlyCheck && !d->dirty) |
757 return; // nothing to do |
766 return; // nothing to do |
758 |
767 |
759 QStyleOptionTabWidgetFrame option; |
768 QStyleOptionTabWidgetFrameV2 option; |
760 initStyleOption(&option); |
769 initStyleOption(&option); |
761 |
770 |
762 // this must be done immediately, because QWidgetItem relies on it (even if !isVisible()) |
771 // this must be done immediately, because QWidgetItem relies on it (even if !isVisible()) |
763 d->setLayoutItemMargins(QStyle::SE_TabWidgetLayoutItem, &option); |
772 d->setLayoutItemMargins(QStyle::SE_TabWidgetLayoutItem, &option); |
764 |
773 |
1165 Paints the tab widget's tab bar in response to the paint \a event. |
1174 Paints the tab widget's tab bar in response to the paint \a event. |
1166 */ |
1175 */ |
1167 void QTabWidget::paintEvent(QPaintEvent *) |
1176 void QTabWidget::paintEvent(QPaintEvent *) |
1168 { |
1177 { |
1169 Q_D(QTabWidget); |
1178 Q_D(QTabWidget); |
1170 QStylePainter p(this); |
|
1171 if (documentMode()) { |
1179 if (documentMode()) { |
|
1180 QStylePainter p(this, tabBar()); |
1172 if (QWidget *w = cornerWidget(Qt::TopLeftCorner)) { |
1181 if (QWidget *w = cornerWidget(Qt::TopLeftCorner)) { |
1173 QStyleOptionTabBarBaseV2 opt; |
1182 QStyleOptionTabBarBaseV2 opt; |
1174 QTabBarPrivate::initStyleBaseOption(&opt, tabBar(), w->size()); |
1183 QTabBarPrivate::initStyleBaseOption(&opt, tabBar(), w->size()); |
1175 opt.rect.moveLeft(w->x() + opt.rect.x()); |
1184 opt.rect.moveLeft(w->x() + opt.rect.x()); |
1176 opt.rect.moveTop(w->y() + opt.rect.y()); |
1185 opt.rect.moveTop(w->y() + opt.rect.y()); |
1183 opt.rect.moveTop(w->y() + opt.rect.y()); |
1192 opt.rect.moveTop(w->y() + opt.rect.y()); |
1184 p.drawPrimitive(QStyle::PE_FrameTabBarBase, opt); |
1193 p.drawPrimitive(QStyle::PE_FrameTabBarBase, opt); |
1185 } |
1194 } |
1186 return; |
1195 return; |
1187 } |
1196 } |
1188 |
1197 QStylePainter p(this); |
1189 QStyleOptionTabWidgetFrame opt; |
1198 |
|
1199 QStyleOptionTabWidgetFrameV2 opt; |
1190 initStyleOption(&opt); |
1200 initStyleOption(&opt); |
1191 opt.rect = d->panelRect; |
1201 opt.rect = d->panelRect; |
1192 p.drawPrimitive(QStyle::PE_FrameTabWidget, opt); |
1202 p.drawPrimitive(QStyle::PE_FrameTabWidget, opt); |
1193 } |
1203 } |
1194 |
1204 |