File indexing completed on 2024-04-28 04:20:21
0001 0002 /* 0003 Copyright (c) 2003-2007 Clarence Dang <dang@kde.org> 0004 All rights reserved. 0005 0006 Redistribution and use in source and binary forms, with or without 0007 modification, are permitted provided that the following conditions 0008 are met: 0009 0010 1. Redistributions of source code must retain the above copyright 0011 notice, this list of conditions and the following disclaimer. 0012 2. Redistributions in binary form must reproduce the above copyright 0013 notice, this list of conditions and the following disclaimer in the 0014 documentation and/or other materials provided with the distribution. 0015 0016 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 0017 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 0018 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 0019 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 0020 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 0021 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0022 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0023 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0024 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 0025 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0026 */ 0027 0028 0029 #include "mainWindow/kpMainWindow.h" 0030 #include "kpMainWindowPrivate.h" 0031 0032 #include "layers/selections/image/kpAbstractImageSelection.h" 0033 #include "imagelib/kpColor.h" 0034 #include "kpDefs.h" 0035 #include "widgets/toolbars/kpColorToolBar.h" 0036 #include "commands/kpCommandHistory.h" 0037 #include "document/kpDocument.h" 0038 #include "commands/imagelib/effects/kpEffectInvertCommand.h" 0039 #include "commands/imagelib/effects/kpEffectReduceColorsCommand.h" 0040 #include "dialogs/imagelib/effects/kpEffectsDialog.h" 0041 #include "commands/imagelib/effects/kpEffectClearCommand.h" 0042 #include "commands/imagelib/effects/kpEffectGrayscaleCommand.h" 0043 #include "commands/kpMacroCommand.h" 0044 #include "layers/selections/text/kpTextSelection.h" 0045 #include "commands/tools/selection/kpToolSelectionCreateCommand.h" 0046 #include "commands/tools/selection/kpToolSelectionPullFromDocumentCommand.h" 0047 #include "commands/tools/selection/text/kpToolTextGiveContentCommand.h" 0048 #include "imagelib/transforms/kpTransformAutoCrop.h" 0049 #include "imagelib/transforms/kpTransformCrop.h" 0050 #include "environments/dialogs/imagelib/transforms/kpTransformDialogEnvironment.h" 0051 #include "commands/imagelib/transforms/kpTransformFlipCommand.h" 0052 #include "commands/imagelib/transforms/kpTransformResizeScaleCommand.h" 0053 #include "dialogs/imagelib/transforms/kpTransformResizeScaleDialog.h" 0054 #include "commands/imagelib/transforms/kpTransformRotateCommand.h" 0055 #include "dialogs/imagelib/transforms/kpTransformRotateDialog.h" 0056 #include "commands/imagelib/transforms/kpTransformSkewCommand.h" 0057 #include "dialogs/imagelib/transforms/kpTransformSkewDialog.h" 0058 #include "views/manager/kpViewManager.h" 0059 #include "commands/imagelib/effects/kpEffectBlurSharpenCommand.h" 0060 #include "imagelib/effects/kpEffectBlurSharpen.h" 0061 #include "kpLogCategories.h" 0062 0063 #include <KActionCollection> 0064 #include <KSharedConfig> 0065 #include <KConfigGroup> 0066 #include <KLocalizedString> 0067 0068 #include <QAction> 0069 #include <QMenuBar> 0070 #include <QSize> 0071 0072 0073 //--------------------------------------------------------------------- 0074 0075 // private 0076 kpTransformDialogEnvironment *kpMainWindow::transformDialogEnvironment () 0077 { 0078 if (!d->transformDialogEnvironment) 0079 d->transformDialogEnvironment = new kpTransformDialogEnvironment (this); 0080 0081 return d->transformDialogEnvironment; 0082 } 0083 0084 //--------------------------------------------------------------------- 0085 0086 // private 0087 bool kpMainWindow::isSelectionActive () const 0088 { 0089 return (d->document ? bool (d->document->selection ()) : false); 0090 } 0091 0092 //--------------------------------------------------------------------- 0093 0094 // private 0095 bool kpMainWindow::isTextSelection () const 0096 { 0097 return (d->document && d->document->textSelection ()); 0098 } 0099 0100 //--------------------------------------------------------------------- 0101 0102 // private 0103 QString kpMainWindow::autoCropText () const 0104 { 0105 return kpTransformAutoCropCommand::text(isSelectionActive(), 0106 kpTransformAutoCropCommand::ShowAccel); 0107 } 0108 0109 //--------------------------------------------------------------------- 0110 0111 // private 0112 void kpMainWindow::setupImageMenuActions () 0113 { 0114 KActionCollection *ac = actionCollection (); 0115 0116 d->actionResizeScale = ac->addAction (QStringLiteral("image_resize_scale")); 0117 d->actionResizeScale->setText (i18n ("R&esize / Scale...")); 0118 connect (d->actionResizeScale, &QAction::triggered, this, &kpMainWindow::slotResizeScale); 0119 0120 ac->setDefaultShortcut (d->actionResizeScale, Qt::CTRL | Qt::Key_E); 0121 0122 d->actionCrop = ac->addAction (QStringLiteral("image_crop")); 0123 d->actionCrop->setText (i18n ("Se&t as Image (Crop)")); 0124 connect (d->actionCrop, &QAction::triggered, this, &kpMainWindow::slotCrop); 0125 ac->setDefaultShortcut (d->actionCrop, Qt::CTRL | Qt::Key_T); 0126 0127 d->actionAutoCrop = ac->addAction (QStringLiteral("image_auto_crop")); 0128 d->actionAutoCrop->setText (autoCropText ()); 0129 connect (d->actionAutoCrop, &QAction::triggered, this, &kpMainWindow::slotAutoCrop); 0130 ac->setDefaultShortcut (d->actionAutoCrop, Qt::CTRL | Qt::Key_U); 0131 0132 d->actionFlip = ac->addAction (QStringLiteral("image_flip")); 0133 d->actionFlip->setText (i18n ("&Flip (upside down)")); 0134 connect (d->actionFlip, &QAction::triggered, this, &kpMainWindow::slotFlip); 0135 ac->setDefaultShortcut (d->actionFlip, Qt::CTRL | Qt::Key_F); 0136 0137 d->actionMirror = ac->addAction (QStringLiteral("image_mirror")); 0138 d->actionMirror->setText (i18n ("Mirror (horizontally)")); 0139 connect (d->actionMirror, &QAction::triggered, this, &kpMainWindow::slotMirror); 0140 //ac->setDefaultShortcut (d->actionMirror, Qt::CTRL | Qt::Key_M); 0141 0142 d->actionRotate = ac->addAction (QStringLiteral("image_rotate")); 0143 d->actionRotate->setText (i18n ("&Rotate...")); 0144 d->actionRotate->setIcon(QIcon::fromTheme(QStringLiteral("transform-rotate"))); 0145 connect (d->actionRotate, &QAction::triggered, this, &kpMainWindow::slotRotate); 0146 ac->setDefaultShortcut (d->actionRotate, Qt::CTRL | Qt::Key_R); 0147 0148 d->actionRotateLeft = ac->addAction (QStringLiteral("image_rotate_270deg")); 0149 d->actionRotateLeft->setText (i18n ("Rotate &Left")); 0150 d->actionRotateLeft->setIcon(QIcon::fromTheme(QStringLiteral("object-rotate-left"))); 0151 connect (d->actionRotateLeft, &QAction::triggered, this, &kpMainWindow::slotRotate270); 0152 ac->setDefaultShortcut (d->actionRotateLeft, Qt::CTRL | Qt::SHIFT | Qt::Key_Left); 0153 0154 d->actionRotateRight = ac->addAction (QStringLiteral("image_rotate_90deg")); 0155 d->actionRotateRight->setText (i18n ("Rotate Righ&t")); 0156 d->actionRotateRight->setIcon(QIcon::fromTheme(QStringLiteral("object-rotate-right"))); 0157 connect (d->actionRotateRight, &QAction::triggered, this, &kpMainWindow::slotRotate90); 0158 ac->setDefaultShortcut (d->actionRotateRight, Qt::CTRL | Qt::SHIFT | Qt::Key_Right); 0159 0160 d->actionSkew = ac->addAction (QStringLiteral("image_skew")); 0161 d->actionSkew->setText (i18n ("S&kew...")); 0162 connect (d->actionSkew, &QAction::triggered, this, &kpMainWindow::slotSkew); 0163 ac->setDefaultShortcut (d->actionSkew, Qt::CTRL | Qt::Key_K); 0164 0165 d->actionConvertToBlackAndWhite = ac->addAction (QStringLiteral("image_convert_to_black_and_white")); 0166 d->actionConvertToBlackAndWhite->setText (i18n ("Reduce to Mo&nochrome (Dithered)")); 0167 connect (d->actionConvertToBlackAndWhite, &QAction::triggered, 0168 this, &kpMainWindow::slotConvertToBlackAndWhite); 0169 0170 d->actionConvertToGrayscale = ac->addAction (QStringLiteral("image_convert_to_grayscale")); 0171 d->actionConvertToGrayscale->setText (i18n ("Reduce to &Grayscale")); 0172 connect (d->actionConvertToGrayscale, &QAction::triggered, this, &kpMainWindow::slotConvertToGrayscale); 0173 0174 d->actionInvertColors = ac->addAction (QStringLiteral("image_invert_colors")); 0175 d->actionInvertColors->setText (i18n ("&Invert Colors")); 0176 connect (d->actionInvertColors, &QAction::triggered, this, &kpMainWindow::slotInvertColors); 0177 ac->setDefaultShortcut (d->actionInvertColors, Qt::CTRL | Qt::Key_I); 0178 0179 d->actionClear = ac->addAction (QStringLiteral("image_clear")); 0180 d->actionClear->setText (i18n ("C&lear")); 0181 connect (d->actionClear, &QAction::triggered, this, &kpMainWindow::slotClear); 0182 ac->setDefaultShortcut (d->actionClear, Qt::CTRL | Qt::SHIFT | Qt::Key_N); 0183 0184 d->actionBlur = ac->addAction(QStringLiteral("image_make_confidential")); 0185 d->actionBlur->setText(i18n("Make Confidential")); 0186 connect(d->actionBlur, &QAction::triggered, this, &kpMainWindow::slotMakeConfidential); 0187 0188 d->actionMoreEffects = ac->addAction (QStringLiteral("image_more_effects")); 0189 d->actionMoreEffects->setText (i18n ("&More Effects...")); 0190 connect (d->actionMoreEffects, &QAction::triggered, this, &kpMainWindow::slotMoreEffects); 0191 ac->setDefaultShortcut (d->actionMoreEffects, Qt::CTRL | Qt::Key_M); 0192 0193 0194 enableImageMenuDocumentActions (false); 0195 } 0196 0197 //--------------------------------------------------------------------- 0198 0199 // private 0200 void kpMainWindow::enableImageMenuDocumentActions (bool enable) 0201 { 0202 d->actionResizeScale->setEnabled (enable); 0203 d->actionCrop->setEnabled (enable); 0204 d->actionAutoCrop->setEnabled (enable); 0205 d->actionFlip->setEnabled (enable); 0206 d->actionMirror->setEnabled (enable); 0207 d->actionRotate->setEnabled (enable); 0208 d->actionRotateLeft->setEnabled (enable); 0209 d->actionRotateRight->setEnabled (enable); 0210 d->actionSkew->setEnabled (enable); 0211 d->actionConvertToBlackAndWhite->setEnabled (enable); 0212 d->actionConvertToGrayscale->setEnabled (enable); 0213 d->actionInvertColors->setEnabled (enable); 0214 d->actionClear->setEnabled (enable); 0215 d->actionBlur->setEnabled (enable); 0216 d->actionMoreEffects->setEnabled (enable); 0217 0218 d->imageMenuDocumentActionsEnabled = enable; 0219 } 0220 0221 //--------------------------------------------------------------------- 0222 0223 // private slot 0224 void kpMainWindow::slotImageMenuUpdateDueToSelection () 0225 { 0226 // SYNC: kolourpaintui.rc 0227 const QString MenuBarItemTextImage = i18nc ( 0228 "Image/Selection Menu caption - make sure the translation has" 0229 " the same accel as the Select&ion translation", 0230 "&Image"); 0231 const QString MenuBarItemTextSelection = i18nc ( 0232 "Image/Selection Menu caption - make sure that translation has" 0233 " the same accel as the &Image translation", 0234 "Select&ion"); 0235 0236 Q_ASSERT (menuBar ()); 0237 for (auto *action : menuBar ()->actions ()) 0238 { 0239 if (action->text () == MenuBarItemTextImage || 0240 action->text () == MenuBarItemTextSelection) 0241 { 0242 if (isSelectionActive ()) { 0243 action->setText (MenuBarItemTextSelection); 0244 } 0245 else { 0246 action->setText (MenuBarItemTextImage); 0247 } 0248 0249 break; 0250 } 0251 } 0252 0253 0254 d->actionResizeScale->setEnabled (d->imageMenuDocumentActionsEnabled); 0255 d->actionCrop->setEnabled (d->imageMenuDocumentActionsEnabled && 0256 isSelectionActive ()); 0257 0258 const bool enable = (d->imageMenuDocumentActionsEnabled && !isTextSelection ()); 0259 d->actionAutoCrop->setText (autoCropText ()); 0260 d->actionAutoCrop->setEnabled (enable); 0261 d->actionFlip->setEnabled (enable); 0262 d->actionMirror->setEnabled (enable); 0263 d->actionRotate->setEnabled (enable); 0264 d->actionRotateLeft->setEnabled (enable); 0265 d->actionRotateRight->setEnabled (enable); 0266 d->actionSkew->setEnabled (enable); 0267 d->actionConvertToBlackAndWhite->setEnabled (enable); 0268 d->actionConvertToGrayscale->setEnabled (enable); 0269 d->actionInvertColors->setEnabled (enable); 0270 d->actionClear->setEnabled (enable); 0271 d->actionBlur->setEnabled (enable); 0272 d->actionMoreEffects->setEnabled (enable); 0273 } 0274 0275 //--------------------------------------------------------------------- 0276 0277 // public 0278 kpColor kpMainWindow::backgroundColor (bool ofSelection) const 0279 { 0280 if (ofSelection) { 0281 return kpColor::Transparent; 0282 } 0283 0284 Q_ASSERT (d->colorToolBar); 0285 return d->colorToolBar->backgroundColor (); 0286 } 0287 0288 //--------------------------------------------------------------------- 0289 0290 // public 0291 // REFACTOR: sync: Code dup with kpAbstractSelectionTool::addNeedingContentCommand(). 0292 void kpMainWindow::addImageOrSelectionCommand (kpCommand *cmd, 0293 bool addSelCreateCmdIfSelAvail, 0294 bool addSelContentCmdIfSelAvail) 0295 { 0296 #if DEBUG_KP_MAIN_WINDOW && 1 0297 qCDebug(kpLogMainWindow) << "kpMainWindow::addImageOrSelectionCommand()" 0298 << " addSelCreateCmdIfSelAvail=" << addSelCreateCmdIfSelAvail 0299 << " addSelContentCmdIfSelAvail=" << addSelContentCmdIfSelAvail; 0300 #endif 0301 0302 Q_ASSERT (d->document); 0303 0304 0305 if (d->viewManager) { 0306 d->viewManager->setQueueUpdates (); 0307 } 0308 0309 0310 kpAbstractSelection *sel = d->document->selection (); 0311 #if DEBUG_KP_MAIN_WINDOW && 1 0312 qCDebug(kpLogMainWindow) << "\timage sel=" << sel 0313 << " sel->hasContent=" << (sel ? sel->hasContent () : 0); 0314 #endif 0315 if (addSelCreateCmdIfSelAvail && sel && !sel->hasContent ()) 0316 { 0317 QString createCmdName; 0318 0319 if (dynamic_cast <kpAbstractImageSelection *> (sel)) { 0320 createCmdName = i18n ("Selection: Create"); 0321 } 0322 else if (dynamic_cast <kpTextSelection *> (sel)) { 0323 createCmdName = i18n ("Text: Create Box"); 0324 } 0325 else { 0326 Q_ASSERT (!"Unknown selection type"); 0327 } 0328 0329 // create selection region 0330 commandHistory ()->addCreateSelectionCommand ( 0331 new kpToolSelectionCreateCommand ( 0332 createCmdName, 0333 *sel, 0334 commandEnvironment ()), 0335 false/*no exec - user already dragged out sel*/); 0336 } 0337 0338 0339 if (addSelContentCmdIfSelAvail && sel && !sel->hasContent ()) 0340 { 0341 auto *imageSel = dynamic_cast <kpAbstractImageSelection *> (sel); 0342 auto *textSel = dynamic_cast <kpTextSelection *> (sel); 0343 0344 if (imageSel && imageSel->transparency ().isTransparent ()) { 0345 d->colorToolBar->flashColorSimilarityToolBarItem (); 0346 } 0347 0348 kpMacroCommand *macroCmd = new kpMacroCommand (cmd->name (), 0349 commandEnvironment ()); 0350 0351 if (imageSel) 0352 { 0353 macroCmd->addCommand ( 0354 new kpToolSelectionPullFromDocumentCommand ( 0355 *imageSel, 0356 backgroundColor (), 0357 QString()/*uninteresting child of macro cmd*/, 0358 commandEnvironment ())); 0359 } 0360 else if (textSel) 0361 { 0362 macroCmd->addCommand ( 0363 new kpToolTextGiveContentCommand ( 0364 *textSel, 0365 QString()/*uninteresting child of macro cmd*/, 0366 commandEnvironment ())); 0367 } 0368 else { 0369 Q_ASSERT (!"Unknown selection type"); 0370 } 0371 0372 macroCmd->addCommand (cmd); 0373 0374 d->commandHistory->addCommand (macroCmd); 0375 } 0376 else 0377 { 0378 d->commandHistory->addCommand (cmd); 0379 } 0380 0381 0382 if (d->viewManager) { 0383 d->viewManager->restoreQueueUpdates (); 0384 } 0385 } 0386 0387 //--------------------------------------------------------------------- 0388 0389 // private slot 0390 void kpMainWindow::slotResizeScale () 0391 { 0392 toolEndShape (); 0393 0394 kpTransformResizeScaleDialog dialog(transformDialogEnvironment(), this); 0395 0396 if (dialog.exec () && !dialog.isNoOp ()) 0397 { 0398 auto *cmd = new kpTransformResizeScaleCommand ( 0399 dialog.actOnSelection (), 0400 dialog.imageWidth (), dialog.imageHeight (), 0401 dialog.type (), 0402 commandEnvironment ()); 0403 0404 bool addSelCreateCommand = (dialog.actOnSelection () || 0405 cmd->scaleSelectionWithImage ()); 0406 bool addSelContentCommand = dialog.actOnSelection (); 0407 0408 addImageOrSelectionCommand ( 0409 cmd, 0410 addSelCreateCommand, 0411 addSelContentCommand); 0412 0413 // Resized document? 0414 if (!dialog.actOnSelection () && 0415 dialog.type () == kpTransformResizeScaleCommand::Resize) 0416 { 0417 // TODO: this should be the responsibility of kpDocument 0418 saveDefaultDocSize (QSize (dialog.imageWidth (), dialog.imageHeight ())); 0419 } 0420 } 0421 } 0422 0423 //--------------------------------------------------------------------- 0424 0425 // public slot 0426 void kpMainWindow::slotCrop () 0427 { 0428 toolEndShape (); 0429 0430 Q_ASSERT (d->document && d->document->selection ()); 0431 0432 0433 ::kpTransformCrop (this); 0434 } 0435 0436 //--------------------------------------------------------------------- 0437 0438 // private slot 0439 void kpMainWindow::slotAutoCrop () 0440 { 0441 toolEndShape (); 0442 0443 ::kpTransformAutoCrop (this); 0444 } 0445 0446 //--------------------------------------------------------------------- 0447 0448 // private slot 0449 void kpMainWindow::slotFlip() 0450 { 0451 toolEndShape(); 0452 0453 addImageOrSelectionCommand( 0454 new kpTransformFlipCommand(d->document->selection(), 0455 false, true, commandEnvironment())); 0456 } 0457 0458 //--------------------------------------------------------------------- 0459 0460 // private slot 0461 void kpMainWindow::slotMirror() 0462 { 0463 toolEndShape(); 0464 0465 addImageOrSelectionCommand( 0466 new kpTransformFlipCommand(d->document->selection(), 0467 true, false, commandEnvironment())); 0468 } 0469 0470 //--------------------------------------------------------------------- 0471 0472 // private slot 0473 void kpMainWindow::slotRotate () 0474 { 0475 toolEndShape (); 0476 0477 kpTransformRotateDialog dialog (static_cast<bool> (d->document->selection ()), 0478 transformDialogEnvironment (), this); 0479 0480 if (dialog.exec () && !dialog.isNoOp ()) 0481 { 0482 addImageOrSelectionCommand ( 0483 new kpTransformRotateCommand (d->document->selection (), 0484 dialog.angle (), 0485 commandEnvironment ())); 0486 } 0487 } 0488 0489 // private slot 0490 void kpMainWindow::slotRotate270 () 0491 { 0492 toolEndShape (); 0493 0494 // TODO: Special command name instead of just "Rotate"? 0495 addImageOrSelectionCommand ( 0496 new kpTransformRotateCommand ( 0497 d->document->selection (), 0498 270, 0499 commandEnvironment ())); 0500 } 0501 0502 // private slot 0503 void kpMainWindow::slotRotate90 () 0504 { 0505 toolEndShape (); 0506 0507 // TODO: Special command name instead of just "Rotate"? 0508 addImageOrSelectionCommand ( 0509 new kpTransformRotateCommand ( 0510 d->document->selection (), 0511 90, 0512 commandEnvironment ())); 0513 } 0514 0515 0516 // private slot 0517 void kpMainWindow::slotSkew () 0518 { 0519 toolEndShape (); 0520 0521 kpTransformSkewDialog dialog (static_cast<bool> (d->document->selection ()), 0522 transformDialogEnvironment (), this); 0523 0524 if (dialog.exec () && !dialog.isNoOp ()) 0525 { 0526 addImageOrSelectionCommand ( 0527 new kpTransformSkewCommand (d->document->selection (), 0528 dialog.horizontalAngle (), dialog.verticalAngle (), 0529 commandEnvironment ())); 0530 } 0531 } 0532 0533 //--------------------------------------------------------------------- 0534 0535 // private slot 0536 void kpMainWindow::slotConvertToBlackAndWhite () 0537 { 0538 toolEndShape (); 0539 0540 addImageOrSelectionCommand ( 0541 new kpEffectReduceColorsCommand (1/*depth*/, true/*dither*/, 0542 d->document->selection (), 0543 commandEnvironment ())); 0544 } 0545 0546 //--------------------------------------------------------------------- 0547 0548 // private slot 0549 void kpMainWindow::slotConvertToGrayscale () 0550 { 0551 toolEndShape (); 0552 0553 addImageOrSelectionCommand ( 0554 new kpEffectGrayscaleCommand (d->document->selection (), 0555 commandEnvironment ())); 0556 } 0557 0558 //-------------------------------------------------------------------------------- 0559 0560 // private slot 0561 void kpMainWindow::slotInvertColors () 0562 { 0563 toolEndShape (); 0564 0565 addImageOrSelectionCommand ( 0566 new kpEffectInvertCommand (d->document->selection (), 0567 commandEnvironment ())); 0568 } 0569 0570 //-------------------------------------------------------------------------------- 0571 0572 // private slot 0573 void kpMainWindow::slotClear () 0574 { 0575 toolEndShape (); 0576 0577 addImageOrSelectionCommand ( 0578 new kpEffectClearCommand ( 0579 d->document->selection (), 0580 backgroundColor (), 0581 commandEnvironment ())); 0582 } 0583 0584 //-------------------------------------------------------------------------------- 0585 0586 void kpMainWindow::slotMakeConfidential() 0587 { 0588 toolEndShape(); 0589 0590 addImageOrSelectionCommand( 0591 new kpEffectBlurSharpenCommand(kpEffectBlurSharpen::MakeConfidential, kpEffectBlurSharpen::MaxStrength, 0592 d->document->selection(), commandEnvironment())); 0593 } 0594 0595 //-------------------------------------------------------------------------------- 0596 0597 // private slot 0598 void kpMainWindow::slotMoreEffects () 0599 { 0600 toolEndShape (); 0601 0602 kpEffectsDialog dialog (static_cast<bool> (d->document->selection ()), 0603 transformDialogEnvironment (), this, 0604 d->moreEffectsDialogLastEffect); 0605 0606 if (dialog.exec () && !dialog.isNoOp ()) 0607 { 0608 addImageOrSelectionCommand (dialog.createCommand ()); 0609 } 0610 0611 0612 if (d->moreEffectsDialogLastEffect != dialog.selectedEffect ()) 0613 { 0614 d->moreEffectsDialogLastEffect = dialog.selectedEffect (); 0615 0616 KConfigGroup cfg (KSharedConfig::openConfig (), QStringLiteral(kpSettingsGroupGeneral)); 0617 0618 cfg.writeEntry (kpSettingMoreEffectsLastEffect, 0619 d->moreEffectsDialogLastEffect); 0620 cfg.sync (); 0621 } 0622 } 0623 0624 //--------------------------------------------------------------------------------