diff --git a/src/Painting/GUI/IntelliPhotoGui.cpp b/src/Painting/GUI/IntelliPhotoGui.cpp index 418cdaa..1535408 100644 --- a/src/Painting/GUI/IntelliPhotoGui.cpp +++ b/src/Painting/GUI/IntelliPhotoGui.cpp @@ -249,14 +249,7 @@ void IntelliPhotoGui::slotAboutDialog() // Define menu actions that call functions void IntelliPhotoGui::createActions() { - // Create the action tied to the menu - actionOpen = new QAction(tr("&Open..."), this); - // Define the associated shortcut key - actionOpen->setShortcuts(QKeySequence::Open); - - // Tie the action to IntelliPhotoGui::open() - connect(actionOpen, SIGNAL(triggered()), this, SLOT(slotOpen())); // Get a list of the supported file formats // QImageWriter is used to write images to files @@ -287,9 +280,13 @@ void IntelliPhotoGui::createActions() // Create exit action and tie to IntelliPhotoGui::close() - actionOpen = new QAction(tr("&Exit"), this); - actionOpen->setShortcuts(QKeySequence::Quit); - connect(actionOpen, SIGNAL(triggered()), this, SLOT(close())); + actionExit = new QAction(tr("&Exit"), this); + actionExit->setShortcuts(QKeySequence::Quit); + connect(actionExit, SIGNAL(triggered()), this, SLOT(close())); + + actionOpen = new QAction(tr("&Open"), this); + actionOpen->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_O)); + connect(actionOpen, SIGNAL(triggered()), this, SLOT(slotOpen())); // Create New Layer action and tie to IntelliPhotoGui::newLayer() actionCreateNewLayer = new QAction(tr("&New Layer..."), this); @@ -373,7 +370,7 @@ void IntelliPhotoGui::createMenus() fileMenu->addAction(actionOpen); fileMenu->addMenu(saveAsMenu); fileMenu->addSeparator(); - fileMenu->addAction(actionOpen); + fileMenu->addAction(actionExit); // Attach all actions to Options optionMenu = new QMenu(tr("&Options"), this); @@ -446,7 +443,9 @@ void IntelliPhotoGui::setIntelliStyle(){ bool IntelliPhotoGui::maybeSave() { // Check for changes since last save - if (paintingArea->isModified()) { + + //TODO insert variable for modified status here to make an save exit message + if (false) { QMessageBox::StandardButton ret; // Painting is the title diff --git a/src/Painting/Image/IntelliImage.cpp b/src/Painting/Image/IntelliImage.cpp index d9f5a48..74b7891 100644 --- a/src/Painting/Image/IntelliImage.cpp +++ b/src/Painting/Image/IntelliImage.cpp @@ -20,7 +20,7 @@ bool IntelliImage::loadImage(const QString &fileName){ return false; // scaled Image to size of Layer - // loadedImage = loadedImage.scaled(imageData.size(),Qt::IgnoreAspectRatio); + loadedImage = loadedImage.scaled(imageData.size(),Qt::IgnoreAspectRatio); imageData = loadedImage.convertToFormat(QImage::Format_ARGB32); return true; @@ -64,6 +64,6 @@ void IntelliImage::drawLine(const QPoint &p1, const QPoint& p2, const QColor& co } -void IntelliImage::floodFill(const QColor& color){ +void IntelliImage::drawPlain(const QColor& color){ imageData.fill(color); } diff --git a/src/Painting/Image/IntelliImage.h b/src/Painting/Image/IntelliImage.h index 72a7310..14e9ec2 100644 --- a/src/Painting/Image/IntelliImage.h +++ b/src/Painting/Image/IntelliImage.h @@ -31,7 +31,7 @@ public: //start on top left virtual void drawPixel(const QPoint &p1, const QColor& color); virtual void drawLine(const QPoint &p1, const QPoint& p2, const QColor& color, const int& penWidth); - virtual void floodFill(const QColor& color); + virtual void drawPlain(const QColor& color); //returns the filtered output virtual QImage getDisplayable(const QSize& displaySize, int alpha)=0; diff --git a/src/Painting/Layer/PaintingArea.cpp b/src/Painting/Layer/PaintingArea.cpp index ecef2ee..7fff2a9 100644 --- a/src/Painting/Layer/PaintingArea.cpp +++ b/src/Painting/Layer/PaintingArea.cpp @@ -21,7 +21,7 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent) this->setUp(maxWidth, maxHeight); //tetsing this->addLayer(200,200,0,0,ImageType::Shaped_Image); - layerBundle[0].image->floodFill(QColor(255,0,0,255)); + layerBundle[0].image->drawPlain(QColor(255,0,0,255)); std::vector polygon; polygon.push_back(QPoint(100,000)); polygon.push_back(QPoint(200,100)); @@ -30,12 +30,16 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent) layerBundle[0].image->setPolygon(polygon); this->addLayer(200,200,150,150); - layerBundle[1].image->floodFill(QColor(0,255,0,255)); + layerBundle[1].image->drawPlain(QColor(0,255,0,255)); layerBundle[1].alpha=200; activeLayer=0; } +PaintingArea::~PaintingArea(){ + delete Tool; +} + void PaintingArea::setUp(int maxWidth, int maxHeight){ //set standart parameter @@ -102,6 +106,7 @@ bool PaintingArea::open(const QString &fileName) } IntelliImage* active = layerBundle[static_cast(activeLayer)].image; bool open = active->loadImage(fileName); + active->calculateVisiblity(); update(); return open; } @@ -138,7 +143,7 @@ void PaintingArea::floodFill(int r, int g, int b, int a){ return; } IntelliImage* active = layerBundle[static_cast(activeLayer)].image; - active->floodFill(QColor(r, g, b, a)); + active->drawPlain(QColor(r, g, b, a)); update(); } diff --git a/src/Painting/Layer/PaintingArea.h b/src/Painting/Layer/PaintingArea.h index 71921c0..a4ec3fa 100644 --- a/src/Painting/Layer/PaintingArea.h +++ b/src/Painting/Layer/PaintingArea.h @@ -34,6 +34,7 @@ class PaintingArea : public QWidget friend IntelliTool; public: PaintingArea(int maxWidth=600, int maxHeight=600, QWidget *parent = nullptr); + ~PaintingArea(); // Handles all events bool open(const QString &fileName); @@ -48,9 +49,6 @@ public: void movePositionActive(int x, int y); void moveActiveLayer(int idx); - // Has the image been modified since last save - bool isModified() const { return modified; } - //change properties of colorPicker void colorPickerSetFirstColor(); void colorPickerSetSecondColor(); @@ -99,9 +97,6 @@ private: void resizeImage(QImage *image_res, const QSize &newSize); - // Will be marked true or false depending on if - // we have saved after a change - bool modified=false; //Helper for Tool void createTempLayerAfter(int idx); diff --git a/src/Painting/Tool/IntelliToolLine.cpp b/src/Painting/Tool/IntelliToolLine.cpp index 1c9fc79..c1d571d 100644 --- a/src/Painting/Tool/IntelliToolLine.cpp +++ b/src/Painting/Tool/IntelliToolLine.cpp @@ -37,7 +37,7 @@ void IntelliToolLine::onMouseLeftReleased(int x, int y){ void IntelliToolLine::onMouseMoved(int x, int y){ IntelliTool::onMouseMoved(x,y); if(this->drawing){ - this->Canvas->image->floodFill(Qt::transparent); + this->Canvas->image->drawPlain(Qt::transparent); QPoint next(x,y); switch(lineStyle){ case LineStyle::SOLID_LINE : diff --git a/src/Painting/Tool/IntelliToolPlain.cpp b/src/Painting/Tool/IntelliToolPlain.cpp index 3302dd7..aaa2a02 100644 --- a/src/Painting/Tool/IntelliToolPlain.cpp +++ b/src/Painting/Tool/IntelliToolPlain.cpp @@ -8,7 +8,7 @@ IntelliToolPlainTool::IntelliToolPlainTool(PaintingArea* Area, IntelliColorPicke void IntelliToolPlainTool::onMouseLeftPressed(int x, int y){ IntelliTool::onMouseLeftPressed(x,y); - this->Canvas->image->floodFill(colorPicker->getFirstColor()); + this->Canvas->image->drawPlain(colorPicker->getFirstColor()); Canvas->image->calculateVisiblity(); }