Add Blur tool
This commit is contained in:
@@ -90,7 +90,8 @@ SOURCES += src/main.cpp\
|
||||
src/capture/workers/launcher/applauncherwidget.cpp \
|
||||
src/capture/tools/applauncher.cpp \
|
||||
src/utils/desktopfileparse.cpp \
|
||||
src/capture/workers/launcher/launcheritemdelegate.cpp
|
||||
src/capture/workers/launcher/launcheritemdelegate.cpp \
|
||||
src/capture/tools/blurtool.cpp
|
||||
|
||||
HEADERS += \
|
||||
src/capture/widget/buttonhandler.h \
|
||||
@@ -145,7 +146,8 @@ HEADERS += \
|
||||
src/capture/workers/launcher/applauncherwidget.h \
|
||||
src/capture/tools/applauncher.h \
|
||||
src/utils/desktopfileparse.h \
|
||||
src/capture/workers/launcher/launcheritemdelegate.h
|
||||
src/capture/workers/launcher/launcheritemdelegate.h \
|
||||
src/capture/tools/blurtool.h
|
||||
|
||||
RESOURCES += \
|
||||
graphics.qrc
|
||||
|
||||
@@ -41,5 +41,7 @@
|
||||
<file>img/buttonIconsWhite/size_indicator.png</file>
|
||||
<file>img/buttonIconsBlack/open_with.png</file>
|
||||
<file>img/buttonIconsWhite/open_with.png</file>
|
||||
<file>img/buttonIconsBlack/blur.png</file>
|
||||
<file>img/buttonIconsWhite/blur.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
BIN
img/buttonIconsBlack/blur.png
Normal file
BIN
img/buttonIconsBlack/blur.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 166 B |
4
img/buttonIconsBlack/blur.svg
Normal file
4
img/buttonIconsBlack/blur.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path d="M6 13c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm-3 .5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM6 5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm15 5.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM14 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0-3.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zm-11 10c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm7 7c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm0-17c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM10 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0 5.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm8 .5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm3 8.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM14 17c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 3.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm-4-12c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0 8.5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm4-4.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-4c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5z"/>
|
||||
<path d="M0 0h24v24H0z" fill="none"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
BIN
img/buttonIconsWhite/blur.png
Normal file
BIN
img/buttonIconsWhite/blur.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 176 B |
59
img/buttonIconsWhite/blur.svg
Normal file
59
img/buttonIconsWhite/blur.svg
Normal file
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
version="1.1"
|
||||
id="svg6"
|
||||
sodipodi:docname="ic_blur_on_24pxw.svg"
|
||||
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)">
|
||||
<metadata
|
||||
id="metadata12">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs10" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1328"
|
||||
inkscape:window-height="739"
|
||||
id="namedview8"
|
||||
showgrid="false"
|
||||
inkscape:zoom="20.857422"
|
||||
inkscape:cx="12"
|
||||
inkscape:cy="12.216392"
|
||||
inkscape:window-x="38"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg6" />
|
||||
<path
|
||||
d="M6 13c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm-3 .5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM6 5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm15 5.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM14 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0-3.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zm-11 10c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm7 7c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm0-17c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM10 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0 5.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm8 .5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm3 8.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM14 17c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 3.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm-4-12c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0 8.5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm4-4.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-4c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5z"
|
||||
id="path2"
|
||||
style="fill:#ffffff;fill-opacity:1" />
|
||||
<path
|
||||
d="M0 0h24v24H0z"
|
||||
fill="none"
|
||||
id="path4" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.0 KiB |
81
src/capture/tools/blurtool.cpp
Normal file
81
src/capture/tools/blurtool.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
// Copyright 2017 Alejandro Sirgo Rica
|
||||
//
|
||||
// This file is part of Flameshot.
|
||||
//
|
||||
// Flameshot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Flameshot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "blurtool.h"
|
||||
#include <QPainter>
|
||||
#include <QGraphicsBlurEffect>
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QGraphicsScene>
|
||||
|
||||
BlurTool::BlurTool(QObject *parent) : CaptureTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
int BlurTool::id() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool BlurTool::isSelectable() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
QString BlurTool::iconName() const {
|
||||
return "blur.png";
|
||||
}
|
||||
|
||||
QString BlurTool::name() const {
|
||||
return tr("Blur");
|
||||
}
|
||||
|
||||
QString BlurTool::description() const {
|
||||
return tr("Sets the Blur as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool::ToolWorkType BlurTool::toolType() const {
|
||||
return TYPE_LINE_DRAWER;
|
||||
}
|
||||
#include <QApplication>
|
||||
void BlurTool::processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness)
|
||||
{
|
||||
Q_UNUSED(color);
|
||||
Q_UNUSED(thickness);
|
||||
QPoint p0 = points[0];
|
||||
QPoint p1 = points[1];
|
||||
|
||||
QRect selection = QRect(p0, p1).normalized();
|
||||
QPixmap *refPixmap = dynamic_cast<QPixmap*>(painter.device());
|
||||
|
||||
QGraphicsBlurEffect *blur = new QGraphicsBlurEffect;
|
||||
blur->setBlurRadius(10);
|
||||
QGraphicsPixmapItem *item = new QGraphicsPixmapItem (
|
||||
refPixmap->copy(selection));
|
||||
item->setGraphicsEffect(blur);
|
||||
|
||||
QGraphicsScene scene;
|
||||
scene.addItem(item);
|
||||
|
||||
scene.render(&painter, selection, QRectF());
|
||||
blur->setBlurRadius(15);
|
||||
scene.render(&painter, selection, QRectF());
|
||||
}
|
||||
|
||||
void BlurTool::onPressed() {
|
||||
}
|
||||
51
src/capture/tools/blurtool.h
Normal file
51
src/capture/tools/blurtool.h
Normal file
@@ -0,0 +1,51 @@
|
||||
// Copyright 2017 Alejandro Sirgo Rica
|
||||
//
|
||||
// This file is part of Flameshot.
|
||||
//
|
||||
// Flameshot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Flameshot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#ifndef BLURTOOL_H
|
||||
#define BLURTOOL_H
|
||||
|
||||
#include "capturetool.h"
|
||||
|
||||
class BlurTool : public CaptureTool
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BlurTool(QObject *parent = nullptr);
|
||||
|
||||
int id() const override;
|
||||
bool isSelectable() const override;
|
||||
ToolWorkType toolType() const override;
|
||||
|
||||
QString iconName() const override;
|
||||
QString name() const override;
|
||||
QString description() const override;
|
||||
|
||||
void processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness) override;
|
||||
|
||||
void onPressed() override;
|
||||
|
||||
private:
|
||||
bool needsAdjustment(const QPoint &p0, const QPoint &p1) const;
|
||||
|
||||
};
|
||||
|
||||
#endif // BLURTOOL_H
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "sizeindicatortool.h"
|
||||
#include "undotool.h"
|
||||
#include "applauncher.h"
|
||||
#include "blurtool.h"
|
||||
|
||||
ToolFactory::ToolFactory(QObject *parent) : QObject(parent)
|
||||
{
|
||||
@@ -88,6 +89,9 @@ CaptureTool* ToolFactory::CreateTool(
|
||||
case CaptureButton::TYPE_OPEN_APP:
|
||||
tool = new AppLauncher(parent);
|
||||
break;
|
||||
case CaptureButton::TYPE_BLUR:
|
||||
tool = new BlurTool(parent);
|
||||
break;
|
||||
default:
|
||||
tool = nullptr;
|
||||
break;
|
||||
|
||||
@@ -191,6 +191,7 @@ static std::map<CaptureButton::ButtonType, int> buttonTypeOrder {
|
||||
{ CaptureButton::TYPE_EXIT, 12 },
|
||||
{ CaptureButton::TYPE_IMAGEUPLOADER, 13 },
|
||||
{ CaptureButton::TYPE_OPEN_APP, 14 },
|
||||
{ CaptureButton::TYPE_BLUR, 15 },
|
||||
};
|
||||
|
||||
int CaptureButton::getPriorityByButton(CaptureButton::ButtonType b) {
|
||||
@@ -214,4 +215,5 @@ QVector<CaptureButton::ButtonType> CaptureButton::iterableButtonTypes = {
|
||||
CaptureButton::TYPE_EXIT,
|
||||
CaptureButton::TYPE_IMAGEUPLOADER,
|
||||
CaptureButton::TYPE_OPEN_APP,
|
||||
CaptureButton::TYPE_BLUR,
|
||||
};
|
||||
|
||||
@@ -49,6 +49,7 @@ public:
|
||||
TYPE_EXIT,
|
||||
TYPE_IMAGEUPLOADER,
|
||||
TYPE_OPEN_APP,
|
||||
TYPE_BLUR,
|
||||
};
|
||||
|
||||
CaptureButton() = delete;
|
||||
|
||||
@@ -446,7 +446,8 @@ void CaptureWidget::setState(CaptureButton *b) {
|
||||
m_state = t;
|
||||
m_toolIsForDrawing =
|
||||
(b->tool()->toolType() !=
|
||||
CaptureTool::ToolWorkType::TYPE_WORKER);
|
||||
CaptureTool::ToolWorkType::TYPE_WORKER) &&
|
||||
b->buttonType() != CaptureButton::TYPE_BLUR;
|
||||
if (m_lastPressedButton) {
|
||||
m_lastPressedButton->setColor(m_uiColor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user