Minor fixes and arrow point fix
This commit is contained in:
@@ -40,11 +40,11 @@ public:
|
||||
rectangle,
|
||||
circle,
|
||||
marker,
|
||||
text,
|
||||
undo,
|
||||
imageUploader,
|
||||
move,
|
||||
last, // used for iteration over the enum
|
||||
text,
|
||||
mouseVisibility,
|
||||
colorPicker
|
||||
};
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -32,11 +32,13 @@ public:
|
||||
QVector<QPoint> getPoints() const;
|
||||
void addPoint(const QPoint);
|
||||
|
||||
private:
|
||||
QVector<QPoint> m_coords;
|
||||
protected:
|
||||
QColor m_color;
|
||||
Button::Type m_type;
|
||||
|
||||
private:
|
||||
QVector<QPoint> m_coords;
|
||||
|
||||
};
|
||||
|
||||
#endif // CAPTURECHANGE_H
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <QSettings>
|
||||
#include <QNetworkReply>
|
||||
#include <QDesktopServices>
|
||||
#include <QLineEdit>
|
||||
|
||||
// CaptureWidget is the main component used to capture the screen. It contains an
|
||||
// are of selection with its respective buttons.
|
||||
|
||||
@@ -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<QPoint> 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;
|
||||
|
||||
@@ -28,6 +28,9 @@ class ConfigWindow : public QWidget {
|
||||
public:
|
||||
explicit ConfigWindow(QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
void setDefaults();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user