summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-05-06 17:01:06 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-05-08 16:41:38 +0200
commit729f1ab9a0b9fe6ffdefc02df490ec546db38d72 (patch)
treea2681089a8c890ca6d072cf3f4fee49a2932b28d /src/widgets
parent6e63d65e5aa73f10b0e36e44f214f274a5ab079f (diff)
Merge QStyleOptionTabV4 into QStyleOptionTab
We don't need the subclass any more now that we can break ABI. Merge it back into the "main" style option class, like already happened during Qt 4->5. Change-Id: Iba6d3df5f87b0c96f01746260f0a93951dad0e27 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/styles/qstyleoption.cpp19
-rw-r--r--src/widgets/styles/qstyleoption.h12
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp4
-rw-r--r--src/widgets/widgets/qtabbar.cpp17
4 files changed, 22 insertions, 30 deletions
diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp
index 3d05392a8f..122775879f 100644
--- a/src/widgets/styles/qstyleoption.cpp
+++ b/src/widgets/styles/qstyleoption.cpp
@@ -1267,6 +1267,14 @@ QStyleOptionToolBar::QStyleOptionToolBar(int version)
*/
/*!
+ \typedef QStyleOptionTabV4
+ \relates QStyleOptionTab
+ \obsolete
+
+ Synonym for QStyleOptionTab.
+*/
+
+/*!
Constructs a QStyleOptionTab object, initializing the members
variables to their default values.
*/
@@ -1471,16 +1479,7 @@ QStyleOptionTab::QStyleOptionTab(int version)
*/
/*!
- Constructs a QStyleOptionTabV4 object, initializing the members
- variables to their default values.
- */
-
-QStyleOptionTabV4::QStyleOptionTabV4() : QStyleOptionTab(QStyleOptionTabV4::Version)
-{
-}
-
-/*!
- \variable QStyleOptionTabV4::tabIndex
+ \variable QStyleOptionTab::tabIndex
\brief the index for the tab being represented.
The default value is -1, i.e. a tab not on a tabbar;
diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h
index a93f0c7ca6..52893ebd83 100644
--- a/src/widgets/styles/qstyleoption.h
+++ b/src/widgets/styles/qstyleoption.h
@@ -265,7 +265,7 @@ class Q_WIDGETS_EXPORT QStyleOptionTab : public QStyleOption
{
public:
enum StyleOptionType { Type = SO_Tab };
- enum StyleOptionVersion { Version = 3 };
+ enum StyleOptionVersion { Version = 4 };
enum TabPosition { Beginning, Middle, End, OnlyOneTab };
enum SelectedPosition { NotAdjacent, NextIsSelected, PreviousIsSelected };
@@ -287,6 +287,7 @@ public:
QSize leftButtonSize;
QSize rightButtonSize;
TabFeatures features;
+ int tabIndex = -1;
QStyleOptionTab();
QStyleOptionTab(const QStyleOptionTab &other) : QStyleOption(Version, Type) { *this = other; }
@@ -296,18 +297,11 @@ protected:
QStyleOptionTab(int version);
};
-class Q_WIDGETS_EXPORT QStyleOptionTabV4 : public QStyleOptionTab
-{
-public:
- enum StyleOptionVersion { Version = 4 };
- QStyleOptionTabV4();
- int tabIndex = -1;
-};
-
Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionTab::CornerWidgets)
typedef Q_DECL_DEPRECATED QStyleOptionTab QStyleOptionTabV2;
typedef Q_DECL_DEPRECATED QStyleOptionTab QStyleOptionTabV3;
+typedef Q_DECL_DEPRECATED QStyleOptionTab QStyleOptionTabV4;
#endif // QT_CONFIG(tabbar)
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 06116ed295..32f86e5b5a 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -6015,11 +6015,11 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab);
if (subRule.hasBox() || !subRule.hasNativeBorder()) {
if (se == SE_TabBarTabText) {
- if (const QStyleOptionTabV4 *tab = qstyleoption_cast<const QStyleOptionTabV4 *>(opt)) {
+ if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
const QTabBar *bar = qobject_cast<const QTabBar *>(w);
const QRect optRect = bar && tab->tabIndex != -1 ? bar->tabRect(tab->tabIndex) : opt->rect;
const QRect r = positionRect(w, subRule, PseudoElement_TabBarTab, optRect, opt->direction);
- QStyleOptionTabV4 tabCopy(*tab);
+ QStyleOptionTab tabCopy(*tab);
tabCopy.rect = subRule.contentsRect(r);
return ParentStyle::subElementRect(se, &tabCopy, w);
}
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index 670cdeb345..7bd346981a 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -231,8 +231,7 @@ void QTabBarPrivate::initBasicStyleOption(QStyleOptionTab *option, int tabIndex)
option->cornerWidgets |= QStyleOptionTab::RightCornerWidget;
}
#endif
- if (QStyleOptionTabV4 *optv4 = qstyleoption_cast<QStyleOptionTabV4 *>(option))
- optv4->tabIndex = tabIndex;
+ option->tabIndex = tabIndex;
}
/*!
@@ -632,7 +631,7 @@ QRect QTabBarPrivate::normalizedScrollRect(int index)
// tab bar itself is in a different orientation.
Q_Q(QTabBar);
- QStyleOptionTabV4 opt;
+ QStyleOptionTab opt;
q->initStyleOption(&opt, currentIndex);
opt.rect = q->rect();
@@ -761,7 +760,7 @@ void QTabBarPrivate::layoutTab(int index)
if (!(tab.leftWidget || tab.rightWidget))
return;
- QStyleOptionTabV4 opt;
+ QStyleOptionTab opt;
q->initStyleOption(&opt, index);
if (tab.leftWidget) {
QRect rect = q->style()->subElementRect(QStyle::SE_TabBarTabLeftButton, &opt, q);
@@ -1007,7 +1006,7 @@ int QTabBar::insertTab(int index, const QIcon& icon, const QString &text)
}
if (d->closeButtonOnTabs) {
- QStyleOptionTabV4 opt;
+ QStyleOptionTab opt;
initStyleOption(&opt, index);
ButtonPosition closeSide = (ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, nullptr, this);
QAbstractButton *closeButton = new CloseButton(this);
@@ -1577,7 +1576,7 @@ QSize QTabBar::tabSizeHint(int index) const
//Note: this must match with the computations in QCommonStylePrivate::tabLayout
Q_D(const QTabBar);
if (const QTabBarPrivate::Tab *tab = d->at(index)) {
- QStyleOptionTabV4 opt;
+ QStyleOptionTab opt;
d->initBasicStyleOption(&opt, index);
opt.text = d->tabList.at(index).text;
QSize iconSize = tab->icon.isNull() ? QSize(0, 0) : opt.iconSize;
@@ -1832,7 +1831,7 @@ void QTabBar::paintEvent(QPaintEvent *)
for (int i = 0; i < d->tabList.count(); ++i) {
if (!d->at(i)->visible)
continue;
- QStyleOptionTabV4 tab;
+ QStyleOptionTab tab;
initStyleOption(&tab, i);
if (d->paintWithOffsets && d->tabList[i].dragOffset != 0) {
if (vertical) {
@@ -1872,7 +1871,7 @@ void QTabBar::paintEvent(QPaintEvent *)
// Draw the selected tab last to get it "on top"
if (selected >= 0) {
- QStyleOptionTabV4 tab;
+ QStyleOptionTab tab;
initStyleOption(&tab, selected);
if (d->paintWithOffsets && d->tabList[selected].dragOffset != 0) {
if (vertical)
@@ -2222,7 +2221,7 @@ void QTabBarPrivate::setupMovableTab()
grabImage.fill(Qt::transparent);
QStylePainter p(&grabImage, q);
- QStyleOptionTabV4 tab;
+ QStyleOptionTab tab;
q->initStyleOption(&tab, pressedIndex);
tab.position = QStyleOptionTab::OnlyOneTab;
if (verticalTabs(shape))