Changeset View
Changeset View
Standalone View
Standalone View
widgets/toolbars/options/kpToolWidgetBrush.cpp
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | |||||
54 | #define BRUSH_SIZE_NUM_COLS (int (sizeof (::BrushSizes [0]) / sizeof (::BrushSizes [0][0]))) | 54 | #define BRUSH_SIZE_NUM_COLS (int (sizeof (::BrushSizes [0]) / sizeof (::BrushSizes [0][0]))) | ||
55 | #define BRUSH_SIZE_NUM_ROWS (int (sizeof (::BrushSizes) / sizeof (::BrushSizes [0]))) | 55 | #define BRUSH_SIZE_NUM_ROWS (int (sizeof (::BrushSizes) / sizeof (::BrushSizes [0]))) | ||
56 | 56 | | |||
57 | 57 | | |||
58 | //--------------------------------------------------------------------- | 58 | //--------------------------------------------------------------------- | ||
59 | 59 | | |||
60 | static void Draw (kpImage *destImage, const QPoint &topLeft, void *userData) | 60 | static void Draw (kpImage *destImage, const QPoint &topLeft, void *userData) | ||
61 | { | 61 | { | ||
62 | kpToolWidgetBrush::DrawPackage *pack = | 62 | auto *pack = static_cast <kpToolWidgetBrush::DrawPackage *> (userData); | ||
63 | static_cast <kpToolWidgetBrush::DrawPackage *> (userData); | | |||
64 | 63 | | |||
65 | #if DEBUG_KP_TOOL_WIDGET_BRUSH | 64 | #if DEBUG_KP_TOOL_WIDGET_BRUSH | ||
66 | qCDebug(kpLogWidgets) << "kptoolwidgetbrush.cpp:Draw(destImage,topLeft=" | 65 | qCDebug(kpLogWidgets) << "kptoolwidgetbrush.cpp:Draw(destImage,topLeft=" | ||
67 | << topLeft << " pack: row=" << pack->row << " col=" << pack->col | 66 | << topLeft << " pack: row=" << pack->row << " col=" << pack->col | ||
68 | << " color=" << (int *) pack->color.toQRgb () | 67 | << " color=" << (int *) pack->color.toQRgb (); | ||
69 | << endl; | | |||
70 | #endif | 68 | #endif | ||
71 | const int size = ::BrushSizes [pack->row][pack->col]; | 69 | const int size = ::BrushSizes [pack->row][pack->col]; | ||
72 | #if DEBUG_KP_TOOL_WIDGET_BRUSH | 70 | #if DEBUG_KP_TOOL_WIDGET_BRUSH | ||
73 | qCDebug(kpLogWidgets) << "\tsize=" << size; | 71 | qCDebug(kpLogWidgets) << "\tsize=" << size; | ||
74 | #endif | 72 | #endif | ||
75 | 73 | | |||
76 | QPainter painter(destImage); | 74 | QPainter painter(destImage); | ||
77 | 75 | | |||
▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Line(s) | 158 | { | |||
184 | startNewOptionRow (); | 182 | startNewOptionRow (); | ||
185 | } | 183 | } | ||
186 | 184 | | |||
187 | finishConstruction (0, 0); | 185 | finishConstruction (0, 0); | ||
188 | } | 186 | } | ||
189 | 187 | | |||
190 | //--------------------------------------------------------------------- | 188 | //--------------------------------------------------------------------- | ||
191 | 189 | | |||
192 | kpToolWidgetBrush::~kpToolWidgetBrush () | 190 | kpToolWidgetBrush::~kpToolWidgetBrush () = default; | ||
193 | { | | |||
194 | } | | |||
195 | 191 | | |||
196 | //--------------------------------------------------------------------- | 192 | //--------------------------------------------------------------------- | ||
197 | 193 | | |||
198 | // private | 194 | // private | ||
199 | QString kpToolWidgetBrush::brushName (int shape, int whichSize) const | 195 | QString kpToolWidgetBrush::brushName (int shape, int whichSize) const | ||
200 | { | 196 | { | ||
201 | int s = ::BrushSizes [shape][whichSize]; | 197 | int s = ::BrushSizes [shape][whichSize]; | ||
202 | 198 | | |||
203 | if (s == 1) | 199 | if (s == 1) { | ||
204 | return i18n ("1x1"); | 200 | return i18n ("1x1"); | ||
201 | } | ||||
205 | 202 | | |||
206 | QString shapeName; | 203 | QString shapeName; | ||
207 | 204 | | |||
208 | // sync: <brushes> | 205 | // sync: <brushes> | ||
209 | switch (shape) | 206 | switch (shape) | ||
210 | { | 207 | { | ||
211 | case 0: | 208 | case 0: | ||
212 | shapeName = i18n ("Circle"); | 209 | shapeName = i18n ("Circle"); | ||
213 | break; | 210 | break; | ||
214 | case 1: | 211 | case 1: | ||
215 | shapeName = i18n ("Square"); | 212 | shapeName = i18n ("Square"); | ||
216 | break; | 213 | break; | ||
217 | case 2: | 214 | case 2: | ||
218 | // TODO: is this really the name of a shape? :) | 215 | // TODO: is this really the name of a shape? :) | ||
219 | shapeName = i18n ("Slash"); | 216 | shapeName = i18n ("Slash"); | ||
220 | break; | 217 | break; | ||
221 | case 3: | 218 | case 3: | ||
222 | // TODO: is this really the name of a shape? :) | 219 | // TODO: is this really the name of a shape? :) | ||
223 | shapeName = i18n ("Backslash"); | 220 | shapeName = i18n ("Backslash"); | ||
224 | break; | 221 | break; | ||
225 | } | 222 | } | ||
226 | 223 | | |||
227 | if (shapeName.isEmpty ()) | 224 | if (shapeName.isEmpty ()) { | ||
228 | return QString(); | 225 | return {}; | ||
226 | } | ||||
229 | 227 | | |||
230 | return i18n ("%1x%2 %3", s, s, shapeName); | 228 | return i18n ("%1x%2 %3", s, s, shapeName); | ||
231 | } | 229 | } | ||
232 | 230 | | |||
233 | //--------------------------------------------------------------------- | 231 | //--------------------------------------------------------------------- | ||
234 | 232 | | |||
235 | // public | 233 | // public | ||
236 | int kpToolWidgetBrush::brushSize () const | 234 | int kpToolWidgetBrush::brushSize () const | ||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | |||||
284 | } | 282 | } | ||
285 | 283 | | |||
286 | //--------------------------------------------------------------------- | 284 | //--------------------------------------------------------------------- | ||
287 | 285 | | |||
288 | // protected slot virtual [base kpToolWidgetBase] | 286 | // protected slot virtual [base kpToolWidgetBase] | ||
289 | bool kpToolWidgetBrush::setSelected (int row, int col, bool saveAsDefault) | 287 | bool kpToolWidgetBrush::setSelected (int row, int col, bool saveAsDefault) | ||
290 | { | 288 | { | ||
291 | const bool ret = kpToolWidgetBase::setSelected (row, col, saveAsDefault); | 289 | const bool ret = kpToolWidgetBase::setSelected (row, col, saveAsDefault); | ||
292 | if (ret) | 290 | if (ret) { | ||
293 | emit brushChanged (); | 291 | emit brushChanged (); | ||
292 | } | ||||
294 | return ret; | 293 | return ret; | ||
295 | } | 294 | } | ||
296 | 295 | | |||
297 | //--------------------------------------------------------------------- | 296 | //--------------------------------------------------------------------- | ||
298 | 297 | |