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>
This commit is contained in:
parent
a2cef41a31
commit
4f952aaea1
@ -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
|
\property QWidget::frameSize
|
||||||
\brief the size of the widget including any window frame
|
\brief the size of the widget including any window frame
|
||||||
@ -11780,7 +11756,20 @@ QWidget *QWidgetPrivate::widgetInNavigationDirection(Direction direction)
|
|||||||
&& targetCandidate->isVisible()
|
&& targetCandidate->isVisible()
|
||||||
// ...is in the same window,
|
// ...is in the same window,
|
||||||
&& targetCandidate->window() == sourceWindow) {
|
&& 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) {
|
if (targetCandidateDistance < shortestDistance) {
|
||||||
shortestDistance = targetCandidateDistance;
|
shortestDistance = targetCandidateDistance;
|
||||||
targetWidget = targetCandidate;
|
targetWidget = targetCandidate;
|
||||||
|
@ -398,8 +398,6 @@ public:
|
|||||||
|
|
||||||
void reparentFocusWidgets(QWidget *oldtlw);
|
void reparentFocusWidgets(QWidget *oldtlw);
|
||||||
|
|
||||||
static int pointToRect(const QPoint &p, const QRect &r);
|
|
||||||
|
|
||||||
void setWinId(WId);
|
void setWinId(WId);
|
||||||
void showChildren(bool spontaneous);
|
void showChildren(bool spontaneous);
|
||||||
void hideChildren(bool spontaneous);
|
void hideChildren(bool spontaneous);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user