diff --git a/docs/dev/qsettings.md b/docs/dev/qsettings.md
index 02a5b5ca..0a63aa85 100644
--- a/docs/dev/qsettings.md
+++ b/docs/dev/qsettings.md
@@ -10,10 +10,6 @@
- value: "drawColor"
- type: QColor
- description: color of the drawing tools.
-- Mouse visibility
- - value: "mouseVisible"
- - type: bool
- - description: visibility of the mouse in the capture.
- UI color
- value: "uiColor"
- type: QColor
@@ -26,7 +22,7 @@
- value: "showHelp"
- type: bool
- description: show Help messages in capture mode.
-- show Help message
+- show desktop notifications
- value: "showDesktopNotification"
- type: bool
- description: show every desktop notification.
diff --git a/flameshot.pro b/flameshot.pro
index 6b179986..61ac4f81 100644
--- a/flameshot.pro
+++ b/flameshot.pro
@@ -37,7 +37,6 @@ DEFINES += QAPPLICATION_CLASS=QApplication
SOURCES += src/main.cpp\
src/controller.cpp \
- src/capture/button.cpp \
src/capture/buttonhandler.cpp \
src/infowindow.cpp \
src/config/configwindow.cpp \
@@ -53,11 +52,28 @@ SOURCES += src/main.cpp\
src/config/filenameeditor.cpp \
src/utils/filenamehandler.cpp \
src/config/strftimechooserwidget.cpp \
- src/capture/screengrabber.cpp
+ src/capture/screengrabber.cpp \
+ src/capture/tools/capturetool.cpp \
+ src/capture/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/utils/confighandler.cpp
HEADERS += \
src/controller.h \
- src/capture/button.h \
src/capture/buttonhandler.h \
src/infowindow.h \
src/config/configwindow.h \
@@ -73,7 +89,25 @@ HEADERS += \
src/config/filenameeditor.h \
src/utils/filenamehandler.h \
src/config/strftimechooserwidget.h \
- src/capture/screengrabber.h
+ src/capture/screengrabber.h \
+ src/capture/tools/capturetool.h \
+ src/capture/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/utils/confighandler.h
RESOURCES += \
graphics.qrc
diff --git a/graphics.qrc b/graphics.qrc
index fd61ec50..b1c54d7f 100644
--- a/graphics.qrc
+++ b/graphics.qrc
@@ -8,11 +8,8 @@
img/buttonIconsBlack/content-copy.png
img/buttonIconsBlack/content-save.png
img/buttonIconsBlack/exit-to-app.png
- img/buttonIconsBlack/format-text.png
img/buttonIconsBlack/line.png
img/buttonIconsBlack/marker.png
- img/buttonIconsBlack/mouse.png
- img/buttonIconsBlack/mouse-off.png
img/buttonIconsBlack/pencil.png
img/buttonIconsBlack/square-outline.png
img/buttonIconsBlack/undo-variant.png
@@ -28,8 +25,6 @@
img/buttonIconsWhite/format-text.png
img/buttonIconsWhite/line.png
img/buttonIconsWhite/marker.png
- img/buttonIconsWhite/mouse-off.png
- img/buttonIconsWhite/mouse.png
img/buttonIconsWhite/pencil.png
img/buttonIconsBlack/cursor-move.png
img/buttonIconsWhite/cursor-move.png
diff --git a/img/buttonIconsBlack/format-text.png b/img/buttonIconsBlack/format-text.png
deleted file mode 100644
index 7c62a4dc..00000000
Binary files a/img/buttonIconsBlack/format-text.png and /dev/null differ
diff --git a/img/buttonIconsBlack/mouse-off.png b/img/buttonIconsBlack/mouse-off.png
deleted file mode 100644
index e52e6bb9..00000000
Binary files a/img/buttonIconsBlack/mouse-off.png and /dev/null differ
diff --git a/img/buttonIconsBlack/mouse.png b/img/buttonIconsBlack/mouse.png
deleted file mode 100644
index b4a87987..00000000
Binary files a/img/buttonIconsBlack/mouse.png and /dev/null differ
diff --git a/img/buttonIconsWhite/mouse-off.png b/img/buttonIconsWhite/mouse-off.png
deleted file mode 100644
index 5774518f..00000000
Binary files a/img/buttonIconsWhite/mouse-off.png and /dev/null differ
diff --git a/img/buttonIconsWhite/mouse.png b/img/buttonIconsWhite/mouse.png
deleted file mode 100644
index 4c270d5f..00000000
Binary files a/img/buttonIconsWhite/mouse.png and /dev/null differ
diff --git a/src/capture/button.cpp b/src/capture/button.cpp
deleted file mode 100644
index d955fdb3..00000000
--- a/src/capture/button.cpp
+++ /dev/null
@@ -1,302 +0,0 @@
-// Copyright 2017 Alejandro Sirgo Rica
-//
-// This file is part of Flameshot.
-//
-// Flameshot is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Flameshot is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Flameshot. If not, see .
-
-#include "button.h"
-#include "src/capture/capturewidget.h"
-#include
-#include
-#include
-#include
-#include
-
-// Button represents a single button of the capture widget, it can enable
-// multiple functionality.
-
-namespace {
- const int BUTTON_SIZE = 30;
-}
-
-Button::Button(const Type t, QWidget *parent) : QPushButton(parent),
- m_buttonType(t), m_pressed(false)
-{
- initButton();
-
- if (t == Button::Type::selectionIndicator) {
- QFont f = this->font();
- setFont(QFont(f.family(), 7, QFont::Bold));
- } else {
- setIcon(getIcon(t));
- }
-}
-
-Button::Button(const Button::Type t, const bool isWhite, QWidget *parent)
- : QPushButton(parent), m_buttonType(t), m_pressed(false)
-{
- initButton();
-
- if (t == Button::Type::selectionIndicator) {
- QFont f = this->font();
- setFont(QFont(f.family(), 7, QFont::Bold));
- } else {
- setIcon(getIcon(t, isWhite));
- }
-}
-
-void Button::initButton() {
- setFocusPolicy(Qt::NoFocus);
- resize(BUTTON_SIZE, BUTTON_SIZE);
- setMouseTracking(true);
- setMask(QRegion(QRect(-1,-1,BUTTON_SIZE+2, BUTTON_SIZE+2), QRegion::Ellipse));
-
- setToolTip(getTypeTooltip(m_buttonType));
-
- emergeAnimation = new QPropertyAnimation(this, "size", this);
- emergeAnimation->setEasingCurve(QEasingCurve::InOutQuad);
- emergeAnimation->setDuration(80);
- emergeAnimation->setStartValue(QSize(0, 0));
- emergeAnimation->setEndValue(QSize(BUTTON_SIZE, BUTTON_SIZE));
-}
-
-// getIcon returns the icon for the type of button, this method lets
-// you choose between black or white icons (needed for the config menu)
-QIcon Button::getIcon(const Type t, bool isWhite) {
- QString iconColor = "Black";
- if (isWhite) {
- iconColor = "White";
- }
- QString path = ":/img/buttonIcons" + iconColor + "/";
-
-// if (t == Type::mouseVisibility) {
-// QSettings settings;
-// bool mouseVisible = settings.value("mouseVisible").toBool();
-// if (mouseVisible){
-// path += "mouse.svg";
-// } else {
-// path += "mouse-off.svg";
-// }
-// return QIcon(path);
-// }
-
- switch (t) {
- case Type::arrow:
- path += "arrow-bottom-left.png";
- break;
- case Type::circle:
- path += "circle-outline.png";
- break;
- case Type::colorPicker:
- path += "square-outline.png";
- break;
- case Type::copy:
- path += "content-copy.png";
- break;
- case Type::exit:
- path += "close.png";
- break;
- case Type::imageUploader:
- path += "cloud-upload.png";
- break;
- case Type::line:
- path += "line.png";
- break;
- case Type::marker:
- path += "marker.png";
- break;
- case Type::pencil:
- path += "pencil.png";
- break;
- case Type::selection:
- path += "square-outline.png";
- break;
- case Type::save:
- path += "content-save.png";
- break;
- case Type::text:
- path += "format-text.png";
- break;
- case Type::undo:
- path += "undo-variant.png";
- break;
- case Type::move:
- path += "cursor-move.png";
- break;
- case Type::rectangle:
- path += "square.png";
- break;
- default:
- break;
- }
- return QIcon(path);
-}
-
-QString Button::getStyle() {
- QSettings settings;
- m_mainColor = settings.value("uiColor").value();
- return getStyle(m_mainColor);
-}
-
-QString Button::getStyle(const QColor &mainColor) {
- m_mainColor = mainColor;
- QString baseSheet = "Button { border-radius: %3;"
- "background-color: %1; color: %4 }"
- "Button:hover { background-color: %2; }"
- "Button:pressed:!hover { "
- "background-color: %1; }";
-
- // define color when mouse is hovering
- QColor contrast(mainColor.darker(120));
- if (mainColor.value() < m_colorValueLimit ||
- mainColor.saturation() > m_colorSaturationLimit) {
- contrast = mainColor.lighter(140);
- }
-
- // foreground color
- QString color = iconIsWhite(mainColor) ? "white" : "black";
-
- return baseSheet.arg(mainColor.name()).arg(contrast.name())
- .arg(BUTTON_SIZE/2).arg(color);
-}
-// get icon returns the icon for the type of button
-QIcon Button::getIcon(const Type t) {
- return getIcon(t, iconIsWhite(m_mainColor));
-}
-
-void Button::enterEvent(QEvent *e) {
- Q_EMIT hovered();
- QWidget::enterEvent(e);
-}
-
-void Button::leaveEvent(QEvent *e) {
- m_pressed = false;
- Q_EMIT mouseExited();
- QWidget::leaveEvent(e);
-}
-
-void Button::mouseReleaseEvent(QMouseEvent *e) {
- CaptureWidget *parent = static_cast(this->parent());
- parent->mouseReleaseEvent(e);
- if (e->button() == Qt::LeftButton && m_pressed) {
-// if (m_buttonType == Type::mouseVisibility) {
-// QSettings settings;
-// bool mouseVisible = settings.value("mouseVisible").toBool();
-// settings.setValue("mouseVisible", !mouseVisible);
-// setIcon(getIcon(Type::mouseVisibility));
-// } else if (m_buttonType == Type::colorPicker) {
-
-// }
- Q_EMIT pressedButton(this);
- }
- m_pressed = false;
-}
-
-void Button::mousePressEvent(QMouseEvent *) {
- m_pressed = true;
-}
-
-void Button::animatedShow() {
- show();
- emergeAnimation->start();
-}
-
-Button::Type Button::getButtonType() const {
- return m_buttonType;
-}
-
-void Button::updateIconColor(const QColor &c) {
- setIcon(getIcon(m_buttonType, iconIsWhite(c)));
-}
-
-void Button::updateIconColor() {
- setIcon(getIcon(m_buttonType, iconIsWhite()));
-}
-// iconIsWhite returns true if the passed color would contain a white icon
-// if applied to a button, and false otherwise
-bool Button::iconIsWhite(const QColor &c) {
- bool isWhite = false;
- if (c.value() < m_colorValueLimit ||
- c.saturation() > m_colorSaturationLimit) {
- isWhite = true;
- }
- return isWhite;
-}
-
-bool Button::iconIsWhite() const {
- return iconIsWhite(m_mainColor);
-}
-// getButtonBaseSize returns the base size of the buttons
-size_t Button::getButtonBaseSize() {
- return BUTTON_SIZE;
-}
-// getTypeByName receives a name and return the corresponding button type.
-// returns Button::Type::last when the corresponding button is not found.
-Button::Type Button::getTypeByName(const QString s) {
- Button::Type res = Type::last;
- for (auto i: typeName.toStdMap())
- if (tr(i.second) == s)
- res = i.first;
- return res;
-}
-
-QString Button::getTypeName(const Button::Type t) {
- return tr(typeName[t]);
-}
-
-QString Button::getTypeTooltip(const Button::Type t) {
- return tr(typeTooltip[t]);
-}
-
-Button::typeData Button::typeTooltip = {
- {Button::Type::selectionIndicator, QT_TR_NOOP("Shows the dimensions of the selection (X Y)")},
- {Button::Type::mouseVisibility, QT_TR_NOOP("Sets the visibility of the mouse pointer")},
- {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 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("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")}
-};
-
-Button::typeData Button::typeName = {
- {Button::Type::selectionIndicator, QT_TR_NOOP("Selection Size Indicator")},
- {Button::Type::mouseVisibility, QT_TR_NOOP("Mouse Visibility")},
- {Button::Type::exit, QT_TR_NOOP("Exit")},
- {Button::Type::copy, QT_TR_NOOP("Copy")},
- {Button::Type::save, QT_TR_NOOP("Save")},
- {Button::Type::pencil, QT_TR_NOOP("Pencil")},
- {Button::Type::line, QT_TR_NOOP("Line")},
- {Button::Type::arrow, QT_TR_NOOP("Arrow")},
- {Button::Type::rectangle, QT_TR_NOOP("Rectangle")},
- {Button::Type::circle, QT_TR_NOOP("Circle")},
- {Button::Type::marker, QT_TR_NOOP("Marker")},
- {Button::Type::text, QT_TR_NOOP("Text")},
- {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")}
-};
-
-QColor Button::m_mainColor = QSettings().value("uiColor").value();
diff --git a/src/capture/buttonhandler.cpp b/src/capture/buttonhandler.cpp
index e63b72d6..b42e855c 100644
--- a/src/capture/buttonhandler.cpp
+++ b/src/capture/buttonhandler.cpp
@@ -25,11 +25,12 @@ namespace {
const int SEPARATION = 6;
}
-ButtonHandler::ButtonHandler(const QVector