Changeset View
Changeset View
Standalone View
Standalone View
mainWindow/kpMainWindow_Image.cpp
Show First 20 Lines • Show All 229 Lines • ▼ Show 20 Line(s) | 228 | const QString MenuBarItemTextImage = i18nc ( | |||
---|---|---|---|---|---|
230 | " the same accel as the Select&ion translation", | 230 | " the same accel as the Select&ion translation", | ||
231 | "&Image"); | 231 | "&Image"); | ||
232 | const QString MenuBarItemTextSelection = i18nc ( | 232 | const QString MenuBarItemTextSelection = i18nc ( | ||
233 | "Image/Selection Menu caption - make sure that translation has" | 233 | "Image/Selection Menu caption - make sure that translation has" | ||
234 | " the same accel as the &Image translation", | 234 | " the same accel as the &Image translation", | ||
235 | "Select&ion"); | 235 | "Select&ion"); | ||
236 | 236 | | |||
237 | Q_ASSERT (menuBar ()); | 237 | Q_ASSERT (menuBar ()); | ||
238 | foreach (QAction *action, menuBar ()->actions ()) | 238 | for (auto *action : menuBar ()->actions ()) | ||
239 | { | 239 | { | ||
240 | if (action->text () == MenuBarItemTextImage || | 240 | if (action->text () == MenuBarItemTextImage || | ||
241 | action->text () == MenuBarItemTextSelection) | 241 | action->text () == MenuBarItemTextSelection) | ||
242 | { | 242 | { | ||
243 | if (isSelectionActive ()) | 243 | if (isSelectionActive ()) { | ||
244 | action->setText (MenuBarItemTextSelection); | 244 | action->setText (MenuBarItemTextSelection); | ||
245 | else | 245 | } | ||
246 | else { | ||||
246 | action->setText (MenuBarItemTextImage); | 247 | action->setText (MenuBarItemTextImage); | ||
248 | } | ||||
247 | 249 | | |||
248 | break; | 250 | break; | ||
249 | } | 251 | } | ||
250 | } | 252 | } | ||
251 | 253 | | |||
252 | 254 | | |||
253 | d->actionResizeScale->setEnabled (d->imageMenuDocumentActionsEnabled); | 255 | d->actionResizeScale->setEnabled (d->imageMenuDocumentActionsEnabled); | ||
254 | d->actionCrop->setEnabled (d->imageMenuDocumentActionsEnabled && | 256 | d->actionCrop->setEnabled (d->imageMenuDocumentActionsEnabled && | ||
Show All 16 Lines | |||||
271 | d->actionMoreEffects->setEnabled (enable); | 273 | d->actionMoreEffects->setEnabled (enable); | ||
272 | } | 274 | } | ||
273 | 275 | | |||
274 | //--------------------------------------------------------------------- | 276 | //--------------------------------------------------------------------- | ||
275 | 277 | | |||
276 | // public | 278 | // public | ||
277 | kpColor kpMainWindow::backgroundColor (bool ofSelection) const | 279 | kpColor kpMainWindow::backgroundColor (bool ofSelection) const | ||
278 | { | 280 | { | ||
279 | if (ofSelection) | 281 | if (ofSelection) { | ||
280 | return kpColor::Transparent; | 282 | return kpColor::Transparent; | ||
281 | else | 283 | } | ||
282 | { | 284 | | ||
283 | Q_ASSERT (d->colorToolBar); | 285 | Q_ASSERT (d->colorToolBar); | ||
284 | return d->colorToolBar->backgroundColor (); | 286 | return d->colorToolBar->backgroundColor (); | ||
285 | } | 287 | } | ||
286 | } | | |||
287 | 288 | | |||
288 | //--------------------------------------------------------------------- | 289 | //--------------------------------------------------------------------- | ||
289 | 290 | | |||
290 | // public | 291 | // public | ||
291 | // REFACTOR: sync: Code dup with kpAbstractSelectionTool::addNeedingContentCommand(). | 292 | // REFACTOR: sync: Code dup with kpAbstractSelectionTool::addNeedingContentCommand(). | ||
292 | void kpMainWindow::addImageOrSelectionCommand (kpCommand *cmd, | 293 | void kpMainWindow::addImageOrSelectionCommand (kpCommand *cmd, | ||
293 | bool addSelCreateCmdIfSelAvail, | 294 | bool addSelCreateCmdIfSelAvail, | ||
294 | bool addSelContentCmdIfSelAvail) | 295 | bool addSelContentCmdIfSelAvail) | ||
295 | { | 296 | { | ||
296 | qCDebug(kpLogMainWindow) << "kpMainWindow::addImageOrSelectionCommand()" | 297 | qCDebug(kpLogMainWindow) << "kpMainWindow::addImageOrSelectionCommand()" | ||
297 | << " addSelCreateCmdIfSelAvail=" << addSelCreateCmdIfSelAvail | 298 | << " addSelCreateCmdIfSelAvail=" << addSelCreateCmdIfSelAvail | ||
298 | << " addSelContentCmdIfSelAvail=" << addSelContentCmdIfSelAvail | 299 | << " addSelContentCmdIfSelAvail=" << addSelContentCmdIfSelAvail; | ||
299 | << endl; | | |||
300 | 300 | | |||
301 | Q_ASSERT (d->document); | 301 | Q_ASSERT (d->document); | ||
302 | 302 | | |||
303 | 303 | | |||
304 | if (d->viewManager) | 304 | if (d->viewManager) { | ||
305 | d->viewManager->setQueueUpdates (); | 305 | d->viewManager->setQueueUpdates (); | ||
306 | } | ||||
306 | 307 | | |||
307 | 308 | | |||
308 | kpAbstractSelection *sel = d->document->selection (); | 309 | kpAbstractSelection *sel = d->document->selection (); | ||
309 | qCDebug(kpLogMainWindow) << "\timage sel=" << sel | 310 | qCDebug(kpLogMainWindow) << "\timage sel=" << sel | ||
310 | << " sel->hasContent=" << (sel ? sel->hasContent () : 0) | 311 | << " sel->hasContent=" << (sel ? sel->hasContent () : 0); | ||
311 | << endl; | | |||
312 | if (addSelCreateCmdIfSelAvail && sel && !sel->hasContent ()) | 312 | if (addSelCreateCmdIfSelAvail && sel && !sel->hasContent ()) | ||
313 | { | 313 | { | ||
314 | QString createCmdName; | 314 | QString createCmdName; | ||
315 | 315 | | |||
316 | if (dynamic_cast <kpAbstractImageSelection *> (sel)) | 316 | if (dynamic_cast <kpAbstractImageSelection *> (sel)) { | ||
317 | createCmdName = i18n ("Selection: Create"); | 317 | createCmdName = i18n ("Selection: Create"); | ||
318 | else if (dynamic_cast <kpTextSelection *> (sel)) | 318 | } | ||
319 | else if (dynamic_cast <kpTextSelection *> (sel)) { | ||||
319 | createCmdName = i18n ("Text: Create Box"); | 320 | createCmdName = i18n ("Text: Create Box"); | ||
320 | else | 321 | } | ||
322 | else { | ||||
321 | Q_ASSERT (!"Unknown selection type"); | 323 | Q_ASSERT (!"Unknown selection type"); | ||
324 | } | ||||
322 | 325 | | |||
323 | // create selection region | 326 | // create selection region | ||
324 | commandHistory ()->addCreateSelectionCommand ( | 327 | commandHistory ()->addCreateSelectionCommand ( | ||
325 | new kpToolSelectionCreateCommand ( | 328 | new kpToolSelectionCreateCommand ( | ||
326 | createCmdName, | 329 | createCmdName, | ||
327 | *sel, | 330 | *sel, | ||
328 | commandEnvironment ()), | 331 | commandEnvironment ()), | ||
329 | false/*no exec - user already dragged out sel*/); | 332 | false/*no exec - user already dragged out sel*/); | ||
330 | } | 333 | } | ||
331 | 334 | | |||
332 | 335 | | |||
333 | if (addSelContentCmdIfSelAvail && sel && !sel->hasContent ()) | 336 | if (addSelContentCmdIfSelAvail && sel && !sel->hasContent ()) | ||
334 | { | 337 | { | ||
335 | kpAbstractImageSelection *imageSel = | 338 | auto *imageSel = dynamic_cast <kpAbstractImageSelection *> (sel); | ||
336 | dynamic_cast <kpAbstractImageSelection *> (sel); | 339 | auto *textSel = dynamic_cast <kpTextSelection *> (sel); | ||
337 | kpTextSelection *textSel = | | |||
338 | dynamic_cast <kpTextSelection *> (sel); | | |||
339 | 340 | | |||
340 | if (imageSel && imageSel->transparency ().isTransparent ()) | 341 | if (imageSel && imageSel->transparency ().isTransparent ()) { | ||
341 | d->colorToolBar->flashColorSimilarityToolBarItem (); | 342 | d->colorToolBar->flashColorSimilarityToolBarItem (); | ||
343 | } | ||||
342 | 344 | | |||
343 | kpMacroCommand *macroCmd = new kpMacroCommand (cmd->name (), | 345 | kpMacroCommand *macroCmd = new kpMacroCommand (cmd->name (), | ||
344 | commandEnvironment ()); | 346 | commandEnvironment ()); | ||
345 | 347 | | |||
346 | if (imageSel) | 348 | if (imageSel) | ||
347 | { | 349 | { | ||
348 | macroCmd->addCommand ( | 350 | macroCmd->addCommand ( | ||
349 | new kpToolSelectionPullFromDocumentCommand ( | 351 | new kpToolSelectionPullFromDocumentCommand ( | ||
350 | *imageSel, | 352 | *imageSel, | ||
351 | backgroundColor (), | 353 | backgroundColor (), | ||
352 | QString()/*uninteresting child of macro cmd*/, | 354 | QString()/*uninteresting child of macro cmd*/, | ||
353 | commandEnvironment ())); | 355 | commandEnvironment ())); | ||
354 | } | 356 | } | ||
355 | else if (textSel) | 357 | else if (textSel) | ||
356 | { | 358 | { | ||
357 | macroCmd->addCommand ( | 359 | macroCmd->addCommand ( | ||
358 | new kpToolTextGiveContentCommand ( | 360 | new kpToolTextGiveContentCommand ( | ||
359 | *textSel, | 361 | *textSel, | ||
360 | QString()/*uninteresting child of macro cmd*/, | 362 | QString()/*uninteresting child of macro cmd*/, | ||
361 | commandEnvironment ())); | 363 | commandEnvironment ())); | ||
362 | } | 364 | } | ||
363 | else | 365 | else { | ||
364 | Q_ASSERT (!"Unknown selection type"); | 366 | Q_ASSERT (!"Unknown selection type"); | ||
367 | } | ||||
365 | 368 | | |||
366 | macroCmd->addCommand (cmd); | 369 | macroCmd->addCommand (cmd); | ||
367 | 370 | | |||
368 | d->commandHistory->addCommand (macroCmd); | 371 | d->commandHistory->addCommand (macroCmd); | ||
369 | } | 372 | } | ||
370 | else | 373 | else | ||
371 | { | 374 | { | ||
372 | d->commandHistory->addCommand (cmd); | 375 | d->commandHistory->addCommand (cmd); | ||
373 | } | 376 | } | ||
374 | 377 | | |||
375 | 378 | | |||
376 | if (d->viewManager) | 379 | if (d->viewManager) { | ||
377 | d->viewManager->restoreQueueUpdates (); | 380 | d->viewManager->restoreQueueUpdates (); | ||
378 | } | 381 | } | ||
382 | } | ||||
379 | 383 | | |||
380 | //--------------------------------------------------------------------- | 384 | //--------------------------------------------------------------------- | ||
381 | 385 | | |||
382 | // private slot | 386 | // private slot | ||
383 | void kpMainWindow::slotResizeScale () | 387 | void kpMainWindow::slotResizeScale () | ||
384 | { | 388 | { | ||
385 | toolEndShape (); | 389 | toolEndShape (); | ||
386 | 390 | | |||
387 | kpTransformResizeScaleDialog dialog(transformDialogEnvironment(), this); | 391 | kpTransformResizeScaleDialog dialog(transformDialogEnvironment(), this); | ||
388 | 392 | | |||
389 | if (dialog.exec () && !dialog.isNoOp ()) | 393 | if (dialog.exec () && !dialog.isNoOp ()) | ||
390 | { | 394 | { | ||
391 | kpTransformResizeScaleCommand *cmd = new kpTransformResizeScaleCommand ( | 395 | auto *cmd = new kpTransformResizeScaleCommand ( | ||
392 | dialog.actOnSelection (), | 396 | dialog.actOnSelection (), | ||
393 | dialog.imageWidth (), dialog.imageHeight (), | 397 | dialog.imageWidth (), dialog.imageHeight (), | ||
394 | dialog.type (), | 398 | dialog.type (), | ||
395 | commandEnvironment ()); | 399 | commandEnvironment ()); | ||
396 | 400 | | |||
397 | bool addSelCreateCommand = (dialog.actOnSelection () || | 401 | bool addSelCreateCommand = (dialog.actOnSelection () || | ||
398 | cmd->scaleSelectionWithImage ()); | 402 | cmd->scaleSelectionWithImage ()); | ||
399 | bool addSelContentCommand = dialog.actOnSelection (); | 403 | bool addSelContentCommand = dialog.actOnSelection (); | ||
▲ Show 20 Lines • Show All 218 Lines • Show Last 20 Lines |