summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r--src/widgets/kernel/qapplication.cpp63
-rw-r--r--src/widgets/kernel/qapplication_p.h7
-rw-r--r--src/widgets/kernel/qwidget.cpp98
-rw-r--r--src/widgets/kernel/qwidget.h3
-rw-r--r--src/widgets/kernel/qwidget_p.h2
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp9
6 files changed, 79 insertions, 103 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index c922aecceb..94b14ecb4f 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -236,9 +236,6 @@ void QApplicationPrivate::createEventDispatcher()
encapsulated in a QStyle object. This can be changed at runtime
with setStyle().
- \li It specifies how the application is to allocate colors. See
- setColorSpec() for details.
-
\li It provides localization of strings that are visible to the
user via translate().
@@ -299,11 +296,6 @@ void QApplicationPrivate::createEventDispatcher()
setStyle().
\row
- \li Color usage
- \li colorSpec(),
- setColorSpec().
-
- \row
\li Text handling
\li installTranslator(),
removeTranslator()
@@ -337,6 +329,7 @@ void QApplicationPrivate::createEventDispatcher()
\sa QCoreApplication, QAbstractEventDispatcher, QEventLoop, QSettings
*/
+#if QT_DEPRECATED_SINCE(5, 8)
// ### fixme: Qt 6: Remove ColorSpec and accessors.
/*!
\enum QApplication::ColorSpec
@@ -350,15 +343,7 @@ void QApplicationPrivate::createEventDispatcher()
See setColorSpec() for full details.
*/
-
-/*!
- \fn QApplication::setGraphicsSystem(const QString &)
- \obsolete
-
- This call has no effect.
-
- Use the QPA framework instead.
-*/
+#endif
/*!
\fn QWidget *QApplication::topLevelAt(const QPoint &point)
@@ -1956,15 +1941,8 @@ bool QApplication::event(QEvent *e)
return QGuiApplication::event(e);
}
-/*!
- \fn void QApplication::syncX()
- Was used to synchronize with the X server in 4.x, here for source compatibility.
- \internal
- \obsolete
-*/
-
// ### FIXME: topLevelWindows does not contain QWidgets without a parent
-// until create_sys is called. So we have to override the
+// until QWidgetPrivate::create is called. So we have to override the
// QGuiApplication::notifyLayoutDirectionChange
// to do the right thing.
void QApplicationPrivate::notifyLayoutDirectionChange()
@@ -3240,13 +3218,18 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
if (spontaneous && phase == Qt::ScrollBegin)
QApplicationPrivate::wheel_widget = nullptr;
- const QPoint &relpos = wheel->pos();
+ QPoint relpos = wheel->position().toPoint();
if (spontaneous && (phase == Qt::NoScrollPhase || phase == Qt::ScrollUpdate))
QApplicationPrivate::giveFocusAccordingToFocusPolicy(w, e, relpos);
+#if QT_DEPRECATED_SINCE(5, 14)
QWheelEvent we(relpos, wheel->globalPos(), wheel->pixelDelta(), wheel->angleDelta(), wheel->delta(), wheel->orientation(), wheel->buttons(),
wheel->modifiers(), phase, wheel->source(), wheel->inverted());
+#else
+ QWheelEvent we(relpos, wheel->globalPosition(), wheel->pixelDelta(), wheel->angleDelta(), wheel->buttons(),
+ wheel->modifiers(), phase, wheel->inverted(), wheel->source());
+#endif
we.setTimestamp(wheel->timestamp());
bool eventAccepted;
do {
@@ -3281,9 +3264,14 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
// is set. Since it accepted the wheel event previously, we continue
// sending those events until we get a ScrollEnd, which signifies
// the end of the natural scrolling sequence.
- const QPoint &relpos = QApplicationPrivate::wheel_widget->mapFromGlobal(wheel->globalPos());
+ const QPoint &relpos = QApplicationPrivate::wheel_widget->mapFromGlobal(wheel->globalPosition().toPoint());
+#if QT_DEPRECATED_SINCE(5, 0)
QWheelEvent we(relpos, wheel->globalPos(), wheel->pixelDelta(), wheel->angleDelta(), wheel->delta(), wheel->orientation(), wheel->buttons(),
wheel->modifiers(), wheel->phase(), wheel->source());
+#else
+ QWheelEvent we(relpos, wheel->globalPosition(), wheel->pixelDelta(), wheel->angleDelta(), wheel->buttons(),
+ wheel->modifiers(), wheel->phase(), wheel->inverted(), wheel->source());
+#endif
we.setTimestamp(wheel->timestamp());
we.spont = true;
we.ignore();
@@ -3833,8 +3821,6 @@ void QApplicationPrivate::openPopup(QWidget *popup)
This feature is available in Qt for Embedded Linux only.
\since 4.6
-
- \sa keypadNavigationEnabled()
*/
void QApplication::setNavigationMode(Qt::NavigationMode mode)
{
@@ -3847,8 +3833,6 @@ void QApplication::setNavigationMode(Qt::NavigationMode mode)
This feature is available in Qt for Embedded Linux only.
\since 4.6
-
- \sa keypadNavigationEnabled()
*/
Qt::NavigationMode QApplication::navigationMode()
{
@@ -3984,15 +3968,6 @@ int QApplication::doubleClickInterval()
}
/*!
- \fn QApplication::keyboardInputDirection()
- \since 4.2
- \deprecated
-
- Returns the current keyboard input direction. Replaced with QInputMethod::inputDirection()
- \sa QInputMethod::inputDirection()
-*/
-
-/*!
\property QApplication::keyboardInputInterval
\brief the time limit in milliseconds that distinguishes a key press
from two consecutive key presses
@@ -4129,14 +4104,6 @@ void QApplication::beep()
\sa QCoreApplication::instance(), qGuiApp
*/
-/*!
- \fn QLocale QApplication::keyboardInputLocale()
- \since 4.2
- \obsolete
-
- Returns the current keyboard input locale. Replaced with QInputMethod::locale()
-*/
-
bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event)
{
return QGuiApplication::sendSpontaneousEvent(receiver, event);
diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h
index 98eb9b73c6..36c0ba8739 100644
--- a/src/widgets/kernel/qapplication_p.h
+++ b/src/widgets/kernel/qapplication_p.h
@@ -136,6 +136,13 @@ public:
static QWidget *tryModalHelper_sys(QWidget *top);
bool canQuit();
#endif
+#ifdef QT_KEYPAD_NAVIGATION
+ static bool keypadNavigationEnabled()
+ {
+ return navigationMode == Qt::NavigationModeKeypadTabOrder ||
+ navigationMode == Qt::NavigationModeKeypadDirectional;
+ }
+#endif
bool notify_helper(QObject *receiver, QEvent * e);
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 89b0e56297..cdea0a570c 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -393,7 +393,7 @@ QPointer<QWidget> QWidgetPrivate::editingWidget;
This feature is only available in Qt for Embedded Linux.
- \sa setEditFocus(), QApplication::keypadNavigationEnabled()
+ \sa setEditFocus(), QApplication::navigationMode()
*/
bool QWidget::hasEditFocus() const
{
@@ -413,7 +413,7 @@ bool QWidget::hasEditFocus() const
This feature is only available in Qt for Embedded Linux.
- \sa hasEditFocus(), QApplication::keypadNavigationEnabled()
+ \sa hasEditFocus(), QApplication::navigationMode()
*/
void QWidget::setEditFocus(bool on)
{
@@ -1193,7 +1193,7 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
q->setAttribute(Qt::WA_ContentsMarginsRespectsSafeArea);
q->setAttribute(Qt::WA_WState_Hidden);
- //give potential windows a bigger "pre-initial" size; create_sys() will give them a new size later
+ //give potential windows a bigger "pre-initial" size; create() will give them a new size later
data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,640,480);
focus_next = focus_prev = q;
@@ -1287,27 +1287,19 @@ QScreen *QWidgetPrivate::associatedScreen() const
/*!
Creates a new widget window.
- The parameter \a window is ignored in Qt 5. Please use
- QWindow::fromWinId() to create a QWindow wrapping a foreign
- window and pass it to QWidget::createWindowContainer() instead.
-
- Initializes the window (sets the geometry etc.) if \a
- initializeWindow is true. If \a initializeWindow is false, no
- initialization is performed. This parameter only makes sense if \a
- window is a valid window.
-
- Destroys the old window if \a destroyOldWindow is true. If \a
- destroyOldWindow is false, you are responsible for destroying the
- window yourself (using platform native code).
-
- The QWidget constructor calls create(0,true,true) to create a
- window for this widget.
+ The parameters \a window, \a initializeWindow, and \a destroyOldWindow
+ are ignored in Qt 5. Please use QWindow::fromWinId() to create a
+ QWindow wrapping a foreign window and pass it to
+ QWidget::createWindowContainer() instead.
\sa createWindowContainer(), QWindow::fromWinId()
*/
void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow)
{
+ Q_UNUSED(initializeWindow);
+ Q_UNUSED(destroyOldWindow);
+
Q_D(QWidget);
if (Q_UNLIKELY(window))
qWarning("QWidget::create(): Parameter 'window' does not have any effect.");
@@ -1367,7 +1359,7 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow)
d->updateIsOpaque();
setAttribute(Qt::WA_WState_Created); // set created flag
- d->create_sys(window, initializeWindow, destroyOldWindow);
+ d->create();
// a real toplevel window needs a backing store
if (isWindow() && windowType() != Qt::Desktop) {
@@ -1431,14 +1423,10 @@ void q_createNativeChildrenAndSetParent(const QWidget *parentWidget)
}
-void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow)
+void QWidgetPrivate::create()
{
Q_Q(QWidget);
- Q_UNUSED(window);
- Q_UNUSED(initializeWindow);
- Q_UNUSED(destroyOldWindow);
-
if (!q->testAttribute(Qt::WA_NativeWindow) && !q->isWindow())
return; // we only care about real toplevels
@@ -6469,8 +6457,18 @@ void QWidget::setFocusProxy(QWidget * w)
}
}
+ QWidget *oldDeepestFocusProxy = d_func()->deepestFocusProxy();
+ if (!oldDeepestFocusProxy)
+ oldDeepestFocusProxy = this;
+ const bool changingAppFocusWidget = (QApplicationPrivate::focus_widget == oldDeepestFocusProxy);
+
d->createExtra();
d->extra->focus_proxy = w;
+
+ if (changingAppFocusWidget) {
+ QWidget *newDeepestFocusProxy = d_func()->deepestFocusProxy();
+ QApplicationPrivate::focus_widget = newDeepestFocusProxy ? newDeepestFocusProxy : this;
+ }
}
@@ -7474,6 +7472,17 @@ QByteArray QWidget::saveGeometry() const
return array;
}
+static void checkRestoredGeometry(const QRect &availableGeometry, QRect *restoredGeometry,
+ int frameHeight)
+{
+ if (!restoredGeometry->intersects(availableGeometry)) {
+ restoredGeometry->moveBottom(qMin(restoredGeometry->bottom(), availableGeometry.bottom()));
+ restoredGeometry->moveLeft(qMax(restoredGeometry->left(), availableGeometry.left()));
+ restoredGeometry->moveRight(qMin(restoredGeometry->right(), availableGeometry.right()));
+ }
+ restoredGeometry->moveTop(qMax(restoredGeometry->top(), availableGeometry.top() + frameHeight));
+}
+
/*!
\since 4.2
@@ -7528,7 +7537,7 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
quint8 fullScreen;
qint32 restoredScreenWidth = 0;
- stream >> restoredFrameGeometry
+ stream >> restoredFrameGeometry // Only used for sanity checks in version 0
>> restoredNormalGeometry
>> restoredScreenNumber
>> maximized
@@ -7558,8 +7567,6 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
}
const int frameHeight = 20;
- if (!restoredFrameGeometry.isValid())
- restoredFrameGeometry = QRect(QPoint(0,0), sizeHint());
if (!restoredNormalGeometry.isValid())
restoredNormalGeometry = QRect(QPoint(0, frameHeight), sizeHint());
@@ -7579,23 +7586,11 @@ bool QWidget::restoreGeometry(const QByteArray &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.
#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
- if (!restoredFrameGeometry.intersects(availableGeometry)) {
- restoredFrameGeometry.moveBottom(qMin(restoredFrameGeometry.bottom(), availableGeometry.bottom()));
- restoredFrameGeometry.moveLeft(qMax(restoredFrameGeometry.left(), availableGeometry.left()));
- restoredFrameGeometry.moveRight(qMin(restoredFrameGeometry.right(), availableGeometry.right()));
- }
- restoredFrameGeometry.moveTop(qMax(restoredFrameGeometry.top(), availableGeometry.top()));
-
- if (!restoredNormalGeometry.intersects(availableGeometry)) {
- restoredNormalGeometry.moveBottom(qMin(restoredNormalGeometry.bottom(), availableGeometry.bottom()));
- restoredNormalGeometry.moveLeft(qMax(restoredNormalGeometry.left(), availableGeometry.left()));
- restoredNormalGeometry.moveRight(qMin(restoredNormalGeometry.right(), availableGeometry.right()));
- }
- restoredNormalGeometry.moveTop(qMax(restoredNormalGeometry.top(), availableGeometry.top() + frameHeight));
+ checkRestoredGeometry(availableGeometry, &restoredGeometry, frameHeight);
+ checkRestoredGeometry(availableGeometry, &restoredNormalGeometry, frameHeight);
if (maximized || fullScreen) {
// set geometry before setting the window state to make
@@ -7649,7 +7644,7 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
Changing the margins will trigger a resizeEvent().
- \sa contentsRect(), getContentsMargins()
+ \sa contentsRect(), contentsMargins()
*/
void QWidget::setContentsMargins(int left, int top, int right, int bottom)
{
@@ -7679,7 +7674,7 @@ void QWidget::setContentsMargins(int left, int top, int right, int bottom)
Changing the margins will trigger a resizeEvent().
- \sa contentsRect(), getContentsMargins()
+ \sa contentsRect(), contentsMargins()
*/
void QWidget::setContentsMargins(const QMargins &margins)
{
@@ -7708,7 +7703,11 @@ void QWidgetPrivate::updateContentsRect()
QCoreApplication::sendEvent(q, &e);
}
+#if QT_DEPRECATED_SINCE(5, 14)
/*!
+ \obsolete
+ Use contentsMargins().
+
Returns the widget's contents margins for \a left, \a top, \a
right, and \a bottom.
@@ -7726,6 +7725,7 @@ void QWidget::getContentsMargins(int *left, int *top, int *right, int *bottom) c
if (bottom)
*bottom = m.bottom();
}
+#endif
// FIXME: Move to qmargins.h for next minor Qt release
QMargins operator|(const QMargins &m1, const QMargins &m2)
@@ -7739,7 +7739,7 @@ QMargins operator|(const QMargins &m1, const QMargins &m2)
\brief The contentsMargins function returns the widget's contents margins.
- \sa getContentsMargins(), setContentsMargins(), contentsRect()
+ \sa setContentsMargins(), contentsRect()
*/
QMargins QWidget::contentsMargins() const
{
@@ -7752,7 +7752,7 @@ QMargins QWidget::contentsMargins() const
/*!
Returns the area inside the widget's margins.
- \sa setContentsMargins(), getContentsMargins()
+ \sa setContentsMargins(), contentsMargins()
*/
QRect QWidget::contentsRect() const
{
@@ -9408,12 +9408,6 @@ bool QWidget::event(QEvent *event)
d->renderToTextureReallyDirty = 1;
#endif
break;
- case QEvent::PlatformSurface: {
- auto surfaceEvent = static_cast<QPlatformSurfaceEvent*>(event);
- if (surfaceEvent->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed)
- d->setWinId(0);
- break;
- }
#ifndef QT_NO_PROPERTIES
case QEvent::DynamicPropertyChange: {
const QByteArray &propName = static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName();
@@ -11392,7 +11386,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
// windowModality property and then reshown.
}
if (testAttribute(Qt::WA_WState_Created)) {
- // don't call setModal_sys() before create_sys()
+ // don't call setModal_sys() before create()
d->setModal_sys();
}
break;
diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h
index e47deb5d0d..0777bed65c 100644
--- a/src/widgets/kernel/qwidget.h
+++ b/src/widgets/kernel/qwidget.h
@@ -524,7 +524,10 @@ public:
void setContentsMargins(int left, int top, int right, int bottom);
void setContentsMargins(const QMargins &margins);
+#if QT_DEPRECATED_SINCE(5, 14)
+ QT_DEPRECATED_X("use contentsMargins()")
void getContentsMargins(int *left, int *top, int *right, int *bottom) const;
+#endif
QMargins contentsMargins() const;
QRect contentsRect() const;
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index 99ec38e050..7cb9a3895a 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -360,7 +360,7 @@ public:
void update(T t);
void init(QWidget *desktopWidget, Qt::WindowFlags f);
- void create_sys(WId window, bool initializeWindow, bool destroyOldWindow);
+ void create();
void createRecursively();
void createWinId();
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index ba10083829..5537ff497a 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -828,14 +828,14 @@ void QWidgetWindow::handleWheelEvent(QWheelEvent *event)
return;
QWidget *rootWidget = m_widget;
- QPoint pos = event->pos();
+ QPoint pos = event->position().toPoint();
// Use proper popup window for wheel event. Some QPA sends the wheel
// event to the root menu, so redirect it to the proper popup window.
QWidget *activePopupWidget = QApplication::activePopupWidget();
if (activePopupWidget && activePopupWidget != m_widget) {
rootWidget = activePopupWidget;
- pos = rootWidget->mapFromGlobal(event->globalPos());
+ pos = rootWidget->mapFromGlobal(event->globalPosition().toPoint());
}
// which child should have it?
@@ -846,7 +846,12 @@ void QWidgetWindow::handleWheelEvent(QWheelEvent *event)
QPoint mapped = widget->mapFrom(rootWidget, pos);
+#if QT_DEPRECATED_SINCE(5, 0)
QWheelEvent translated(mapped, event->globalPos(), event->pixelDelta(), event->angleDelta(), event->delta(), event->orientation(), event->buttons(), event->modifiers(), event->phase(), event->source(), event->inverted());
+#else
+ QWheelEvent translated(QPointF(mapped), event->globalPosition(), event->pixelDelta(), event->angleDelta(),
+ event->buttons(), event->modifiers(), event->phase(), event->inverted(), event->source());
+#endif
translated.setTimestamp(event->timestamp());
QGuiApplication::forwardEvent(widget, &translated, event);
}