Changeset View
Changeset View
Standalone View
Standalone View
generic/kpWidgetMapper.cpp
Show All 33 Lines | |||||
34 | 34 | | |||
35 | 35 | | |||
36 | namespace kpWidgetMapper | 36 | namespace kpWidgetMapper | ||
37 | { | 37 | { | ||
38 | 38 | | |||
39 | 39 | | |||
40 | QPoint fromGlobal (const QWidget *widget, const QPoint &point) | 40 | QPoint fromGlobal (const QWidget *widget, const QPoint &point) | ||
41 | { | 41 | { | ||
42 | if (!widget) | 42 | if (!widget) { | ||
43 | return point; | 43 | return point; | ||
44 | } | ||||
44 | 45 | | |||
45 | return widget->mapFromGlobal (point); | 46 | return widget->mapFromGlobal (point); | ||
46 | } | 47 | } | ||
47 | 48 | | |||
48 | QRect fromGlobal (const QWidget *widget, const QRect &rect) | 49 | QRect fromGlobal (const QWidget *widget, const QRect &rect) | ||
49 | { | 50 | { | ||
50 | if (!widget || !rect.isValid ()) | 51 | if (!widget || !rect.isValid ()) { | ||
51 | return rect; | 52 | return rect; | ||
53 | } | ||||
52 | 54 | | |||
53 | QPoint topLeft = fromGlobal (widget, rect.topLeft ()); | 55 | auto topLeft = fromGlobal (widget, rect.topLeft ()); | ||
54 | return QRect (topLeft.x (), topLeft.y (), rect.width (), rect.height ()); | 56 | return {topLeft.x (), topLeft.y (), rect.width (), rect.height ()}; | ||
55 | } | 57 | } | ||
56 | 58 | | |||
57 | 59 | | |||
58 | QPoint toGlobal (const QWidget *widget, const QPoint &point) | 60 | QPoint toGlobal (const QWidget *widget, const QPoint &point) | ||
59 | { | 61 | { | ||
60 | if (!widget) | 62 | if (!widget) { | ||
61 | return point; | 63 | return point; | ||
64 | } | ||||
62 | 65 | | |||
63 | return widget->mapToGlobal (point); | 66 | return widget->mapToGlobal (point); | ||
64 | } | 67 | } | ||
65 | 68 | | |||
66 | QRect toGlobal (const QWidget *widget, const QRect &rect) | 69 | QRect toGlobal (const QWidget *widget, const QRect &rect) | ||
67 | { | 70 | { | ||
68 | if (!widget || !rect.isValid ()) | 71 | if (!widget || !rect.isValid ()) { | ||
69 | return rect; | 72 | return rect; | ||
73 | } | ||||
70 | 74 | | |||
71 | QPoint topLeft = toGlobal (widget, rect.topLeft ()); | 75 | auto topLeft = toGlobal (widget, rect.topLeft ()); | ||
72 | return QRect (topLeft.x (), topLeft.y (), rect.width (), rect.height ()); | 76 | return {topLeft.x (), topLeft.y (), rect.width (), rect.height ()}; | ||
73 | } | 77 | } | ||
74 | 78 | | |||
75 | 79 | | |||
76 | } // namespace kpWidgetMapper { | 80 | } // namespace kpWidgetMapper |