<commit_before>/*
 * This source file is part of EasyPaint.
 *
 * Copyright (c) 2012 EasyPaint <https://github.com/Gr1N/EasyPaint>
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#ifndef IMAGEAREA_H
#define IMAGEAREA_H

#include "easypaintenums.h"
#include "effects.h"
#include "additionaltools.h"

#include <QtGui/QWidget>
#include <QtGui/QImage>

QT_BEGIN_NAMESPACE
class PaintInstruments;
QT_END_NAMESPACE

/**
 * @brief Base class which contains view image and controller for painting
 *
 */
class ImageArea : public QWidget
{
    Q_OBJECT

public:
    /**
     * @brief Constructor
     *
     * @param isOpen Flag which shows opens a new image or from file.
     * @param parent Pointer for parent.
     */
    explicit ImageArea(const bool &isOpen = false, QWidget *parent = 0);
    ~ImageArea();

    /**
     * @brief Save image to file with existing path.
     *
     */
    void save();
    /**
     * @brief Save image to file with unknown path.
     *
     */
    void saveAs();
    /**
     * @brief Print image.
     *
     */
    void print();
    /**
     * @brief Resize image.
     *
     */
    void resizeImage();
    /**
     * @brief Rotate image.
     *
     * @param flag Rotate to left or to right.
     */
    void rotateImage(bool flag);

    inline QString getFileName() { return mFilePath.split('/').last(); }
    inline QImage* getImage() { return mImage; }
    inline void setImage(const QImage &image) { *mImage = image; }
    /**
     * @brief Set flag which shows that image edited.
     *
     * @param flag Boolean flag.
     */
    inline void setEdited(bool flag) { mIsEdited = flag; }
    /**
     * @brief Get flag which shows that image edited.
     *
     * @return bool Flag.
     */
    inline bool getEdited() { return mIsEdited; }
    /**
     * @brief Apply gray effect.
     *
     */
    inline void effectGray() { mEffects->gray(); }
    /**
     * @brief Apply negative effect.
     *
     */
    inline void effectNegative() { mEffects->negative(); }
    
    inline bool isModified() { return mIsModified; }
private:
    /**
     * @brief Initialize image with base params.
     *
     */
    void initializeImage();
    /**
     * @brief Open file from file.
     *
     */
    void open();

    QImage *mImage,  /**< Main image. */
           mImageCopy; /**< Copy of main image, need for events. */
    QSize mBaseSize; /**< Base size of image. */
    PaintInstruments *mPaintInstruments;
    AdditionalTools *mAdditionalTools;
    Effects *mEffects;
    QString mFilePath; /**< Path where located image. */
    bool mIsEdited, mIsPaint, mIsResize;
    bool mIsModified;

signals:
    /**
     * @brief Send first color for ToolBar.
     *
     */
    void sendFirstColorView();
    /**
     * @brief Send second color for ToolBar.
     *
     */
    void sendSecondColorView();
    void sendNewImageSize(const QSize&);
    void sendCursorPos(const QPoint&);
    /**
     * @brief Send state of image.
     *
     * @param b true, if image has unsaved data, false otherwise.
     */
    void smthModified(bool b);
    
private slots:

protected:
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
    void paintEvent(QPaintEvent *event);<commit_msg>Added save changes dialog when window closing (issue #12)<commit_after>/*
 * This source file is part of EasyPaint.
 *
 * Copyright (c) 2012 EasyPaint <https://github.com/Gr1N/EasyPaint>
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#ifndef IMAGEAREA_H
#define IMAGEAREA_H

#include "easypaintenums.h"
#include "effects.h"
#include "additionaltools.h"

#include <QtGui/QWidget>
#include <QtGui/QImage>

QT_BEGIN_NAMESPACE
class PaintInstruments;
QT_END_NAMESPACE

/**
 * @brief Base class which contains view image and controller for painting
 *
 */
class ImageArea : public QWidget
{
    Q_OBJECT

public:
    /**
     * @brief Constructor
     *
     * @param isOpen Flag which shows opens a new image or from file.
     * @param parent Pointer for parent.
     */
    explicit ImageArea(const bool &isOpen = false, QWidget *parent = 0);
    ~ImageArea();

    /**
     * @brief Save image to file with existing path.
     *
     */
    void save();
    /**
     * @brief Save image to file with unknown path.
     *
     */
    void saveAs();
    /**
     * @brief Print image.
     *
     */
    void print();
    /**
     * @brief Resize image.
     *
     */
    void resizeImage();
    /**
     * @brief Rotate image.
     *
     * @param flag Rotate to left or to right.
     */
    void rotateImage(bool flag);

    inline QString getFileName() { return mFilePath.split('/').last(); }
    inline QImage* getImage() { return mImage; }
    inline void setImage(const QImage &image) { *mImage = image; }
    /**
     * @brief Set flag which shows that image edited.
     *
     * @param flag Boolean flag.
     */
    inline void setEdited(bool flag) { mIsEdited = flag; }
    /**
     * @brief Get flag which shows that image edited.
     *
     * @return bool Flag.
     */
    inline bool getEdited() { return mIsEdited; }
    /**
     * @brief Apply gray effect.
     *
     */
    inline void effectGray() { mEffects->gray(); }
    /**
     * @brief Apply negative effect.
     *
     */
    inline void effectNegative() { mEffects->negative(); }
    
    inline bool isModified() { return mIsModified; }
private:
    /**
     * @brief Initialize image with base params.
     *
     */
    void initializeImage();
    /**
     * @brief Open file from file.
     *
     */
    void open();

    QImage *mImage,  /**< Main image. */
           mImageCopy; /**< Copy of main image, need for events. */
    QSize mBaseSize; /**< Base size of image. */
    PaintInstruments *mPaintInstruments;
    AdditionalTools *mAdditionalTools;
    Effects *mEffects;
    QString mFilePath; /**< Path where located image. */
    bool mIsEdited, mIsPaint, mIsResize;
    bool mIsModified;

signals:
    /**
     * @brief Send first color for ToolBar.
     *
     */
    void sendFirstColorView();
    /**
     * @brief Send second color for ToolBar.
     *
     */
    void sendSecondColorView();
    void sendNewImageSize(const QSize&);
    void sendCursorPos(const QPoint&);
    
private slots:

protected:
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
    void paintEvent(QPaintEvent *event);
{'fraction_non_alphanumeric': 0.10062010062010061, 'fraction_numerical': 0.001638001638001638, 'mean_word_length': 2.681309216192937, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5750442', 'n_tokens_mistral': 2496, 'n_tokens_neox': 2413, 'n_words': 913}