summaryrefslogtreecommitdiffstats
path: root/src
diff options
Diffstat (limited to 'src')
-rw-r--r--src/gui/accessible/qaccessible.cpp21
-rw-r--r--src/gui/accessible/qplatformaccessibility.cpp18
-rw-r--r--src/gui/accessible/qplatformaccessibility.h6
-rw-r--r--src/gui/painting/qcolortransferfunction_p.h3
-rw-r--r--src/plugins/platforms/wasm/qwasmaccessibility.cpp4
-rw-r--r--src/plugins/platforms/wasm/qwasmwindow.cpp1
-rw-r--r--src/plugins/platforms/xcb/qxcbbackingstore.cpp5
-rw-r--r--src/plugins/styles/modernwindows/qwindows11style.cpp10
-rw-r--r--src/plugins/styles/modernwindows/qwindowsvistastyle.cpp29
-rw-r--r--src/widgets/CMakeLists.txt8
-rw-r--r--src/widgets/kernel/qapplication.cpp16
-rw-r--r--src/widgets/kernel/qlayout.cpp40
-rw-r--r--src/widgets/kernel/qlayoutitem.cpp6
-rw-r--r--src/widgets/kernel/qtooltip.cpp12
-rw-r--r--src/widgets/kernel/qwidget.cpp24
-rw-r--r--src/widgets/styles/qstyleoption.cpp2
-rw-r--r--src/widgets/styles/qstyleoption.h2
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp10
-rw-r--r--src/widgets/styles/qwindowsstyle.cpp2
-rw-r--r--src/widgets/widgets/qdockwidget.cpp1
-rw-r--r--src/widgets/widgets/qlabel.cpp6
-rw-r--r--src/widgets/widgets/qlineedit.cpp5
-rw-r--r--src/widgets/widgets/qmenu.cpp3
-rw-r--r--src/widgets/widgets/qmenubar.cpp3
-rw-r--r--src/widgets/widgets/qtoolbar.cpp9
25 files changed, 144 insertions, 102 deletions
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp
index 510931b4760..87b29d8662c 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/gui/accessible/qaccessible.cpp
@@ -688,6 +688,11 @@ void QAccessible::installActivationObserver(QAccessible::ActivationObserver *obs
if (qAccessibleActivationObservers()->contains(observer))
return;
qAccessibleActivationObservers()->append(observer);
+
+ // Make sure the newly added observer gets a callback on the next
+ // QPlatformAccessibility::setActive() callback
+ if (QPlatformAccessibility *pfAccessibility = platformAccessibility())
+ pfAccessibility->clearActiveNotificationState();
}
/*!
@@ -702,6 +707,17 @@ void QAccessible::removeActivationObserver(ActivationObserver *observer)
}
/*!
+ \internal
+
+ Sends accessibility activation notifications to all registered observers.
+*/
+void qAccessibleNotifyActivationObservers(bool active)
+{
+ for (int i = 0; i < qAccessibleActivationObservers()->size(); ++i)
+ qAccessibleActivationObservers()->at(i)->accessibilityActiveChanged(active);
+}
+
+/*!
If a QAccessibleInterface implementation exists for the given \a object,
this function returns a pointer to the implementation; otherwise it
returns \nullptr.
@@ -870,11 +886,10 @@ bool QAccessible::isActive()
*/
void QAccessible::setActive(bool active)
{
- for (int i = 0; i < qAccessibleActivationObservers()->size() ;++i)
- qAccessibleActivationObservers()->at(i)->accessibilityActiveChanged(active);
+ if (QPlatformAccessibility *pfAccessibility = platformAccessibility())
+ pfAccessibility->setActive(active);
}
-
/*!
Sets the root object of the accessible objects of this application
to \a object. All other accessible objects are reachable using object
diff --git a/src/gui/accessible/qplatformaccessibility.cpp b/src/gui/accessible/qplatformaccessibility.cpp
index ae7635ff7c9..4dd32a911c7 100644
--- a/src/gui/accessible/qplatformaccessibility.cpp
+++ b/src/gui/accessible/qplatformaccessibility.cpp
@@ -35,7 +35,6 @@ Q_GLOBAL_STATIC(QList<QAccessibleBridge *>, bridges)
\sa QAccessible
*/
QPlatformAccessibility::QPlatformAccessibility()
- : m_active(false)
{
}
@@ -99,10 +98,25 @@ void QPlatformAccessibility::cleanup()
qDeleteAll(*bridges());
}
+void qAccessibleNotifyActivationObservers(bool active); // qaccessible.cpp
+
void QPlatformAccessibility::setActive(bool active)
{
m_active = active;
- QAccessible::setActive(active);
+
+ // Send activeChanged notifications if the new active status differs from
+ // the notifed one.
+ if ((active && m_activeNotificationState != std::optional<bool>{true}) ||
+ (!active && m_activeNotificationState != std::optional<bool>{false})) {
+ qAccessibleNotifyActivationObservers(active);
+ }
+
+ m_activeNotificationState = active;
+}
+
+void QPlatformAccessibility::clearActiveNotificationState()
+{
+ m_activeNotificationState = std::nullopt;
}
#endif // QT_CONFIG(accessibility)
diff --git a/src/gui/accessible/qplatformaccessibility.h b/src/gui/accessible/qplatformaccessibility.h
index 004fcfb40fc..d262c2f6585 100644
--- a/src/gui/accessible/qplatformaccessibility.h
+++ b/src/gui/accessible/qplatformaccessibility.h
@@ -19,6 +19,8 @@
#include <QtCore/qobject.h>
#include <QtGui/qaccessible.h>
+#include <optional>
+
QT_BEGIN_NAMESPACE
@@ -35,9 +37,11 @@ public:
inline bool isActive() const { return m_active; }
void setActive(bool active);
+ void clearActiveNotificationState();
private:
- bool m_active;
+ bool m_active = false;
+ std::optional<bool> m_activeNotificationState = std::nullopt;
};
QT_END_NAMESPACE
diff --git a/src/gui/painting/qcolortransferfunction_p.h b/src/gui/painting/qcolortransferfunction_p.h
index b9a09b4646a..3ae2fdd410d 100644
--- a/src/gui/painting/qcolortransferfunction_p.h
+++ b/src/gui/painting/qcolortransferfunction_p.h
@@ -56,7 +56,8 @@ public:
if (x < m_d)
return m_c * x + m_f;
float t = std::pow(m_a * x + m_b, m_g);
- if (std::isfinite(t))
+ // Avoid NaN math, and leave room to multiply with 65280 and store in an int.
+ if (std::isfinite(t) && t > std::numeric_limits<short>::min() && t < std::numeric_limits<short>::max())
return t + m_e;
if (t > 0.f)
return 1.f;
diff --git a/src/plugins/platforms/wasm/qwasmaccessibility.cpp b/src/plugins/platforms/wasm/qwasmaccessibility.cpp
index 42fa8ac875f..c58819923b3 100644
--- a/src/plugins/platforms/wasm/qwasmaccessibility.cpp
+++ b/src/plugins/platforms/wasm/qwasmaccessibility.cpp
@@ -313,6 +313,10 @@ emscripten::val QWasmAccessibility::createHtmlElement(QAccessibleInterface *ifac
element = document.call<emscripten::val>("createElement", std::string("div"));
}
+ element.call<void>("addEventListener", emscripten::val("focus"),
+ QWasmSuspendResumeControl::get()->jsEventHandlerAt(m_eventHandlerIndex),
+ true);
+
return element;
}();
diff --git a/src/plugins/platforms/wasm/qwasmwindow.cpp b/src/plugins/platforms/wasm/qwasmwindow.cpp
index 5e1bdc35624..74e83b18162 100644
--- a/src/plugins/platforms/wasm/qwasmwindow.cpp
+++ b/src/plugins/platforms/wasm/qwasmwindow.cpp
@@ -110,6 +110,7 @@ QWasmWindow::QWasmWindow(QWindow *w, QWasmDeadKeySupport *deadKeySupport,
// Set inputMode to none to stop the mobile keyboard from opening
// when the user clicks on the window.
m_window.set("inputMode", std::string("none"));
+ m_windowInput.set("inputMode", std::string("none"));
// Hide the canvas from screen readers.
m_canvas.call<void>("setAttribute", std::string("aria-hidden"), std::string("true"));
diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
index e8226284bc4..8353fac6a92 100644
--- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp
+++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp
@@ -226,7 +226,6 @@ void QXcbBackingStoreImage::resize(const QSize &size)
m_xcb_image->data = m_shm_info.shmaddr ? m_shm_info.shmaddr : (uint8_t *)malloc(segmentSize);
m_qimage = QImage(static_cast<uchar *>(m_xcb_image->data), m_xcb_image->width,
m_xcb_image->height, m_xcb_image->stride, m_qimage_format);
- m_qimage.setDevicePixelRatio(m_backingStore->window()->devicePixelRatio());
m_graphics_buffer = new QXcbGraphicsBuffer(&m_qimage);
m_xcb_pixmap = xcb_generate_id(xcb_connection());
@@ -821,9 +820,7 @@ QImage QXcbBackingStore::toImage() const
// Return an image that does not share QImageData with the original image,
// even if they both point to the same data of the m_xcb_image, otherwise
// painting to m_qimage would detach it from the m_xcb_image data.
- QImage imageWrapper = QImage(image.constBits(), image.width(), image.height(), image.format());
- imageWrapper.setDevicePixelRatio(image.devicePixelRatio());
- return imageWrapper;
+ return QImage(image.constBits(), image.width(), image.height(), image.format());
}
QPlatformGraphicsBuffer *QXcbBackingStore::graphicsBuffer() const
diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp
index 6ca4291feeb..79044f1cdb5 100644
--- a/src/plugins/styles/modernwindows/qwindows11style.cpp
+++ b/src/plugins/styles/modernwindows/qwindows11style.cpp
@@ -148,10 +148,8 @@ static void drawArrow(const QStyle *style, const QStyleOptionToolButton *toolbut
/*!
Constructs a QWindows11Style object.
*/
-QWindows11Style::QWindows11Style() : QWindowsVistaStyle(*new QWindows11StylePrivate)
+QWindows11Style::QWindows11Style() : QWindows11Style(*new QWindows11StylePrivate)
{
- highContrastTheme = QGuiApplicationPrivate::styleHints->colorScheme() == Qt::ColorScheme::Unknown;
- colorSchemeIndex = QGuiApplicationPrivate::styleHints->colorScheme() == Qt::ColorScheme::Light ? 0 : 1;
}
/*!
@@ -759,6 +757,7 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
break;
}
case PE_FrameTabWidget:
+#if QT_CONFIG(tabwidget)
if (const QStyleOptionTabWidgetFrame *frame = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) {
QRectF frameRect = frame->rect.marginsRemoved(QMargins(0,0,0,0));
painter->setPen(Qt::NoPen);
@@ -769,6 +768,7 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
painter->setBrush(Qt::NoBrush);
painter->drawRoundedRect(frameRect.marginsRemoved(QMarginsF(0.5,0.5,0.5,0.5)), secondLevelRoundingRadius, secondLevelRoundingRadius);
}
+#endif // QT_CONFIG(tabwidget)
break;
case PE_FrameGroupBox:
if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
@@ -1158,6 +1158,7 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
}
break;
case QStyle::CE_TabBarTabShape:
+#if QT_CONFIG(tabbar)
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
QRectF tabRect = tab->rect.marginsRemoved(QMargins(2,2,0,0));
painter->setPen(Qt::NoPen);
@@ -1176,8 +1177,10 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
painter->drawRoundedRect(tabRect.adjusted(0.5,0.5,-0.5,-0.5),2,2);
}
+#endif // QT_CONFIG(tabbar)
break;
case CE_ToolButtonLabel:
+#if QT_CONFIG(toolbutton)
if (const QStyleOptionToolButton *toolbutton
= qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
QRect rect = toolbutton->rect;
@@ -1261,6 +1264,7 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
}
}
}
+#endif // QT_CONFIG(toolbutton)
break;
case QStyle::CE_ShapedFrame:
if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
diff --git a/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp b/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp
index 4c0cc02646b..3bc9d9a500f 100644
--- a/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp
+++ b/src/plugins/styles/modernwindows/qwindowsvistastyle.cpp
@@ -1280,7 +1280,7 @@ static inline bool supportsStateTransition(QStyle::PrimitiveElement element,
/*!
Constructs a QWindowsVistaStyle object.
*/
-QWindowsVistaStyle::QWindowsVistaStyle() : QWindowsStyle(*new QWindowsVistaStylePrivate)
+QWindowsVistaStyle::QWindowsVistaStyle() : QWindowsVistaStyle(*new QWindowsVistaStylePrivate)
{
}
@@ -1736,6 +1736,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
#endif // QT_CONFIG(dockwidget)
case PE_FrameTabWidget:
+#if QT_CONFIG(tabwidget)
if (const auto *tab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) {
themeNumber = QWindowsVistaStylePrivate::TabTheme;
partId = TABP_PANE;
@@ -1793,7 +1794,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
}
}
break;
-
+#endif // QT_CONFIG(tabwidget)
case PE_FrameStatusBarItem:
themeNumber = QWindowsVistaStylePrivate::StatusTheme;
partId = SP_PANE;
@@ -2005,6 +2006,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
}
case PE_FrameTabBarBase:
+#if QT_CONFIG(tabbar)
if (const auto *tbb = qstyleoption_cast<const QStyleOptionTabBarBase *>(option)) {
painter->save();
switch (tbb->shape) {
@@ -2035,6 +2037,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt
}
painter->restore();
}
+#endif // QT_CONFIG(tabbar)
return;
case PE_Widget: {
@@ -2537,11 +2540,14 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
return;
case CE_TabBarTab:
+#if QT_CONFIG(tabwidget)
if (const auto *tab = qstyleoption_cast<const QStyleOptionTab *>(option))
stateId = tab->state & State_Enabled ? TIS_NORMAL : TIS_DISABLED;
+#endif // QT_CONFIG(tabwidget)
break;
case CE_TabBarTabShape:
+#if QT_CONFIG(tabwidget)
if (const auto *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
themeNumber = QWindowsVistaStylePrivate::TabTheme;
const bool isDisabled = !(tab->state & State_Enabled);
@@ -2643,6 +2649,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
}
}
}
+#endif // QT_CONFIG(tabwidget)
break;
case CE_ProgressBarGroove: {
@@ -3019,6 +3026,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
}
case CE_ToolBar:
+#if QT_CONFIG(toolbar)
if (const auto *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
QPalette pal = option->palette;
pal.setColor(QPalette::Dark, option->palette.window().color().darker(130));
@@ -3026,6 +3034,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
copyOpt.palette = pal;
QWindowsStyle::drawControl(element, &copyOpt, painter, widget);
}
+#endif // QT_CONFIG(toolbar)
return;
#if QT_CONFIG(dockwidget)
@@ -4163,6 +4172,7 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption
case SE_TabWidgetTabContents:
rect = QWindowsStyle::subElementRect(element, option, widget);
+#if QT_CONFIG(tabwidget)
if (qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) {
rect = QWindowsStyle::subElementRect(element, option, widget);
if (const QTabWidget *tabWidget = qobject_cast<const QTabWidget *>(widget)) {
@@ -4171,10 +4181,12 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption
rect.adjust(0, 0, -2, -2);
}
}
+#endif // QT_CONFIG(tabwidget)
break;
case SE_TabWidgetTabBar: {
rect = QWindowsStyle::subElementRect(element, option, widget);
+#if QT_CONFIG(tabwidget)
const auto *twfOption = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option);
if (twfOption && twfOption->direction == Qt::RightToLeft
&& (twfOption->shape == QTabBar::RoundedNorth
@@ -4187,6 +4199,7 @@ QRect QWindowsVistaStyle::subElementRect(SubElement element, const QStyleOption
int borderThickness = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget);
rect.adjust(-overlap + borderThickness, 0, -overlap + borderThickness, 0);
}
+#endif // QT_CONFIG(tabwidget)
break;
}
@@ -4525,6 +4538,7 @@ int QWindowsVistaStyle::pixelMetric(PixelMetric metric, const QStyleOption *opti
res = 2;
break;
+#if QT_CONFIG(tabbar)
case PM_TabBarBaseOverlap:
if (const auto *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
switch (tab->shape) {
@@ -4545,6 +4559,7 @@ int QWindowsVistaStyle::pixelMetric(PixelMetric metric, const QStyleOption *opti
}
}
break;
+#endif // QT_CONFIG(tabbar)
case PM_SplitterWidth:
res = QStyleHelper::dpiScaled(5., option);
@@ -4565,10 +4580,12 @@ int QWindowsVistaStyle::pixelMetric(PixelMetric metric, const QStyleOption *opti
res = int(QStyleHelper::dpiScaled(4., option));
break;
+#if QT_CONFIG(toolbutton)
case PM_ButtonShiftHorizontal:
case PM_ButtonShiftVertical:
res = qstyleoption_cast<const QStyleOptionToolButton *>(option) ? 1 : 0;
break;
+#endif // QT_CONFIG(toolbutton)
default:
res = QWindowsStyle::pixelMetric(metric, option, widget);
@@ -4590,8 +4607,12 @@ void QWindowsVistaStyle::polish(QWidget *widget)
#if QT_CONFIG(abstractbutton)
|| qobject_cast<QAbstractButton*>(widget)
#endif // QT_CONFIG(abstractbutton)
+#if QT_CONFIG(toolbutton)
|| qobject_cast<QToolButton*>(widget)
+#endif // QT_CONFIG(toolbutton)
+#if QT_CONFIG(tabbar)
|| qobject_cast<QTabBar*>(widget)
+#endif // QT_CONFIG(tabbar)
#if QT_CONFIG(combobox)
|| qobject_cast<QComboBox*>(widget)
#endif // QT_CONFIG(combobox)
@@ -4699,8 +4720,12 @@ void QWindowsVistaStyle::unpolish(QWidget *widget)
#if QT_CONFIG(abstractbutton)
|| qobject_cast<QAbstractButton*>(widget)
#endif
+ #if QT_CONFIG(toolbutton)
|| qobject_cast<QToolButton*>(widget)
+ #endif // QT_CONFIG(toolbutton)
+ #if QT_CONFIG(tabbar)
|| qobject_cast<QTabBar*>(widget)
+ #endif // QT_CONFIG(tabbar)
#if QT_CONFIG(combobox)
|| qobject_cast<QComboBox*>(widget)
#endif // QT_CONFIG(combobox)
diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt
index b77339b40f9..631bc3f59ee 100644
--- a/src/widgets/CMakeLists.txt
+++ b/src/widgets/CMakeLists.txt
@@ -43,8 +43,6 @@ qt_internal_add_module(Widgets
styles/qstyleoption.cpp styles/qstyleoption.h
styles/qstylepainter.cpp styles/qstylepainter.h
styles/qstyleplugin.cpp styles/qstyleplugin.h
- styles/qstylesheetstyle.cpp styles/qstylesheetstyle_p.h
- styles/qstylesheetstyle_default.cpp
util/qcolormap.cpp util/qcolormap.h
util/qsystemtrayicon.cpp util/qsystemtrayicon.h util/qsystemtrayicon_p.h
widgets/qabstractscrollarea.cpp widgets/qabstractscrollarea.h widgets/qabstractscrollarea_p.h
@@ -425,6 +423,12 @@ qt_internal_extend_target(Widgets CONDITION QT_FEATURE_animation
styles/qstyleanimation.cpp styles/qstyleanimation_p.h
)
+qt_internal_extend_target(Widgets CONDITION QT_FEATURE_style_stylesheet
+ SOURCES
+ styles/qstylesheetstyle.cpp styles/qstylesheetstyle_p.h
+ styles/qstylesheetstyle_default.cpp
+)
+
qt_internal_extend_target(Widgets CONDITION QT_FEATURE_style_windows
SOURCES
styles/qwindowsstyle.cpp styles/qwindowsstyle_p.h
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index d3cf1587c45..c01ae29c680 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -33,7 +33,9 @@
#include "private/qguiapplication_p.h"
#include "qcolormap.h"
#include "qdebug.h"
+#if QT_CONFIG(style_stylesheet)
#include "private/qstylesheetstyle_p.h"
+#endif
#include "private/qstyle_p.h"
#if QT_CONFIG(messagebox)
#include "qmessagebox.h"
@@ -316,7 +318,7 @@ QWidget *QApplication::topLevelAt(const QPoint &pos)
void qt_init_tooltip_palette();
QStyle *QApplicationPrivate::app_style = nullptr; // default application style
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
QString QApplicationPrivate::styleSheet; // default application stylesheet
#endif
QPointer<QWidget> QApplicationPrivate::leaveAfterRelease = nullptr;
@@ -385,7 +387,7 @@ void QApplicationPrivate::process_cmdline()
++arg;
if (strcmp(arg, "-qdevel") == 0 || strcmp(arg, "-qdebug") == 0) {
// obsolete argument
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
} else if (strcmp(arg, "-stylesheet") == 0 && i < argc -1) {
styleSheet = "file:///"_L1;
styleSheet.append(QString::fromLocal8Bit(argv[++i]));
@@ -878,7 +880,7 @@ bool QApplication::autoSipEnabled() const
return QApplicationPrivate::autoSipEnabled;
}
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
QString QApplication::styleSheet() const
{
@@ -938,7 +940,7 @@ QStyle *QApplication::style()
QGuiApplicationPrivate::updatePalette();
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
if (!QApplicationPrivate::styleSheet.isEmpty()) {
qApp->setStyleSheet(QApplicationPrivate::styleSheet);
} else
@@ -996,7 +998,7 @@ void QApplication::setStyle(QStyle *style)
QStyle *old = QApplicationPrivate::app_style; // save
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
if (!QApplicationPrivate::styleSheet.isEmpty() && !qt_styleSheet(style)) {
// we have a stylesheet already and a new style is being set
QStyleSheetStyle *newStyleSheetStyle = new QStyleSheetStyle(style);
@@ -1029,7 +1031,7 @@ void QApplication::setStyle(QStyle *style)
if (w->windowType() != Qt::Desktop && w->testAttribute(Qt::WA_WState_Polished)) {
if (w->style() == QApplicationPrivate::app_style)
QApplicationPrivate::app_style->polish(w); // repolish
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
else
w->setStyleSheet(w->styleSheet()); // touch
#endif
@@ -1046,7 +1048,7 @@ void QApplication::setStyle(QStyle *style)
}
}
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
if (QStyleSheetStyle *oldStyleSheetStyle = qt_styleSheet(old)) {
oldStyleSheetStyle->deref();
} else
diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index a826ea75bc6..ec28581b041 100644
--- a/src/widgets/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
@@ -3,20 +3,10 @@
#include "qlayout.h"
-#include "qapplication.h"
#include "qlayoutengine_p.h"
-#if QT_CONFIG(menubar)
-#include "qmenubar.h"
-#endif
-#if QT_CONFIG(toolbar)
-#include "qtoolbar.h"
-#endif
-#if QT_CONFIG(sizegrip)
-#include "qsizegrip.h"
-#endif
+#include "qguiapplication.h"
#include "qevent.h"
#include "qstyle.h"
-#include "qvariant.h"
#include "qwidget_p.h"
#include "qlayout_p.h"
@@ -504,10 +494,8 @@ void QLayoutPrivate::doResize()
const int mbTop = rect.top();
rect.setTop(mbTop + mbh);
q->setGeometry(rect);
-#if QT_CONFIG(menubar)
if (menubar)
menubar->setGeometry(rect.left(), mbTop, rect.width(), mbh);
-#endif
}
@@ -537,10 +525,8 @@ void QLayout::widgetEvent(QEvent *e)
QObject *child = c->child();
QObjectPrivate *op = QObjectPrivate::get(child);
if (op->wasWidget) {
-#if QT_CONFIG(menubar)
if (child == d->menubar)
d->menubar = nullptr;
-#endif
removeWidgetRecursively(this, child);
}
}
@@ -585,10 +571,8 @@ int QLayout::totalMinimumHeightForWidth(int w) const
side += wd->leftmargin + wd->rightmargin;
top += wd->topmargin + wd->bottommargin;
}
- int h = minimumHeightForWidth(w - side) + top;
-#if QT_CONFIG(menubar)
- h += menuBarHeightForWidth(d->menubar, w);
-#endif
+ int h = minimumHeightForWidth(w - side) + top +
+ menuBarHeightForWidth(d->menubar, w);
return h;
}
@@ -607,10 +591,8 @@ int QLayout::totalHeightForWidth(int w) const
side += wd->leftmargin + wd->rightmargin;
top += wd->topmargin + wd->bottommargin;
}
- int h = heightForWidth(w - side) + top;
-#if QT_CONFIG(menubar)
- h += menuBarHeightForWidth(d->menubar, w);
-#endif
+ int h = heightForWidth(w - side) + top +
+ menuBarHeightForWidth(d->menubar, w);
return h;
}
@@ -631,9 +613,7 @@ QSize QLayout::totalMinimumSize() const
}
QSize s = minimumSize();
-#if QT_CONFIG(menubar)
top += menuBarHeightForWidth(d->menubar, s.width() + side);
-#endif
return s + QSize(side, top);
}
@@ -656,9 +636,7 @@ QSize QLayout::totalSizeHint() const
QSize s = sizeHint();
if (hasHeightForWidth())
s.setHeight(heightForWidth(s.width() + side));
-#if QT_CONFIG(menubar)
top += menuBarHeightForWidth(d->menubar, s.width());
-#endif
return s + QSize(side, top);
}
@@ -679,9 +657,7 @@ QSize QLayout::totalMaximumSize() const
}
QSize s = maximumSize();
-#if QT_CONFIG(menubar)
top += menuBarHeightForWidth(d->menubar, s.width());
-#endif
if (d->topLevel)
s = QSize(qMin(s.width() + side, QLAYOUTSIZE_MAX),
@@ -757,11 +733,9 @@ void QLayoutPrivate::reparentChildWidgets(QWidget *mw)
Q_Q(QLayout);
int n = q->count();
-#if QT_CONFIG(menubar)
- if (menubar && menubar->parentWidget() != mw) {
+ if (menubar && menubar->parentWidget() != mw)
menubar->setParent(mw);
- }
-#endif
+
bool mwVisible = mw && mw->isVisible();
for (int i = 0; i < n; ++i) {
QLayoutItem *item = q->itemAt(i);
diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp
index 246d090828e..08cf7962e7d 100644
--- a/src/widgets/kernel/qlayoutitem.cpp
+++ b/src/widgets/kernel/qlayoutitem.cpp
@@ -5,12 +5,6 @@
#include "qapplication.h"
#include "qlayoutengine_p.h"
-#if QT_CONFIG(menubar)
-#include "qmenubar.h"
-#endif
-#if QT_CONFIG(toolbar)
-#include "qtoolbar.h"
-#endif
#include "qevent.h"
#include "qstyle.h"
#include "qvariant.h"
diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp
index 5485777eabb..12ba8ae545b 100644
--- a/src/widgets/kernel/qtooltip.cpp
+++ b/src/widgets/kernel/qtooltip.cpp
@@ -16,7 +16,9 @@
#include <qdebug.h>
#include <qpa/qplatformscreen.h>
#include <qpa/qplatformcursor.h>
+#if QT_CONFIG(style_stylesheet)
#include <private/qstylesheetstyle_p.h>
+#endif
#include <qlabel.h>
#include <QtWidgets/private/qlabel_p.h>
@@ -120,7 +122,7 @@ protected:
void mouseMoveEvent(QMouseEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
public slots:
/** \internal
Cleanup the _q_stylesheet_parent property.
@@ -143,7 +145,7 @@ QTipLabel *QTipLabel::instance = nullptr;
QTipLabel::QTipLabel(const QString &text, const QPoint &pos, QWidget *w, int msecDisplayTime)
: QLabel(w, Qt::ToolTip | Qt::BypassGraphicsProxyWidget)
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
, styleSheetParent(nullptr)
#endif
, widget(nullptr)
@@ -178,7 +180,7 @@ void QTipLabel::restartExpireTimer(int msecDisplayTime)
void QTipLabel::reuseTip(const QString &text, int msecDisplayTime, const QPoint &pos)
{
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
if (styleSheetParent){
disconnect(styleSheetParent, &QWidget::destroyed,
this, &QTipLabel::styleSheetParentDestroyed);
@@ -346,7 +348,7 @@ QScreen *QTipLabel::getTipScreen(const QPoint &pos, QWidget *w)
void QTipLabel::placeTip(const QPoint &pos, QWidget *w)
{
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
if (testAttribute(Qt::WA_StyleSheet) || (w && qt_styleSheet(w->style()))) {
//the stylesheet need to know the real parent
QTipLabel::instance->setProperty("_q_stylesheet_parent", QVariant::fromValue(w));
@@ -365,7 +367,7 @@ void QTipLabel::placeTip(const QPoint &pos, QWidget *w)
// correct content margin.
QTipLabel::instance->updateSize(pos);
}
-#endif //QT_NO_STYLE_STYLESHEET
+#endif //QT_CONFIG(style_stylesheet)
QPoint p = pos;
const QScreen *screen = getTipScreen(pos, w);
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index eaf6d00942e..f36d7f094dd 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -36,7 +36,9 @@
#include "qwhatsthis.h"
#endif
#include "qdebug.h"
+#if QT_CONFIG(style_stylesheet)
#include "private/qstylesheetstyle_p.h"
+#endif
#include "private/qstyle_p.h"
#include "qfileinfo.h"
#include "qscopeguard.h"
@@ -1682,7 +1684,7 @@ void QWidgetPrivate::deleteExtra()
{
if (extra) { // if exists
deleteSysExtra();
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
// dereference the stylesheet style
if (QStyleSheetStyle *proxy = qt_styleSheet(extra->style))
proxy->deref();
@@ -2542,7 +2544,7 @@ void QWidget::setScreen(QScreen *screen)
d->setScreen(screen);
}
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
/*!
\property QWidget::styleSheet
@@ -2647,7 +2649,7 @@ void QWidget::setStyle(QStyle *style)
Q_D(QWidget);
setAttribute(Qt::WA_SetStyle, style != nullptr);
d->createExtra();
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
if (QStyleSheetStyle *styleSheetStyle = qt_styleSheet(style)) {
//if for some reason someone try to set a QStyleSheetStyle, ref it
//(this may happen for example in QButtonDialogBox which propagates its style)
@@ -2668,7 +2670,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate)
createExtra();
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
QPointer<QStyle> origStyle = extra->style;
#endif
extra->style = newStyle;
@@ -2689,7 +2691,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate)
}
}
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
if (!qt_styleSheet(newStyle)) {
if (const QStyleSheetStyle* cssStyle = qt_styleSheet(origStyle)) {
cssStyle->clearWidgetFont(q);
@@ -2700,7 +2702,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate)
QEvent e(QEvent::StyleChange);
QCoreApplication::sendEvent(q, &e);
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
// dereference the old stylesheet style
if (QStyleSheetStyle *proxy = qt_styleSheet(origStyle))
proxy->deref();
@@ -2710,7 +2712,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate)
// Inherits style from the current parent and propagates it as necessary
void QWidgetPrivate::inheritStyle()
{
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
Q_Q(QWidget);
QStyle *extraStyle = extra ? (QStyle*)extra->style : nullptr;
@@ -4688,7 +4690,7 @@ void QWidget::setFont(const QFont &font)
{
Q_D(QWidget);
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
const QStyleSheetStyle* style;
if (d->extra && (style = qt_styleSheet(d->extra->style)))
style->saveWidgetFont(this, font);
@@ -4797,7 +4799,7 @@ void QWidgetPrivate::resolveFont()
void QWidgetPrivate::updateFont(const QFont &font)
{
Q_Q(QWidget);
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
const QStyleSheetStyle* cssStyle;
cssStyle = extra ? qt_styleSheet(extra->style) : nullptr;
const bool useStyleSheetPropagationInWidgetStyles =
@@ -4827,7 +4829,7 @@ void QWidgetPrivate::updateFont(const QFont &font)
QWidget *w = qobject_cast<QWidget*>(children.at(i));
if (w) {
if (0) {
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
} else if (!useStyleSheetPropagationInWidgetStyles && w->testAttribute(Qt::WA_StyleSheet)) {
// Style sheets follow a different font propagation scheme.
if (cssStyle)
@@ -4842,7 +4844,7 @@ void QWidgetPrivate::updateFont(const QFont &font)
}
}
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
if (!useStyleSheetPropagationInWidgetStyles && cssStyle) {
cssStyle->updateStyleSheetFont(q);
}
diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp
index f1fc18003c1..af14d1ff98b 100644
--- a/src/widgets/styles/qstyleoption.cpp
+++ b/src/widgets/styles/qstyleoption.cpp
@@ -2285,6 +2285,7 @@ QStyleOptionDockWidget::QStyleOptionDockWidget(int version)
The default value is true.
*/
+#if QT_CONFIG(toolbutton)
/*!
\class QStyleOptionToolButton
\brief The QStyleOptionToolButton class is used to describe the
@@ -2445,6 +2446,7 @@ QStyleOptionToolButton::QStyleOptionToolButton(int version)
Qt::ToolButtonTextOnly. By default, the application's default font
is used.
*/
+#endif // QT_CONFIG(toolbutton)
/*!
\class QStyleOptionComboBox
diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h
index 49b37132de3..715a1794634 100644
--- a/src/widgets/styles/qstyleoption.h
+++ b/src/widgets/styles/qstyleoption.h
@@ -542,6 +542,7 @@ protected:
};
#endif // QT_CONFIG(spinbox)
+#if QT_CONFIG(toolbutton)
class Q_WIDGETS_EXPORT QStyleOptionToolButton : public QStyleOptionComplex
{
public:
@@ -570,6 +571,7 @@ protected:
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionToolButton::ToolButtonFeatures)
+#endif // QT_CONFIG(toolbutton)
class Q_WIDGETS_EXPORT QStyleOptionComboBox : public QStyleOptionComplex
{
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
index f8417f0fe03..5253a011c8f 100644
--- a/src/widgets/styles/qstylesheetstyle.cpp
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -3290,6 +3290,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
break;
case CC_ToolButton:
+#if QT_CONFIG(toolbutton)
if (const QStyleOptionToolButton *tool = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
QStyleOptionToolButton toolOpt(*tool);
rule.configurePalette(&toolOpt.palette, QPalette::ButtonText, QPalette::Button);
@@ -3440,6 +3441,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC
}
return;
}
+#endif // QT_CONFIG(toolbutton)
break;
#if QT_CONFIG(scrollbar)
@@ -3671,6 +3673,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
switch (ce) {
case CE_ToolButtonLabel:
+#if QT_CONFIG(toolbutton)
if (const QStyleOptionToolButton *btn = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
if (rule.hasBox() || btn->features & QStyleOptionToolButton::Arrow) {
QWindowsStyle::drawControl(ce, opt, p, w);
@@ -3681,6 +3684,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
}
return;
}
+#endif // QT_CONFIG(toolbutton)
break;
case CE_FocusFrame:
@@ -5979,6 +5983,7 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp
break;
case CC_ToolButton:
+#if QT_CONFIG(toolbutton)
if (const QStyleOptionToolButton *tb = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
if (rule.hasBox() || !rule.hasNativeBorder()) {
switch (sc) {
@@ -5996,8 +6001,9 @@ QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComp
tool.rect = rule.borderRect(opt->rect);
return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &tool, sc, w)
: QWindowsStyle::subControlRect(cc, &tool, sc, w);
- }
- break;
+ }
+#endif // QT_CONFIG(toolbutton)
+ break;
#if QT_CONFIG(scrollbar)
case CC_ScrollBar:
diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp
index 3036f61d17e..a5ffa93e167 100644
--- a/src/widgets/styles/qwindowsstyle.cpp
+++ b/src/widgets/styles/qwindowsstyle.cpp
@@ -2260,8 +2260,10 @@ QSize QWindowsStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
break;
#endif
case CT_ToolButton:
+#if QT_CONFIG(toolbutton)
if (qstyleoption_cast<const QStyleOptionToolButton *>(opt))
return sz += QSize(7, 6);
+#endif // QT_CONFIG(toolbutton)
Q_FALLTHROUGH();
default:
diff --git a/src/widgets/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 4387b7626a7..33e9c8f3e88 100644
--- a/src/widgets/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
@@ -17,7 +17,6 @@
#include <qdebug.h>
#include <private/qwidgetresizehandler_p.h>
-#include <private/qstylesheetstyle_p.h>
#include <qpa/qplatformtheme.h>
#include <private/qhighdpiscaling_p.h>
diff --git a/src/widgets/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index 12327e90af8..a71faa77782 100644
--- a/src/widgets/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
@@ -8,9 +8,11 @@
#include "qstyleoption.h"
#include "qlabel_p.h"
#include "private/qhexstring_p.h"
-#include "private/qstylesheetstyle_p.h"
#include <qmath.h>
+#if QT_CONFIG(style_stylesheet)
+#include "private/qstylesheetstyle_p.h"
+#endif
#if QT_CONFIG(abstractbutton)
#include "qabstractbutton.h"
#endif
@@ -983,7 +985,7 @@ void QLabel::paintEvent(QPaintEvent *)
QRectF lr = d->layoutRect().toAlignedRect();
QStyleOption opt;
opt.initFrom(this);
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
if (QStyleSheetStyle* cssStyle = qt_styleSheet(style))
cssStyle->styleSheetPalette(this, &opt, &opt.palette);
#endif
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index b08fa06ea16..2f68ad5d4d5 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -41,8 +41,9 @@
#if QT_CONFIG(itemviews)
#include "qabstractitemview.h"
#endif
+#if QT_CONFIG(style_stylesheet)
#include "private/qstylesheetstyle_p.h"
-
+#endif
#if QT_CONFIG(shortcut)
#include "private/qapplication_p.h"
#include "private/qshortcutmap_p.h"
@@ -2070,7 +2071,7 @@ void QLineEdit::paintEvent(QPaintEvent *)
QPoint topLeft = lineRect.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent());
// draw text, selections and cursors
-#ifndef QT_NO_STYLE_STYLESHEET
+#if QT_CONFIG(style_stylesheet)
if (QStyleSheetStyle* cssStyle = qt_styleSheet(style())) {
cssStyle->styleSheetPalette(this, &panel, &pal);
}
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index 8535056be3c..b44046969f5 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -30,9 +30,6 @@
#include "qmenubar_p.h"
#endif
#include "qwidgetaction.h"
-#if QT_CONFIG(toolbutton)
-#include "qtoolbutton.h"
-#endif
#include "qpushbutton.h"
#if QT_CONFIG(tooltip)
#include "qtooltip.h"
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index c9c9191c173..fcf0759462c 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -15,9 +15,6 @@
#if QT_CONFIG(mainwindow)
#include <qmainwindow.h>
#endif
-#if QT_CONFIG(toolbar)
-#include <qtoolbar.h>
-#endif
#if QT_CONFIG(toolbutton)
#include <qtoolbutton.h>
#endif
diff --git a/src/widgets/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp
index d6993ca453c..229cba89ecb 100644
--- a/src/widgets/widgets/qtoolbar.cpp
+++ b/src/widgets/widgets/qtoolbar.cpp
@@ -4,9 +4,6 @@
#include "qtoolbar.h"
#include <qapplication.h>
-#if QT_CONFIG(combobox)
-#include <qcombobox.h>
-#endif
#if QT_CONFIG(draganddrop)
#include <qdrag.h>
#endif
@@ -14,13 +11,7 @@
#include <qlayout.h>
#include <qmainwindow.h>
#include <qmenu.h>
-#if QT_CONFIG(menubar)
-#include <qmenubar.h>
-#endif
#include <qmimedata.h>
-#if QT_CONFIG(rubberband)
-#include <qrubberband.h>
-#endif
#include <qstylepainter.h>
#include <qstyleoption.h>
#include <qtoolbutton.h>
close