Skip to content

Commit

Permalink
Add classes documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Mar 31, 2024
1 parent 8be78b7 commit 31b6eb5
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
83 changes: 83 additions & 0 deletions src/core/drawingcanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,32 @@ class DrawingCanvas : public QQuickPaintedItem
{
Q_OBJECT

/**
* This property is set to TRUE when no canvas has been created or a previously
* created canvas has been cleared.
*/
Q_PROPERTY( bool isEmpty READ isEmpty NOTIFY isEmptyChanged )

/**
* This property is set to TRUE when a created canvas has been modified.
*/
Q_PROPERTY( bool isDirty READ isDirty NOTIFY isDirtyChanged )

/**
* This property holds the color of the canvas frame.
*/
Q_PROPERTY( QColor frameColor READ frameColor WRITE setFrameColor NOTIFY frameColorChanged )

/**
* This property holds the current zoom factor of the canvas. A value of 1.0 means the canvas
* is at native resolutio (i.e. one screen pixel represents one canvas pixel).
*/
Q_PROPERTY( double zoomFactor READ zoomFactor WRITE setZoomFactor NOTIFY zoomFactorChanged )

/**
* This property holds the offset from the center of the canvas as a result of
* panning operations.
*/
Q_PROPERTY( QPointF offset READ offset WRITE setOffset NOTIFY offsetChanged )

public:
Expand All @@ -37,34 +59,95 @@ class DrawingCanvas : public QQuickPaintedItem

void paint( QPainter *painter ) override;

//! \copydoc DrawingCanvas::isEmpty
bool isEmpty() const;

//! \copydoc DrawingCanvas::isEmpty
void setIsEmpty( bool empty );

//! \copydoc DrawingCanvas::isDirty
bool isDirty() const;

//! \copydoc DrawingCanvas::isDirty
void setIsDirty( bool dirty );

//! \copydoc DrawingCanvas::frameColor
QColor frameColor() const;

//! \copydoc DrawingCanvas::frameColor
void setFrameColor( const QColor &color );

//! \copydoc DrawingCanvas::zoomFactor
double zoomFactor() const;

//! \copydoc DrawingCanvas::zoomFactor
void setZoomFactor( double factor );

//! \copydoc DrawingCanvas::offset
QPointF offset() const;

//! \copydoc DrawingCanvas::offset
void setOffset( const QPointF &offset );

/**
* Creates a blank drawing canvas.
* \param width the width of the canvas.
* \param height the height of the canvas.
* \param backgroundColor the background color of the canvas.
*/
Q_INVOKABLE void createBlankCanvas( int width, int height, QColor backgroundColor = QColor( 255, 255, 255 ) );

/**
* Creates a drawing canvas from a given image which will be the background on which
* the drawing will be overlayed.
* \param path the image path.
*/
Q_INVOKABLE void createCanvasFromImage( const QString &path );

/**
* Clears the drawing canvas.
* \see isEmpty()
*/
Q_INVOKABLE void clear();

/**
* Saves the drawing canvas to a temporary location.
* \returns the temporary file path of the saved image.
*/
Q_INVOKABLE QString save() const;

/**
* Fits the drawing canvas to match available width and height.
*/
Q_INVOKABLE void fitCanvas();

/**
* Pans the drawing canvas by the distance between two points.
*/
Q_INVOKABLE void pan( const QPointF &oldPosition, const QPointF &newPosition );

/**
* Zooms the drawing canvas by the provided \a scale value.
*/
Q_INVOKABLE void zoom( double scale );

/**
* Begins a stroke operation.
* \param point the first point of the stroke
* \param color the color of the stroke
*/
Q_INVOKABLE void strokeBegin( const QPointF &point, const QColor color = QColor( 0, 0, 0 ) );

/**
* Adds a new \a point to the current stroke path.
* \note The function strokeBegin must have been called prior to this function.
*/
Q_INVOKABLE void strokeMove( const QPointF &point );

/**
* Ends the current stroke with a final \a point added to the stroke path.
* \note The function strokeBegin must have been called prior to this function.
*/
Q_INVOKABLE void strokeEnd( const QPointF &point );

signals:
Expand Down
14 changes: 14 additions & 0 deletions src/core/drawingtemplatemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ class DrawingTemplateModel : public QAbstractListModel
{
Q_OBJECT

/**
* This property holds the project file path where project templates will be looked for.
*/
Q_PROPERTY( QString projectFilePath READ projectFilePath WRITE setProjectFilePath NOTIFY projectFilePathChanged )

/**
* This property holds whether the model contains project templates.
*/
Q_PROPERTY( bool hasProjectTemplate READ hasProjectTemplate NOTIFY hasProjectTemplateChanged )

public:
Expand All @@ -42,16 +49,23 @@ class DrawingTemplateModel : public QAbstractListModel

explicit DrawingTemplateModel( QObject *parent = nullptr );

//! \copydoc DrawingTemplateModel::projectFilePath
QString projectFilePath() const;

//! \copydoc DrawingTemplateModel::projectFilePath
void setProjectFilePath( const QString &path );

//! \copydoc DrawingTemplateModel::hasProjectTemplate
bool hasProjectTemplate() const;

QHash<int, QByteArray> roleNames() const override;

int rowCount( const QModelIndex &parent ) const override;
QVariant data( const QModelIndex &index, int role ) const override;

/**
* Reloads the drawing template model.
*/
Q_INVOKABLE void reloadModel();

signals:
Expand Down

0 comments on commit 31b6eb5

Please sign in to comment.