From 80515c811a4c455d7f2fb9ded751b2406b08d045 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 24 Jan 2018 17:13:24 -0800 Subject: Introducing SH_SpinBox_ButtonsInsideFrame This is currently only used in QMacStyle since, on macOS, the spin-box buttons are always beside the line-edit. Hence, there is no need to tamper with the line-edit frame. Change-Id: I8ccfbab547fccae89a8ddeaeb7005cb17d5951e6 Reviewed-by: Jake Petroules --- src/widgets/styles/qcommonstyle.cpp | 3 +++ src/widgets/styles/qstyle.cpp | 4 ++++ src/widgets/styles/qstyle.h | 1 + src/widgets/widgets/qabstractspinbox.cpp | 8 ++++++-- 4 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 1190099c16..12b60c634c 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -5303,6 +5303,9 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget case SH_ComboBox_AllowWheelScrolling: ret = true; break; + case SH_SpinBox_ButtonsInsideFrame: + ret = true; + break; default: ret = 0; break; diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index c22f45d54e..73a6554f1a 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -1997,6 +1997,10 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, This is on by default in all styles except the Mac style. This enum value has been introduced in Qt 5.10. + \value SH_SpinBox_ButtonsInsideFrame + Determnines if the spin box buttons are inside the line edit frame. + This enum value has been introduced in Qt 5.11. + \sa styleHint() */ diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h index ab61534a96..cef569d514 100644 --- a/src/widgets/styles/qstyle.h +++ b/src/widgets/styles/qstyle.h @@ -740,6 +740,7 @@ public: SH_TitleBar_ShowToolTipsOnButtons, SH_Widget_Animation_Duration, SH_ComboBox_AllowWheelScrolling, + SH_SpinBox_ButtonsInsideFrame, // Add new style hint values here SH_CustomBase = 0xf0000000 diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index fe2801fcbf..7ca47e9f0f 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -691,7 +691,7 @@ void QAbstractSpinBox::setLineEdit(QLineEdit *lineEdit) if (d->edit->parent() != this) d->edit->setParent(this); - d->edit->setFrame(false); + d->edit->setFrame(!style()->styleHint(QStyle::SH_SpinBox_ButtonsInsideFrame, nullptr, this)); d->edit->setFocusProxy(this); d->edit->setAcceptDrops(false); @@ -823,6 +823,8 @@ void QAbstractSpinBox::changeEvent(QEvent *event) d->spinClickTimerInterval = style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatRate, 0, this); d->spinClickThresholdTimerInterval = style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatThreshold, 0, this); + if (d->edit) + d->edit->setFrame(!style()->styleHint(QStyle::SH_SpinBox_ButtonsInsideFrame, nullptr, this)); d->reset(); d->updateEditFieldGeometry(); break; @@ -1649,7 +1651,9 @@ void QAbstractSpinBox::initStyleOption(QStyleOptionSpinBox *option) const option->initFrom(this); option->activeSubControls = QStyle::SC_None; option->buttonSymbols = d->buttonSymbols; - option->subControls = QStyle::SC_SpinBoxFrame | QStyle::SC_SpinBoxEditField; + option->subControls = QStyle::SC_SpinBoxEditField; + if (!style()->styleHint(QStyle::SH_SpinBox_ButtonsInsideFrame, nullptr, this)) + option->subControls |= QStyle::SC_SpinBoxFrame; if (d->buttonSymbols != QAbstractSpinBox::NoButtons) { option->subControls |= QStyle::SC_SpinBoxUp | QStyle::SC_SpinBoxDown; if (d->buttonState & Up) { -- cgit v1.2.3