Add rectangle button

This commit is contained in:
lupoDharkael
2017-06-02 01:59:43 +02:00
parent 1802d05fde
commit c4849142e8
10 changed files with 172 additions and 55 deletions

View File

@@ -33,5 +33,7 @@
<file>img/buttonIconsWhite/pencil.png</file>
<file>img/buttonIconsBlack/cursor-move.png</file>
<file>img/buttonIconsWhite/cursor-move.png</file>
<file>img/buttonIconsBlack/square.png</file>
<file>img/buttonIconsWhite/square.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

View File

@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24"><path d="M3,3V21H21V3" /></svg>

After

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

View File

@@ -0,0 +1,56 @@
<?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="square.svg"
inkscape:version="0.92+devel unknown">
<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" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs8" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
inkscape:document-rotation="0"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1366"
inkscape:window-height="709"
id="namedview6"
showgrid="false"
inkscape:zoom="18.333333"
inkscape:cx="24.272727"
inkscape:cy="12"
inkscape:window-x="1024"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg4" />
<path
d="M3,3V21H21V3"
id="path2"
style="fill:#ffffff" />
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -119,7 +119,7 @@ QIcon Button::getIcon(const Type t, bool isWhite) {
case Type::pencil:
path += "pencil.png";
break;
case Type::rectangle:
case Type::selection:
path += "square-outline.png";
break;
case Type::save:
@@ -134,6 +134,9 @@ QIcon Button::getIcon(const Type t, bool isWhite) {
case Type::move:
path += "cursor-move.png";
break;
case Type::rectangle:
path += "square.png";
break;
default:
break;
}
@@ -261,16 +264,17 @@ Button::typeData Button::typeTooltip = {
{Button::Type::exit, QT_TR_NOOP("Leaves the capture screen")},
{Button::Type::copy, QT_TR_NOOP("Copies the selecion into the clipboard")},
{Button::Type::save, QT_TR_NOOP("Opens the save image window")},
{Button::Type::pencil, QT_TR_NOOP("Sets the paint tool to a pencil")},
{Button::Type::line, QT_TR_NOOP("Sets the paint tool to a line drawer")},
{Button::Type::arrow, QT_TR_NOOP("Sets the paint tool to an arrow drawer")},
{Button::Type::rectangle, QT_TR_NOOP("Sets the paint tool to a rectagle drawer")},
{Button::Type::circle, QT_TR_NOOP("Sets the paint tool to a circle drawer")},
{Button::Type::marker, QT_TR_NOOP("Sets the paint tool to a marker")},
{Button::Type::text, QT_TR_NOOP("Sets the paint tool to a text creator")},
{Button::Type::pencil, QT_TR_NOOP("Sets the Pencil as the paint tool")},
{Button::Type::line, QT_TR_NOOP("Sets the Line as the paint tool")},
{Button::Type::arrow, QT_TR_NOOP("Sets the Arrow as the paint tool")},
{Button::Type::rectangle, QT_TR_NOOP("Sets the Rectangle as the paint tool")},
{Button::Type::circle, QT_TR_NOOP("Sets the Circle as the paint tool")},
{Button::Type::marker, QT_TR_NOOP("Sets the Marker as the paint tool")},
{Button::Type::text, QT_TR_NOOP("Sets the Text as the paint tool")},
{Button::Type::colorPicker, QT_TR_NOOP("Opens the color picker widget")},
{Button::Type::undo, QT_TR_NOOP("Undo the last modification")},
{Button::Type::imageUploader, QT_TR_NOOP("Upload the selection to Imgur")},
{Button::Type::imageUploader, QT_TR_NOOP("Uploads the selection to Imgur")},
{Button::Type::selection, QT_TR_NOOP("Sets the Selection as the paint tool")},
{Button::Type::move, QT_TR_NOOP("Move the selection area")}
};
@@ -290,6 +294,7 @@ Button::typeData Button::typeName = {
{Button::Type::colorPicker, QT_TR_NOOP("Color Picker")},
{Button::Type::undo, QT_TR_NOOP("Undo")},
{Button::Type::imageUploader, QT_TR_NOOP("Image Uploader")},
{Button::Type::selection, QT_TR_NOOP("Rectangular Selection")},
{Button::Type::move, QT_TR_NOOP("Move")}
};

View File

@@ -43,6 +43,7 @@ public:
undo,
imageUploader,
move,
selection,
last, // used for iteration over the enum
text,
mouseVisibility,

View File

@@ -25,9 +25,12 @@ CaptureModification::CaptureModification(const Button::Type t, const QPoint p,
const QColor c) : m_color(c), m_type(t)
{
m_coords.append(p);
if (m_type == Button::Type::circle || m_type == Button::Type::rectangle
|| m_type == Button::Type::arrow || m_type == Button::Type::line ||
m_type == Button::Type::marker) {
if (m_type == Button::Type::circle
|| m_type == Button::Type::rectangle
|| m_type == Button::Type::arrow
|| m_type == Button::Type::line
|| m_type == Button::Type::marker
|| m_type == Button::Type::selection) {
m_coords.append(p);
}
}
@@ -49,9 +52,12 @@ QVector<QPoint> CaptureModification::getPoints() const {
}
// addPoint adds a point to the vector of points
void CaptureModification::addPoint(const QPoint p) {
if (m_type == Button::Type::circle || m_type == Button::Type::rectangle
|| m_type == Button::Type::arrow || m_type == Button::Type::line ||
m_type == Button::Type::marker) {
if (m_type == Button::Type::circle
|| m_type == Button::Type::rectangle
|| m_type == Button::Type::arrow
|| m_type == Button::Type::line
|| m_type == Button::Type::marker
|| m_type == Button::Type::selection) {
m_coords[1] = p;
} else {
m_coords.append(p);

View File

@@ -228,7 +228,11 @@ void Screenshot::paintInPainter(QPainter &painter,
case Button::Type::pencil:
painter.drawPolyline(points.data(), points.size());
break;
case Button::Type::selection:
painter.drawRect(QRect(points[0], points[1]));
break;
case Button::Type::rectangle:
painter.setBrush(QBrush(modification.getColor()));
painter.drawRect(QRect(points[0], points[1]));
break;
default:

View File

@@ -4,162 +4,204 @@
<context>
<name>Button</name>
<message>
<location filename="../src/capture/button.cpp" line="259"/>
<location filename="../src/capture/button.cpp" line="262"/>
<source>Shows the dimensions of the selection (X Y)</source>
<translation>Muestra la dimensión de ls selección (X Y)</translation>
<translation>Muestra la dimensión de la selección (X Y)</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="260"/>
<location filename="../src/capture/button.cpp" line="263"/>
<source>Sets the visibility of the mouse pointer</source>
<translation>Selecciona la visibilidad del puntero del ratón</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="261"/>
<location filename="../src/capture/button.cpp" line="264"/>
<source>Leaves the capture screen</source>
<translation>Cierra la pantalla de captura</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="262"/>
<location filename="../src/capture/button.cpp" line="265"/>
<source>Copies the selecion into the clipboard</source>
<translation>Copia la selección al portapapeles</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="263"/>
<location filename="../src/capture/button.cpp" line="266"/>
<source>Opens the save image window</source>
<translation>Abre la ventana de guardar imagen</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="264"/>
<source>Sets the paint tool to a pencil</source>
<translation>Establece el lápiz como herramienta de dibujo</translation>
<translation type="obsolete">Establece el lápiz como herramienta de dibujo</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="265"/>
<source>Sets the paint tool to a line drawer</source>
<translation>Establece la línea como herramienta de dibujo</translation>
<translation type="obsolete">Establece la línea como herramienta de dibujo</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="266"/>
<source>Sets the paint tool to an arrow drawer</source>
<translation>Establece la flecha como herramienta de dibujo</translation>
<translation type="obsolete">Establece la flecha como herramienta de dibujo</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="267"/>
<source>Sets the paint tool to a rectagle drawer</source>
<translation>Establece el rectángulo como herramienta de dibujo</translation>
<translation type="obsolete">Establece el rectángulo como herramienta de dibujo</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="268"/>
<source>Sets the paint tool to a circle drawer</source>
<translation>Establece el círculo como herramienta de dibujo</translation>
<translation type="obsolete">Establece el círculo como herramienta de dibujo</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="269"/>
<source>Sets the paint tool to a marker</source>
<translation>Establece el marcador como herramienta de dibujo</translation>
<translation type="obsolete">Establece el marcador como herramienta de dibujo</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="270"/>
<source>Sets the paint tool to a text creator</source>
<translation>Establece el texto como herramienta de dibujo</translation>
<translation type="obsolete">Establece el texto como herramienta de dibujo</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="271"/>
<location filename="../src/capture/button.cpp" line="274"/>
<source>Opens the color picker widget</source>
<translation>Abre el selector de color</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="272"/>
<location filename="../src/capture/button.cpp" line="275"/>
<source>Undo the last modification</source>
<translation>Deshace la última modificación</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="273"/>
<source>Upload the selection to Imgur</source>
<translation type="obsolete">Sube la selección a Imgur</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="267"/>
<source>Sets the Pencil as the paint tool</source>
<translation>Establece el Lápiz como herramienta de dibujo</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="268"/>
<source>Sets the Line as the paint tool</source>
<translation>Establece la Línea como herramienta de dibujo</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="269"/>
<source>Sets the Arrow as the paint tool</source>
<translation>Establece la Flecha como herramienta de dibujo</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="270"/>
<source>Sets the Rectangle as the paint tool</source>
<translation>Establece el Rectángulo como herramienta de dibujo</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="271"/>
<source>Sets the Circle as the paint tool</source>
<translation>Establece el Círculo como herramienta de dibujo</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="272"/>
<source>Sets the Marker as the paint tool</source>
<translation>Establece el Marcador como herramienta de dibujo</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="273"/>
<source>Sets the Text as the paint tool</source>
<translation>Establece el Texto como herramienta de dibujo</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="276"/>
<source>Uploads the selection to Imgur</source>
<translation>Sube la selección a Imgur</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="274"/>
<location filename="../src/capture/button.cpp" line="277"/>
<source>Sets the Selection as the paint tool</source>
<translation>Establece la Selección como herramienta de dibujo</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="278"/>
<source>Move the selection area</source>
<translation>Mueve la selección</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="278"/>
<location filename="../src/capture/button.cpp" line="282"/>
<source>Selection Size Indicator</source>
<translation>Indicador de Tamaño de Selección</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="279"/>
<location filename="../src/capture/button.cpp" line="283"/>
<source>Mouse Visibility</source>
<translation>Visibilidad del Ratón</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="280"/>
<location filename="../src/capture/button.cpp" line="284"/>
<source>Exit</source>
<translation>Salir</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="281"/>
<location filename="../src/capture/button.cpp" line="285"/>
<source>Copy</source>
<translation>Copiar</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="282"/>
<location filename="../src/capture/button.cpp" line="286"/>
<source>Save</source>
<translation>Guardar</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="283"/>
<location filename="../src/capture/button.cpp" line="287"/>
<source>Pencil</source>
<translation>Lápiz</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="284"/>
<location filename="../src/capture/button.cpp" line="288"/>
<source>Line</source>
<translation>Línea</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="285"/>
<location filename="../src/capture/button.cpp" line="289"/>
<source>Arrow</source>
<translation>Flecha</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="286"/>
<location filename="../src/capture/button.cpp" line="290"/>
<source>Rectangle</source>
<translation>Rectángulo</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="287"/>
<location filename="../src/capture/button.cpp" line="291"/>
<source>Circle</source>
<translation>Círculo</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="288"/>
<location filename="../src/capture/button.cpp" line="292"/>
<source>Marker</source>
<translation>Marcador</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="289"/>
<location filename="../src/capture/button.cpp" line="293"/>
<source>Text</source>
<translation>Texto</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="290"/>
<location filename="../src/capture/button.cpp" line="294"/>
<source>Color Picker</source>
<translation>Selector de Color</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="291"/>
<location filename="../src/capture/button.cpp" line="295"/>
<source>Undo</source>
<translation>Deshacer</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="292"/>
<location filename="../src/capture/button.cpp" line="296"/>
<source>Image Uploader</source>
<translation>Subir Imagen</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="293"/>
<location filename="../src/capture/button.cpp" line="297"/>
<source>Rectangular Selection</source>
<translation>Selección Rectangular</translation>
</message>
<message>
<location filename="../src/capture/button.cpp" line="298"/>
<source>Move</source>
<translation>Mover Selección</translation>
</message>