mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-22 09:51:06 +00:00
Code refactor
More flexible tool API Minor code format fixes Clipboard freeze fixed(?) Arrow correcly growing close to the start point Improve maintainability Add undo/redo stack
This commit is contained in:
145
flameshot.pro
145
flameshot.pro
@@ -66,13 +66,11 @@ include(src/third-party/Qt-Color-Widgets//color_widgets.pri)
|
||||
DEFINES += QAPPLICATION_CLASS=QApplication
|
||||
|
||||
SOURCES += src/main.cpp \
|
||||
src/capture/widgets/buttonhandler.cpp \
|
||||
src/infowindow.cpp \
|
||||
src/widgets/capture/buttonhandler.cpp \
|
||||
src/widgets/infowindow.cpp \
|
||||
src/config/configwindow.cpp \
|
||||
src/capture/screenshot.cpp \
|
||||
src/capture/widgets/capturewidget.cpp \
|
||||
src/capture/capturemodification.cpp \
|
||||
src/capture/widgets/colorpicker.cpp \
|
||||
src/widgets/capture/capturewidget.cpp \
|
||||
src/widgets/capture/colorpicker.cpp \
|
||||
src/config/buttonlistview.cpp \
|
||||
src/config/uicoloreditor.cpp \
|
||||
src/config/geneneralconf.cpp \
|
||||
@@ -80,23 +78,23 @@ SOURCES += src/main.cpp \
|
||||
src/config/clickablelabel.cpp \
|
||||
src/config/filenameeditor.cpp \
|
||||
src/config/strftimechooserwidget.cpp \
|
||||
src/capture/tools/capturetool.cpp \
|
||||
src/capture/widgets/capturebutton.cpp \
|
||||
src/capture/tools/penciltool.cpp \
|
||||
src/capture/tools/undotool.cpp \
|
||||
src/capture/tools/arrowtool.cpp \
|
||||
src/capture/tools/circletool.cpp \
|
||||
src/capture/tools/copytool.cpp \
|
||||
src/capture/tools/exittool.cpp \
|
||||
src/capture/tools/imguruploadertool.cpp \
|
||||
src/capture/tools/linetool.cpp \
|
||||
src/capture/tools/markertool.cpp \
|
||||
src/capture/tools/movetool.cpp \
|
||||
src/capture/tools/rectangletool.cpp \
|
||||
src/capture/tools/savetool.cpp \
|
||||
src/capture/tools/selectiontool.cpp \
|
||||
src/capture/tools/sizeindicatortool.cpp \
|
||||
src/capture/tools/toolfactory.cpp \
|
||||
src/widgets/capture/capturebutton.cpp \
|
||||
src/tools/pencil/penciltool.cpp \
|
||||
src/tools/undo/undotool.cpp \
|
||||
src/tools/redo/redotool.cpp \
|
||||
src/tools/arrow/arrowtool.cpp \
|
||||
src/tools/circle/circletool.cpp \
|
||||
src/tools/copy/copytool.cpp \
|
||||
src/tools/exit/exittool.cpp \
|
||||
src/tools/imgur/imguruploadertool.cpp \
|
||||
src/tools/line/linetool.cpp \
|
||||
src/tools/marker/markertool.cpp \
|
||||
src/tools/move/movetool.cpp \
|
||||
src/tools/rectangle/rectangletool.cpp \
|
||||
src/tools/save/savetool.cpp \
|
||||
src/tools/selection/selectiontool.cpp \
|
||||
src/tools/sizeindicator/sizeindicatortool.cpp \
|
||||
src/tools/toolfactory.cpp \
|
||||
src/utils/filenamehandler.cpp \
|
||||
src/utils/screengrabber.cpp \
|
||||
src/utils/confighandler.cpp \
|
||||
@@ -104,32 +102,36 @@ SOURCES += src/main.cpp \
|
||||
src/cli/commandlineparser.cpp \
|
||||
src/cli/commandoption.cpp \
|
||||
src/cli/commandargument.cpp \
|
||||
src/capture/workers/screenshotsaver.cpp \
|
||||
src/capture/workers/imgur/imguruploader.cpp \
|
||||
src/utils/screenshotsaver.cpp \
|
||||
src/tools/imgur/imguruploader.cpp \
|
||||
src/widgets/loadspinner.cpp \
|
||||
src/widgets/imagelabel.cpp \
|
||||
src/widgets/notificationwidget.cpp \
|
||||
src/core/resourceexporter.cpp \
|
||||
src/capture/widgets/notifierbox.cpp \
|
||||
src/widgets/capture/notifierbox.cpp \
|
||||
src/utils/desktopinfo.cpp \
|
||||
src/capture/workers/launcher/applauncherwidget.cpp \
|
||||
src/capture/tools/applauncher.cpp \
|
||||
src/tools/launcher/applauncherwidget.cpp \
|
||||
src/utils/desktopfileparse.cpp \
|
||||
src/capture/workers/launcher/launcheritemdelegate.cpp \
|
||||
src/capture/tools/blurtool.cpp \
|
||||
src/capture/workers/launcher/terminallauncher.cpp \
|
||||
src/tools/launcher/launcheritemdelegate.cpp \
|
||||
src/tools/blur/blurtool.cpp \
|
||||
src/tools/launcher/terminallauncher.cpp \
|
||||
src/config/visualseditor.cpp \
|
||||
src/config/extendedslider.cpp \
|
||||
src/capture/workers/launcher/openwithprogram.cpp \
|
||||
src/utils/pathinfo.cpp
|
||||
src/tools/launcher/openwithprogram.cpp \
|
||||
src/tools/launcher/applaunchertool.cpp \
|
||||
src/utils/pathinfo.cpp \
|
||||
src/utils/colorutils.cpp \
|
||||
src/tools/capturecontext.cpp \
|
||||
src/widgets/capture/modificationcommand.cpp \
|
||||
src/tools/abstractpathtool.cpp \
|
||||
src/tools/abstracttwopointtool.cpp \
|
||||
src/tools/abstractactiontool.cpp \
|
||||
src/utils/globalvalues.cpp
|
||||
|
||||
HEADERS += src/capture/widgets/buttonhandler.h \
|
||||
src/infowindow.h \
|
||||
HEADERS += src/widgets/capture/buttonhandler.h \
|
||||
src/widgets/infowindow.h \
|
||||
src/config/configwindow.h \
|
||||
src/capture/screenshot.h \
|
||||
src/capture/widgets/capturewidget.h \
|
||||
src/capture/capturemodification.h \
|
||||
src/capture/widgets/colorpicker.h \
|
||||
src/widgets/capture/capturewidget.h \
|
||||
src/widgets/capture/colorpicker.h \
|
||||
src/config/buttonlistview.h \
|
||||
src/config/uicoloreditor.h \
|
||||
src/config/geneneralconf.h \
|
||||
@@ -138,47 +140,54 @@ HEADERS += src/capture/widgets/buttonhandler.h \
|
||||
src/utils/filenamehandler.h \
|
||||
src/config/strftimechooserwidget.h \
|
||||
src/utils/screengrabber.h \
|
||||
src/capture/tools/capturetool.h \
|
||||
src/capture/widgets/capturebutton.h \
|
||||
src/capture/tools/penciltool.h \
|
||||
src/capture/tools/undotool.h \
|
||||
src/capture/tools/arrowtool.h \
|
||||
src/capture/tools/circletool.h \
|
||||
src/capture/tools/copytool.h \
|
||||
src/capture/tools/exittool.h \
|
||||
src/capture/tools/imguruploadertool.h \
|
||||
src/capture/tools/linetool.h \
|
||||
src/capture/tools/markertool.h \
|
||||
src/capture/tools/movetool.h \
|
||||
src/capture/tools/rectangletool.h \
|
||||
src/capture/tools/savetool.h \
|
||||
src/capture/tools/selectiontool.h \
|
||||
src/capture/tools/sizeindicatortool.h \
|
||||
src/capture/tools/toolfactory.h \
|
||||
src/tools/capturetool.h \
|
||||
src/widgets/capture/capturebutton.h \
|
||||
src/tools/pencil/penciltool.h \
|
||||
src/tools/undo/undotool.h \
|
||||
src/tools/redo/redotool.h \
|
||||
src/tools/arrow/arrowtool.h \
|
||||
src/tools/circle/circletool.h \
|
||||
src/tools/copy/copytool.h \
|
||||
src/tools/exit/exittool.h \
|
||||
src/tools/imgur/imguruploadertool.h \
|
||||
src/tools/line/linetool.h \
|
||||
src/tools/marker/markertool.h \
|
||||
src/tools/move/movetool.h \
|
||||
src/tools/rectangle/rectangletool.h \
|
||||
src/tools/save/savetool.h \
|
||||
src/tools/selection/selectiontool.h \
|
||||
src/tools/sizeindicator/sizeindicatortool.h \
|
||||
src/tools/toolfactory.h \
|
||||
src/utils/confighandler.h \
|
||||
src/core/controller.h \
|
||||
src/utils/systemnotification.h \
|
||||
src/cli/commandlineparser.h \
|
||||
src/cli/commandoption.h \
|
||||
src/cli/commandargument.h \
|
||||
src/capture/workers/screenshotsaver.h \
|
||||
src/capture/workers/imgur/imguruploader.h \
|
||||
src/utils/screenshotsaver.h \
|
||||
src/tools/imgur/imguruploader.h \
|
||||
src/widgets/loadspinner.h \
|
||||
src/widgets/imagelabel.h \
|
||||
src/widgets/notificationwidget.h \
|
||||
src/core/resourceexporter.h \
|
||||
src/capture/widgets/notifierbox.h \
|
||||
src/widgets/capture/notifierbox.h \
|
||||
src/utils/desktopinfo.h \
|
||||
src/capture/workers/launcher/applauncherwidget.h \
|
||||
src/capture/tools/applauncher.h \
|
||||
src/tools/launcher/applauncherwidget.h \
|
||||
src/utils/desktopfileparse.h \
|
||||
src/capture/workers/launcher/launcheritemdelegate.h \
|
||||
src/capture/tools/blurtool.h \
|
||||
src/capture/workers/launcher/terminallauncher.h \
|
||||
src/tools/launcher/launcheritemdelegate.h \
|
||||
src/tools/blur/blurtool.h \
|
||||
src/tools/launcher/terminallauncher.h \
|
||||
src/config/visualseditor.h \
|
||||
src/config/extendedslider.h \
|
||||
src/capture/workers/launcher/openwithprogram.h \
|
||||
src/utils/pathinfo.h
|
||||
src/tools/launcher/openwithprogram.h \
|
||||
src/utils/pathinfo.h \
|
||||
src/tools/capturecontext.h \
|
||||
src/tools/launcher/applaunchertool.h \
|
||||
src/utils/globalvalues.h \
|
||||
src/utils/colorutils.h \
|
||||
src/widgets/capture/modificationcommand.h \
|
||||
src/tools/abstractpathtool.h \
|
||||
src/tools/abstracttwopointtool.h \
|
||||
src/tools/abstractactiontool.h
|
||||
|
||||
unix:!macx {
|
||||
SOURCES += src/core/flameshotdbusadapter.cpp \
|
||||
|
||||
@@ -43,5 +43,7 @@
|
||||
<file>img/buttonIconsWhite/open_with.png</file>
|
||||
<file>img/buttonIconsBlack/blur.png</file>
|
||||
<file>img/buttonIconsWhite/blur.png</file>
|
||||
<file>img/buttonIconsBlack/redo-variant.png</file>
|
||||
<file>img/buttonIconsWhite/redo-variant.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
BIN
img/buttonIconsBlack/redo-variant.png
Normal file
BIN
img/buttonIconsBlack/redo-variant.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 325 B |
54
img/buttonIconsBlack/redo-variant.svg
Normal file
54
img/buttonIconsBlack/redo-variant.svg
Normal file
@@ -0,0 +1,54 @@
|
||||
<?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"
|
||||
version="1.1"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
id="svg4"
|
||||
sodipodi:docname="redo-variant.svg"
|
||||
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)">
|
||||
<metadata
|
||||
id="metadata10">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs8" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="640"
|
||||
inkscape:window-height="480"
|
||||
id="namedview6"
|
||||
showgrid="false"
|
||||
inkscape:zoom="9.8333333"
|
||||
inkscape:cx="16.611047"
|
||||
inkscape:cy="12"
|
||||
inkscape:window-x="36"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg4" />
|
||||
<path
|
||||
d="M 10.5,7 C 6.91,7 4,9.91 4,13.5 4,17.09 6.91,20 10.5,20 H 14 V 18 H 10.5 C 8,18 6,16 6,13.5 6,11 8,9 10.5,9 h 5.67 L 13.09,12.09 14.5,13.5 20,8 14.5,2.5 13.08,3.91 16.17,7 H 10.5 M 18,18 h -2 v 2 h 2 z"
|
||||
id="path2"
|
||||
inkscape:connector-curvature="0" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
BIN
img/buttonIconsWhite/redo-variant.png
Normal file
BIN
img/buttonIconsWhite/redo-variant.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 317 B |
55
img/buttonIconsWhite/redo-variant.svg
Normal file
55
img/buttonIconsWhite/redo-variant.svg
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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"
|
||||
version="1.1"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
id="svg4"
|
||||
sodipodi:docname="redo-variant.svg"
|
||||
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)">
|
||||
<metadata
|
||||
id="metadata10">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs8" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="640"
|
||||
inkscape:window-height="496"
|
||||
id="namedview6"
|
||||
showgrid="false"
|
||||
inkscape:zoom="6.9532167"
|
||||
inkscape:cx="2.3915659"
|
||||
inkscape:cy="17.47305"
|
||||
inkscape:window-x="36"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg4" />
|
||||
<path
|
||||
d="M 10.5,7 C 6.91,7 4,9.91 4,13.5 4,17.09 6.91,20 10.5,20 H 14 V 18 H 10.5 C 8,18 6,16 6,13.5 6,11 8,9 10.5,9 h 5.67 L 13.09,12.09 14.5,13.5 20,8 14.5,2.5 13.08,3.91 16.17,7 H 10.5 M 18,18 h -2 v 2 h 2 z"
|
||||
id="path2"
|
||||
style="fill:#ffffff"
|
||||
inkscape:connector-curvature="0" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
@@ -1,72 +0,0 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "src/capture/tools/capturetool.h"
|
||||
#include "capturemodification.h"
|
||||
#include "src/capture/tools/toolfactory.h"
|
||||
#include "src/capture/tools/capturetool.h"
|
||||
#include <QColor>
|
||||
|
||||
// CaptureModification is a single modification in the screenshot drawn
|
||||
// by the user.
|
||||
|
||||
CaptureModification::CaptureModification(
|
||||
const CaptureButton::ButtonType t,
|
||||
const QPoint &p,
|
||||
const QColor &c,
|
||||
const int thickness,
|
||||
QObject *parent) :
|
||||
QObject(parent),
|
||||
m_color(c),
|
||||
m_type(t),
|
||||
m_thickness(thickness)
|
||||
{
|
||||
m_tool = ToolFactory().CreateTool(t, this);
|
||||
m_coords.append(p);
|
||||
if (m_tool->isSelectable()) {
|
||||
m_coords.append(p);
|
||||
}
|
||||
}
|
||||
|
||||
CaptureButton::ButtonType CaptureModification::buttonType() const {
|
||||
return m_type;
|
||||
}
|
||||
|
||||
QColor CaptureModification::color() const {
|
||||
return m_color;
|
||||
}
|
||||
|
||||
QVector<QPoint> CaptureModification::points() const {
|
||||
return m_coords;
|
||||
}
|
||||
|
||||
CaptureTool* CaptureModification::tool() const{
|
||||
return m_tool;
|
||||
}
|
||||
|
||||
int CaptureModification::thickness() const {
|
||||
return m_thickness;
|
||||
}
|
||||
|
||||
// addPoint adds a point to the vector of points
|
||||
void CaptureModification::addPoint(const QPoint p) {
|
||||
if (m_tool->toolType() == CaptureTool::TYPE_LINE_DRAWER) {
|
||||
m_coords[1] = p;
|
||||
} else {
|
||||
m_coords.append(p);
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "src/capture/widgets/capturebutton.h"
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
|
||||
class CaptureButton;
|
||||
class QPoint;
|
||||
|
||||
class CaptureModification : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
CaptureModification(QObject *parent = nullptr) = delete;
|
||||
CaptureModification(
|
||||
const CaptureButton::ButtonType,
|
||||
const QPoint &initialPoint,
|
||||
const QColor &color,
|
||||
const int thickness,
|
||||
QObject *parent = nullptr
|
||||
);
|
||||
QColor color() const;
|
||||
QVector<QPoint> points() const;
|
||||
CaptureTool* tool() const;
|
||||
int thickness() const;
|
||||
CaptureButton::ButtonType buttonType() const;
|
||||
void addPoint(const QPoint);
|
||||
|
||||
protected:
|
||||
QColor m_color;
|
||||
CaptureButton::ButtonType m_type;
|
||||
QVector<QPoint> m_coords;
|
||||
CaptureTool *m_tool;
|
||||
int m_thickness;
|
||||
|
||||
};
|
||||
@@ -1,109 +0,0 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "src/capture/screenshot.h"
|
||||
#include "src/capture/widgets/capturebutton.h"
|
||||
#include "capturemodification.h"
|
||||
#include "src/capture/tools/capturetool.h"
|
||||
#include "src/utils/filenamehandler.h"
|
||||
#include "src/utils/confighandler.h"
|
||||
#include <QMessageBox>
|
||||
#include <QImageWriter>
|
||||
#include <QFileDialog>
|
||||
#include <QPainter>
|
||||
#include <QBuffer>
|
||||
#include <QUrlQuery>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkAccessManager>
|
||||
|
||||
// Screenshot is an extension of QPixmap which lets you manage specific tasks
|
||||
|
||||
Screenshot::Screenshot(const QPixmap &p, QObject *parent) : QObject(parent),
|
||||
m_baseScreenshot(p),
|
||||
m_modifiedScreenshot(p)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Screenshot::~Screenshot() {
|
||||
}
|
||||
|
||||
void Screenshot::setScreenshot(const QPixmap &p) {
|
||||
m_baseScreenshot = p;
|
||||
m_modifiedScreenshot = p;
|
||||
}
|
||||
|
||||
// getScreenshot returns the screenshot with no modifications
|
||||
QPixmap Screenshot::baseScreenshot() const {
|
||||
return m_baseScreenshot;
|
||||
}
|
||||
|
||||
// getScreenshot returns the screenshot with all the modifications
|
||||
QPixmap Screenshot::screenshot() const {
|
||||
return m_modifiedScreenshot;
|
||||
}
|
||||
|
||||
QPixmap Screenshot::croppedScreenshot(const QRect &selection) const {
|
||||
return m_modifiedScreenshot.copy(selection);
|
||||
}
|
||||
|
||||
// paintModification adds a new modification to the screenshot
|
||||
QPixmap Screenshot::paintModification(const CaptureModification *modification) {
|
||||
QPainter painter(&m_modifiedScreenshot);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
paintInPainter(painter, modification);
|
||||
return m_modifiedScreenshot;
|
||||
}
|
||||
|
||||
// paintTemporalModification paints a modification without updating the
|
||||
// member pixmap
|
||||
QPixmap Screenshot::paintTemporalModification(
|
||||
const CaptureModification *modification)
|
||||
{
|
||||
QPixmap tempPix(m_modifiedScreenshot);
|
||||
QPainter painter(&tempPix);
|
||||
if (modification->buttonType() != CaptureButton::TYPE_PENCIL) {
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
}
|
||||
paintInPainter(painter, modification);
|
||||
return tempPix;
|
||||
}
|
||||
|
||||
// paintBaseModifications overrides the modifications of the screenshot
|
||||
// with new ones.
|
||||
QPixmap Screenshot::overrideModifications(
|
||||
const QVector<CaptureModification*> &m)
|
||||
{
|
||||
m_modifiedScreenshot = m_baseScreenshot;
|
||||
for (const CaptureModification *const modification: m) {
|
||||
paintModification(modification);
|
||||
}
|
||||
return m_modifiedScreenshot;
|
||||
}
|
||||
|
||||
// paintInPainter is an aux method to prevent duplicated code, it draws the
|
||||
// passed modification to the painter.
|
||||
void Screenshot::paintInPainter(QPainter &painter,
|
||||
const CaptureModification *modification)
|
||||
{
|
||||
const QVector<QPoint> &points = modification->points();
|
||||
QColor color = modification->color();
|
||||
int thickness = modification->thickness();
|
||||
modification->tool()->processImage(painter, points, color, thickness);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "arrowtool.h"
|
||||
#include <QPainter>
|
||||
|
||||
namespace {
|
||||
|
||||
const int ArrowWidth = 10;
|
||||
const int ArrowHeight = 18;
|
||||
|
||||
QPainterPath getArrowHead(QPoint p1, QPoint p2, const int thickness) {
|
||||
QLineF body(p1, p2);
|
||||
int originalLength = body.length();
|
||||
body.setLength(ArrowWidth + thickness*2);
|
||||
// move across the line up to the head
|
||||
QLineF temp(QPoint(0,0), p2-p1);
|
||||
temp.setLength(originalLength - ArrowHeight - thickness*2);
|
||||
QPointF bottonTranslation(temp.p2());
|
||||
|
||||
// generates the transformation to center of the arrowhead
|
||||
body.setAngle(body.angle()+90);
|
||||
QPointF temp2 = p1-body.p2();
|
||||
QPointF centerTranslation((temp2.x()/2), (temp2.y()/2));
|
||||
|
||||
body.translate(bottonTranslation);
|
||||
body.translate(centerTranslation);
|
||||
|
||||
QPainterPath path;
|
||||
path.moveTo(p2);
|
||||
path.lineTo(body.p1());
|
||||
path.lineTo(body.p2());
|
||||
path.lineTo(p2);
|
||||
return path;
|
||||
}
|
||||
|
||||
// gets a shorter line to prevent overlap in the point of the arrow
|
||||
QLine getShorterLine(QPoint p1, QPoint p2, const int thickness) {
|
||||
QLineF l(p1, p2);
|
||||
l.setLength(l.length() - ArrowHeight - thickness*2);
|
||||
return l.toLine();
|
||||
}
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
ArrowTool::ArrowTool(QObject *parent) : CaptureTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
int ArrowTool::id() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ArrowTool::isSelectable() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
QString ArrowTool::iconName() const {
|
||||
return "arrow-bottom-left.png";
|
||||
}
|
||||
|
||||
QString ArrowTool::name() const {
|
||||
return tr("Arrow");
|
||||
}
|
||||
|
||||
QString ArrowTool::description() const {
|
||||
return tr("Sets the Arrow as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool::ToolWorkType ArrowTool::toolType() const {
|
||||
return TYPE_LINE_DRAWER;
|
||||
}
|
||||
|
||||
void ArrowTool::processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness)
|
||||
{
|
||||
painter.setPen(QPen(color, 2 + thickness));
|
||||
painter.drawLine(getShorterLine(points[0], points[1], thickness));
|
||||
painter.fillPath(getArrowHead(points[0], points[1], thickness), QBrush(color));
|
||||
}
|
||||
|
||||
void ArrowTool::onPressed() {
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
|
||||
class QPainter;
|
||||
|
||||
class CaptureTool : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum ToolWorkType {
|
||||
TYPE_WORKER,
|
||||
TYPE_PATH_DRAWER,
|
||||
TYPE_LINE_DRAWER
|
||||
};
|
||||
|
||||
enum Request {
|
||||
REQ_CLOSE_GUI,
|
||||
REQ_HIDE_GUI,
|
||||
REQ_HIDE_SELECTION,
|
||||
REQ_UNDO_MODIFICATION,
|
||||
REQ_CLEAR_MODIFICATIONS,
|
||||
REQ_SAVE_SCREENSHOT,
|
||||
REQ_SELECT_ALL,
|
||||
REQ_TO_CLIPBOARD,
|
||||
REQ_UPLOAD_TO_IMGUR,
|
||||
REQ_MOVE_MODE,
|
||||
REQ_OPEN_APP,
|
||||
};
|
||||
|
||||
explicit CaptureTool(QObject *parent = nullptr);
|
||||
|
||||
virtual int id() const = 0;
|
||||
virtual bool isSelectable() const = 0;
|
||||
virtual ToolWorkType toolType() const = 0;
|
||||
|
||||
virtual QString iconName() const = 0;
|
||||
virtual QString name() const = 0;
|
||||
virtual QString description() const = 0;
|
||||
|
||||
virtual void processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness) = 0;
|
||||
|
||||
signals:
|
||||
void requestAction(Request r);
|
||||
|
||||
public slots:
|
||||
virtual void onPressed() = 0;
|
||||
|
||||
};
|
||||
@@ -1,60 +0,0 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "circletool.h"
|
||||
#include <QPainter>
|
||||
|
||||
CircleTool::CircleTool(QObject *parent) : CaptureTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
int CircleTool::id() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CircleTool::isSelectable() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
QString CircleTool::iconName() const {
|
||||
return "circle-outline.png";
|
||||
}
|
||||
|
||||
QString CircleTool::name() const {
|
||||
return tr("Circle");
|
||||
}
|
||||
|
||||
QString CircleTool::description() const {
|
||||
return tr("Sets the Circle as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool::ToolWorkType CircleTool::toolType() const {
|
||||
return TYPE_LINE_DRAWER;
|
||||
}
|
||||
|
||||
void CircleTool::processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness)
|
||||
{
|
||||
painter.setPen(QPen(color, 2 + thickness));
|
||||
painter.drawEllipse(QRect(points[0], points[1]));
|
||||
}
|
||||
|
||||
void CircleTool::onPressed() {
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "linetool.h"
|
||||
#include <QPainter>
|
||||
|
||||
#define ADJ_VALUE 13
|
||||
|
||||
LineTool::LineTool(QObject *parent) : CaptureTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
int LineTool::id() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool LineTool::isSelectable() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
QString LineTool::iconName() const {
|
||||
return "line.png";
|
||||
}
|
||||
|
||||
QString LineTool::name() const {
|
||||
return tr("Line");
|
||||
}
|
||||
|
||||
QString LineTool::description() const {
|
||||
return tr("Sets the Line as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool::ToolWorkType LineTool::toolType() const {
|
||||
return TYPE_LINE_DRAWER;
|
||||
}
|
||||
|
||||
void LineTool::processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness)
|
||||
{
|
||||
QPoint p0 = points[0];
|
||||
QPoint p1 = points[1];
|
||||
if (needsAdjustment(p0, p1)) {
|
||||
p1.setY(p0.y());
|
||||
}
|
||||
painter.setPen(QPen(color, 2 + thickness));
|
||||
painter.drawLine(p0, p1);
|
||||
}
|
||||
|
||||
void LineTool::onPressed() {
|
||||
}
|
||||
|
||||
// Have to force horizontal position
|
||||
bool LineTool::needsAdjustment(const QPoint &p0, const QPoint &p1) const {
|
||||
return (p1.y() >= p0.y() - ADJ_VALUE) && (p1.y() <= p0.y() + ADJ_VALUE);
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "markertool.h"
|
||||
#include <QPainter>
|
||||
|
||||
#define ADJ_VALUE 14
|
||||
|
||||
MarkerTool::MarkerTool(QObject *parent) : CaptureTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
int MarkerTool::id() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool MarkerTool::isSelectable() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
QString MarkerTool::iconName() const {
|
||||
return "marker.png";
|
||||
}
|
||||
|
||||
QString MarkerTool::name() const {
|
||||
return tr("Marker");
|
||||
}
|
||||
|
||||
QString MarkerTool::description() const {
|
||||
return tr("Sets the Marker as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool::ToolWorkType MarkerTool::toolType() const {
|
||||
return TYPE_LINE_DRAWER;
|
||||
}
|
||||
|
||||
void MarkerTool::processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness)
|
||||
{
|
||||
QPoint p0 = points[0];
|
||||
QPoint p1 = points[1];
|
||||
if (needsAdjustment(p0, p1)) {
|
||||
p1.setY(p0.y());
|
||||
}
|
||||
painter.setOpacity(0.35);
|
||||
painter.setPen(QPen(color, 14 + thickness));
|
||||
painter.drawLine(p0, p1);
|
||||
painter.setOpacity(1);
|
||||
}
|
||||
|
||||
void MarkerTool::onPressed() {
|
||||
}
|
||||
|
||||
// Have to force horizontal position
|
||||
bool MarkerTool::needsAdjustment(const QPoint &p0, const QPoint &p1) const {
|
||||
return (p1.y() >= p0.y() - ADJ_VALUE) && (p1.y() <= p0.y() + ADJ_VALUE);
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "penciltool.h"
|
||||
#include <QPainter>
|
||||
|
||||
PencilTool::PencilTool(QObject *parent) : CaptureTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
int PencilTool::id() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool PencilTool::isSelectable() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
QString PencilTool::iconName() const {
|
||||
return "pencil.png";
|
||||
}
|
||||
|
||||
QString PencilTool::name() const {
|
||||
return tr("Pencil");
|
||||
}
|
||||
|
||||
QString PencilTool::description() const {
|
||||
return tr("Sets the Pencil as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool::ToolWorkType PencilTool::toolType() const {
|
||||
return TYPE_PATH_DRAWER;
|
||||
}
|
||||
|
||||
void PencilTool::processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness)
|
||||
{
|
||||
painter.setPen(QPen(color, 2 + thickness));
|
||||
if (points.length() == 2) {
|
||||
painter.drawLine(points[0], points[1]);
|
||||
} else {
|
||||
painter.drawPolyline(points.data(), points.size());
|
||||
}
|
||||
}
|
||||
|
||||
void PencilTool::onPressed() {
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "rectangletool.h"
|
||||
#include <QPainter>
|
||||
|
||||
RectangleTool::RectangleTool(QObject *parent) : CaptureTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
int RectangleTool::id() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool RectangleTool::isSelectable() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
QString RectangleTool::iconName() const {
|
||||
return "square.png";
|
||||
}
|
||||
|
||||
QString RectangleTool::name() const {
|
||||
return tr("Rectangle");
|
||||
}
|
||||
|
||||
QString RectangleTool::description() const {
|
||||
return tr("Sets the Rectangle as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool::ToolWorkType RectangleTool::toolType() const {
|
||||
return TYPE_LINE_DRAWER;
|
||||
}
|
||||
|
||||
void RectangleTool::processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness)
|
||||
{
|
||||
painter.setPen(QPen(color, 2 + thickness));
|
||||
painter.setBrush(QBrush(color));
|
||||
painter.drawRect(QRect(points[0], points[1]));
|
||||
painter.setBrush(QBrush());
|
||||
}
|
||||
|
||||
void RectangleTool::onPressed() {
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "selectiontool.h"
|
||||
#include <QPainter>
|
||||
|
||||
SelectionTool::SelectionTool(QObject *parent) : CaptureTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
int SelectionTool::id() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool SelectionTool::isSelectable() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
QString SelectionTool::iconName() const {
|
||||
return "square-outline.png";
|
||||
}
|
||||
|
||||
QString SelectionTool::name() const {
|
||||
return tr("Rectangular Selection");
|
||||
}
|
||||
|
||||
QString SelectionTool::description() const {
|
||||
return tr("Sets the Selection as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool::ToolWorkType SelectionTool::toolType() const {
|
||||
return TYPE_LINE_DRAWER;
|
||||
}
|
||||
|
||||
void SelectionTool::processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness)
|
||||
{
|
||||
painter.setPen(QPen(color, 2 + thickness));
|
||||
painter.drawRect(QRect(points[0], points[1]));
|
||||
}
|
||||
|
||||
void SelectionTool::onPressed() {
|
||||
}
|
||||
@@ -19,8 +19,7 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
class CommandArgument
|
||||
{
|
||||
class CommandArgument {
|
||||
public:
|
||||
CommandArgument();
|
||||
explicit CommandArgument(const QString &name, const QString &description);
|
||||
@@ -38,5 +37,4 @@ public:
|
||||
private:
|
||||
QString m_name;
|
||||
QString m_description;
|
||||
|
||||
};
|
||||
|
||||
@@ -21,8 +21,7 @@
|
||||
#include "src/cli/commandoption.h"
|
||||
#include <QMap>
|
||||
|
||||
class CommandLineParser
|
||||
{
|
||||
class CommandLineParser {
|
||||
public:
|
||||
CommandLineParser();
|
||||
|
||||
@@ -87,5 +86,4 @@ private:
|
||||
bool processOptions(const QStringList &args,
|
||||
QStringList::const_iterator &actualIt,
|
||||
Node *const actualNode);
|
||||
|
||||
};
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
|
||||
using std::function;
|
||||
|
||||
class CommandOption
|
||||
{
|
||||
class CommandOption {
|
||||
public:
|
||||
CommandOption(const QString &name, const QString &description,
|
||||
const QString &valueName = QString(),
|
||||
@@ -61,5 +60,4 @@ private:
|
||||
|
||||
function<bool(QString const&)> m_checker;
|
||||
QString m_errorMsg;
|
||||
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "buttonlistview.h"
|
||||
#include "src/capture/tools/toolfactory.h"
|
||||
#include "src/tools/toolfactory.h"
|
||||
#include "src/utils/confighandler.h"
|
||||
#include <QListWidgetItem>
|
||||
#include <algorithm>
|
||||
@@ -45,14 +45,7 @@ void ButtonListView::initButtonList() {
|
||||
|
||||
// when the background is lighter than gray, it uses the white icons
|
||||
QColor bgColor = this->palette().color(QWidget::backgroundRole());
|
||||
QString color = bgColor.valueF() < 0.6 ? "White" : "Black";
|
||||
QString iconPath = QStringLiteral(":/img/buttonIcons%1/%2")
|
||||
.arg(color).arg(tool->iconName());
|
||||
if (t == CaptureButton::TYPE_SELECTIONINDICATOR) {
|
||||
iconPath = QStringLiteral(":/img/buttonIcons%1/size_indicator.png")
|
||||
.arg(color);
|
||||
}
|
||||
m_buttonItem->setIcon(QIcon(iconPath));
|
||||
m_buttonItem->setIcon(tool->icon(bgColor, false));
|
||||
|
||||
m_buttonItem->setFlags(Qt::ItemIsUserCheckable);
|
||||
QColor foregroundColor = this->palette().color(QWidget::foregroundRole());
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "src/capture/widgets/capturebutton.h"
|
||||
#include "src/widgets/capture/capturebutton.h"
|
||||
#include <QListWidget>
|
||||
|
||||
class ButtonListView : public QListWidget {
|
||||
@@ -39,5 +39,4 @@ private:
|
||||
QMap<QString, CaptureButton::ButtonType> m_buttonTypeByName;
|
||||
|
||||
void updateActiveButtons(QListWidgetItem *);
|
||||
|
||||
};
|
||||
|
||||
@@ -26,5 +26,5 @@ ClickableLabel::ClickableLabel(QString s, QWidget *parent) : QLabel(parent) {
|
||||
}
|
||||
|
||||
void ClickableLabel::mousePressEvent(QMouseEvent *) {
|
||||
Q_EMIT clicked();
|
||||
emit clicked();
|
||||
}
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
|
||||
#include <QLabel>
|
||||
|
||||
class ClickableLabel : public QLabel
|
||||
{
|
||||
class ClickableLabel : public QLabel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ClickableLabel(QWidget *parent = nullptr);
|
||||
@@ -31,5 +30,4 @@ signals:
|
||||
|
||||
private:
|
||||
void mousePressEvent (QMouseEvent *);
|
||||
|
||||
};
|
||||
|
||||
@@ -16,12 +16,15 @@
|
||||
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "configwindow.h"
|
||||
#include "src/capture/widgets/capturebutton.h"
|
||||
#include "src/utils/colorutils.h"
|
||||
#include "src/utils/confighandler.h"
|
||||
#include "src/utils/pathinfo.h"
|
||||
#include "src/widgets/capture/capturebutton.h"
|
||||
#include "src/config/geneneralconf.h"
|
||||
#include "src/config/filenameeditor.h"
|
||||
#include "src/config/strftimechooserwidget.h"
|
||||
#include "src/utils/confighandler.h"
|
||||
#include "src/config/visualseditor.h"
|
||||
#include "src/utils/globalvalues.h"
|
||||
#include <QIcon>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
@@ -32,7 +35,7 @@
|
||||
|
||||
ConfigWindow::ConfigWindow(QWidget *parent) : QTabWidget(parent) {
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
const int size = CaptureButton::buttonBaseSize() * 12;
|
||||
const int size = GlobalValues::buttonBaseSize() * 12;
|
||||
setMinimumSize(size, size);
|
||||
setWindowIcon(QIcon(":img/flameshot.png"));
|
||||
setWindowTitle(tr("Configuration"));
|
||||
@@ -42,7 +45,7 @@ ConfigWindow::ConfigWindow(QWidget *parent) : QTabWidget(parent) {
|
||||
if (!files.contains(s)) {
|
||||
this->m_configWatcher->addPath(s);
|
||||
}
|
||||
Q_EMIT updateChildren();
|
||||
emit updateChildren();
|
||||
};
|
||||
m_configWatcher = new QFileSystemWatcher(this);
|
||||
m_configWatcher->addPath(ConfigHandler().configFilePath());
|
||||
@@ -50,8 +53,8 @@ ConfigWindow::ConfigWindow(QWidget *parent) : QTabWidget(parent) {
|
||||
this, changedSlot);
|
||||
|
||||
QColor background = this->palette().background().color();
|
||||
bool isWhite = CaptureButton::iconIsWhiteByColor(background);
|
||||
QString modifier = isWhite ? ":img/configWhite/" : ":img/configBlack/";
|
||||
bool isDark = ColorUtils::colorIsDark(background);
|
||||
QString modifier = isDark ? PathInfo::whiteIconPath() : PathInfo::blackIconPath();
|
||||
|
||||
// visuals
|
||||
m_visuals = new VisualsEditor();
|
||||
|
||||
@@ -40,5 +40,4 @@ private:
|
||||
GeneneralConf *m_generalConfig;
|
||||
VisualsEditor *m_visuals;
|
||||
QFileSystemWatcher *m_configWatcher;
|
||||
|
||||
};
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
#include <QSlider>
|
||||
#include <QTimer>
|
||||
|
||||
class ExtendedSlider : public QSlider
|
||||
{
|
||||
class ExtendedSlider : public QSlider {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ExtendedSlider(QWidget *parent = nullptr);
|
||||
@@ -38,5 +37,4 @@ private slots:
|
||||
|
||||
private:
|
||||
QTimer m_timer;
|
||||
|
||||
};
|
||||
|
||||
@@ -26,8 +26,7 @@ class FileNameHandler;
|
||||
class QPushButton;
|
||||
class StrftimeChooserWidget;
|
||||
|
||||
class FileNameEditor : public QWidget
|
||||
{
|
||||
class FileNameEditor : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FileNameEditor(QWidget *parent = nullptr);
|
||||
@@ -53,5 +52,4 @@ private slots:
|
||||
void savePattern();
|
||||
void showParsedPattern(const QString &);
|
||||
void resetName();
|
||||
|
||||
};
|
||||
|
||||
@@ -55,5 +55,4 @@ private:
|
||||
void initShowTrayIcon();
|
||||
void initConfingButtons();
|
||||
void initAutostart();
|
||||
|
||||
};
|
||||
|
||||
@@ -37,7 +37,7 @@ StrftimeChooserWidget::StrftimeChooserWidget(QWidget *parent) : QWidget(parent)
|
||||
button->setMinimumHeight(25);
|
||||
layout->addWidget(button, j, i);
|
||||
connect(button, &QPushButton::clicked,
|
||||
this, [variable, this](){Q_EMIT variableEmitted(variable);});
|
||||
this, [variable, this](){emit variableEmitted(variable);});
|
||||
}
|
||||
}
|
||||
setLayout(layout);
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class StrftimeChooserWidget : public QWidget
|
||||
{
|
||||
class StrftimeChooserWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit StrftimeChooserWidget(QWidget *parent = nullptr);
|
||||
@@ -30,5 +29,4 @@ signals:
|
||||
|
||||
private:
|
||||
static QMap<QString, QString> m_buttonData;
|
||||
|
||||
};
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "src/utils/confighandler.h"
|
||||
#include "uicoloreditor.h"
|
||||
#include "clickablelabel.h"
|
||||
#include "src/utils/globalvalues.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QApplication>
|
||||
#include <QVBoxLayout>
|
||||
@@ -85,7 +86,7 @@ void UIcolorEditor::initColorWheel() {
|
||||
connect(m_colorWheel, &color_widgets::ColorWheel::colorChanged, this,
|
||||
&UIcolorEditor::updateLocalColor);
|
||||
|
||||
const int size = CaptureButton::buttonBaseSize() * 3;
|
||||
const int size = GlobalValues::buttonBaseSize() * 3;
|
||||
m_colorWheel->setMinimumSize(size, size);
|
||||
m_colorWheel->setMaximumSize(size*2, size*2);
|
||||
m_colorWheel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
@@ -96,8 +97,8 @@ void UIcolorEditor::initColorWheel() {
|
||||
}
|
||||
|
||||
void UIcolorEditor::initButtons() {
|
||||
const int extraSize = CaptureButton::buttonBaseSize() / 3;
|
||||
int frameSize = CaptureButton::buttonBaseSize() + extraSize;
|
||||
const int extraSize = GlobalValues::buttonBaseSize() / 3;
|
||||
int frameSize = GlobalValues::buttonBaseSize() + extraSize;
|
||||
|
||||
m_vLayout->addWidget(new QLabel(tr("Select a Button to modify it"), this));
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "color_wheel.hpp"
|
||||
#include "src/capture/widgets/capturebutton.h"
|
||||
#include "src/widgets/capture/capturebutton.h"
|
||||
#include <QGroupBox>
|
||||
|
||||
class QVBoxLayout;
|
||||
@@ -55,5 +55,4 @@ private:
|
||||
|
||||
void initColorWheel();
|
||||
void initButtons();
|
||||
|
||||
};
|
||||
|
||||
@@ -24,8 +24,7 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
VisualsEditor::VisualsEditor(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
VisualsEditor::VisualsEditor(QWidget *parent) : QWidget(parent) {
|
||||
m_layout= new QVBoxLayout();
|
||||
setLayout(m_layout);
|
||||
initWidgets();
|
||||
|
||||
@@ -24,8 +24,7 @@ class QVBoxLayout;
|
||||
class ButtonListView;
|
||||
class UIcolorEditor;
|
||||
|
||||
class VisualsEditor : public QWidget
|
||||
{
|
||||
class VisualsEditor : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VisualsEditor(QWidget *parent = nullptr);
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "controller.h"
|
||||
#include "src/capture/widgets/capturewidget.h"
|
||||
#include "src/widgets/capture/capturewidget.h"
|
||||
#include "src/utils/confighandler.h"
|
||||
#include "src/infowindow.h"
|
||||
#include "src/widgets/infowindow.h"
|
||||
#include "src/config/configwindow.h"
|
||||
#include "src/capture/widgets/capturebutton.h"
|
||||
#include "src/widgets/capture/capturebutton.h"
|
||||
#include <QFile>
|
||||
#include <QApplication>
|
||||
#include <QSystemTrayIcon>
|
||||
@@ -34,8 +34,7 @@
|
||||
// Controller is the core component of Flameshot, creates the trayIcon and
|
||||
// launches the capture widget
|
||||
|
||||
Controller::Controller() : m_captureWindow(nullptr)
|
||||
{
|
||||
Controller::Controller() : m_captureWindow(nullptr) {
|
||||
qApp->setQuitOnLastWindowClosed(false);
|
||||
|
||||
// init tray icon
|
||||
|
||||
@@ -63,5 +63,4 @@ private:
|
||||
QPointer<InfoWindow> m_infoWindow;
|
||||
QPointer<ConfigWindow> m_configWindow;
|
||||
QPointer<QSystemTrayIcon> m_trayIcon;
|
||||
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "src/utils/confighandler.h"
|
||||
#include "src/utils/screengrabber.h"
|
||||
#include "src/core/controller.h"
|
||||
#include "src/core/resourceexporter.h"
|
||||
#include "src/utils/screenshotsaver.h"
|
||||
#include "src/utils/systemnotification.h"
|
||||
#include <QTimer>
|
||||
#include <functional>
|
||||
@@ -72,20 +72,19 @@ void FlameshotDBusAdapter::fullScreen(
|
||||
QPixmap p(ScreenGrabber().grabEntireDesktop(ok));
|
||||
if (!ok) {
|
||||
SystemNotification().sendMessage(tr("Unable to capture screen"));
|
||||
Q_EMIT captureFailed(id);
|
||||
emit captureFailed(id);
|
||||
return;
|
||||
}
|
||||
// This needs to be done first in order to prevent a severe block
|
||||
if(!path.isEmpty()) {
|
||||
ResourceExporter().captureToFile(p, path);
|
||||
ScreenshotSaver().saveToFilesystem(p, path);
|
||||
}
|
||||
if(toClipboard) {
|
||||
ResourceExporter().captureToClipboard(p);
|
||||
ScreenshotSaver().saveToClipboard(p);
|
||||
}
|
||||
QByteArray byteArray;
|
||||
QBuffer buffer(&byteArray);
|
||||
p.save(&buffer, "PNG");
|
||||
Q_EMIT captureTaken(id, byteArray);
|
||||
emit captureTaken(id, byteArray);
|
||||
};
|
||||
//QTimer::singleShot(delay, this, f); // // requires Qt 5.4
|
||||
doLater(delay, this, f);
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
#include <QtDBus/QDBusAbstractAdaptor>
|
||||
#include "src/core/controller.h"
|
||||
|
||||
class FlameshotDBusAdapter : public QDBusAbstractAdaptor
|
||||
{
|
||||
class FlameshotDBusAdapter : public QDBusAbstractAdaptor {
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.dharkael.Flameshot")
|
||||
|
||||
@@ -38,5 +37,4 @@ public slots:
|
||||
Q_NOREPLY void fullScreen(QString path, bool toClipboard, int delay, uint id);
|
||||
Q_NOREPLY void openConfig();
|
||||
Q_NOREPLY void trayIconEnabled(bool enabled);
|
||||
|
||||
};
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
class GlobalShortcutFilter : public QObject, public QAbstractNativeEventFilter {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GlobalShortcutFilter(QObject *parent = 0);
|
||||
explicit GlobalShortcutFilter(QObject *parent = nullptr);
|
||||
|
||||
bool nativeEventFilter(const QByteArray &eventType, void *message, long *result);
|
||||
|
||||
@@ -35,5 +35,4 @@ private:
|
||||
quint32 nativeKeycode(Qt::Key key);
|
||||
bool registerShortcut(quint32 nativeKey, quint32 nativeMods);
|
||||
bool unregisterShortcut(quint32 nativeKey, quint32 nativeMods);
|
||||
|
||||
};
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "resourceexporter.h"
|
||||
#include "src/capture/workers/imgur/imguruploader.h"
|
||||
#include "src/capture/workers/screenshotsaver.h"
|
||||
#include "src/capture/workers/launcher/openwithprogram.h"
|
||||
|
||||
ResourceExporter::ResourceExporter() {
|
||||
|
||||
}
|
||||
|
||||
void ResourceExporter::captureToClipboard(const QPixmap &p) {
|
||||
ScreenshotSaver().saveToClipboard(p);
|
||||
}
|
||||
|
||||
void ResourceExporter::captureToFile(const QPixmap &p, const QString &path) {
|
||||
ScreenshotSaver().saveToFilesystem(p, path);
|
||||
}
|
||||
|
||||
void ResourceExporter::captureToFileUi(const QPixmap &p) {
|
||||
ScreenshotSaver().saveToFilesystemGUI(p);
|
||||
}
|
||||
|
||||
void ResourceExporter::captureToImgur(const QPixmap &p) {
|
||||
auto w = new ImgurUploader(p);
|
||||
w->show();
|
||||
}
|
||||
|
||||
void ResourceExporter::captureToProgram(const QPixmap &p) {
|
||||
showOpenWithMenu(p);
|
||||
}
|
||||
@@ -46,7 +46,7 @@ int main(int argc, char *argv[]) {
|
||||
SingleApplication app(argc, argv);
|
||||
|
||||
QTranslator translator;
|
||||
QStringList trPaths = PathInfo::translations();
|
||||
QStringList trPaths = PathInfo::translationsPaths();
|
||||
bool match = false;
|
||||
for (const QString &path: trPaths) {
|
||||
match = translator.load(QLocale::system().language(),
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
Q_DECLARE_FLAGS(DisplayFlags, DisplayEnum)
|
||||
Q_FLAGS(DisplayFlags)
|
||||
|
||||
explicit ColorWheel(QWidget *parent = 0);
|
||||
explicit ColorWheel(QWidget *parent = nullptr);
|
||||
~ColorWheel();
|
||||
|
||||
/// Get current color
|
||||
|
||||
@@ -381,8 +381,8 @@ void ColorWheel::mouseMoveEvent(QMouseEvent *ev)
|
||||
p->hue = p->line_to_point(ev->pos()).angle()/360.0;
|
||||
p->render_inner_selector();
|
||||
|
||||
Q_EMIT colorSelected(color());
|
||||
Q_EMIT colorChanged(color());
|
||||
emit colorSelected(color());
|
||||
emit colorChanged(color());
|
||||
update();
|
||||
}
|
||||
else if(p->mouse_status == DragSquare)
|
||||
@@ -414,8 +414,8 @@ void ColorWheel::mouseMoveEvent(QMouseEvent *ev)
|
||||
p->sat = qBound(0.0, (pt.y()-ymin)/slice_h, 1.0);
|
||||
}
|
||||
|
||||
Q_EMIT colorSelected(color());
|
||||
Q_EMIT colorChanged(color());
|
||||
emit colorSelected(color());
|
||||
emit colorChanged(color());
|
||||
update();
|
||||
}
|
||||
}
|
||||
@@ -440,7 +440,7 @@ void ColorWheel::mouseReleaseEvent(QMouseEvent *ev)
|
||||
{
|
||||
mouseMoveEvent(ev);
|
||||
p->mouse_status = Nothing;
|
||||
Q_EMIT mouseReleaseOnColor(color());
|
||||
emit mouseReleaseOnColor(color());
|
||||
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ void ColorWheel::setColor(QColor c)
|
||||
if (!qFuzzyCompare(oldh+1, p->hue+1))
|
||||
p->render_inner_selector();
|
||||
update();
|
||||
Q_EMIT colorChanged(c);
|
||||
emit colorChanged(c);
|
||||
}
|
||||
|
||||
void ColorWheel::setHue(qreal h)
|
||||
@@ -522,7 +522,7 @@ void ColorWheel::setDisplayFlags(DisplayFlags flags)
|
||||
p->display_flags = flags;
|
||||
p->render_inner_selector();
|
||||
update();
|
||||
Q_EMIT displayFlagsChanged(flags);
|
||||
emit displayFlagsChanged(flags);
|
||||
}
|
||||
|
||||
ColorWheel::DisplayFlags ColorWheel::displayFlags(DisplayFlags mask) const
|
||||
|
||||
@@ -313,7 +313,7 @@ void SingleApplicationPrivate::slotConnectionEstablished()
|
||||
&QLocalSocket::aboutToClose,
|
||||
this,
|
||||
[nextConnSocket, instanceId, this]() {
|
||||
Q_EMIT this->slotClientConnectionClosed( nextConnSocket, instanceId );
|
||||
emit this->slotClientConnectionClosed( nextConnSocket, instanceId );
|
||||
}
|
||||
);
|
||||
|
||||
@@ -322,7 +322,7 @@ void SingleApplicationPrivate::slotConnectionEstablished()
|
||||
&QLocalSocket::readyRead,
|
||||
this,
|
||||
[nextConnSocket, instanceId, this]() {
|
||||
Q_EMIT this->slotDataAvailable( nextConnSocket, instanceId );
|
||||
emit this->slotDataAvailable( nextConnSocket, instanceId );
|
||||
}
|
||||
);
|
||||
|
||||
@@ -331,24 +331,24 @@ void SingleApplicationPrivate::slotConnectionEstablished()
|
||||
options & SingleApplication::Mode::SecondaryNotification
|
||||
)
|
||||
) {
|
||||
Q_EMIT q->instanceStarted();
|
||||
emit q->instanceStarted();
|
||||
}
|
||||
|
||||
if( nextConnSocket->bytesAvailable() > 0 ) {
|
||||
Q_EMIT this->slotDataAvailable( nextConnSocket, instanceId );
|
||||
emit this->slotDataAvailable( nextConnSocket, instanceId );
|
||||
}
|
||||
}
|
||||
|
||||
void SingleApplicationPrivate::slotDataAvailable( QLocalSocket *dataSocket, quint32 instanceId )
|
||||
{
|
||||
Q_Q(SingleApplication);
|
||||
Q_EMIT q->receivedMessage( instanceId, dataSocket->readAll() );
|
||||
emit q->receivedMessage( instanceId, dataSocket->readAll() );
|
||||
}
|
||||
|
||||
void SingleApplicationPrivate::slotClientConnectionClosed( QLocalSocket *closedSocket, quint32 instanceId )
|
||||
{
|
||||
if( closedSocket->bytesAvailable() > 0 )
|
||||
Q_EMIT slotDataAvailable( closedSocket, instanceId );
|
||||
emit slotDataAvailable( closedSocket, instanceId );
|
||||
closedSocket->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
1
src/tools/TODO SPLIT SCREENSHOT SAVER
Normal file
1
src/tools/TODO SPLIT SCREENSHOT SAVER
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
71
src/tools/abstractactiontool.cpp
Normal file
71
src/tools/abstractactiontool.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "abstractactiontool.h"
|
||||
|
||||
AbstractActionTool::AbstractActionTool(QObject *parent) : CaptureTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
bool AbstractActionTool::isValid() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AbstractActionTool::isSelectable() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AbstractActionTool::showMousePreview() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
QWidget *AbstractActionTool::widget() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QWidget *AbstractActionTool::configurationWidget() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void AbstractActionTool::undo(QPixmap &pixmap) {
|
||||
Q_UNUSED(pixmap);
|
||||
}
|
||||
|
||||
void AbstractActionTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) {
|
||||
Q_UNUSED(painter);
|
||||
Q_UNUSED(pixmap);
|
||||
Q_UNUSED(recordUndo);
|
||||
}
|
||||
|
||||
void AbstractActionTool::paintMousePreview(
|
||||
QPainter &painter, const CaptureContext &context)
|
||||
{
|
||||
Q_UNUSED(painter);
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
|
||||
void AbstractActionTool::drawEnd(const QPoint &p) {
|
||||
Q_UNUSED(p);
|
||||
}
|
||||
|
||||
void AbstractActionTool::drawMove(const QPoint &p) {
|
||||
Q_UNUSED(p);
|
||||
}
|
||||
|
||||
void AbstractActionTool::drawStart(const CaptureContext &context) {
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
42
src/tools/abstractactiontool.h
Normal file
42
src/tools/abstractactiontool.h
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "capturetool.h"
|
||||
|
||||
class AbstractActionTool : public CaptureTool{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AbstractActionTool(QObject *parent = nullptr);
|
||||
|
||||
bool isValid() const;
|
||||
bool isSelectable() const override;
|
||||
bool showMousePreview() const override;
|
||||
|
||||
QWidget* widget() override;
|
||||
QWidget* configurationWidget() override;
|
||||
|
||||
void undo(QPixmap &pixmap) override;
|
||||
void process(QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) override;
|
||||
void paintMousePreview(QPainter &painter, const CaptureContext &context) override;
|
||||
|
||||
public slots:
|
||||
void drawEnd(const QPoint &p) override;
|
||||
void drawMove(const QPoint &p) override;
|
||||
void drawStart(const CaptureContext &context) override;
|
||||
};
|
||||
82
src/tools/abstractpathtool.cpp
Normal file
82
src/tools/abstractpathtool.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "abstractpathtool.h"
|
||||
|
||||
AbstractPathTool::AbstractPathTool(QObject *parent) : CaptureTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
bool AbstractPathTool::isValid() const {
|
||||
return m_points.length() > 1;
|
||||
}
|
||||
|
||||
bool AbstractPathTool::closeOnButtonPressed() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AbstractPathTool::isSelectable() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AbstractPathTool::showMousePreview() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
QWidget *AbstractPathTool::widget() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QWidget *AbstractPathTool::configurationWidget() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void AbstractPathTool::undo(QPixmap &pixmap) {
|
||||
QPainter p(&pixmap);
|
||||
const int val = m_thickness;
|
||||
QRect area = m_backupArea + QMargins(val, val, val, val);
|
||||
p.drawPixmap(area.intersected(pixmap.rect())
|
||||
.topLeft(), m_pixmapBackup);
|
||||
}
|
||||
|
||||
void AbstractPathTool::drawEnd(const QPoint &p) {
|
||||
Q_UNUSED(p);
|
||||
}
|
||||
|
||||
void AbstractPathTool::drawMove(const QPoint &p) {
|
||||
addPoint(p);
|
||||
}
|
||||
|
||||
void AbstractPathTool::updateBackup(const QPixmap &pixmap) {
|
||||
const int val = m_thickness;
|
||||
QRect area = m_backupArea.normalized() + QMargins(val, val, val, val);
|
||||
m_pixmapBackup = pixmap.copy(area);
|
||||
}
|
||||
|
||||
void AbstractPathTool::addPoint(const QPoint &point) {
|
||||
if (m_backupArea.left() > point.x()) {
|
||||
m_backupArea.setLeft(point.x());
|
||||
} else if (m_backupArea.right() < point.x()) {
|
||||
m_backupArea.setRight(point.x());
|
||||
}
|
||||
if (m_backupArea.top() > point.y()) {
|
||||
m_backupArea.setTop(point.y());
|
||||
} else if (m_backupArea.bottom() < point.y()) {
|
||||
m_backupArea.setBottom(point.y());
|
||||
}
|
||||
m_points.append(point);
|
||||
}
|
||||
49
src/tools/abstractpathtool.h
Normal file
49
src/tools/abstractpathtool.h
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "capturetool.h"
|
||||
|
||||
class AbstractPathTool : public CaptureTool {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AbstractPathTool(QObject *parent = nullptr);
|
||||
|
||||
bool isValid() const;
|
||||
bool closeOnButtonPressed() const;
|
||||
bool isSelectable() const override;
|
||||
bool showMousePreview() const override;
|
||||
|
||||
QWidget* widget() override;
|
||||
QWidget* configurationWidget() override;
|
||||
|
||||
void undo(QPixmap &pixmap) override;
|
||||
|
||||
public slots:
|
||||
void drawEnd(const QPoint &p) override;
|
||||
void drawMove(const QPoint &p) override;
|
||||
|
||||
protected:
|
||||
void updateBackup(const QPixmap &pixmap);
|
||||
void addPoint(const QPoint &point);
|
||||
|
||||
QPixmap m_pixmapBackup;
|
||||
QRect m_backupArea;
|
||||
QVector<QPoint> m_points;
|
||||
int m_thickness;
|
||||
};
|
||||
66
src/tools/abstracttwopointtool.cpp
Normal file
66
src/tools/abstracttwopointtool.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "abstracttwopointtool.h"
|
||||
|
||||
bool AbstractTwoPointTool::isValid() const {
|
||||
return (m_points.first != m_points.second);
|
||||
}
|
||||
|
||||
bool AbstractTwoPointTool::closeOnButtonPressed() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AbstractTwoPointTool::isSelectable() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AbstractTwoPointTool::showMousePreview() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
QWidget *AbstractTwoPointTool::widget() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QWidget *AbstractTwoPointTool::configurationWidget() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void AbstractTwoPointTool::undo(QPixmap &pixmap) {
|
||||
QPainter p(&pixmap);
|
||||
p.drawPixmap(backupRect(pixmap.rect()).topLeft(), m_pixmapBackup);
|
||||
}
|
||||
|
||||
void AbstractTwoPointTool::drawEnd(const QPoint &p) {
|
||||
Q_UNUSED(p);
|
||||
}
|
||||
|
||||
void AbstractTwoPointTool::drawMove(const QPoint &p) {
|
||||
m_points.second = p;
|
||||
}
|
||||
|
||||
void AbstractTwoPointTool::updateBackup(const QPixmap &pixmap) {
|
||||
m_pixmapBackup = pixmap.copy(backupRect(pixmap.rect()));
|
||||
}
|
||||
|
||||
QRect AbstractTwoPointTool::backupRect(const QRect &limits) const {
|
||||
QRect r = QRect(m_points.first, m_points.second).normalized();
|
||||
const int val = m_thickness;
|
||||
r += QMargins(val, val, val, val);
|
||||
return r.intersected(limits);
|
||||
}
|
||||
49
src/tools/abstracttwopointtool.h
Normal file
49
src/tools/abstracttwopointtool.h
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "capturetool.h"
|
||||
|
||||
class AbstractTwoPointTool : public CaptureTool {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AbstractTwoPointTool(QObject *parent = nullptr) : CaptureTool(parent){}
|
||||
|
||||
bool isValid() const;
|
||||
bool closeOnButtonPressed() const;
|
||||
bool isSelectable() const override;
|
||||
bool showMousePreview() const override;
|
||||
|
||||
QWidget* widget() override;
|
||||
QWidget* configurationWidget() override;
|
||||
|
||||
void undo(QPixmap &pixmap) override;
|
||||
|
||||
public slots:
|
||||
void drawEnd(const QPoint &p) override;
|
||||
void drawMove(const QPoint &p) override;
|
||||
|
||||
protected:
|
||||
void updateBackup(const QPixmap &pixmap);
|
||||
QRect backupRect(const QRect &limits) const;
|
||||
|
||||
QPixmap m_pixmapBackup;
|
||||
QPair<QPoint, QPoint> m_points;
|
||||
int m_thickness;
|
||||
|
||||
};
|
||||
118
src/tools/arrow/arrowtool.cpp
Normal file
118
src/tools/arrow/arrowtool.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "arrowtool.h"
|
||||
|
||||
namespace {
|
||||
|
||||
#define PADDING_VALUE 2
|
||||
|
||||
const int ArrowWidth = 10;
|
||||
const int ArrowHeight = 18;
|
||||
|
||||
QPainterPath getArrowHead(QPoint p1, QPoint p2, const int thickness) {
|
||||
QLineF base(p1, p2);
|
||||
// Create the vector for the position of the base of the arrowhead
|
||||
QLineF temp(QPoint(0,0), p2-p1);
|
||||
int val = ArrowHeight + thickness*4;
|
||||
if (base.length() < val) {
|
||||
val = (base.length() + thickness*2);
|
||||
}
|
||||
temp.setLength(base.length() + thickness*2 - val);
|
||||
// Move across the line up to the head
|
||||
QPointF bottonTranslation(temp.p2());
|
||||
|
||||
// Rotate base of the arrowhead
|
||||
base.setLength(ArrowWidth + thickness*2);
|
||||
base.setAngle(base.angle() + 90);
|
||||
// Move to the correct point
|
||||
QPointF temp2 = p1 - base.p2();
|
||||
// Center it
|
||||
QPointF centerTranslation((temp2.x()/2), (temp2.y()/2));
|
||||
|
||||
base.translate(bottonTranslation);
|
||||
base.translate(centerTranslation);
|
||||
|
||||
QPainterPath path;
|
||||
path.moveTo(p2);
|
||||
path.lineTo(base.p1());
|
||||
path.lineTo(base.p2());
|
||||
path.lineTo(p2);
|
||||
return path;
|
||||
}
|
||||
|
||||
// gets a shorter line to prevent overlap in the point of the arrow
|
||||
QLine getShorterLine(QPoint p1, QPoint p2, const int thickness) {
|
||||
QLineF l(p1, p2);
|
||||
int val = ArrowHeight + thickness*4;
|
||||
if (l.length() < val) {
|
||||
val = (l.length() + thickness*2);
|
||||
}
|
||||
l.setLength(l.length() + thickness*2 - val);
|
||||
return l.toLine();
|
||||
}
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
ArrowTool::ArrowTool(QObject *parent) : AbstractTwoPointTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
QIcon ArrowTool::icon(const QColor &background, bool inEditor) const {
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "arrow-bottom-left.png");
|
||||
}
|
||||
QString ArrowTool::name() const {
|
||||
return tr("Arrow");
|
||||
}
|
||||
|
||||
QString ArrowTool::nameID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString ArrowTool::description() const {
|
||||
return tr("Sets the Arrow as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool* ArrowTool::copy(QObject *parent) {
|
||||
return new ArrowTool(parent);
|
||||
}
|
||||
|
||||
void ArrowTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) {
|
||||
if (recordUndo) {
|
||||
updateBackup(pixmap);
|
||||
}
|
||||
painter.setPen(QPen(m_color, m_thickness));
|
||||
painter.drawLine(getShorterLine(m_points.first, m_points.second, m_thickness));
|
||||
painter.fillPath(getArrowHead(m_points.first, m_points.second, m_thickness), QBrush(m_color));
|
||||
}
|
||||
|
||||
void ArrowTool::paintMousePreview(QPainter &painter, const CaptureContext &context) {
|
||||
painter.setPen(QPen(context.color, PADDING_VALUE + context.thickness));
|
||||
painter.drawLine(context.mousePos, context.mousePos);
|
||||
}
|
||||
|
||||
void ArrowTool::drawStart(const CaptureContext &context) {
|
||||
m_color = context.color;
|
||||
m_thickness = context.thickness + PADDING_VALUE;
|
||||
m_points.first = context.mousePos;
|
||||
m_points.second = context.mousePos;
|
||||
}
|
||||
|
||||
void ArrowTool::pressed(const CaptureContext &context) {
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
@@ -17,28 +17,28 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "capturetool.h"
|
||||
#include "src/tools/abstracttwopointtool.h"
|
||||
#include <QPainter>
|
||||
|
||||
class ArrowTool : public CaptureTool
|
||||
{
|
||||
class ArrowTool : public AbstractTwoPointTool {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ArrowTool(QObject *parent = nullptr);
|
||||
|
||||
int id() const override;
|
||||
bool isSelectable() const override;
|
||||
ToolWorkType toolType() const override;
|
||||
|
||||
QString iconName() const override;
|
||||
QIcon icon(const QColor &background, bool inEditor) const override;
|
||||
QString name() const override;
|
||||
static QString nameID();
|
||||
QString description() const override;
|
||||
|
||||
void processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness) override;
|
||||
CaptureTool* copy(QObject *parent = nullptr) override;
|
||||
void process(
|
||||
QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) override;
|
||||
void paintMousePreview(QPainter &painter, const CaptureContext &context) override;
|
||||
|
||||
void onPressed() override;
|
||||
public slots:
|
||||
void drawStart(const CaptureContext &context) override;
|
||||
void pressed(const CaptureContext &context) override;
|
||||
|
||||
private:
|
||||
QColor m_color;
|
||||
};
|
||||
@@ -20,53 +20,45 @@
|
||||
#include <QGraphicsBlurEffect>
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QGraphicsScene>
|
||||
#include <QApplication>
|
||||
|
||||
BlurTool::BlurTool(QObject *parent) : CaptureTool(parent) {
|
||||
BlurTool::BlurTool(QObject *parent) : AbstractTwoPointTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
int BlurTool::id() const {
|
||||
return 0;
|
||||
QIcon BlurTool::icon(const QColor &background, bool inEditor) const {
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "blur.png");
|
||||
}
|
||||
|
||||
bool BlurTool::isSelectable() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
QString BlurTool::iconName() const {
|
||||
return "blur.png";
|
||||
}
|
||||
|
||||
QString BlurTool::name() const {
|
||||
return tr("Blur");
|
||||
}
|
||||
|
||||
QString BlurTool::nameID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString BlurTool::description() const {
|
||||
return tr("Sets the Blur as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool::ToolWorkType BlurTool::toolType() const {
|
||||
return TYPE_LINE_DRAWER;
|
||||
CaptureTool* BlurTool::copy(QObject *parent) {
|
||||
return new BlurTool(parent);
|
||||
}
|
||||
#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];
|
||||
|
||||
void BlurTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) {
|
||||
if (recordUndo) {
|
||||
updateBackup(pixmap);
|
||||
}
|
||||
QPoint &p0 = m_points.first;
|
||||
QPoint &p1 = m_points.second;
|
||||
|
||||
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));
|
||||
pixmap.copy(selection));
|
||||
item->setGraphicsEffect(blur);
|
||||
|
||||
QGraphicsScene scene;
|
||||
@@ -78,5 +70,17 @@ void BlurTool::processImage(
|
||||
scene.render(&painter, selection, QRectF());
|
||||
}
|
||||
|
||||
void BlurTool::onPressed() {
|
||||
void BlurTool::paintMousePreview(QPainter &painter, const CaptureContext &context) {
|
||||
Q_UNUSED(context);
|
||||
Q_UNUSED(painter);
|
||||
}
|
||||
|
||||
void BlurTool::drawStart(const CaptureContext &context) {
|
||||
m_thickness = context.thickness;
|
||||
m_points.first = context.mousePos;
|
||||
m_points.second = context.mousePos;
|
||||
}
|
||||
|
||||
void BlurTool::pressed(const CaptureContext &context) {
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
@@ -17,31 +17,24 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "capturetool.h"
|
||||
#include "src/tools/abstracttwopointtool.h"
|
||||
|
||||
class BlurTool : public CaptureTool
|
||||
{
|
||||
class BlurTool : public AbstractTwoPointTool {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BlurTool(QObject *parent = nullptr);
|
||||
|
||||
int id() const override;
|
||||
bool isSelectable() const override;
|
||||
ToolWorkType toolType() const override;
|
||||
|
||||
QString iconName() const override;
|
||||
QIcon icon(const QColor &background, bool inEditor) const override;
|
||||
QString name() const override;
|
||||
static QString nameID();
|
||||
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;
|
||||
CaptureTool* copy(QObject *parent = nullptr) override;
|
||||
void process(
|
||||
QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) override;
|
||||
void paintMousePreview(QPainter &painter, const CaptureContext &context) override;
|
||||
|
||||
public slots:
|
||||
void drawStart(const CaptureContext &context) override;
|
||||
void pressed(const CaptureContext &context) override;
|
||||
};
|
||||
26
src/tools/capturecontext.cpp
Normal file
26
src/tools/capturecontext.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "capturecontext.h"
|
||||
|
||||
QPixmap CaptureContext::selectedScreenshotArea() const {
|
||||
if (selection.isNull()) {
|
||||
return screenshot;
|
||||
} else {
|
||||
return screenshot.copy(selection);
|
||||
}
|
||||
}
|
||||
@@ -17,34 +17,32 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QRect>
|
||||
#include <QPointer>
|
||||
#include <QObject>
|
||||
#include <QPoint>
|
||||
#include <QPixmap>
|
||||
#include <QPainter>
|
||||
|
||||
class QString;
|
||||
class CaptureModification;
|
||||
class QNetworkAccessManager;
|
||||
|
||||
class Screenshot : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Screenshot(const QPixmap &, QObject *parent = nullptr);
|
||||
~Screenshot();
|
||||
|
||||
void setScreenshot(const QPixmap &);
|
||||
QPixmap baseScreenshot() const;
|
||||
QPixmap screenshot() const;
|
||||
QPixmap croppedScreenshot(const QRect &selection) const;
|
||||
|
||||
QPixmap paintModification(const CaptureModification*);
|
||||
QPixmap paintTemporalModification(const CaptureModification*);
|
||||
QPixmap overrideModifications(const QVector<CaptureModification*> &);
|
||||
|
||||
private:
|
||||
QPixmap m_baseScreenshot;
|
||||
QPixmap m_modifiedScreenshot;
|
||||
|
||||
void paintInPainter(QPainter &, const CaptureModification *);
|
||||
struct CaptureContext {
|
||||
// screenshot with modifications
|
||||
QPixmap screenshot;
|
||||
// unmodified screenshot
|
||||
QPixmap origScreenshot;
|
||||
// Selection area
|
||||
QRect selection;
|
||||
// Widget dimensions
|
||||
QRect widgetDimensions;
|
||||
// Selected tool color
|
||||
QColor color;
|
||||
// Path where the content has to be saved
|
||||
QString savePath;
|
||||
// Ofset of the capture widget based on the system's screen (top-left)
|
||||
QPoint widgetOffset;
|
||||
// Mouse position inside the widget
|
||||
QPoint mousePos;
|
||||
// Value of the desired thickness
|
||||
int thickness;
|
||||
// Mode of the capture widget
|
||||
bool fullscreen;
|
||||
|
||||
QPixmap selectedScreenshotArea() const ;
|
||||
};
|
||||
109
src/tools/capturetool.h
Normal file
109
src/tools/capturetool.h
Normal file
@@ -0,0 +1,109 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "src/tools/capturecontext.h"
|
||||
#include "src/utils/colorutils.h"
|
||||
#include "src/utils/pathinfo.h"
|
||||
#include <QIcon>
|
||||
#include <QPainter>
|
||||
|
||||
class CaptureTool : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Request actions on the main widget
|
||||
enum Request {
|
||||
REQ_CLOSE_GUI,
|
||||
REQ_HIDE_GUI,
|
||||
REQ_SELECT_ALL,
|
||||
REQ_HIDE_SELECTION,
|
||||
REQ_UNDO_MODIFICATION,
|
||||
REQ_REDO_MODIFICATION,
|
||||
REQ_CLEAR_MODIFICATIONS,
|
||||
REQ_MOVE_MODE,
|
||||
REQ_SHOW_COLOR_PICKER,
|
||||
REQ_TOGGLE_SIDEBAR,
|
||||
REQ_REDRAW,
|
||||
REQ_CAPTURE_DONE_OK,
|
||||
REQ_ADD_CHILD_WIDGETS,
|
||||
REQ_ADD_CHILD_WINDOW,
|
||||
REQ_ADD_EXTERNAL_WIDGETS,
|
||||
};
|
||||
|
||||
explicit CaptureTool(QObject *parent = nullptr) : QObject(parent){}
|
||||
|
||||
// Returns false when the tool is in an inconsistent state and shouldn't
|
||||
// be included in the tool undo/redo stack.
|
||||
virtual bool isValid() const = 0;
|
||||
// Close the capture after the process() call if the tool was activated
|
||||
// from a button press.
|
||||
virtual bool closeOnButtonPressed() const = 0;
|
||||
// If the tool keeps active after the selection.
|
||||
virtual bool isSelectable() const = 0;
|
||||
// Enable mouse preview.
|
||||
virtual bool showMousePreview() const = 0;
|
||||
|
||||
// The icon of the tool.
|
||||
// inEditor is true when the icon is requested inside the editor
|
||||
// and false otherwise.
|
||||
virtual QIcon icon(const QColor &background,
|
||||
bool inEditor) const = 0;
|
||||
// Name displayed for the tool, this could be translated with tr()
|
||||
virtual QString name() const = 0;
|
||||
// Codename for the tool, this hsouldn't change as it is used as ID
|
||||
// for the tool in the internals of Flameshot
|
||||
static QString nameID();
|
||||
virtual QString description() const = 0;
|
||||
|
||||
// if the type is TYPE_WIDGET the widget is loaded in the main widget.
|
||||
// If the type is TYPE_EXTERNAL_WIDGET it is created outside as an
|
||||
// individual widget.
|
||||
virtual QWidget* widget() = 0;
|
||||
// When the tool is selected this method is called and the widget is added
|
||||
// to the configuration panel inside the main widget.
|
||||
virtual QWidget* configurationWidget() = 0;
|
||||
// Return a copy of the tool
|
||||
virtual CaptureTool* copy(QObject *parent = nullptr) = 0;
|
||||
|
||||
// revert changes
|
||||
virtual void undo(QPixmap &pixmap) = 0;
|
||||
// Called everytime the tool has to draw
|
||||
virtual void process(
|
||||
QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) = 0;
|
||||
// When the tool is selected, this is called when the mouse moves
|
||||
virtual void paintMousePreview(QPainter &painter, const CaptureContext &context) = 0;
|
||||
|
||||
signals:
|
||||
void requestAction(Request r);
|
||||
|
||||
protected:
|
||||
QString iconPath(const QColor &c) const {
|
||||
return ColorUtils::colorIsDark(c) ?
|
||||
PathInfo::whiteIconPath() : PathInfo::blackIconPath();
|
||||
}
|
||||
|
||||
public slots:
|
||||
// On mouse release
|
||||
virtual void drawEnd(const QPoint &p) = 0;
|
||||
// Mouse pressed and moving, called once a pixel
|
||||
virtual void drawMove(const QPoint &p) = 0;
|
||||
// Called when the tool is activated
|
||||
virtual void drawStart(const CaptureContext &context) = 0;
|
||||
virtual void pressed(const CaptureContext &context) = 0;
|
||||
};
|
||||
71
src/tools/circle/circletool.cpp
Normal file
71
src/tools/circle/circletool.cpp
Normal file
@@ -0,0 +1,71 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "circletool.h"
|
||||
#include <QPainter>
|
||||
|
||||
namespace {
|
||||
#define PADDING_VALUE 2
|
||||
}
|
||||
|
||||
CircleTool::CircleTool(QObject *parent) : AbstractTwoPointTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
QIcon CircleTool::icon(const QColor &background, bool inEditor) const {
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "circle-outline.png");
|
||||
}
|
||||
QString CircleTool::name() const {
|
||||
return tr("Circle");
|
||||
}
|
||||
|
||||
QString CircleTool::nameID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString CircleTool::description() const {
|
||||
return tr("Sets the Circle as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool* CircleTool::copy(QObject *parent) {
|
||||
return new CircleTool(parent);
|
||||
}
|
||||
|
||||
void CircleTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) {
|
||||
if (recordUndo) {
|
||||
updateBackup(pixmap);
|
||||
}
|
||||
painter.setPen(QPen(m_color, m_thickness));
|
||||
painter.drawEllipse(QRect(m_points.first, m_points.second));
|
||||
}
|
||||
|
||||
void CircleTool::paintMousePreview(QPainter &painter, const CaptureContext &context) {
|
||||
painter.setPen(QPen(context.color, PADDING_VALUE + context.thickness));
|
||||
painter.drawLine(context.mousePos, context.mousePos);
|
||||
}
|
||||
|
||||
void CircleTool::drawStart(const CaptureContext &context) {
|
||||
m_color = context.color;
|
||||
m_thickness = context.thickness + PADDING_VALUE;
|
||||
m_points.first = context.mousePos;
|
||||
m_points.second = context.mousePos;
|
||||
}
|
||||
|
||||
void CircleTool::pressed(const CaptureContext &context) {
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
@@ -17,28 +17,27 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "capturetool.h"
|
||||
#include "src/tools/abstracttwopointtool.h"
|
||||
|
||||
class CircleTool : public CaptureTool
|
||||
{
|
||||
class CircleTool : public AbstractTwoPointTool {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CircleTool(QObject *parent = nullptr);
|
||||
|
||||
int id() const override;
|
||||
bool isSelectable() const override;
|
||||
ToolWorkType toolType() const override;
|
||||
|
||||
QString iconName() const override;
|
||||
QIcon icon(const QColor &background, bool inEditor) const override;
|
||||
QString name() const override;
|
||||
static QString nameID();
|
||||
QString description() const override;
|
||||
|
||||
void processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness) override;
|
||||
CaptureTool* copy(QObject *parent = nullptr) override;
|
||||
void process(
|
||||
QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) override;
|
||||
void paintMousePreview(QPainter &painter, const CaptureContext &context) override;
|
||||
|
||||
void onPressed() override;
|
||||
public slots:
|
||||
void drawStart(const CaptureContext &context) override;
|
||||
void pressed(const CaptureContext &context) override;
|
||||
|
||||
private:
|
||||
QColor m_color;
|
||||
};
|
||||
@@ -16,49 +16,38 @@
|
||||
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "copytool.h"
|
||||
#include "src/utils/screenshotsaver.h"
|
||||
#include <QPainter>
|
||||
|
||||
CopyTool::CopyTool(QObject *parent) : CaptureTool(parent) {
|
||||
CopyTool::CopyTool(QObject *parent) : AbstractActionTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
int CopyTool::id() const {
|
||||
return 0;
|
||||
bool CopyTool::closeOnButtonPressed() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CopyTool::isSelectable() const {
|
||||
return false;
|
||||
QIcon CopyTool::icon(const QColor &background, bool inEditor) const {
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "content-copy.png");
|
||||
}
|
||||
|
||||
QString CopyTool::iconName() const {
|
||||
return "content-copy.png";
|
||||
}
|
||||
|
||||
QString CopyTool::name() const {
|
||||
return tr("Copy");
|
||||
}
|
||||
|
||||
QString CopyTool::nameID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString CopyTool::description() const {
|
||||
return tr("Copies the selecion into the clipboard");
|
||||
}
|
||||
|
||||
CaptureTool::ToolWorkType CopyTool::toolType() const {
|
||||
return TYPE_WORKER;
|
||||
CaptureTool* CopyTool::copy(QObject *parent) {
|
||||
return new CopyTool(parent);
|
||||
}
|
||||
|
||||
void CopyTool::processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness)
|
||||
{
|
||||
Q_UNUSED(painter);
|
||||
Q_UNUSED(points);
|
||||
Q_UNUSED(color);
|
||||
Q_UNUSED(thickness);
|
||||
}
|
||||
|
||||
void CopyTool::onPressed() {
|
||||
Q_EMIT requestAction(REQ_TO_CLIPBOARD);
|
||||
Q_EMIT requestAction(REQ_CLOSE_GUI);
|
||||
void CopyTool::pressed(const CaptureContext &context) {
|
||||
emit requestAction(REQ_CAPTURE_DONE_OK);
|
||||
ScreenshotSaver().saveToClipboard(context.selectedScreenshotArea());
|
||||
}
|
||||
@@ -17,28 +17,22 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "capturetool.h"
|
||||
#include "src/tools/abstractactiontool.h"
|
||||
|
||||
class CopyTool : public CaptureTool
|
||||
{
|
||||
class CopyTool : public AbstractActionTool {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CopyTool(QObject *parent = nullptr);
|
||||
|
||||
int id() const override;
|
||||
bool isSelectable() const override;
|
||||
ToolWorkType toolType() const override;
|
||||
bool closeOnButtonPressed() const;
|
||||
|
||||
QString iconName() const override;
|
||||
QIcon icon(const QColor &background, bool inEditor) const override;
|
||||
QString name() const override;
|
||||
static QString nameID();
|
||||
QString description() const override;
|
||||
|
||||
void processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness) override;
|
||||
|
||||
void onPressed() override;
|
||||
CaptureTool* copy(QObject *parent = nullptr) override;
|
||||
|
||||
public slots:
|
||||
void pressed(const CaptureContext &context) override;
|
||||
};
|
||||
@@ -18,46 +18,35 @@
|
||||
#include "exittool.h"
|
||||
#include <QPainter>
|
||||
|
||||
ExitTool::ExitTool(QObject *parent) : CaptureTool(parent) {
|
||||
ExitTool::ExitTool(QObject *parent) : AbstractActionTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
int ExitTool::id() const {
|
||||
return 0;
|
||||
bool ExitTool::closeOnButtonPressed() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ExitTool::isSelectable() const {
|
||||
return false;
|
||||
QIcon ExitTool::icon(const QColor &background, bool inEditor) const {
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "close.png");
|
||||
}
|
||||
|
||||
QString ExitTool::iconName() const {
|
||||
return "close.png";
|
||||
}
|
||||
|
||||
QString ExitTool::name() const {
|
||||
return tr("Exit");
|
||||
}
|
||||
|
||||
QString ExitTool::nameID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString ExitTool::description() const {
|
||||
return tr("Leave the capture screen");
|
||||
}
|
||||
|
||||
CaptureTool::ToolWorkType ExitTool::toolType() const {
|
||||
return TYPE_WORKER;
|
||||
CaptureTool* ExitTool::copy(QObject *parent) {
|
||||
return new ExitTool(parent);
|
||||
}
|
||||
|
||||
void ExitTool::processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness)
|
||||
{
|
||||
Q_UNUSED(painter);
|
||||
Q_UNUSED(points);
|
||||
Q_UNUSED(color);
|
||||
Q_UNUSED(thickness);
|
||||
}
|
||||
|
||||
void ExitTool::onPressed() {
|
||||
Q_EMIT requestAction(REQ_CLOSE_GUI);
|
||||
void ExitTool::pressed(const CaptureContext &context) {
|
||||
Q_UNUSED(context);
|
||||
emit requestAction(REQ_CLOSE_GUI);
|
||||
}
|
||||
@@ -17,28 +17,22 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "capturetool.h"
|
||||
#include "src/tools/abstractactiontool.h"
|
||||
|
||||
class ExitTool : public CaptureTool
|
||||
{
|
||||
class ExitTool : public AbstractActionTool {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ExitTool(QObject *parent = nullptr);
|
||||
|
||||
int id() const override;
|
||||
bool isSelectable() const override;
|
||||
ToolWorkType toolType() const override;
|
||||
bool closeOnButtonPressed() const;
|
||||
|
||||
QString iconName() const override;
|
||||
QIcon icon(const QColor &background, bool inEditor) const override;
|
||||
QString name() const override;
|
||||
static QString nameID();
|
||||
QString description() const override;
|
||||
|
||||
void processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness) override;
|
||||
|
||||
void onPressed() override;
|
||||
CaptureTool* copy(QObject *parent = nullptr) override;
|
||||
|
||||
public slots:
|
||||
void pressed(const CaptureContext &context) override;
|
||||
};
|
||||
@@ -30,8 +30,7 @@ class QPushButton;
|
||||
class QUrl;
|
||||
class NotificationWidget;
|
||||
|
||||
class ImgurUploader : public QWidget
|
||||
{
|
||||
class ImgurUploader : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ImgurUploader(const QPixmap &p, QWidget *parent = nullptr);
|
||||
@@ -16,48 +16,43 @@
|
||||
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "imguruploadertool.h"
|
||||
#include "imguruploader.h"
|
||||
#include <QPainter>
|
||||
|
||||
ImgurUploaderTool::ImgurUploaderTool(QObject *parent) : CaptureTool(parent) {
|
||||
ImgurUploaderTool::ImgurUploaderTool(QObject *parent) : AbstractActionTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
int ImgurUploaderTool::id() const {
|
||||
return 0;
|
||||
bool ImgurUploaderTool::closeOnButtonPressed() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ImgurUploaderTool::isSelectable() const {
|
||||
return false;
|
||||
QIcon ImgurUploaderTool::icon(const QColor &background, bool inEditor) const {
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "cloud-upload.png");
|
||||
}
|
||||
|
||||
QString ImgurUploaderTool::iconName() const {
|
||||
return "cloud-upload.png";
|
||||
}
|
||||
|
||||
QString ImgurUploaderTool::name() const {
|
||||
return tr("Image Uploader");
|
||||
}
|
||||
|
||||
QString ImgurUploaderTool::nameID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString ImgurUploaderTool::description() const {
|
||||
return tr("Uploads the selection to Imgur");
|
||||
}
|
||||
|
||||
CaptureTool::ToolWorkType ImgurUploaderTool::toolType() const {
|
||||
return TYPE_WORKER;
|
||||
QWidget* ImgurUploaderTool::widget() {
|
||||
return new ImgurUploader(capture);
|
||||
}
|
||||
|
||||
void ImgurUploaderTool::processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness)
|
||||
{
|
||||
Q_UNUSED(painter);
|
||||
Q_UNUSED(points);
|
||||
Q_UNUSED(color);
|
||||
Q_UNUSED(thickness);
|
||||
CaptureTool* ImgurUploaderTool::copy(QObject *parent) {
|
||||
return new ImgurUploaderTool(parent);
|
||||
}
|
||||
|
||||
void ImgurUploaderTool::onPressed() {
|
||||
Q_EMIT requestAction(REQ_UPLOAD_TO_IMGUR);
|
||||
void ImgurUploaderTool::pressed(const CaptureContext &context) {
|
||||
capture = context.selectedScreenshotArea();
|
||||
emit requestAction(REQ_CAPTURE_DONE_OK);
|
||||
emit requestAction(REQ_ADD_EXTERNAL_WIDGETS);
|
||||
}
|
||||
@@ -17,28 +17,27 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "capturetool.h"
|
||||
#include "src/tools/abstractactiontool.h"
|
||||
|
||||
class ImgurUploaderTool : public CaptureTool
|
||||
{
|
||||
class ImgurUploaderTool : public AbstractActionTool {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ImgurUploaderTool(QObject *parent = nullptr);
|
||||
|
||||
int id() const override;
|
||||
bool isSelectable() const override;
|
||||
ToolWorkType toolType() const override;
|
||||
bool closeOnButtonPressed() const;
|
||||
|
||||
QString iconName() const override;
|
||||
QIcon icon(const QColor &background, bool inEditor) const override;
|
||||
QString name() const override;
|
||||
static QString nameID();
|
||||
QString description() const override;
|
||||
|
||||
void processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness) override;
|
||||
QWidget* widget() override;
|
||||
|
||||
void onPressed() override;
|
||||
CaptureTool* copy(QObject *parent = nullptr) override;
|
||||
|
||||
public slots:
|
||||
void pressed(const CaptureContext &context) override;
|
||||
|
||||
private:
|
||||
QPixmap capture;
|
||||
};
|
||||
@@ -15,49 +15,43 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "applauncher.h"
|
||||
#include "applaunchertool.h"
|
||||
#include "applauncherwidget.h"
|
||||
|
||||
AppLauncher::AppLauncher(QObject *parent) : CaptureTool(parent)
|
||||
{
|
||||
AppLauncher::AppLauncher(QObject *parent) : AbstractActionTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
int AppLauncher::id() const {
|
||||
return 0;
|
||||
bool AppLauncher::closeOnButtonPressed() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AppLauncher::isSelectable() const {
|
||||
return false;
|
||||
QIcon AppLauncher::icon(const QColor &background, bool inEditor) const {
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "open_with.png");
|
||||
}
|
||||
|
||||
QString AppLauncher::iconName() const {
|
||||
return "open_with.png";
|
||||
}
|
||||
|
||||
QString AppLauncher::name() const {
|
||||
return tr("App Launcher");
|
||||
}
|
||||
|
||||
QString AppLauncher::nameID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString AppLauncher::description() const {
|
||||
return tr("Choose an app to open the capture");
|
||||
}
|
||||
|
||||
CaptureTool::ToolWorkType AppLauncher::toolType() const {
|
||||
return TYPE_WORKER;
|
||||
QWidget* AppLauncher::widget() {
|
||||
return new AppLauncherWidget(capture);
|
||||
}
|
||||
|
||||
void AppLauncher::processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness)
|
||||
{
|
||||
Q_UNUSED(painter);
|
||||
Q_UNUSED(points);
|
||||
Q_UNUSED(color);
|
||||
Q_UNUSED(thickness);
|
||||
CaptureTool* AppLauncher::copy(QObject *parent) {
|
||||
return new AppLauncher(parent); // TODO
|
||||
}
|
||||
|
||||
void AppLauncher::onPressed() {
|
||||
Q_EMIT requestAction(REQ_OPEN_APP);
|
||||
void AppLauncher::pressed(const CaptureContext &context) {
|
||||
capture = context.selectedScreenshotArea();
|
||||
emit requestAction(REQ_CAPTURE_DONE_OK);
|
||||
emit requestAction(REQ_ADD_EXTERNAL_WIDGETS);
|
||||
}
|
||||
@@ -17,27 +17,27 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "capturetool.h"
|
||||
#include "src/tools/abstractactiontool.h"
|
||||
|
||||
class AppLauncher : public CaptureTool
|
||||
{
|
||||
class AppLauncher : public AbstractActionTool {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AppLauncher(QObject *parent = nullptr);
|
||||
|
||||
int id() const override;
|
||||
bool isSelectable() const override;
|
||||
ToolWorkType toolType() const override;
|
||||
bool closeOnButtonPressed() const;
|
||||
|
||||
QString iconName() const override;
|
||||
QIcon icon(const QColor &background, bool inEditor) const override;
|
||||
QString name() const override;
|
||||
static QString nameID();
|
||||
QString description() const override;
|
||||
|
||||
void processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness) override;
|
||||
QWidget* widget() override;
|
||||
|
||||
void onPressed() override;
|
||||
CaptureTool* copy(QObject *parent = nullptr) override;
|
||||
|
||||
public slots:
|
||||
void pressed(const CaptureContext &context) override;
|
||||
|
||||
private:
|
||||
QPixmap capture;
|
||||
};
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
#include "applauncherwidget.h"
|
||||
#include "src/utils/filenamehandler.h"
|
||||
#include "src/capture/workers/launcher/launcheritemdelegate.h"
|
||||
#include "src/capture/widgets/capturebutton.h"
|
||||
#include "src/tools/launcher/launcheritemdelegate.h"
|
||||
#include "src/utils/globalvalues.h"
|
||||
#include "src/utils/confighandler.h"
|
||||
#include "terminallauncher.h"
|
||||
#include <QDir>
|
||||
@@ -156,7 +156,7 @@ void AppLauncherWidget::searchChanged(const QString &text) {
|
||||
|
||||
void AppLauncherWidget::initListWidget() {
|
||||
m_tabWidget = new QTabWidget;
|
||||
const int size = CaptureButton::buttonBaseSize();
|
||||
const int size = GlobalValues::buttonBaseSize();
|
||||
m_tabWidget->setIconSize(QSize(size, size));
|
||||
|
||||
for (auto const& i : catIconNames.toStdMap()) {
|
||||
@@ -221,7 +221,7 @@ void AppLauncherWidget::configureListView(QListWidget *widget) {
|
||||
widget->setSpacing(4);
|
||||
widget->setFlow(QListView::LeftToRight);
|
||||
widget->setDragEnabled(false);
|
||||
widget->setMinimumWidth(CaptureButton::buttonBaseSize() * 11);
|
||||
widget->setMinimumWidth(GlobalValues::buttonBaseSize() * 11);
|
||||
connect(widget, &QListWidget::clicked,
|
||||
this, &AppLauncherWidget::launch);
|
||||
}
|
||||
@@ -27,8 +27,7 @@ class QVBoxLayout;
|
||||
class QLineEdit;
|
||||
class QListWidget;
|
||||
|
||||
class AppLauncherWidget: public QWidget
|
||||
{
|
||||
class AppLauncherWidget: public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AppLauncherWidget(const QPixmap &p, QWidget *parent = nullptr);
|
||||
@@ -16,7 +16,7 @@
|
||||
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "launcheritemdelegate.h"
|
||||
#include "src/capture/widgets/capturebutton.h"
|
||||
#include "src/utils/globalvalues.h"
|
||||
#include <QPainter>
|
||||
|
||||
LauncherItemDelegate::LauncherItemDelegate(QObject *parent) :
|
||||
@@ -40,7 +40,7 @@ void LauncherItemDelegate::paint(
|
||||
}
|
||||
QIcon icon = index.data(Qt::DecorationRole).value<QIcon>();
|
||||
|
||||
const int iconSide = CaptureButton::buttonBaseSize() * 1.3;
|
||||
const int iconSide = GlobalValues::buttonBaseSize() * 1.3;
|
||||
const int halfIcon = iconSide/2;
|
||||
const int halfWidth = rect.width()/2;
|
||||
const int halfHeight = rect.height()/2;
|
||||
@@ -61,6 +61,6 @@ QSize LauncherItemDelegate::sizeHint(
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(index);
|
||||
const int size = CaptureButton::buttonBaseSize();
|
||||
const int size = GlobalValues::buttonBaseSize();
|
||||
return QSize(size * 3.2, size * 3.7);
|
||||
}
|
||||
@@ -20,8 +20,7 @@
|
||||
#include "src/utils/desktopfileparse.h"
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
class LauncherItemDelegate : public QStyledItemDelegate
|
||||
{
|
||||
class LauncherItemDelegate : public QStyledItemDelegate {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LauncherItemDelegate(QObject *parent = nullptr);
|
||||
@@ -31,7 +30,4 @@ public:
|
||||
const QModelIndex &index) const;
|
||||
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
#pragma comment(lib, "Shell32.lib")
|
||||
#else
|
||||
#include "src/capture/workers/launcher/applauncherwidget.h"
|
||||
#include "src/tools/launcher/applauncherwidget.h"
|
||||
#endif
|
||||
|
||||
void showOpenWithMenu(const QPixmap &capture) {
|
||||
@@ -24,8 +24,7 @@ struct TerminalApp {
|
||||
QString arg;
|
||||
};
|
||||
|
||||
class TerminalLauncher : public QObject
|
||||
{
|
||||
class TerminalLauncher : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TerminalLauncher(QObject *parent = nullptr);
|
||||
86
src/tools/line/linetool.cpp
Normal file
86
src/tools/line/linetool.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "linetool.h"
|
||||
#include <QPainter>
|
||||
|
||||
namespace {
|
||||
|
||||
#define ADJ_VALUE 13
|
||||
#define PADDING_VALUE 2
|
||||
|
||||
// Have to force horizontal position
|
||||
bool needsAdjustment(const QPoint &p0, const QPoint &p1) {
|
||||
return (p1.y() >= p0.y() - ADJ_VALUE) && (p1.y() <= p0.y() + ADJ_VALUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LineTool::LineTool(QObject *parent) : AbstractTwoPointTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
QIcon LineTool::icon(const QColor &background, bool inEditor) const {
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "line.png");
|
||||
}
|
||||
QString LineTool::name() const {
|
||||
return tr("Line");
|
||||
}
|
||||
|
||||
QString LineTool::nameID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString LineTool::description() const {
|
||||
return tr("Sets the Line as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool* LineTool::copy(QObject *parent) {
|
||||
return new LineTool(parent);
|
||||
}
|
||||
|
||||
void LineTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) {
|
||||
if (recordUndo) {
|
||||
updateBackup(pixmap);
|
||||
}
|
||||
painter.setPen(QPen(m_color, m_thickness));
|
||||
painter.drawLine(m_points.first, m_points.second);
|
||||
}
|
||||
|
||||
void LineTool::paintMousePreview(QPainter &painter, const CaptureContext &context) {
|
||||
painter.setPen(QPen(context.color, PADDING_VALUE + context.thickness));
|
||||
painter.drawLine(context.mousePos, context.mousePos);
|
||||
}
|
||||
|
||||
void LineTool::drawMove(const QPoint &p) {
|
||||
m_points.second = p;
|
||||
if (needsAdjustment(m_points.first, m_points.second)) {
|
||||
m_points.second.setY(m_points.first.y());
|
||||
}
|
||||
}
|
||||
|
||||
void LineTool::drawStart(const CaptureContext &context) {
|
||||
m_color = context.color;
|
||||
m_thickness = context.thickness + PADDING_VALUE;
|
||||
m_points.first = context.mousePos;
|
||||
m_points.second = context.mousePos;
|
||||
}
|
||||
|
||||
void LineTool::pressed(const CaptureContext &context) {
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
@@ -17,31 +17,28 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "capturetool.h"
|
||||
#include "src/tools/abstracttwopointtool.h"
|
||||
|
||||
class LineTool : public CaptureTool
|
||||
{
|
||||
class LineTool : public AbstractTwoPointTool {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LineTool(QObject *parent = nullptr);
|
||||
|
||||
int id() const override;
|
||||
bool isSelectable() const override;
|
||||
ToolWorkType toolType() const override;
|
||||
|
||||
QString iconName() const override;
|
||||
QIcon icon(const QColor &background, bool inEditor) const override;
|
||||
QString name() const override;
|
||||
static QString nameID();
|
||||
QString description() const override;
|
||||
|
||||
void processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness) override;
|
||||
CaptureTool* copy(QObject *parent = nullptr) override;
|
||||
void process(
|
||||
QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) override;
|
||||
void paintMousePreview(QPainter &painter, const CaptureContext &context) override;
|
||||
|
||||
void onPressed() override;
|
||||
public slots:
|
||||
void drawMove(const QPoint &p) override;
|
||||
void drawStart(const CaptureContext &context) override;
|
||||
void pressed(const CaptureContext &context) override;
|
||||
|
||||
private:
|
||||
bool needsAdjustment(const QPoint &p0, const QPoint &p1) const;
|
||||
|
||||
QColor m_color;
|
||||
};
|
||||
88
src/tools/marker/markertool.cpp
Normal file
88
src/tools/marker/markertool.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "markertool.h"
|
||||
#include <QPainter>
|
||||
|
||||
namespace {
|
||||
|
||||
#define ADJ_VALUE 14
|
||||
#define PADDING_VALUE 14
|
||||
|
||||
// Have to force horizontal position
|
||||
bool needsAdjustment(const QPoint &p0, const QPoint &p1) {
|
||||
return (p1.y() >= p0.y() - ADJ_VALUE) && (p1.y() <= p0.y() + ADJ_VALUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
MarkerTool::MarkerTool(QObject *parent) : AbstractTwoPointTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
QIcon MarkerTool::icon(const QColor &background, bool inEditor) const {
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "marker.png");
|
||||
}
|
||||
QString MarkerTool::name() const {
|
||||
return tr("Marker");
|
||||
}
|
||||
|
||||
QString MarkerTool::nameID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString MarkerTool::description() const {
|
||||
return tr("Sets the Marker as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool* MarkerTool::copy(QObject *parent) {
|
||||
return new MarkerTool(parent);
|
||||
}
|
||||
|
||||
void MarkerTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) {
|
||||
if (recordUndo) {
|
||||
updateBackup(pixmap);
|
||||
}
|
||||
painter.setOpacity(0.35);
|
||||
painter.setPen(QPen(m_color, m_thickness));
|
||||
painter.drawLine(m_points.first, m_points.second);
|
||||
}
|
||||
|
||||
void MarkerTool::paintMousePreview(QPainter &painter, const CaptureContext &context) {
|
||||
painter.setOpacity(0.35);
|
||||
painter.setPen(QPen(context.color, PADDING_VALUE + context.thickness));
|
||||
painter.drawLine(context.mousePos, context.mousePos);
|
||||
}
|
||||
|
||||
void MarkerTool::drawMove(const QPoint &p) {
|
||||
m_points.second = p;
|
||||
if (needsAdjustment(m_points.first, m_points.second)) {
|
||||
m_points.second.setY(m_points.first.y());
|
||||
}
|
||||
}
|
||||
|
||||
void MarkerTool::drawStart(const CaptureContext &context) {
|
||||
m_color = context.color;
|
||||
m_thickness = context.thickness + PADDING_VALUE;
|
||||
m_points.first = context.mousePos;
|
||||
m_points.second = context.mousePos;
|
||||
}
|
||||
|
||||
void MarkerTool::pressed(const CaptureContext &context) {
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
@@ -17,31 +17,28 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "capturetool.h"
|
||||
#include "src/tools/abstracttwopointtool.h"
|
||||
|
||||
class MarkerTool : public CaptureTool
|
||||
{
|
||||
class MarkerTool : public AbstractTwoPointTool {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MarkerTool(QObject *parent = nullptr);
|
||||
|
||||
int id() const override;
|
||||
bool isSelectable() const override;
|
||||
ToolWorkType toolType() const override;
|
||||
|
||||
QString iconName() const override;
|
||||
QIcon icon(const QColor &background, bool inEditor) const override;
|
||||
QString name() const override;
|
||||
static QString nameID();
|
||||
QString description() const override;
|
||||
|
||||
void processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness) override;
|
||||
CaptureTool* copy(QObject *parent = nullptr) override;
|
||||
void process(
|
||||
QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) override;
|
||||
void paintMousePreview(QPainter &painter, const CaptureContext &context) override;
|
||||
|
||||
void onPressed() override;
|
||||
public slots:
|
||||
void drawMove(const QPoint &p) override;
|
||||
void drawStart(const CaptureContext &context) override;
|
||||
void pressed(const CaptureContext &context) override;
|
||||
|
||||
private:
|
||||
bool needsAdjustment(const QPoint &p0, const QPoint &p1) const;
|
||||
|
||||
QColor m_color;
|
||||
};
|
||||
@@ -18,46 +18,35 @@
|
||||
#include "movetool.h"
|
||||
#include <QPainter>
|
||||
|
||||
MoveTool::MoveTool(QObject *parent) : CaptureTool(parent) {
|
||||
MoveTool::MoveTool(QObject *parent) : AbstractActionTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
int MoveTool::id() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool MoveTool::isSelectable() const {
|
||||
bool MoveTool::closeOnButtonPressed() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
QString MoveTool::iconName() const {
|
||||
return "cursor-move.png";
|
||||
QIcon MoveTool::icon(const QColor &background, bool inEditor) const {
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "cursor-move.png");
|
||||
}
|
||||
|
||||
QString MoveTool::name() const {
|
||||
return tr("Move");
|
||||
}
|
||||
|
||||
QString MoveTool::nameID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString MoveTool::description() const {
|
||||
return tr("Move the selection area");
|
||||
}
|
||||
|
||||
CaptureTool::ToolWorkType MoveTool::toolType() const {
|
||||
return TYPE_WORKER;
|
||||
CaptureTool* MoveTool::copy(QObject *parent) {
|
||||
return new MoveTool(parent);
|
||||
}
|
||||
|
||||
void MoveTool::processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness)
|
||||
{
|
||||
Q_UNUSED(painter);
|
||||
Q_UNUSED(points);
|
||||
Q_UNUSED(color);
|
||||
Q_UNUSED(thickness);
|
||||
}
|
||||
|
||||
void MoveTool::onPressed() {
|
||||
Q_EMIT requestAction(REQ_MOVE_MODE);
|
||||
void MoveTool::pressed(const CaptureContext &context) {
|
||||
Q_UNUSED(context);
|
||||
emit requestAction(REQ_MOVE_MODE);
|
||||
}
|
||||
@@ -17,28 +17,22 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "capturetool.h"
|
||||
#include "src/tools/abstractactiontool.h"
|
||||
|
||||
class MoveTool : public CaptureTool
|
||||
{
|
||||
class MoveTool : public AbstractActionTool {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MoveTool(QObject *parent = nullptr);
|
||||
|
||||
int id() const override;
|
||||
bool isSelectable() const override;
|
||||
ToolWorkType toolType() const override;
|
||||
bool closeOnButtonPressed() const;
|
||||
|
||||
QString iconName() const override;
|
||||
QIcon icon(const QColor &background, bool inEditor) const override;
|
||||
QString name() const override;
|
||||
static QString nameID();
|
||||
QString description() const override;
|
||||
|
||||
void processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness) override;
|
||||
|
||||
void onPressed() override;
|
||||
CaptureTool* copy(QObject *parent = nullptr) override;
|
||||
|
||||
public slots:
|
||||
void pressed(const CaptureContext &context) override;
|
||||
};
|
||||
68
src/tools/pencil/penciltool.cpp
Normal file
68
src/tools/pencil/penciltool.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "penciltool.h"
|
||||
#include <QPainter>
|
||||
|
||||
PencilTool::PencilTool(QObject *parent) : AbstractPathTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
QIcon PencilTool::icon(const QColor &background, bool inEditor) const {
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "pencil.png");
|
||||
}
|
||||
QString PencilTool::name() const {
|
||||
return tr("Pencil");
|
||||
}
|
||||
|
||||
QString PencilTool::nameID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString PencilTool::description() const {
|
||||
return tr("Sets the Pencil as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool* PencilTool::copy(QObject *parent) {
|
||||
return new PencilTool(parent);
|
||||
}
|
||||
|
||||
void PencilTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) {
|
||||
if (recordUndo) {
|
||||
updateBackup(pixmap);
|
||||
}
|
||||
painter.setPen(QPen(m_color, m_thickness));
|
||||
painter.drawPolyline(m_points.data(), m_points.size());
|
||||
}
|
||||
|
||||
void PencilTool::paintMousePreview(QPainter &painter, const CaptureContext &context) {
|
||||
painter.setPen(QPen(context.color, context.thickness + 2));
|
||||
painter.drawLine(context.mousePos, context.mousePos);
|
||||
}
|
||||
|
||||
void PencilTool::drawStart(const CaptureContext &context) {
|
||||
m_color = context.color;
|
||||
m_thickness = context.thickness + 2;
|
||||
m_points.append(context.mousePos);
|
||||
m_backupArea.setTopLeft(context.mousePos);
|
||||
m_backupArea.setBottomRight(context.mousePos);
|
||||
}
|
||||
|
||||
void PencilTool::pressed(const CaptureContext &context) {
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
@@ -17,28 +17,28 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "capturetool.h"
|
||||
#include "src/tools/abstractpathtool.h"
|
||||
|
||||
class PencilTool : public CaptureTool
|
||||
{
|
||||
class PencilTool : public AbstractPathTool {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit PencilTool(QObject *parent = nullptr);
|
||||
|
||||
int id() const override;
|
||||
bool isSelectable() const override;
|
||||
ToolWorkType toolType() const override;
|
||||
|
||||
QString iconName() const override;
|
||||
QIcon icon(const QColor &background, bool inEditor) const override;
|
||||
QString name() const override;
|
||||
static QString nameID();
|
||||
QString description() const override;
|
||||
|
||||
void processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness) override;
|
||||
CaptureTool* copy(QObject *parent = nullptr) override;
|
||||
|
||||
void onPressed() override;
|
||||
void process(
|
||||
QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) override;
|
||||
void paintMousePreview(QPainter &painter, const CaptureContext &context) override;
|
||||
|
||||
public slots:
|
||||
void drawStart(const CaptureContext &context) override;
|
||||
void pressed(const CaptureContext &context) override;
|
||||
|
||||
private:
|
||||
QColor m_color;
|
||||
};
|
||||
72
src/tools/rectangle/rectangletool.cpp
Normal file
72
src/tools/rectangle/rectangletool.cpp
Normal file
@@ -0,0 +1,72 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "rectangletool.h"
|
||||
#include <QPainter>
|
||||
|
||||
namespace {
|
||||
#define PADDING_VALUE 2
|
||||
}
|
||||
|
||||
RectangleTool::RectangleTool(QObject *parent) : AbstractTwoPointTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
QIcon RectangleTool::icon(const QColor &background, bool inEditor) const {
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "square.png");
|
||||
}
|
||||
QString RectangleTool::name() const {
|
||||
return tr("Rectangle");
|
||||
}
|
||||
|
||||
QString RectangleTool::nameID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString RectangleTool::description() const {
|
||||
return tr("Sets the Rectangle as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool* RectangleTool::copy(QObject *parent) {
|
||||
return new RectangleTool(parent);
|
||||
}
|
||||
|
||||
void RectangleTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) {
|
||||
if (recordUndo) {
|
||||
updateBackup(pixmap);
|
||||
}
|
||||
painter.setPen(QPen(m_color, m_thickness));
|
||||
painter.setBrush(QBrush(m_color));
|
||||
painter.drawRect(QRect(m_points.first, m_points.second));
|
||||
}
|
||||
|
||||
void RectangleTool::paintMousePreview(QPainter &painter, const CaptureContext &context) {
|
||||
painter.setPen(QPen(context.color, PADDING_VALUE + context.thickness));
|
||||
painter.drawLine(context.mousePos, context.mousePos);
|
||||
}
|
||||
|
||||
void RectangleTool::drawStart(const CaptureContext &context) {
|
||||
m_color = context.color;
|
||||
m_thickness = context.thickness + PADDING_VALUE;
|
||||
m_points.first = context.mousePos;
|
||||
m_points.second = context.mousePos;
|
||||
}
|
||||
|
||||
void RectangleTool::pressed(const CaptureContext &context) {
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
@@ -17,28 +17,27 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "capturetool.h"
|
||||
#include "src/tools/abstracttwopointtool.h"
|
||||
|
||||
class RectangleTool : public CaptureTool
|
||||
{
|
||||
class RectangleTool : public AbstractTwoPointTool {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RectangleTool(QObject *parent = nullptr);
|
||||
|
||||
int id() const override;
|
||||
bool isSelectable() const override;
|
||||
ToolWorkType toolType() const override;
|
||||
|
||||
QString iconName() const override;
|
||||
QIcon icon(const QColor &background, bool inEditor) const override;
|
||||
QString name() const override;
|
||||
static QString nameID();
|
||||
QString description() const override;
|
||||
|
||||
void processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness) override;
|
||||
CaptureTool* copy(QObject *parent = nullptr) override;
|
||||
void process(
|
||||
QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) override;
|
||||
void paintMousePreview(QPainter &painter, const CaptureContext &context) override;
|
||||
|
||||
void onPressed() override;
|
||||
public slots:
|
||||
void drawStart(const CaptureContext &context) override;
|
||||
void pressed(const CaptureContext &context) override;
|
||||
|
||||
private:
|
||||
QColor m_color;
|
||||
};
|
||||
@@ -15,49 +15,38 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "savetool.h"
|
||||
#include "redotool.h"
|
||||
#include <QPainter>
|
||||
|
||||
SaveTool::SaveTool(QObject *parent) : CaptureTool(parent) {
|
||||
RedoTool::RedoTool(QObject *parent) : AbstractActionTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
int SaveTool::id() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool SaveTool::isSelectable() const {
|
||||
bool RedoTool::closeOnButtonPressed() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
QString SaveTool::iconName() const {
|
||||
return "content-save.png";
|
||||
QIcon RedoTool::icon(const QColor &background, bool inEditor) const {
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "redo-variant.png");
|
||||
}
|
||||
QString RedoTool::name() const {
|
||||
return tr("Redo");
|
||||
}
|
||||
|
||||
QString SaveTool::name() const {
|
||||
return tr("Save");
|
||||
QString RedoTool::nameID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString SaveTool::description() const {
|
||||
return tr("Save the capture");
|
||||
QString RedoTool::description() const {
|
||||
return "Redo the next modification";
|
||||
}
|
||||
|
||||
CaptureTool::ToolWorkType SaveTool::toolType() const {
|
||||
return TYPE_WORKER;
|
||||
CaptureTool* RedoTool::copy(QObject *parent) {
|
||||
return new RedoTool(parent);
|
||||
}
|
||||
|
||||
void SaveTool::processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness)
|
||||
{
|
||||
Q_UNUSED(painter);
|
||||
Q_UNUSED(points);
|
||||
Q_UNUSED(color);
|
||||
Q_UNUSED(thickness);
|
||||
}
|
||||
|
||||
void SaveTool::onPressed() {
|
||||
Q_EMIT requestAction(REQ_SAVE_SCREENSHOT);
|
||||
void RedoTool::pressed(const CaptureContext &context) {
|
||||
Q_UNUSED(context);
|
||||
emit requestAction(REQ_REDO_MODIFICATION);
|
||||
}
|
||||
39
src/tools/redo/redotool.h
Normal file
39
src/tools/redo/redotool.h
Normal file
@@ -0,0 +1,39 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "src/tools/abstractactiontool.h"
|
||||
|
||||
class RedoTool : public AbstractActionTool {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RedoTool(QObject *parent = nullptr);
|
||||
|
||||
bool closeOnButtonPressed() const;
|
||||
|
||||
QIcon icon(const QColor &background, bool inEditor) const override;
|
||||
QString name() const override;
|
||||
static QString nameID();
|
||||
QString description() const override;
|
||||
|
||||
CaptureTool* copy(QObject *parent = nullptr) override;
|
||||
|
||||
public slots:
|
||||
void pressed(const CaptureContext &context) override;
|
||||
|
||||
};
|
||||
66
src/tools/save/savetool.cpp
Normal file
66
src/tools/save/savetool.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "savetool.h"
|
||||
#include "src/utils/screenshotsaver.h"
|
||||
#include <QPainter>
|
||||
|
||||
SaveTool::SaveTool(QObject *parent) : AbstractActionTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
bool SaveTool::closeOnButtonPressed() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
QIcon SaveTool::icon(const QColor &background, bool inEditor) const {
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "content-save.png");
|
||||
}
|
||||
QString SaveTool::name() const {
|
||||
return tr("Save");
|
||||
}
|
||||
|
||||
QString SaveTool::nameID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString SaveTool::description() const {
|
||||
return tr("Save the capture");
|
||||
}
|
||||
|
||||
CaptureTool* SaveTool::copy(QObject *parent) {
|
||||
return new SaveTool(parent);
|
||||
}
|
||||
|
||||
void SaveTool::pressed(const CaptureContext &context) {
|
||||
// TODO blocks type and others
|
||||
if (context.savePath.isEmpty()) {
|
||||
emit requestAction(REQ_HIDE_GUI);
|
||||
bool ok = ScreenshotSaver().saveToFilesystemGUI(
|
||||
context.selectedScreenshotArea());
|
||||
if (ok) {
|
||||
emit requestAction(REQ_CAPTURE_DONE_OK);
|
||||
}
|
||||
} else {
|
||||
bool ok = ScreenshotSaver().saveToFilesystem(
|
||||
context.selectedScreenshotArea(), context.savePath);
|
||||
if (ok) {
|
||||
emit requestAction(REQ_CAPTURE_DONE_OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,28 +17,22 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "capturetool.h"
|
||||
#include "src/tools/abstractactiontool.h"
|
||||
|
||||
class SaveTool : public CaptureTool
|
||||
{
|
||||
class SaveTool : public AbstractActionTool {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SaveTool(QObject *parent = nullptr);
|
||||
|
||||
int id() const override;
|
||||
bool isSelectable() const override;
|
||||
ToolWorkType toolType() const override;
|
||||
bool closeOnButtonPressed() const;
|
||||
|
||||
QString iconName() const override;
|
||||
QIcon icon(const QColor &background, bool inEditor) const override;
|
||||
QString name() const override;
|
||||
static QString nameID();
|
||||
QString description() const override;
|
||||
|
||||
void processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness) override;
|
||||
|
||||
void onPressed() override;
|
||||
CaptureTool* copy(QObject *parent = nullptr) override;
|
||||
|
||||
public slots:
|
||||
void pressed(const CaptureContext &context) override;
|
||||
};
|
||||
75
src/tools/selection/selectiontool.cpp
Normal file
75
src/tools/selection/selectiontool.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
// Copyright(c) 2017-2018 Alejandro Sirgo Rica & Contributors
|
||||
//
|
||||
// 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 "selectiontool.h"
|
||||
#include <QPainter>
|
||||
|
||||
namespace {
|
||||
#define PADDING_VALUE 2
|
||||
}
|
||||
|
||||
SelectionTool::SelectionTool(QObject *parent) : AbstractTwoPointTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
bool SelectionTool::closeOnButtonPressed() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
QIcon SelectionTool::icon(const QColor &background, bool inEditor) const {
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "square-outline.png");
|
||||
}
|
||||
QString SelectionTool::name() const {
|
||||
return tr("Rectangular Selection");
|
||||
}
|
||||
|
||||
QString SelectionTool::nameID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString SelectionTool::description() const {
|
||||
return tr("Sets the Selection as the paint tool");
|
||||
}
|
||||
|
||||
CaptureTool* SelectionTool::copy(QObject *parent) {
|
||||
return new SelectionTool(parent);
|
||||
}
|
||||
|
||||
void SelectionTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) {
|
||||
if (recordUndo) {
|
||||
updateBackup(pixmap);
|
||||
}
|
||||
painter.setPen(QPen(m_color, m_thickness));
|
||||
painter.drawRect(QRect(m_points.first, m_points.second));
|
||||
}
|
||||
|
||||
void SelectionTool::paintMousePreview(QPainter &painter, const CaptureContext &context) {
|
||||
painter.setPen(QPen(context.color, PADDING_VALUE + context.thickness));
|
||||
painter.drawLine(context.mousePos, context.mousePos);
|
||||
}
|
||||
|
||||
void SelectionTool::drawStart(const CaptureContext &context) {
|
||||
m_color = context.color;
|
||||
m_thickness = context.thickness + PADDING_VALUE;
|
||||
m_points.first = context.mousePos;
|
||||
m_points.second = context.mousePos;
|
||||
}
|
||||
|
||||
void SelectionTool::pressed(const CaptureContext &context) {
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
@@ -17,28 +17,29 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "capturetool.h"
|
||||
#include "src/tools/abstracttwopointtool.h"
|
||||
|
||||
class SelectionTool : public CaptureTool
|
||||
{
|
||||
class SelectionTool : public AbstractTwoPointTool {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SelectionTool(QObject *parent = nullptr);
|
||||
|
||||
int id() const override;
|
||||
bool isSelectable() const override;
|
||||
ToolWorkType toolType() const override;
|
||||
bool closeOnButtonPressed() const;
|
||||
|
||||
QString iconName() const override;
|
||||
QIcon icon(const QColor &background, bool inEditor) const override;
|
||||
QString name() const override;
|
||||
static QString nameID();
|
||||
QString description() const override;
|
||||
|
||||
void processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness) override;
|
||||
CaptureTool* copy(QObject *parent = nullptr) override;
|
||||
void process(
|
||||
QPainter &painter, const QPixmap &pixmap, bool recordUndo = false) override;
|
||||
void paintMousePreview(QPainter &painter, const CaptureContext &context) override;
|
||||
|
||||
void onPressed() override;
|
||||
public slots:
|
||||
void drawStart(const CaptureContext &context) override;
|
||||
void pressed(const CaptureContext &context) override;
|
||||
|
||||
private:
|
||||
QColor m_color;
|
||||
};
|
||||
@@ -18,45 +18,34 @@
|
||||
#include "sizeindicatortool.h"
|
||||
#include <QPainter>
|
||||
|
||||
SizeIndicatorTool::SizeIndicatorTool(QObject *parent) : CaptureTool(parent) {
|
||||
SizeIndicatorTool::SizeIndicatorTool(QObject *parent) : AbstractActionTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
int SizeIndicatorTool::id() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool SizeIndicatorTool::isSelectable() const {
|
||||
bool SizeIndicatorTool::closeOnButtonPressed() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
QString SizeIndicatorTool::iconName() const {
|
||||
return QString();
|
||||
QIcon SizeIndicatorTool::icon(const QColor &background, bool inEditor) const {
|
||||
return inEditor ? QIcon() :
|
||||
QIcon(iconPath(background) + "size_indicator.png");
|
||||
}
|
||||
|
||||
QString SizeIndicatorTool::name() const {
|
||||
return tr("Selection Size Indicator");
|
||||
}
|
||||
|
||||
QString SizeIndicatorTool::nameID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString SizeIndicatorTool::description() const {
|
||||
return tr("Shows the dimensions of the selection (X Y)");
|
||||
}
|
||||
|
||||
CaptureTool::ToolWorkType SizeIndicatorTool::toolType() const {
|
||||
return TYPE_WORKER;
|
||||
CaptureTool* SizeIndicatorTool::copy(QObject *parent) {
|
||||
return new SizeIndicatorTool(parent);
|
||||
}
|
||||
|
||||
void SizeIndicatorTool::processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness)
|
||||
{
|
||||
Q_UNUSED(painter);
|
||||
Q_UNUSED(points);
|
||||
Q_UNUSED(color);
|
||||
Q_UNUSED(thickness);
|
||||
}
|
||||
|
||||
void SizeIndicatorTool::onPressed() {
|
||||
void SizeIndicatorTool::pressed(const CaptureContext &context) {
|
||||
Q_UNUSED(context);
|
||||
}
|
||||
@@ -17,28 +17,22 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "capturetool.h"
|
||||
#include "src/tools/abstractactiontool.h"
|
||||
|
||||
class SizeIndicatorTool : public CaptureTool
|
||||
{
|
||||
class SizeIndicatorTool : public AbstractActionTool {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SizeIndicatorTool(QObject *parent = nullptr);
|
||||
|
||||
int id() const override;
|
||||
bool isSelectable() const override;
|
||||
ToolWorkType toolType() const override;
|
||||
bool closeOnButtonPressed() const;
|
||||
|
||||
QString iconName() const override;
|
||||
QIcon icon(const QColor &background, bool inEditor) const override;
|
||||
QString name() const override;
|
||||
static QString nameID();
|
||||
QString description() const override;
|
||||
|
||||
void processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness) override;
|
||||
|
||||
void onPressed() override;
|
||||
CaptureTool* copy(QObject *parent = nullptr) override;
|
||||
|
||||
public slots:
|
||||
void pressed(const CaptureContext &context) override;
|
||||
};
|
||||
@@ -16,25 +16,25 @@
|
||||
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "toolfactory.h"
|
||||
#include "arrowtool.h"
|
||||
#include "circletool.h"
|
||||
#include "copytool.h"
|
||||
#include "exittool.h"
|
||||
#include "imguruploadertool.h"
|
||||
#include "linetool.h"
|
||||
#include "markertool.h"
|
||||
#include "movetool.h"
|
||||
#include "penciltool.h"
|
||||
#include "rectangletool.h"
|
||||
#include "savetool.h"
|
||||
#include "selectiontool.h"
|
||||
#include "sizeindicatortool.h"
|
||||
#include "undotool.h"
|
||||
#include "applauncher.h"
|
||||
#include "blurtool.h"
|
||||
#include "arrow/arrowtool.h"
|
||||
#include "circle/circletool.h"
|
||||
#include "copy/copytool.h"
|
||||
#include "exit/exittool.h"
|
||||
#include "imgur/imguruploadertool.h"
|
||||
#include "line/linetool.h"
|
||||
#include "marker/markertool.h"
|
||||
#include "move/movetool.h"
|
||||
#include "pencil/penciltool.h"
|
||||
#include "rectangle/rectangletool.h"
|
||||
#include "save/savetool.h"
|
||||
#include "selection/selectiontool.h"
|
||||
#include "sizeindicator/sizeindicatortool.h"
|
||||
#include "undo/undotool.h"
|
||||
#include "launcher/applaunchertool.h"
|
||||
#include "blur/blurtool.h"
|
||||
#include "redo/redotool.h"
|
||||
|
||||
ToolFactory::ToolFactory(QObject *parent) : QObject(parent)
|
||||
{
|
||||
ToolFactory::ToolFactory(QObject *parent) : QObject(parent) {
|
||||
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ CaptureTool* ToolFactory::CreateTool(
|
||||
case CaptureButton::TYPE_IMAGEUPLOADER:
|
||||
tool = new ImgurUploaderTool(parent);
|
||||
break;
|
||||
case CaptureButton::TYPE_LINE:
|
||||
case CaptureButton::TYPE_DRAWER:
|
||||
tool = new LineTool(parent);
|
||||
break;
|
||||
case CaptureButton::TYPE_MARKER:
|
||||
@@ -86,6 +86,9 @@ CaptureTool* ToolFactory::CreateTool(
|
||||
case CaptureButton::TYPE_UNDO:
|
||||
tool = new UndoTool(parent);
|
||||
break;
|
||||
case CaptureButton::TYPE_REDO:
|
||||
tool = new RedoTool(parent);
|
||||
break;
|
||||
case CaptureButton::TYPE_OPEN_APP:
|
||||
tool = new AppLauncher(parent);
|
||||
break;
|
||||
@@ -17,20 +17,16 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "src/widgets/capture/capturebutton.h"
|
||||
#include "src/tools/capturetool.h"
|
||||
#include <QObject>
|
||||
#include "src/capture/widgets/capturebutton.h"
|
||||
#include "src/capture/tools/capturetool.h"
|
||||
|
||||
class CaptureTool;
|
||||
|
||||
class ToolFactory : public QObject
|
||||
{
|
||||
class ToolFactory : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum ToolType {
|
||||
|
||||
};
|
||||
|
||||
explicit ToolFactory(QObject *parent = nullptr);
|
||||
|
||||
@@ -40,5 +36,4 @@ public:
|
||||
CaptureTool* CreateTool(
|
||||
CaptureButton::ButtonType t,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
};
|
||||
@@ -18,46 +18,35 @@
|
||||
#include "undotool.h"
|
||||
#include <QPainter>
|
||||
|
||||
UndoTool::UndoTool(QObject *parent) : CaptureTool(parent) {
|
||||
UndoTool::UndoTool(QObject *parent) : AbstractActionTool(parent) {
|
||||
|
||||
}
|
||||
|
||||
int UndoTool::id() const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool UndoTool::isSelectable() const {
|
||||
bool UndoTool::closeOnButtonPressed() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
QString UndoTool::iconName() const {
|
||||
return "undo-variant.png";
|
||||
QIcon UndoTool::icon(const QColor &background, bool inEditor) const {
|
||||
Q_UNUSED(inEditor);
|
||||
return QIcon(iconPath(background) + "undo-variant.png");
|
||||
}
|
||||
|
||||
QString UndoTool::name() const {
|
||||
return tr("Undo");
|
||||
}
|
||||
|
||||
QString UndoTool::nameID() {
|
||||
return "";
|
||||
}
|
||||
|
||||
QString UndoTool::description() const {
|
||||
return tr("Undo the last modification");
|
||||
}
|
||||
|
||||
CaptureTool::ToolWorkType UndoTool::toolType() const {
|
||||
return TYPE_WORKER;
|
||||
CaptureTool* UndoTool::copy(QObject *parent) {
|
||||
return new UndoTool(parent);
|
||||
}
|
||||
|
||||
void UndoTool::processImage(
|
||||
QPainter &painter,
|
||||
const QVector<QPoint> &points,
|
||||
const QColor &color,
|
||||
const int thickness)
|
||||
{
|
||||
Q_UNUSED(painter);
|
||||
Q_UNUSED(points);
|
||||
Q_UNUSED(color);
|
||||
Q_UNUSED(thickness);
|
||||
}
|
||||
|
||||
void UndoTool::onPressed() {
|
||||
Q_EMIT requestAction(REQ_UNDO_MODIFICATION);
|
||||
void UndoTool::pressed(const CaptureContext &context) {
|
||||
Q_UNUSED(context);
|
||||
emit requestAction(REQ_UNDO_MODIFICATION);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user