Commit 015d25f5 authored by Martin Koller's avatar Martin Koller

add a "make confidential" action which blurs the image/selection

FEATURE: 366436
parent 23d779e4
......@@ -59,13 +59,11 @@
//
static QImage BlurQImage (const QImage qimage_, int strength)
static QImage BlurQImage(const QImage &qimage, int strength)
{
QImage qimage = qimage_;
if (strength == 0)
return qimage;
// The numbers that follow were picked by experimentation to try to get
// an effect linearly proportional to <strength> and at the same time,
// be fast enough.
......@@ -85,11 +83,8 @@ static QImage BlurQImage (const QImage qimage_, int strength)
<< endl;
#endif
qimage = Blitz::blur (qimage, qRound (radius));
return qimage;
QImage img(qimage);
return Blitz::blur(img, qRound(radius));
}
//---------------------------------------------------------------------
......@@ -160,7 +155,7 @@ static QImage SharpenQImage (const QImage &qimage_, int strength)
for (int i = 0; i < repeat; i++)
{
#if DEBUG_KP_EFFECT_BLUR_SHARPEN
QTime timer; timer.start ();
QTime timer; timer.start ();
#endif
qimage = Blitz::gaussianSharpen (qimage, radius, sigma);
#if DEBUG_KP_EFFECT_BLUR_SHARPEN
......@@ -192,6 +187,11 @@ kpImage kpEffectBlurSharpen::applyEffect (const kpImage &image,
return ::BlurQImage (image, strength);
else if (type == Sharpen)
return ::SharpenQImage (image, strength);
else if (type == MakeConfidential)
{
QImage img(image);
return Blitz::blur(img, qMin(20, img.width() / 2));
}
else
return kpImage();
}
......
......@@ -38,7 +38,7 @@ class kpEffectBlurSharpen
public:
enum Type
{
None = 0, Blur, Sharpen
None = 0, Blur, Sharpen, MakeConfidential
};
// Blur or Sharpen with this strength is the same as None.
......
......@@ -4,7 +4,7 @@ SYNC: Do not change the number of quotes before the version number
- it is parsed by the KolourPaint wrapper shell script (in standalone
backport releases of KolourPaint)
-->
<gui name="kolourpaint" version="73">
<gui name="kolourpaint" version="74">
<!--
SYNC: Check for duplicate actions in menus caused by some of our actions
......@@ -84,6 +84,7 @@ SYNC: Check for duplicate actions in menus caused by some of our actions
<Separator />
<Action name="image_convert_to_black_and_white" />
<Action name="image_convert_to_grayscale" />
<Action name="image_make_confidential" />
<Action name="image_more_effects" />
<Separator />
<Action name="image_invert_colors" />
......
......@@ -558,11 +558,11 @@ public:
bool addSelCreateCmdIfSelAvail = true,
bool addSelContentCmdIfSelAvail = true);
private slots:
void slotResizeScale ();
public slots:
void slotCrop ();
private slots:
void slotResizeScale ();
void slotAutoCrop ();
void slotFlip ();
void slotMirror ();
......@@ -576,6 +576,7 @@ private slots:
void slotConvertToGrayscale ();
void slotInvertColors ();
void slotClear ();
void slotMakeConfidential();
void slotMoreEffects ();
......
......@@ -191,6 +191,7 @@ struct kpMainWindowPrivate
actionSkew(0),
actionConvertToBlackAndWhite(0),
actionConvertToGrayscale(0),
actionBlur(0),
actionMoreEffects(0),
actionInvertColors(0),
actionClear(0),
......@@ -367,7 +368,7 @@ struct kpMainWindowPrivate
*actionRotate, *actionRotateLeft, *actionRotateRight,
*actionSkew,
*actionConvertToBlackAndWhite, *actionConvertToGrayscale,
*actionMoreEffects,
*actionBlur, *actionMoreEffects,
*actionInvertColors, *actionClear;
// Implemented in kpMainWindow_Tools.cpp, not kpImageWindow_Image.cpp
......
......@@ -56,6 +56,8 @@
#include "commands/imagelib/transforms/kpTransformSkewCommand.h"
#include "dialogs/imagelib/transforms/kpTransformSkewDialog.h"
#include "views/manager/kpViewManager.h"
#include "commands/imagelib/effects/kpEffectBlurSharpenCommand.h"
#include "imagelib/effects/kpEffectBlurSharpen.h"
#include <kactioncollection.h>
#include <kapplication.h>
......@@ -181,6 +183,10 @@ void kpMainWindow::setupImageMenuActions ()
connect (d->actionClear, SIGNAL (triggered (bool)), SLOT (slotClear ()));
ac->setDefaultShortcut (d->actionClear, Qt::CTRL + Qt::SHIFT + Qt::Key_N);
d->actionBlur = ac->addAction("image_make_confidential");
d->actionBlur->setText(i18n("Make Confidential"));
connect(d->actionBlur, SIGNAL(triggered(bool)), SLOT(slotMakeConfidential()));
d->actionMoreEffects = ac->addAction ("image_more_effects");
d->actionMoreEffects->setText (i18n ("&More Effects..."));
connect (d->actionMoreEffects, SIGNAL (triggered (bool)), SLOT (slotMoreEffects ()));
......@@ -208,6 +214,7 @@ void kpMainWindow::enableImageMenuDocumentActions (bool enable)
d->actionConvertToGrayscale->setEnabled (enable);
d->actionInvertColors->setEnabled (enable);
d->actionClear->setEnabled (enable);
d->actionBlur->setEnabled (enable);
d->actionMoreEffects->setEnabled (enable);
d->imageMenuDocumentActionsEnabled = enable;
......@@ -261,6 +268,7 @@ void kpMainWindow::slotImageMenuUpdateDueToSelection ()
d->actionConvertToGrayscale->setEnabled (enable);
d->actionInvertColors->setEnabled (enable);
d->actionClear->setEnabled (enable);
d->actionBlur->setEnabled (enable);
d->actionMoreEffects->setEnabled (enable);
}
......@@ -545,6 +553,8 @@ void kpMainWindow::slotConvertToGrayscale ()
commandEnvironment ()));
}
//--------------------------------------------------------------------------------
// private slot
void kpMainWindow::slotInvertColors ()
{
......@@ -555,6 +565,8 @@ void kpMainWindow::slotInvertColors ()
commandEnvironment ()));
}
//--------------------------------------------------------------------------------
// private slot
void kpMainWindow::slotClear ()
{
......@@ -567,6 +579,19 @@ void kpMainWindow::slotClear ()
commandEnvironment ()));
}
//--------------------------------------------------------------------------------
void kpMainWindow::slotMakeConfidential()
{
toolEndShape();
addImageOrSelectionCommand(
new kpEffectBlurSharpenCommand(kpEffectBlurSharpen::MakeConfidential, kpEffectBlurSharpen::MaxStrength,
d->document->selection(), commandEnvironment()));
}
//--------------------------------------------------------------------------------
// private slot
void kpMainWindow::slotMoreEffects ()
{
......@@ -593,3 +618,5 @@ void kpMainWindow::slotMoreEffects ()
cfg.sync ();
}
}
//--------------------------------------------------------------------------------
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment