summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-01-07 08:34:53 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-01-07 08:34:53 +0100
commit75391511ff75d6999822cda9f699da585f49ad37 (patch)
tree566dbd70ca624e733025a68612a95aaade463bba /src/widgets
parentfd9b0b86bb5f78ffa855409c4dd5976505ef83f5 (diff)
parent68c30e372b01561e8809fcfa5426ae896da70b8e (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/styles/qstyleoption.cpp16
-rw-r--r--src/widgets/styles/qstyleoption.h8
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp11
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp7
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp3
-rw-r--r--src/widgets/widgets/qtabbar.cpp16
6 files changed, 49 insertions, 12 deletions
diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp
index 4b861d938e..5a2ca2f2e7 100644
--- a/src/widgets/styles/qstyleoption.cpp
+++ b/src/widgets/styles/qstyleoption.cpp
@@ -1470,6 +1470,22 @@ QStyleOptionTab::QStyleOptionTab(int version)
The default value is QSize(-1, -1), i.e. an invalid size;
*/
+/*!
+ Constructs a QStyleOptionTabV4 object, initializing the members
+ variables to their default values.
+ */
+
+QStyleOptionTabV4::QStyleOptionTabV4() : QStyleOptionTab(QStyleOptionTabV4::Version)
+{
+}
+
+/*!
+ \variable QStyleOptionTabV4::tabIndex
+ \brief the index for the tab being represented.
+
+ The default value is -1, i.e. a tab not on a tabbar;
+ */
+
#endif // QT_CONFIG(tabbar)
/*!
diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h
index 7f5edf4279..a8ce3b465e 100644
--- a/src/widgets/styles/qstyleoption.h
+++ b/src/widgets/styles/qstyleoption.h
@@ -296,6 +296,14 @@ 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;
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index 7e8c9a6050..2eccb24431 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -3027,6 +3027,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
r = positionRect(w, subRule, subRule2, PseudoElement_ComboBoxArrow, r, opt->direction);
subRule2.drawRule(p, r);
} else {
+ rule.configurePalette(&cmbOpt.palette, QPalette::ButtonText, QPalette::Button);
cmbOpt.subControls = QStyle::SC_ComboBoxArrow;
QWindowsStyle::drawComplexControl(cc, &cmbOpt, p, w);
}
@@ -6009,6 +6010,16 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c
case SE_TabBarTabRightButton: {
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)) {
+ 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);
+ tabCopy.rect = subRule.contentsRect(r);
+ return ParentStyle::subElementRect(se, &tabCopy, w);
+ }
+ }
return ParentStyle::subElementRect(se, opt, w);
}
break;
diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp
index 33300b542a..00fe0cd776 100644
--- a/src/widgets/widgets/qdatetimeedit.cpp
+++ b/src/widgets/widgets/qdatetimeedit.cpp
@@ -341,7 +341,6 @@ void QDateTimeEdit::setCalendar(QCalendar calendar)
/*!
\since 4.4
\property QDateTimeEdit::minimumDateTime
-
\brief the minimum datetime of the date time edit
Changing this property implicitly updates the \l minimumDate and \l
@@ -643,8 +642,8 @@ void QDateTimeEdit::setDateRange(const QDate &min, const QDate &max)
Note that these only constrain the date time edit's value on,
respectively, the \l minimumDate and \l maximumDate. When these date
- properties do not coincide, times after \a maximumTime are allowed on dates
- before \l maximumDate and times before \a minimumTime are allowed on dates
+ properties do not coincide, times after \a max are allowed on dates
+ before \l maximumDate and times before \a min are allowed on dates
after \l minimumDate.
\snippet code/src_gui_widgets_qdatetimeedit.cpp 5
@@ -655,7 +654,7 @@ void QDateTimeEdit::setDateRange(const QDate &min, const QDate &max)
If either \a min or \a max is invalid, this function does nothing. This
function preserves the \l minimumDate and \l maximumDate properties. If those
- properties coincide and max is \a less than \a min, \a min is used as \a max.
+ properties coincide and \a max is less than \a min, \a min is used as \a max.
\sa minimumTime, maximumTime, setDateTimeRange(), QTime::isValid()
*/
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index 0bfaa767c6..d54c0d0b20 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -839,7 +839,8 @@ void QPlainTextEditPrivate::_q_textChanged()
placeholderVisible = !placeholderText.isEmpty()
&& q->document()->isEmpty()
- && q->firstVisibleBlock().layout()->preeditAreaText().isEmpty();
+ && (!q->firstVisibleBlock().isValid() ||
+ q->firstVisibleBlock().layout()->preeditAreaText().isEmpty());
if (placeholderCurrentyVisible != placeholderVisible)
viewport->update();
diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index aff95b0931..a7b115a1bc 100644
--- a/src/widgets/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
@@ -229,6 +229,8 @@ void QTabBarPrivate::initBasicStyleOption(QStyleOptionTab *option, int tabIndex)
option->cornerWidgets |= QStyleOptionTab::RightCornerWidget;
}
#endif
+ if (QStyleOptionTabV4 *optv4 = qstyleoption_cast<QStyleOptionTabV4 *>(option))
+ optv4->tabIndex = tabIndex;
}
/*!
@@ -628,7 +630,7 @@ QRect QTabBarPrivate::normalizedScrollRect(int index)
// tab bar itself is in a different orientation.
Q_Q(QTabBar);
- QStyleOptionTab opt;
+ QStyleOptionTabV4 opt;
q->initStyleOption(&opt, currentIndex);
opt.rect = q->rect();
@@ -757,7 +759,7 @@ void QTabBarPrivate::layoutTab(int index)
if (!(tab.leftWidget || tab.rightWidget))
return;
- QStyleOptionTab opt;
+ QStyleOptionTabV4 opt;
q->initStyleOption(&opt, index);
if (tab.leftWidget) {
QRect rect = q->style()->subElementRect(QStyle::SE_TabBarTabLeftButton, &opt, q);
@@ -1003,7 +1005,7 @@ int QTabBar::insertTab(int index, const QIcon& icon, const QString &text)
}
if (d->closeButtonOnTabs) {
- QStyleOptionTab opt;
+ QStyleOptionTabV4 opt;
initStyleOption(&opt, index);
ButtonPosition closeSide = (ButtonPosition)style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, nullptr, this);
QAbstractButton *closeButton = new CloseButton(this);
@@ -1574,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)) {
- QStyleOptionTab opt;
+ QStyleOptionTabV4 opt;
d->initBasicStyleOption(&opt, index);
opt.text = d->tabList.at(index).text;
QSize iconSize = tab->icon.isNull() ? QSize(0, 0) : opt.iconSize;
@@ -1819,7 +1821,7 @@ void QTabBar::paintEvent(QPaintEvent *)
for (int i = 0; i < d->tabList.count(); ++i) {
if (!d->at(i)->visible)
continue;
- QStyleOptionTab tab;
+ QStyleOptionTabV4 tab;
initStyleOption(&tab, i);
if (d->paintWithOffsets && d->tabList[i].dragOffset != 0) {
if (vertical) {
@@ -1859,7 +1861,7 @@ void QTabBar::paintEvent(QPaintEvent *)
// Draw the selected tab last to get it "on top"
if (selected >= 0) {
- QStyleOptionTab tab;
+ QStyleOptionTabV4 tab;
initStyleOption(&tab, selected);
if (d->paintWithOffsets && d->tabList[selected].dragOffset != 0) {
if (vertical)
@@ -2209,7 +2211,7 @@ void QTabBarPrivate::setupMovableTab()
grabImage.fill(Qt::transparent);
QStylePainter p(&grabImage, q);
- QStyleOptionTab tab;
+ QStyleOptionTabV4 tab;
q->initStyleOption(&tab, pressedIndex);
tab.position = QStyleOptionTab::OnlyOneTab;
if (verticalTabs(shape))