Skip to content

Commit

Permalink
Merge branch 'master' of github.com:nomacs/nomacs-plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
diemmarkus committed Mar 13, 2020
2 parents db4b594 + 9adaf77 commit 9fff6f7
Show file tree
Hide file tree
Showing 12 changed files with 438 additions and 5 deletions.
339 changes: 335 additions & 4 deletions PaintPlugin/src/DkPaintPlugin.cpp

Large diffs are not rendered by default.

68 changes: 68 additions & 0 deletions PaintPlugin/src/DkPaintPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
#include <QString>
#include <QMessageBox>
#include <QAction>
#include <QLineEdit>
#include <QGraphicsPathItem>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsBlurEffect>
#include <QToolBar>
#include <QMainWindow>
#include <QColorDialog>
Expand All @@ -55,6 +57,17 @@ namespace nmp {
class DkPaintViewPort;
class DkPaintToolBar;

enum {
mode_pencil = 0,
mode_line,
mode_arrow,
mode_circle,
mode_square,
mode_square_fill,
mode_blur,
mode_text,
};

class DkPaintPlugin : public QObject, nmc::DkViewPortInterface {
Q_OBJECT
Q_INTERFACES(nmc::DkViewPortInterface)
Expand All @@ -68,6 +81,10 @@ class DkPaintPlugin : public QObject, nmc::DkViewPortInterface {
QImage image() const override;
bool hideHUD() const override;

QPainterPath getArrowHead(QPainterPath line, const int thickness);
QLineF getShorterLine(QPainterPath line, const int thickness);
void getBlur(QPainterPath rect, QPainter *painter, QPixmap &pixmap, int radius);

QSharedPointer<nmc::DkImageContainer> runPlugin(const QString &runID = QString(), QSharedPointer<nmc::DkImageContainer> image = QSharedPointer<nmc::DkImageContainer>()) const override;
nmc::DkPluginViewPort* getViewPort() override;
bool createViewPort(QWidget* parent) override;
Expand Down Expand Up @@ -104,6 +121,14 @@ public slots:
virtual void setVisible(bool visible);
void undoLastPaint();

signals:
void editShowSignal(bool show);

protected slots:
void setMode(int mode);
void textChange(const QString &text);
void textEditFinsh();

protected:
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
Expand All @@ -116,6 +141,13 @@ public slots:

QVector<QPainterPath> paths;
QVector<QPen> pathsPen;
QVector<int> pathsMode;
QPointF begin;
QString sbuffer;

int selectedMode;
bool textinputenable;
QPainterPath ArrowHead;

bool cancelTriggered;
bool isOutside;
Expand All @@ -140,9 +172,19 @@ class DkPaintToolBar : public QToolBar {
pan_icon,
undo_icon,

pencil_icon,
line_icon,
arrow_icon,
circle_icon,
square_icon,
square_fill_icon,
blur_icon,
text_icon,

icons_end,
};


DkPaintToolBar(const QString & title, QWidget * parent = 0);
virtual ~DkPaintToolBar();

Expand All @@ -154,10 +196,21 @@ public slots:
void on_applyAction_triggered();
void on_cancelAction_triggered();
void on_panAction_toggled(bool checked);
void on_pencilAction_toggled(bool checked);
void on_lineAction_toggled(bool checked);
void on_arrowAction_toggled(bool checked);
void on_circleAction_toggled(bool checked);
void on_squareAction_toggled(bool checked);
void on_squarefillAction_toggled(bool checked);
void on_blurAction_toggled(bool checked);
void on_textAction_toggled(bool checked);
void on_penColButton_clicked();
void on_widthBox_valueChanged(int val);
void on_alphaBox_valueChanged(int val);
void on_textInput_textChanged(const QString &text);
void on_textInput_editingFinished();
void on_undoAction_triggered();
void showLineEdit(bool show);
virtual void setVisible(bool visible);

signals:
Expand All @@ -169,6 +222,9 @@ public slots:
void shadingHint(bool invert);
void panSignal(bool checked);
void undoSignal();
void modeChangeSignal(int mode);
void textChangeSignal(const QString &text);
void editFinishSignal();

protected:
void createLayout();
Expand All @@ -180,9 +236,21 @@ public slots:
QSpinBox* alphaBox;
QColor penCol;
int penAlpha;
QMap<QString, QAction*> toolbarWidgetList;
QAction* panAction;
QAction* undoAction;

QAction* pencilAction;
QAction* lineAction;
QAction* arrowAction;
QAction* circleAction;
QAction* squareAction;
QAction* squarefillAction;
QAction* blurAction;
QAction* textAction;

QLineEdit* textInput;

QVector<QIcon> icons; // needed for colorizing

};
Expand Down
2 changes: 1 addition & 1 deletion PaintPlugin/src/DkPaintPlugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"AuthorName" : "Tim Jerman",
"Company" : "",
"DateCreated" : "2014-05-01",
"DateModified" : "2018-11-30",
"DateModified" : "2020-01-29",
"Description" : "Paint on an image. The color, size and opacity of the brush can be changed.",
"Tagline" : "Draw with adjustable brushes to an image.",
"PluginId" : "ad970ef36cc24737afd2b53ad015ff0d",
Expand Down
3 changes: 3 additions & 0 deletions PaintPlugin/src/img/arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions PaintPlugin/src/img/blur.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions PaintPlugin/src/img/circle-outline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions PaintPlugin/src/img/line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions PaintPlugin/src/img/pencil.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions PaintPlugin/src/img/square-outline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions PaintPlugin/src/img/square.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions PaintPlugin/src/img/text.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions PaintPlugin/src/nomacsPlugin.qrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<RCC>
<qresource prefix="/nomacsPluginPaint">
<file>img/description.png</file>
<file>img/pencil.svg</file>
<file>img/line.svg</file>
<file>img/arrow.svg</file>
<file>img/circle-outline.svg</file>
<file>img/square-outline.svg</file>
<file>img/square.svg</file>
<file>img/blur.svg</file>
<file>img/text.svg</file>
</qresource>
</RCC>

0 comments on commit 9fff6f7

Please sign in to comment.