summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r--src/widgets/kernel/qwidget.cpp88
1 files changed, 45 insertions, 43 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 3d870fc5cc..d372d69d02 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -98,9 +98,11 @@
#include <QtGui/private/qwindow_p.h>
#include "qaction_p.h"
#include "qlayout_p.h"
+#if QT_CONFIG(graphicsview)
#include "QtWidgets/qgraphicsproxywidget.h"
#include "QtWidgets/qgraphicsscene.h"
#include "private/qgraphicsproxywidget_p.h"
+#endif
#include "QtWidgets/qabstractscrollarea.h"
#include "private/qabstractscrollarea_p.h"
#include "private/qevent_p.h"
@@ -1615,7 +1617,7 @@ QWidget::~QWidget()
QT_TRY {
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
const QWidget* w = this;
while (w->d_func()->extra && w->d_func()->extra->focus_proxy)
w = w->d_func()->extra->focus_proxy;
@@ -1802,7 +1804,7 @@ void QWidgetPrivate::createExtra()
extra = new QWExtra;
extra->glContext = 0;
extra->topextra = 0;
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
extra->proxyWidget = 0;
#endif
#ifndef QT_NO_CURSOR
@@ -2018,12 +2020,12 @@ void QWidgetPrivate::propagatePaletteChange()
{
Q_Q(QWidget);
// Propagate a new inherited mask to all children.
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
if (!q->parentWidget() && extra && extra->proxyWidget) {
QGraphicsProxyWidget *p = extra->proxyWidget;
inheritedPaletteResolveMask = p->d_func()->inheritedPaletteResolveMask | p->palette().resolve();
} else
-#endif //QT_NO_GRAPHICSVIEW
+#endif // QT_CONFIG(graphicsview)
if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) {
inheritedPaletteResolveMask = 0;
}
@@ -4042,7 +4044,7 @@ void QWidget::setMinimumSize(int minw, int minh)
if (maximized)
data->window_state = data->window_state | Qt::WindowMaximized;
}
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
if (d->extra) {
if (d->extra->proxyWidget)
d->extra->proxyWidget->setMinimumSize(minw, minh);
@@ -4100,7 +4102,7 @@ void QWidget::setMaximumSize(int maxw, int maxh)
setAttribute(Qt::WA_Resized, resized); //not a user resize
}
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
if (d->extra) {
if (d->extra->proxyWidget)
d->extra->proxyWidget->setMaximumSize(maxw, maxh);
@@ -4618,9 +4620,9 @@ QPalette QWidgetPrivate::naturalWidgetPalette(uint inheritedMask) const
QPalette naturalPalette = QApplication::palette(q);
if ((!q->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles)
&& (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation)
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
|| (extra && extra->proxyWidget)
-#endif //QT_NO_GRAPHICSVIEW
+#endif // QT_CONFIG(graphicsview)
)) {
if (QWidget *p = q->parentWidget()) {
if (!p->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles) {
@@ -4633,13 +4635,13 @@ QPalette QWidgetPrivate::naturalWidgetPalette(uint inheritedMask) const
}
}
}
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
else if (extra && extra->proxyWidget) {
QPalette inheritedPalette = extra->proxyWidget->palette();
inheritedPalette.resolve(inheritedMask);
naturalPalette = inheritedPalette.resolve(naturalPalette);
}
-#endif //QT_NO_GRAPHICSVIEW
+#endif // QT_CONFIG(graphicsview)
}
naturalPalette.resolve(0);
return naturalPalette;
@@ -4766,9 +4768,9 @@ QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const
QFont naturalFont = QApplication::font(q);
if ((!q->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles)
&& (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation)
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
|| (extra && extra->proxyWidget)
-#endif //QT_NO_GRAPHICSVIEW
+#endif // QT_CONFIG(graphicsview)
)) {
if (QWidget *p = q->parentWidget()) {
if (!p->testAttribute(Qt::WA_StyleSheet) || useStyleSheetPropagationInWidgetStyles) {
@@ -4783,7 +4785,7 @@ QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const
}
}
}
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
else if (extra && extra->proxyWidget) {
if (inheritedMask != 0) {
QFont inheritedFont = extra->proxyWidget->font();
@@ -4791,7 +4793,7 @@ QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const
naturalFont = inheritedFont.resolve(naturalFont);
} // else nothing to do (naturalFont = naturalFont)
}
-#endif //QT_NO_GRAPHICSVIEW
+#endif // QT_CONFIG(graphicsview)
}
naturalFont.resolve(0);
return naturalFont;
@@ -4837,12 +4839,12 @@ void QWidgetPrivate::updateFont(const QFont &font)
data.fnt.x11SetScreen(xinfo.screen());
#endif
// Combine new mask with natural mask and propagate to children.
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
if (!q->parentWidget() && extra && extra->proxyWidget) {
QGraphicsProxyWidget *p = extra->proxyWidget;
inheritedFontResolveMask = p->d_func()->inheritedFontResolveMask | p->font().resolve();
} else
-#endif //QT_NO_GRAPHICSVIEW
+#endif // QT_CONFIG(graphicsview)
if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) {
inheritedFontResolveMask = 0;
}
@@ -5840,9 +5842,9 @@ void QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *pdev, const QObjectLis
}
if (w->updatesEnabled()
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
&& (!w->d_func()->extra || !w->d_func()->extra->proxyWidget)
-#endif //QT_NO_GRAPHICSVIEW
+#endif // QT_CONFIG(graphicsview)
) {
QRegion wRegion(rgn);
wRegion &= wd->effectiveRectFor(w->data->crect);
@@ -5930,7 +5932,7 @@ QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *
}
#endif // QT_CONFIG(graphicseffect)
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
/*!
\internal
@@ -6481,13 +6483,13 @@ bool QWidget::hasFocus() const
const QWidget* w = this;
while (w->d_func()->extra && w->d_func()->extra->focus_proxy)
w = w->d_func()->extra->focus_proxy;
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
if (QWidget *window = w->window()) {
QWExtra *e = window->d_func()->extra;
if (e && e->proxyWidget && e->proxyWidget->hasFocus() && window->focusWidget() == w)
return true;
}
-#endif // !QT_NO_GRAPHICSVIEW
+#endif // QT_CONFIG(graphicsview)
return (QApplication::focusWidget() == w);
}
@@ -6542,7 +6544,7 @@ void QWidget::setFocus(Qt::FocusReason reason)
)
return;
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
QWidget *previousProxyFocus = 0;
if (QWExtra *topData = window()->d_func()->extra) {
if (topData->proxyWidget && topData->proxyWidget->hasFocus()) {
@@ -6555,7 +6557,7 @@ void QWidget::setFocus(Qt::FocusReason reason)
}
#endif
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
// Update proxy state
if (QWExtra *topData = window()->d_func()->extra) {
if (topData->proxyWidget && !topData->proxyWidget->hasFocus()) {
@@ -6597,7 +6599,7 @@ void QWidget::setFocus(Qt::FocusReason reason)
QAccessible::updateAccessibility(&event);
}
#endif
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
if (QWExtra *topData = window()->d_func()->extra) {
if (topData->proxyWidget) {
if (previousProxyFocus && previousProxyFocus != f) {
@@ -6609,7 +6611,7 @@ void QWidget::setFocus(Qt::FocusReason reason)
QApplication::sendEvent(that->style(), &event);
}
if (!isHidden()) {
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
// Update proxy state
if (QWExtra *topData = window()->d_func()->extra)
if (topData->proxyWidget && topData->proxyWidget->hasFocus())
@@ -6718,7 +6720,7 @@ void QWidget::clearFocus()
emit extra->window->focusObjectChanged(extra->window->focusObject());
}
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
QWExtra *topData = d_func()->extra;
if (topData && topData->proxyWidget)
topData->proxyWidget->clearFocus();
@@ -6790,7 +6792,7 @@ bool QWidget::focusNextPrevChild(bool next)
bool isSubWindow = (windowType() == Qt::SubWindow);
if (!isWindow() && !isSubWindow && p)
return p->focusNextPrevChild(next);
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
Q_D(QWidget);
if (d->extra && d->extra->proxyWidget)
return d->extra->proxyWidget->focusNextPrevChild(next);
@@ -6884,7 +6886,7 @@ bool QWidget::isActiveWindow() const
if(tlw == QApplication::activeWindow() || (isVisible() && (tlw->windowType() == Qt::Popup)))
return true;
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
if (QWExtra *tlwExtra = tlw->d_func()->extra) {
if (isVisible() && tlwExtra->proxyWidget)
return tlwExtra->proxyWidget->isActiveWindow();
@@ -7895,7 +7897,7 @@ void QWidgetPrivate::show_helper()
const bool isWindow = q->isWindow();
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
bool isEmbedded = isWindow && q->graphicsProxyWidget() != Q_NULLPTR;
#else
bool isEmbedded = false;
@@ -7919,7 +7921,7 @@ void QWidgetPrivate::show_helper()
// Automatic embedding of child windows of widgets already embedded into
// QGraphicsProxyWidget when they are shown the first time.
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
if (isWindow) {
if (!isEmbedded && !bypassGraphicsProxyWidget(q)) {
QGraphicsProxyWidget *ancestorProxy = nearestGraphicsProxyWidget(q->parentWidget());
@@ -7982,7 +7984,7 @@ void QWidgetPrivate::show_sys()
q->setAttribute(Qt::WA_Mapped);
// add our window the modal window list (native dialogs)
if (window && q->isWindow()
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
&& (!extra || !extra->proxyWidget)
#endif
&& q->windowModality() != Qt::NonModal) {
@@ -8056,7 +8058,7 @@ void QWidgetPrivate::hide_helper()
Q_Q(QWidget);
bool isEmbedded = false;
-#if !defined QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
isEmbedded = q->isWindow() && !bypassGraphicsProxyWidget(q) && nearestGraphicsProxyWidget(q->parentWidget()) != 0;
#else
Q_UNUSED(isEmbedded);
@@ -8120,7 +8122,7 @@ void QWidgetPrivate::hide_sys()
q->setAttribute(Qt::WA_Mapped, false);
// remove our window from the modal window list (native dialogs)
if (window && q->isWindow()
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
&& (!extra || !extra->proxyWidget)
#endif
&& q->windowModality() != Qt::NonModal) {
@@ -10238,7 +10240,7 @@ void QWidget::setSizePolicy(QSizePolicy policy)
d->size_policy = policy;
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
if (QWExtra *extra = d->extra) {
if (extra->proxyWidget)
extra->proxyWidget->setSizePolicy(policy);
@@ -10669,7 +10671,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
d->updateIsOpaque();
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
// Embed the widget into a proxy if the parent is embedded.
// ### Doesn't handle reparenting out of an embedded widget.
if (oldtlw->graphicsProxyWidget()) {
@@ -10811,7 +10813,7 @@ void QWidget::scroll(int dx, int dy)
if (dx == 0 && dy == 0)
return;
Q_D(QWidget);
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) {
// Graphics View maintains its own dirty region as a list of rects;
// until we can connect item updates directly to the view, we must
@@ -10851,7 +10853,7 @@ void QWidget::scroll(int dx, int dy, const QRect &r)
if (dx == 0 && dy == 0)
return;
Q_D(QWidget);
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) {
// Graphics View maintains its own dirty region as a list of rects;
// until we can connect item updates directly to the view, we must
@@ -11430,7 +11432,7 @@ void QWidget::setWindowOpacity(qreal opacity)
if (!testAttribute(Qt::WA_WState_Created))
return;
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
if (QGraphicsProxyWidget *proxy = graphicsProxyWidget()) {
// Avoid invalidating the cache if set.
if (proxy->cacheMode() == QGraphicsItem::NoCache)
@@ -12298,7 +12300,7 @@ Q_WIDGETS_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget)
}
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
/*!
\since 4.5
@@ -12448,7 +12450,7 @@ static inline bool canMapPosition(QWindow *window)
return window->handle() && !qt_window_private(window)->resizeEventPending;
}
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
static inline QGraphicsProxyWidget *graphicsProxyWidget(const QWidget *w)
{
QGraphicsProxyWidget *result = Q_NULLPTR;
@@ -12457,7 +12459,7 @@ static inline QGraphicsProxyWidget *graphicsProxyWidget(const QWidget *w)
result = d->extra->proxyWidget;
return result;
}
-#endif // !QT_NO_GRAPHICSVIEW
+#endif // QT_CONFIG(graphicsview)
struct MapToGlobalTransformResult {
QTransform transform;
@@ -12469,7 +12471,7 @@ static MapToGlobalTransformResult mapToGlobalTransform(const QWidget *w)
MapToGlobalTransformResult result;
result.window = Q_NULLPTR;
for ( ; w ; w = w->parentWidget()) {
-#ifndef QT_NO_GRAPHICSVIEW
+#if QT_CONFIG(graphicsview)
if (QGraphicsProxyWidget *qgpw = graphicsProxyWidget(w)) {
if (const QGraphicsScene *scene = qgpw->scene()) {
const QList <QGraphicsView *> views = scene->views();
@@ -12480,7 +12482,7 @@ static MapToGlobalTransformResult mapToGlobalTransform(const QWidget *w)
}
}
}
-#endif // !QT_NO_GRAPHICSVIEW
+#endif // QT_CONFIG(graphicsview)
QWindow *window = w->windowHandle();
if (window && canMapPosition(window)) {
result.window = window;