summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-07-07 22:11:14 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-07-07 23:09:38 +0000
commit4f952aaea13adfc2d271ed98f111fc8f6d9614ef (patch)
treef49db9d74611be2b2a7a55e0dfcdb315166338d6
parenta2cef41a3199b7bdaa64c911c7a2e7d0b0daecd4 (diff)
Move method only used in keypad navigation to a better place
QDesktopWidget in particular doesn't use that code anymore. Change-Id: I8eed752175c5478663b25872c7ffe78c814245d7 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/widgets/kernel/qwidget.cpp39
-rw-r--r--src/widgets/kernel/qwidget_p.h2
2 files changed, 14 insertions, 27 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 5a75900f84..7c20657a85 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -6872,30 +6872,6 @@ void QWidgetPrivate::reparentFocusWidgets(QWidget * oldtlw)
}
-/*!\internal
-
- Measures the shortest distance from a point to a rect.
-
- This function is called from QDesktopwidget::screen(QPoint) to find the
- closest screen for a point.
- In directional KeypadNavigation, it is called to find the closest
- widget to the current focus widget center.
-*/
-int QWidgetPrivate::pointToRect(const QPoint &p, const QRect &r)
-{
- int dx = 0;
- int dy = 0;
- if (p.x() < r.left())
- dx = r.left() - p.x();
- else if (p.x() > r.right())
- dx = p.x() - r.right();
- if (p.y() < r.top())
- dy = r.top() - p.y();
- else if (p.y() > r.bottom())
- dy = p.y() - r.bottom();
- return dx + dy;
-}
-
/*!
\property QWidget::frameSize
\brief the size of the widget including any window frame
@@ -11780,7 +11756,20 @@ QWidget *QWidgetPrivate::widgetInNavigationDirection(Direction direction)
&& targetCandidate->isVisible()
// ...is in the same window,
&& targetCandidate->window() == sourceWindow) {
- const int targetCandidateDistance = pointToRect(sourcePoint, targetCandidateRect);
+ const int targetCandidateDistance = [](const QPoint &sourcePoint,
+ const QRect &targetCandidateRect) {
+ int dx = 0;
+ int dy = 0;
+ if (p.x() < r.left())
+ dx = r.left() - p.x();
+ else if (p.x() > r.right())
+ dx = p.x() - r.right();
+ if (p.y() < r.top())
+ dy = r.top() - p.y();
+ else if (p.y() > r.bottom())
+ dy = p.y() - r.bottom();
+ return dx + dy;
+ }();
if (targetCandidateDistance < shortestDistance) {
shortestDistance = targetCandidateDistance;
targetWidget = targetCandidate;
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index 08954cc778..f6a1ee539d 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -398,8 +398,6 @@ public:
void reparentFocusWidgets(QWidget *oldtlw);
- static int pointToRect(const QPoint &p, const QRect &r);
-
void setWinId(WId);
void showChildren(bool spontaneous);
void hideChildren(bool spontaneous);