Changeset View
Changeset View
Standalone View
Standalone View
tools/rectangular/kpToolRectangularBase.cpp
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | |||||
51 | #include "views/kpView.h" | 51 | #include "views/kpView.h" | ||
52 | #include "views/manager/kpViewManager.h" | 52 | #include "views/manager/kpViewManager.h" | ||
53 | 53 | | |||
54 | 54 | | |||
55 | //--------------------------------------------------------------------- | 55 | //--------------------------------------------------------------------- | ||
56 | 56 | | |||
57 | struct kpToolRectangularBasePrivate | 57 | struct kpToolRectangularBasePrivate | ||
58 | { | 58 | { | ||
59 | kpToolRectangularBase::DrawShapeFunc drawShapeFunc; | 59 | kpToolRectangularBase::DrawShapeFunc drawShapeFunc{}; | ||
60 | 60 | | |||
61 | kpToolWidgetLineWidth *toolWidgetLineWidth; | 61 | kpToolWidgetLineWidth *toolWidgetLineWidth{}; | ||
62 | kpToolWidgetFillStyle *toolWidgetFillStyle; | 62 | kpToolWidgetFillStyle *toolWidgetFillStyle{}; | ||
63 | 63 | | |||
64 | QRect toolRectangleRect; | 64 | QRect toolRectangleRect; | ||
65 | }; | 65 | }; | ||
66 | 66 | | |||
67 | //--------------------------------------------------------------------- | 67 | //--------------------------------------------------------------------- | ||
68 | 68 | | |||
69 | kpToolRectangularBase::kpToolRectangularBase ( | 69 | kpToolRectangularBase::kpToolRectangularBase ( | ||
70 | const QString &text, | 70 | const QString &text, | ||
Show All 20 Lines | |||||
91 | } | 91 | } | ||
92 | 92 | | |||
93 | //--------------------------------------------------------------------- | 93 | //--------------------------------------------------------------------- | ||
94 | 94 | | |||
95 | 95 | | |||
96 | // private slot virtual | 96 | // private slot virtual | ||
97 | void kpToolRectangularBase::slotLineWidthChanged () | 97 | void kpToolRectangularBase::slotLineWidthChanged () | ||
98 | { | 98 | { | ||
99 | if (hasBegunDraw ()) | 99 | if (hasBegunDraw ()) { | ||
100 | updateShape (); | 100 | updateShape (); | ||
101 | } | 101 | } | ||
102 | } | ||||
102 | 103 | | |||
103 | //--------------------------------------------------------------------- | 104 | //--------------------------------------------------------------------- | ||
104 | 105 | | |||
105 | // private slot virtual | 106 | // private slot virtual | ||
106 | void kpToolRectangularBase::slotFillStyleChanged () | 107 | void kpToolRectangularBase::slotFillStyleChanged () | ||
107 | { | 108 | { | ||
108 | if (hasBegunDraw ()) | 109 | if (hasBegunDraw ()) { | ||
109 | updateShape (); | 110 | updateShape (); | ||
110 | } | 111 | } | ||
112 | } | ||||
111 | 113 | | |||
112 | //--------------------------------------------------------------------- | 114 | //--------------------------------------------------------------------- | ||
113 | 115 | | |||
114 | // private | 116 | // private | ||
115 | QString kpToolRectangularBase::haventBegunDrawUserMessage () const | 117 | QString kpToolRectangularBase::haventBegunDrawUserMessage () const | ||
116 | { | 118 | { | ||
117 | return i18n ("Drag to draw."); | 119 | return i18n ("Drag to draw."); | ||
118 | } | 120 | } | ||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | 176 | { | |||
192 | // rounded rectangle --> rounded square | 194 | // rounded rectangle --> rounded square | ||
193 | // ellipse --> circle | 195 | // ellipse --> circle | ||
194 | if (shiftPressed ()) | 196 | if (shiftPressed ()) | ||
195 | { | 197 | { | ||
196 | if (!controlPressed ()) | 198 | if (!controlPressed ()) | ||
197 | { | 199 | { | ||
198 | if (rect.width () < rect.height ()) | 200 | if (rect.width () < rect.height ()) | ||
199 | { | 201 | { | ||
200 | if (startPoint ().y () == rect.y ()) | 202 | if (startPoint ().y () == rect.y ()) { | ||
201 | rect.setHeight (rect.width ()); | 203 | rect.setHeight (rect.width ()); | ||
202 | else | 204 | } | ||
205 | else { | ||||
203 | rect.setY (rect.bottom () - rect.width () + 1); | 206 | rect.setY (rect.bottom () - rect.width () + 1); | ||
204 | } | 207 | } | ||
208 | } | ||||
205 | else | 209 | else | ||
206 | { | 210 | { | ||
207 | if (startPoint ().x () == rect.x ()) | 211 | if (startPoint ().x () == rect.x ()) { | ||
208 | rect.setWidth (rect.height ()); | 212 | rect.setWidth (rect.height ()); | ||
209 | else | 213 | } | ||
214 | else { | ||||
210 | rect.setX (rect.right () - rect.height () + 1); | 215 | rect.setX (rect.right () - rect.height () + 1); | ||
211 | } | 216 | } | ||
212 | } | 217 | } | ||
218 | } | ||||
213 | // have to maintain the center | 219 | // have to maintain the center | ||
214 | else | 220 | else | ||
215 | { | 221 | { | ||
216 | if (rect.width () < rect.height ()) | 222 | if (rect.width () < rect.height ()) | ||
217 | { | 223 | { | ||
218 | QPoint center = rect.center (); | 224 | QPoint center = rect.center (); | ||
219 | rect.setHeight (rect.width ()); | 225 | rect.setHeight (rect.width ()); | ||
220 | rect.moveCenter (center); | 226 | rect.moveCenter (center); | ||
▲ Show 20 Lines • Show All 153 Lines • Show Last 20 Lines |