diff --git a/src/capture/button.h b/src/capture/button.h index 47b80f17..f6b8d0fa 100644 --- a/src/capture/button.h +++ b/src/capture/button.h @@ -40,11 +40,11 @@ public: rectangle, circle, marker, - text, undo, imageUploader, move, last, // used for iteration over the enum + text, mouseVisibility, colorPicker }; diff --git a/src/capture/capturemodification.cpp b/src/capture/capturemodification.cpp index b3e0a316..42a5f680 100644 --- a/src/capture/capturemodification.cpp +++ b/src/capture/capturemodification.cpp @@ -21,15 +21,14 @@ // CaptureModification is a single modification in the screenshot drawn // by the user. -CaptureModification::CaptureModification( - const Button::Type t, QPoint p, const QColor c) : m_type(t) { +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) { m_coords.append(p); } - m_color = c; } CaptureModification::CaptureModification() { diff --git a/src/capture/capturemodification.h b/src/capture/capturemodification.h index aea9ee47..491aff34 100644 --- a/src/capture/capturemodification.h +++ b/src/capture/capturemodification.h @@ -32,11 +32,13 @@ public: QVector getPoints() const; void addPoint(const QPoint); -private: - QVector m_coords; +protected: QColor m_color; Button::Type m_type; +private: + QVector m_coords; + }; #endif // CAPTURECHANGE_H diff --git a/src/capture/capturewidget.cpp b/src/capture/capturewidget.cpp index 12f5d387..2ff58ada 100644 --- a/src/capture/capturewidget.cpp +++ b/src/capture/capturewidget.cpp @@ -38,6 +38,7 @@ #include #include #include +#include // CaptureWidget is the main component used to capture the screen. It contains an // are of selection with its respective buttons. diff --git a/src/capture/screenshot.cpp b/src/capture/screenshot.cpp index cf6dcc3e..576ad523 100644 --- a/src/capture/screenshot.cpp +++ b/src/capture/screenshot.cpp @@ -156,32 +156,48 @@ QPixmap Screenshot::paintBaseModifications( return m_modifiedScreenshot; } -QPainterPath getArrowHead(QPoint p1, QPoint p2) { - QLineF body(p1, p2); - int originalLength = body.length(); - body.setLength(10); - // move across the line up to the head - //QPointF = ; - QLineF temp(QPoint(0,0), p2-p1); - temp.setLength(originalLength-20); - QPointF bottonTranslation(temp.p2()); +namespace { + const int ArrowWidth = 10; + const int ArrowHeight = 18; - // generates the transformation to center the head of the arrow - body.setAngle(body.angle()+90); - QPointF temp2 = p1-body.p2(); - QPointF centerTranslation((temp2.x()/2), (temp2.y()/2)); + QPainterPath getArrowHead(QPoint p1, QPoint p2) { + QLineF body(p1, p2); + int originalLength = body.length(); + body.setLength(ArrowWidth); + // move across the line up to the head + //QPointF = ; + QLineF temp(QPoint(0,0), p2-p1); + temp.setLength(originalLength-ArrowHeight); + QPointF bottonTranslation(temp.p2()); - body.translate(bottonTranslation); - body.translate(centerTranslation); + // 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) { + QLineF l(p1, p2); + l.setLength(l.length()-ArrowHeight); + return l.toLine(); + } - QPainterPath path; - path.moveTo(p2); - path.lineTo(body.p1()); - path.lineTo(body.p2()); - path.lineTo(p2); - return path; } + + + // paintInPainter is an aux method to prevent duplicated code, it draws the // passed modification to the painter. void Screenshot::paintInPainter(QPainter &painter, @@ -190,7 +206,7 @@ void Screenshot::paintInPainter(QPainter &painter, QVector points = modification.getPoints(); switch (modification.getType()) { case Button::Type::arrow: - painter.drawLine(points[0], points[1]); + painter.drawLine(getShorterLine(points[0], points[1])); painter.fillPath(getArrowHead(points[0], points[1]), QBrush(modification.getColor())); break; diff --git a/src/config/configwindow.h b/src/config/configwindow.h index 47f2c562..62cbe31a 100644 --- a/src/config/configwindow.h +++ b/src/config/configwindow.h @@ -28,6 +28,9 @@ class ConfigWindow : public QWidget { public: explicit ConfigWindow(QWidget *parent = 0); +signals: + void setDefaults(); + private: }; diff --git a/src/controller.h b/src/controller.h index b6398500..617e0676 100644 --- a/src/controller.h +++ b/src/controller.h @@ -39,11 +39,11 @@ private slots: void openConfigWindow(); void openInfoWindow(); void showMessage(QString); + void initDefaults(); private: void createActions(); void createTrayIcon(); - void initDefaults(); QAction *m_configAction; QAction *m_infoAction;