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.cpp241
1 files changed, 97 insertions, 144 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 09a89e4591..ace50f13ee 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -59,7 +59,7 @@
#ifndef QT_NO_ACCESSIBILITY
# include "qaccessible.h"
#endif
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
# include "qt_mac_p.h"
# include "qt_cocoa_helpers_mac_p.h"
# include "qmainwindow.h"
@@ -85,7 +85,7 @@
#include <private/qgraphicseffect_p.h>
#include <qbackingstore.h>
#include <private/qwidgetbackingstore_p.h>
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
# include <private/qpaintengine_mac_p.h>
#endif
#include <private/qpaintengine_raster_p.h>
@@ -118,7 +118,7 @@
QT_BEGIN_NAMESPACE
static bool qt_enable_backingstore = true;
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
// for compatibility with Qt 4.0
Q_WIDGETS_EXPORT void qt_x11_set_global_double_buffer(bool enable)
{
@@ -126,7 +126,7 @@ Q_WIDGETS_EXPORT void qt_x11_set_global_double_buffer(bool enable)
}
#endif
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
bool qt_mac_clearDirtyOnWidgetInsideDrawWidget = false;
#endif
@@ -141,7 +141,7 @@ static inline bool hasBackingStoreSupport()
return true;
}
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
# define QT_NO_PAINT_DEBUG
#endif
@@ -288,13 +288,13 @@ QWidgetPrivate::QWidgetPrivate(int version)
#if defined(Q_OS_WIN)
, noPaintOnScreen(0)
#endif
-#if defined(Q_DEAD_CODE_FROM_QT4_X11)
+#if 0 // Used to be included in Qt4 for Q_WS_X11
, picture(0)
-#elif defined(Q_DEAD_CODE_FROM_QT4_WIN)
+#elif 0 // Used to be included in Qt4 for Q_WS_WIN
#ifndef QT_NO_GESTURES
, nativeGesturePanEnabled(0)
#endif
-#elif defined(Q_DEAD_CODE_FROM_QT4_MAC)
+#elif 0 // Used to be included in Qt4 for Q_WS_MAC
, needWindowChange(0)
, window_event(0)
, qd_hd(0)
@@ -317,7 +317,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
isWidget = true;
memset(high_attributes, 0, sizeof(high_attributes));
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
drawRectOriginalAdded = false;
originalDrawMethod = true;
changeMethods = false;
@@ -326,7 +326,7 @@ QWidgetPrivate::QWidgetPrivate(int version)
toolbar_ancestor = 0;
flushRequested = false;
touchEventsEnabled = false;
-#endif // Q_DEAD_CODE_FROM_QT4_MAC
+#endif
#ifdef QWIDGET_EXTRA_DEBUG
static int count = 0;
qDebug() << "widgets" << ++count;
@@ -1091,7 +1091,7 @@ void QWidgetPrivate::adjustFlags(Qt::WindowFlags &flags, QWidget *w)
// Only enable this on non-Mac platforms. Since the old way of doing this would
// interpret WindowSystemMenuHint as a close button and we can't change that behavior
// we can't just add this in.
-#ifndef Q_DEAD_CODE_FROM_QT4_MAC
+#if 1 // Used to be excluded in Qt4 for Q_WS_MAC
if ((flags & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowContextHelpButtonHint))
# ifdef Q_OS_WIN
&& type != Qt::Dialog // QTBUG-2027, allow for menu-less dialogs.
@@ -1115,11 +1115,7 @@ void QWidgetPrivate::adjustFlags(Qt::WindowFlags &flags, QWidget *w)
if (customize)
; // don't modify window flags if the user explicitly set them.
else if (type == Qt::Dialog || type == Qt::Sheet)
-#ifndef Q_OS_WINCE
flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint;
-#else
- flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
-#endif
else if (type == Qt::Tool)
flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
else
@@ -1155,7 +1151,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
}
#endif
-#if defined(Q_DEAD_CODE_FROM_QT4_X11)
+#if 0 // Used to be included in Qt4 for Q_WS_X11
if (desktopWidget) {
// make sure the widget is created on the same screen as the
// programmer specified desktop widget
@@ -1189,7 +1185,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
mustHaveWindowHandle = 1;
q->setAttribute(Qt::WA_NativeWindow);
}
-//#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+//#if 0 // Used to be included in Qt4 for Q_WS_MAC
// q->setAttribute(Qt::WA_NativeWindow);
//#endif
@@ -1214,9 +1210,9 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
setOpaque(q->isWindow() && background.style() != Qt::NoBrush && background.isOpaque());
}
data.fnt = QFont(data.fnt, q);
-#if defined(Q_DEAD_CODE_FROM_QT4_X11)
+#if 0 // Used to be included in Qt4 for Q_WS_X11
data.fnt.x11SetScreen(xinfo.screen());
-#endif // Q_DEAD_CODE_FROM_QT4_X11
+#endif
q->setAttribute(Qt::WA_PendingMoveEvent);
q->setAttribute(Qt::WA_PendingResizeEvent);
@@ -1233,7 +1229,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
extraPaintEngine = 0;
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
// If we add a child to the unified toolbar, we have to redirect the painting.
if (parentWidget && parentWidget->d_func() && parentWidget->d_func()->isInUnifiedToolbar) {
if (parentWidget->d_func()->unifiedSurface) {
@@ -1241,7 +1237,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
parentWidget->d_func()->unifiedSurface->recursiveRedirect(toolbar, toolbar, toolbar->d_func()->toolbar_offset);
}
}
-#endif // Q_DEAD_CODE_FROM_QT4_MAC
+#endif
}
@@ -1331,14 +1327,14 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow)
<< "Alien?" << !testAttribute(Qt::WA_NativeWindow);
#endif
-#if defined (Q_DEAD_CODE_FROM_QT4_WIN) && !defined(QT_NO_DRAGANDDROP)
+#if 0 /* Used to be included in Qt4 for Q_WS_WIN */ && !defined(QT_NO_DRAGANDDROP)
// Unregister the dropsite (if already registered) before we
// re-create the widget with a native window.
if (testAttribute(Qt::WA_WState_Created) && !internalWinId() && testAttribute(Qt::WA_NativeWindow)
&& d->extra && d->extra->dropTarget) {
d->registerDropSite(false);
}
-#endif // defined (Q_DEAD_CODE_FROM_QT4_WIN) && !defined(QT_NO_DRAGANDDROP)
+#endif
d->updateIsOpaque();
@@ -1638,7 +1634,7 @@ QWidget::~QWidget()
}
}
-#if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_X11)|| defined(Q_DEAD_CODE_FROM_QT4_MAC)
+#if 0 /* Used to be included in Qt4 for Q_WS_WIN */ || 0 /* Used to be included in Qt4 for Q_WS_X11 */|| 0 /* Used to be included in Qt4 for Q_WS_MAC */
else if (!internalWinId() && isVisible()) {
qApp->d_func()->sendSyntheticEnterLeave(this);
}
@@ -1685,7 +1681,7 @@ QWidget::~QWidget()
d->blockSig = blocked;
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
// QCocoaView holds a pointer back to this widget. Clear it now
// to make sure it's not followed later on. The lifetime of the
// QCocoaView might exceed the lifetime of this widget in cases
@@ -1736,7 +1732,7 @@ void QWidgetPrivate::setWinId(WId id) // set widget identifier
const WId oldWinId = data.winid;
data.winid = id;
-#if defined(Q_DEAD_CODE_FROM_QT4_X11)
+#if 0 // Used to be included in Qt4 for Q_WS_X11
hd = id; // X11: hd == ident
#endif
if (mapper && id && !userDesktopWidget) {
@@ -1772,9 +1768,9 @@ void QWidgetPrivate::createTLExtra()
x->window = 0;
x->shareContext = 0;
x->initialScreenIndex = -1;
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
x->wasMaximized = false;
-#endif // Q_DEAD_CODE_FROM_QT4_MAC
+#endif
#ifdef QWIDGET_EXTRA_DEBUG
static int count = 0;
qDebug() << "tlextra" << ++count;
@@ -2199,10 +2195,10 @@ void QWidgetPrivate::subtractOpaqueSiblings(QRegion &sourceRegion, bool *hasDirt
if (disableSubtractOpaqueSiblings || q->isWindow())
return;
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
if (q->d_func()->isInUnifiedToolbar)
return;
-#endif // Q_DEAD_CODE_FROM_QT4_MAC
+#endif
QRect clipBoundingRect;
bool dirtyClipBoundingRect = true;
@@ -2336,7 +2332,7 @@ void QWidgetPrivate::updateIsOpaque()
#endif //QT_NO_GRAPHICSEFFECT
Q_Q(QWidget);
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
if (q->testAttribute(Qt::WA_X11OpenGLOverlay)) {
setOpaque(false);
return;
@@ -2395,7 +2391,7 @@ static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QBrus
Q_ASSERT(painter);
if (brush.style() == Qt::TexturePattern) {
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
// Optimize pattern filling on mac by using HITheme directly
// when filling with the standard widget background.
// Defined in qmacstyle_mac.cpp
@@ -2407,7 +2403,7 @@ static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QBrus
painter->setClipRegion(rgn);
painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft());
}
-#endif // Q_DEAD_CODE_FROM_QT4_MAC
+#endif
} else if (brush.gradient()
&& brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode) {
@@ -2416,9 +2412,8 @@ static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QBrus
painter->fillRect(0, 0, painter->device()->width(), painter->device()->height(), brush);
painter->restore();
} else {
- const QVector<QRect> &rects = rgn.rects();
- for (int i = 0; i < rects.size(); ++i)
- painter->fillRect(rects.at(i), brush);
+ for (const QRect &rect : rgn)
+ painter->fillRect(rect, brush);
}
}
@@ -2479,7 +2474,7 @@ void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int
visible widgets.
*/
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
extern QPointer<QWidget> qt_button_down;
#else
extern QWidget *qt_button_down;
@@ -2759,7 +2754,7 @@ void QWidget::setStyle(QStyle *style)
}
void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate, bool
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
metalHack
#endif
)
@@ -2770,7 +2765,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate, bool
QPointer<QStyle> origStyle;
#endif
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
// the metalhack boolean allows Qt/Mac to do a proper re-polish depending
// on how the Qt::WA_MacBrushedMetal attribute is set. It is only ever
// set when changing that attribute and passes the widget's CURRENT style.
@@ -2790,12 +2785,12 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate, bool
if (q->windowType() != Qt::Desktop) {
if (polished) {
oldStyle->unpolish(q);
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
if (metalHack)
macUpdateMetalAttribute();
#endif
q->style()->polish(q);
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
} else if (metalHack) {
macUpdateMetalAttribute();
#endif
@@ -3160,7 +3155,7 @@ bool QWidget::isFullScreen() const
*/
void QWidget::showFullScreen()
{
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
// If the unified toolbar is enabled, we have to disable it before going fullscreen.
QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this);
if (mainWindow && mainWindow->unifiedTitleAndToolBarOnMac()) {
@@ -3168,7 +3163,7 @@ void QWidget::showFullScreen()
QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout());
mainLayout->activateUnifiedToolbarAfterFullScreen = true;
}
-#endif // Q_DEAD_CODE_FROM_QT4_MAC
+#endif
ensurePolished();
setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowMaximized))
@@ -3196,7 +3191,7 @@ void QWidget::showMaximized()
setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowFullScreen))
| Qt::WindowMaximized);
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
// If the unified toolbar was enabled before going fullscreen, we have to enable it back.
QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this);
if (mainWindow)
@@ -3207,7 +3202,7 @@ void QWidget::showMaximized()
mainLayout->activateUnifiedToolbarAfterFullScreen = false;
}
}
-#endif // Q_DEAD_CODE_FROM_QT4_MAC
+#endif
setVisible(true);
}
@@ -3225,7 +3220,7 @@ void QWidget::showNormal()
setWindowState(windowState() & ~(Qt::WindowMinimized
| Qt::WindowMaximized
| Qt::WindowFullScreen));
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
// If the unified toolbar was enabled before going fullscreen, we have to enable it back.
QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this);
if (mainWindow)
@@ -3236,7 +3231,7 @@ void QWidget::showNormal()
mainLayout->activateUnifiedToolbarAfterFullScreen = false;
}
}
-#endif // Q_DEAD_CODE_FROM_QT4_MAC
+#endif
setVisible(true);
}
@@ -3452,7 +3447,7 @@ void QWidgetPrivate::setEnabled_helper(bool enable)
if (w && !w->testAttribute(attribute))
w->d_func()->setEnabled_helper(enable);
}
-#if defined(Q_DEAD_CODE_FROM_QT4_X11)
+#if 0 // Used to be included in Qt4 for Q_WS_X11
if (q->testAttribute(Qt::WA_SetCursor) || q->isWindow()) {
// enforce the windows behavior of clearing the cursor on
// disabled widgets
@@ -3466,7 +3461,7 @@ void QWidgetPrivate::setEnabled_helper(bool enable)
qt_qpa_set_cursor(q, false);
}
#endif
-#if defined(Q_DEAD_CODE_FROM_QT4_MAC)
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
setEnabled_helper_sys(enable);
#endif
#ifndef QT_NO_IM
@@ -4564,13 +4559,13 @@ const QPalette &QWidget::palette() const
if (!isEnabled()) {
data->pal.setCurrentColorGroup(QPalette::Disabled);
} else if ((!isVisible() || isActiveWindow())
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
&& !QApplicationPrivate::isBlockedByModal(const_cast<QWidget *>(this))
#endif
) {
data->pal.setCurrentColorGroup(QPalette::Active);
} else {
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
extern bool qt_mac_can_clickThrough(const QWidget *); //qwidget_mac.cpp
if (qt_mac_can_clickThrough(this))
data->pal.setCurrentColorGroup(QPalette::Active);
@@ -4828,7 +4823,7 @@ void QWidgetPrivate::updateFont(const QFont &font)
#endif
data.fnt = QFont(font, q);
-#if defined(Q_DEAD_CODE_FROM_QT4_X11)
+#if 0 // Used to be included in Qt4 for Q_WS_X11
// make sure the font set on this widget is associated with the correct screen
data.fnt.x11SetScreen(xinfo.screen());
#endif
@@ -5001,7 +4996,7 @@ void QWidget::setCursor(const QCursor &cursor)
{
Q_D(QWidget);
// On Mac we must set the cursor even if it is the ArrowCursor.
-#if !defined(Q_DEAD_CODE_FROM_QT4_MAC)
+#if 1 // Used to be excluded in Qt4 for Q_WS_MAC
if (cursor.shape() != Qt::ArrowCursor
|| (d->extra && d->extra->curs))
#endif
@@ -5433,7 +5428,7 @@ void QWidgetPrivate::render_helper(QPainter *painter, const QPoint &targetOffset
Q_ASSERT(!toBePainted.isEmpty());
Q_Q(QWidget);
-#ifndef Q_DEAD_CODE_FROM_QT4_MAC
+#if 1 // Used to be excluded in Qt4 for Q_WS_MAC
const QTransform originalTransform = painter->worldTransform();
const bool useDeviceCoordinates = originalTransform.isScaling();
if (!useDeviceCoordinates) {
@@ -5460,7 +5455,7 @@ void QWidgetPrivate::render_helper(QPainter *painter, const QPoint &targetOffset
if (restore)
painter->setRenderHints(QPainter::SmoothPixmapTransform, false);
-#ifndef Q_DEAD_CODE_FROM_QT4_MAC
+#if 1 // Used to be excluded in Qt4 for Q_WS_MAC
} else {
// Render via a pixmap in device coordinates (to avoid pixmap scaling).
QTransform transform = originalTransform;
@@ -5540,7 +5535,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
return;
}
}
-#endif //QT_NO_GRAFFICSEFFECT
+#endif //QT_NO_GRAPHICSEFFECT
const bool alsoOnScreen = flags & DrawPaintOnScreen;
const bool recursive = flags & DrawRecursive;
@@ -5569,7 +5564,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
if (paintEngine) {
setRedirected(pdev, -offset);
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
// (Alien support) Special case for Mac when redirecting: If the paint device
// is of the Widget type we need to set WA_WState_InPaintEvent since painting
// outside the paint event is not supported on QWidgets. The attributeis
@@ -5655,7 +5650,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP
//restore
if (paintEngine) {
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
if (pdev->devType() == QInternal::Widget)
static_cast<QWidget *>(pdev)->setAttribute(Qt::WA_WState_InPaintEvent, false);
#endif
@@ -5729,7 +5724,7 @@ void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset,
if (paintRegion.isEmpty())
return;
-#ifndef Q_DEAD_CODE_FROM_QT4_MAC
+#if 1 // Used to be excluded in Qt4 for Q_WS_MAC
QPainter *oldSharedPainter = inRenderWithPainter ? sharedPainter() : 0;
// Use the target's shared painter if set (typically set when doing
@@ -6510,7 +6505,7 @@ void QWidget::setFocus(Qt::FocusReason reason)
f = f->d_func()->extra->focus_proxy;
if (QApplication::focusWidget() == f
-#if defined(Q_DEAD_CODE_FROM_QT4_WIN)
+#if 0 // Used to be included in Qt4 for Q_WS_WIN
&& GetFocus() == f->internalWinId()
#endif
)
@@ -6695,7 +6690,7 @@ void QWidget::clearFocus()
if (hasFocus()) {
// Update proxy state
QApplicationPrivate::setFocusWidget(0, Qt::OtherFocusReason);
-#if defined(Q_DEAD_CODE_FROM_QT4_WIN)
+#if 0 // Used to be included in Qt4 for Q_WS_WIN
if (!(windowType() == Qt::Popup) && GetFocus() == internalWinId())
SetFocus(0);
else
@@ -7327,7 +7322,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
*/
QByteArray QWidget::saveGeometry() const
{
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
// We check if the window was maximized during this invocation. If so, we need to record the
// starting position as 0,0.
Q_D(const QWidget);
@@ -7338,7 +7333,7 @@ QByteArray QWidget::saveGeometry() const
newFramePosition.moveTo(0, 0);
newNormalPosition.moveTo(0, 0);
}
-#endif // Q_DEAD_CODE_FROM_QT4_MAC
+#endif
QByteArray array;
QDataStream stream(&array, QIODevice::WriteOnly);
stream.setVersion(QDataStream::Qt_4_0);
@@ -7352,13 +7347,13 @@ QByteArray QWidget::saveGeometry() const
stream << magicNumber
<< majorVersion
<< minorVersion
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
<< newFramePosition
<< newNormalPosition
#else
<< frameGeometry()
<< normalGeometry()
-#endif // Q_DEAD_CODE_FROM_QT4_MAC
+#endif
<< qint32(screenNumber)
<< quint8(windowState() & Qt::WindowMaximized)
<< quint8(windowState() & Qt::WindowFullScreen)
@@ -7466,7 +7461,7 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
// - The title bar is outside the available geometry.
// - (Mac only) The window is higher than the available geometry. It must
// be possible to bring the size grip on screen by moving the window.
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
restoredFrameGeometry.setHeight(qMin(restoredFrameGeometry.height(), availableGeometry.height()));
restoredNormalGeometry.setHeight(qMin(restoredNormalGeometry.height(), availableGeometry.height() - frameHeight));
#endif
@@ -7515,7 +7510,7 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
d_func()->topData()->normalGeometry = restoredNormalGeometry;
} else {
QPoint offset;
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
if (isFullScreen())
offset = d_func()->topData()->fullScreenOffset;
#endif
@@ -7913,7 +7908,7 @@ void QWidgetPrivate::show_helper()
// On Windows, show the popup now so that our own focus handling
// stores the correct old focus widget even if it's stolen in the
// showevent
-#if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_MAC)
+#if 0 /* Used to be included in Qt4 for Q_WS_WIN */ || 0 /* Used to be included in Qt4 for Q_WS_MAC */
if (!isEmbedded && q->windowType() == Qt::Popup)
qApp->d_func()->openPopup(q);
#endif
@@ -8042,7 +8037,7 @@ void QWidgetPrivate::hide_helper()
if (!isEmbedded && (q->windowType() == Qt::Popup))
qApp->d_func()->closePopup(q);
-#if defined(Q_DEAD_CODE_FROM_QT4_WIN)
+#if 0 // Used to be included in Qt4 for Q_WS_WIN
if (q->isWindow() && !(q->windowType() == Qt::Popup) && q->parentWidget()
&& !q->parentWidget()->isHidden() && q->isActiveWindow())
q->parentWidget()->activateWindow(); // Activate parent
@@ -8226,7 +8221,7 @@ void QWidget::setVisible(bool visible)
} else { // hide
if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden))
return;
-#if defined(Q_DEAD_CODE_FROM_QT4_WIN)
+#if 0 // Used to be included in Qt4 for Q_WS_WIN
// reset WS_DISABLED style in a Blocked window
if(isWindow() && testAttribute(Qt::WA_WState_Created)
&& QApplicationPrivate::isBlockedByModal(this))
@@ -8311,7 +8306,7 @@ void QWidgetPrivate::hideChildren(bool spontaneous)
QWidget *widget = qobject_cast<QWidget*>(childList.at(i));
if (!widget || widget->isWindow() || widget->testAttribute(Qt::WA_WState_Hidden))
continue;
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
// Before doing anything we need to make sure that we don't leave anything in a non-consistent state.
// When hiding a widget we need to make sure that no mouse_down events are active, because
// the mouse_up event will never be received by a hidden widget or one of its descendants.
@@ -8327,7 +8322,7 @@ void QWidgetPrivate::hideChildren(bool spontaneous)
// supposed to trigger because it is not visible.
if(widget == qt_button_down)
qt_button_down = 0;
-#endif // Q_DEAD_CODE_FROM_QT4_MAC
+#endif
if (spontaneous)
widget->setAttribute(Qt::WA_Mapped, false);
else
@@ -8562,18 +8557,14 @@ QSize QWidgetPrivate::adjustedSize() const
s.setWidth(qMax(s.width(), 200));
if (exp & Qt::Vertical)
s.setHeight(qMax(s.height(), 100));
-#if defined(Q_DEAD_CODE_FROM_QT4_X11)
+#if 0 // Used to be included in Qt4 for Q_WS_X11
QRect screen = QApplication::desktop()->screenGeometry(q->x11Info().screen());
#else // all others
QRect screen = QApplication::desktop()->screenGeometry(q->pos());
#endif
-#if defined (Q_OS_WINCE)
- s.setWidth(qMin(s.width(), screen.width()));
- s.setHeight(qMin(s.height(), screen.height()));
-#else
s.setWidth(qMin(s.width(), screen.width()*2/3));
s.setHeight(qMin(s.height(), screen.height()*2/3));
-#endif
+
if (QTLWExtra *extra = maybeTopData())
extra->sizeAdjusted = true;
}
@@ -8695,7 +8686,7 @@ bool QWidget::isAncestorOf(const QWidget *child) const
return false;
}
-#if defined(Q_DEAD_CODE_FROM_QT4_WIN)
+#if 0 // Used to be included in Qt4 for Q_WS_WIN
inline void setDisabledStyle(QWidget *w, bool setStyle)
{
// set/reset WS_DISABLED style.
@@ -8854,7 +8845,7 @@ bool QWidget::event(QEvent *event)
case QEvent::KeyRelease:
keyReleaseEvent((QKeyEvent*)event);
- // fall through
+ Q_FALLTHROUGH();
case QEvent::ShortcutOverride:
break;
@@ -8973,7 +8964,7 @@ bool QWidget::event(QEvent *event)
0, this);
break;
}
- // fall through
+ Q_FALLTHROUGH();
#endif
default:
event->ignore();
@@ -9127,7 +9118,7 @@ bool QWidget::event(QEvent *event)
}
}
}
-#if defined(Q_DEAD_CODE_FROM_QT4_WIN)
+#if 0 // Used to be included in Qt4 for Q_WS_WIN
setDisabledStyle(this, (event->type() == QEvent::WindowBlocked));
#endif
break;
@@ -9154,7 +9145,7 @@ bool QWidget::event(QEvent *event)
case QEvent::EmbeddingControl:
d->topData()->frameStrut.setCoords(0 ,0, 0, 0);
data->fstrut_dirty = false;
-#if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_X11)
+#if 0 /* Used to be included in Qt4 for Q_WS_WIN */ || 0 /* Used to be included in Qt4 for Q_WS_X11 */
d->topData()->embedded = 1;
#endif
break;
@@ -9179,7 +9170,7 @@ bool QWidget::event(QEvent *event)
}
break;
}
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
case QEvent::MacGLWindowChange:
d->needWindowChange = false;
break;
@@ -9222,7 +9213,7 @@ bool QWidget::event(QEvent *event)
}
if (windowHandle() && !qstrncmp(propName, "_q_platform_", 12))
windowHandle()->setProperty(propName, property(propName));
- // fall through
+ Q_FALLTHROUGH();
}
#endif
default:
@@ -9293,7 +9284,7 @@ void QWidget::changeEvent(QEvent * event)
case QEvent::MacSizeChange:
updateGeometry();
break;
-#elif defined Q_DEAD_CODE_FROM_QT4_MAC
+#elif 0 // Used to be included in Qt4 for Q_WS_MAC
case QEvent::ToolTipChange:
case QEvent::MouseTrackingChange:
qt_mac_update_mouseTracking(this);
@@ -9470,10 +9461,13 @@ void QWidget::tabletEvent(QTabletEvent *event)
void QWidget::keyPressEvent(QKeyEvent *event)
{
+#ifndef QT_NO_SHORTCUT
if ((windowType() == Qt::Popup) && event->matches(QKeySequence::Cancel)) {
event->accept();
close();
- } else {
+ } else
+#endif
+ {
event->ignore();
}
}
@@ -9555,7 +9549,7 @@ void QWidget::focusOutEvent(QFocusEvent *)
if (focusPolicy() != Qt::NoFocus || !isWindow())
update();
-#ifndef Q_OS_IOS
+#if !defined(QT_PLATFORM_UIKIT)
// FIXME: revisit autoSIP logic, QTBUG-42906
if (qApp->autoSipEnabled() && testAttribute(Qt::WA_InputMethodEnabled))
QGuiApplication::inputMethod()->hide();
@@ -10566,7 +10560,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
// (f & Qt::MSWindowsOwnDC) clause (which is set on QGLWidgets on all
// platforms).
if (newParent
-#if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(QT_OPENGL_ES)
+#if 0 /* Used to be included in Qt4 for Q_WS_WIN */ || defined(QT_OPENGL_ES)
|| (f & Qt::MSWindowsOwnDC)
#endif
) {
@@ -10586,7 +10580,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
}
//### already hidden above ---> must probably do something smart on the mac
-// #ifdef Q_DEAD_CODE_FROM_QT4_MAC
+// #if 0 // Used to be included in Qt4 for Q_WS_MAC
// extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp
// if(!qt_mac_is_macdrawer(q)) //special case
// q->setAttribute(Qt::WA_WState_Hidden);
@@ -10765,10 +10759,8 @@ void QWidget::scroll(int dx, int dy)
// Graphics View maintains its own dirty region as a list of rects;
// until we can connect item updates directly to the view, we must
// separately add a translated dirty region.
- if (!d->dirty.isEmpty()) {
- foreach (const QRect &rect, (d->dirty.translated(dx, dy)).rects())
- proxy->update(rect);
- }
+ for (const QRect &rect : d->dirty)
+ proxy->update(rect.translated(dx, dy));
proxy->scroll(dx, dy, proxy->subWidgetRect(this));
return;
}
@@ -10808,7 +10800,7 @@ void QWidget::scroll(int dx, int dy, const QRect &r)
// until we can connect item updates directly to the view, we must
// separately add a translated dirty region.
if (!d->dirty.isEmpty()) {
- foreach (const QRect &rect, (d->dirty.translated(dx, dy) & r).rects())
+ for (const QRect &rect : d->dirty.translated(dx, dy) & r)
proxy->update(rect);
}
proxy->scroll(dx, dy, r.translated(proxy->subWidgetRect(this).topLeft().toPoint()));
@@ -11116,7 +11108,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
d->receiveChildEvents = !on;
break;
case Qt::WA_MacBrushedMetal:
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
d->setStyle_helper(style(), false, true); // Make sure things get unpolished/polished correctly.
// fall through since changing the metal attribute affects the opaque size grip.
case Qt::WA_MacOpaqueSizeGrip:
@@ -11133,7 +11125,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
break;
#endif
case Qt::WA_MacAlwaysShowToolWindow:
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
d->macUpdateHideOnSuspend();
#endif
break;
@@ -11210,7 +11202,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
}
case Qt::WA_PaintOnScreen:
d->updateIsOpaque();
-#if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_X11) || defined(Q_DEAD_CODE_FROM_QT4_MAC)
+#if 0 /* Used to be included in Qt4 for Q_WS_WIN */ || 0 /* Used to be included in Qt4 for Q_WS_X11 */ || 0 /* Used to be included in Qt4 for Q_WS_MAC */
// Recreate the widget if it's already created as an alien widget and
// WA_PaintOnScreen is enabled. Paint on screen widgets must have win id.
// So must their children.
@@ -11219,18 +11211,18 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
d->enforceNativeChildren();
}
#endif
- // fall through
+ Q_FALLTHROUGH();
case Qt::WA_OpaquePaintEvent:
d->updateIsOpaque();
break;
case Qt::WA_NoSystemBackground:
d->updateIsOpaque();
- // fall through...
+ Q_FALLTHROUGH();
case Qt::WA_UpdatesDisabled:
d->updateSystemBackground();
break;
case Qt::WA_TransparentForMouseEvents:
-#ifdef Q_DEAD_CODE_FROM_QT4_MAC
+#if 0 // Used to be included in Qt4 for Q_WS_MAC
d->macUpdateIgnoreMouseEvents();
#endif
break;
@@ -11249,7 +11241,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
d->resolveFont();
d->resolveLocale();
break;
-#ifdef Q_DEAD_CODE_FROM_QT4_X11
+#if 0 // Used to be included in Qt4 for Q_WS_X11
case Qt::WA_NoX11EventCompression:
if (!d->extra)
d->createExtra();
@@ -11306,7 +11298,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
break;
case Qt::WA_AcceptTouchEvents:
-#if defined(Q_DEAD_CODE_FROM_QT4_WIN) || defined(Q_DEAD_CODE_FROM_QT4_MAC)
+#if 0 /* Used to be included in Qt4 for Q_WS_WIN */ || 0 /* Used to be included in Qt4 for Q_WS_MAC */
if (on)
d->registerTouchWindow();
#endif
@@ -11925,7 +11917,7 @@ QRect QWidgetPrivate::frameStrut() const
}
if (data.fstrut_dirty
-#ifndef Q_DEAD_CODE_FROM_QT4_WIN
+#if 1 // Used to be excluded in Qt4 for Q_WS_WIN
// ### Fix properly for 4.3
&& q->isVisible()
#endif
@@ -12861,7 +12853,7 @@ void QWidget::setMask(const QRegion &newMask)
d->extra->mask = newMask;
d->extra->hasMask = !newMask.isEmpty();
-#ifndef Q_DEAD_CODE_FROM_QT4_MAC
+#if 1 // Used to be excluded in Qt4 for Q_WS_MAC
if (!testAttribute(Qt::WA_WState_Created))
return;
#endif
@@ -13057,45 +13049,6 @@ QDebug operator<<(QDebug debug, const QWidget *widget)
}
#endif // !QT_NO_DEBUG_STREAM
-/*! \fn Qt::HANDLE QWidget::macCGHandle() const
- \internal
-
- Returns the CoreGraphics handle of the widget. Use of this function is not portable.
- This function will return 0 if no painter context can be established, or if the handle
- could not be created.
-
- \warning This function is only available on \macos.
-*/
-/*! \fn Qt::HANDLE QWidget::macQDHandle() const
- \internal
-
- Returns the QuickDraw handle of the widget. Use of this function is not portable.
- This function will return 0 if QuickDraw is not supported, or if the handle could
- not be created.
-
- \warning This function is only available on \macos.
-*/
-/*! \fn const QX11Info &QWidget::x11Info() const
- \internal
-
- Returns information about the configuration of the X display used to display
- the widget.
-
- \warning This function is only available on X11.
-*/
-
-/*! \fn Qt::HANDLE QWidget::x11PictureHandle() const
- \internal
-
- Returns the X11 picture handle of the widget for XRender
- support. Use of this function is not portable. This function will
- return 0 if XRender support is not compiled into Qt, if the
- XRender extension is not supported on the X11 display, or if the
- handle could not be created.
-
- \warning This function is only available on X11.
-
-*/
QT_END_NAMESPACE
#include "moc_qwidget.cpp"