From 9bc45dedfdf33230583ef80649659cdf92851128 Mon Sep 17 00:00:00 2001 From: Sonaion Date: Thu, 19 Dec 2019 14:33:28 +0100 Subject: [PATCH] gui changes for tool anwendung --- src/GUI/IntelliPhotoGui.cpp | 36 ++++++++++++++++++++++++++++++++++-- src/GUI/IntelliPhotoGui.h | 8 ++++++++ src/Layer/PaintingArea.cpp | 21 ++++++++++++++++++++- src/Layer/PaintingArea.h | 4 ++++ 4 files changed, 66 insertions(+), 3 deletions(-) diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 0c9a620..25eecb3 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -195,7 +195,7 @@ void IntelliPhotoGui::slotSetActiveLayer(){ if (ok1) { paintingArea->setLayerToActive(layer); - } + } } void IntelliPhotoGui::slotSetFirstColor(){ @@ -203,7 +203,7 @@ void IntelliPhotoGui::slotSetFirstColor(){ } void IntelliPhotoGui::slotSetSecondColor(){ - paintingArea->colorPickerSetSecondColor(); + paintingArea->colorPickerSetSecondColor(); } void IntelliPhotoGui::slotSwitchColor(){ @@ -222,6 +222,22 @@ void IntelliPhotoGui::slotCreateLineTool(){ paintingArea->createLineTool(); } +void IntelliPhotoGui::slotCreateRectangleTool(){ + paintingArea->createRectangleTool(); +} + +void IntelliPhotoGui::slotCreateCircleTool(){ + paintingArea->createCircleTool(); +} + +void IntelliPhotoGui::slotCreatePolygonTool(){ + paintingArea->createPolygonTool(); +} + +void IntelliPhotoGui::slotCreateFloodFillTool(){ + paintingArea->createFloodFillTool(); +} + // Open an about dialog void IntelliPhotoGui::slotAboutDialog(){ // Window title and text to display @@ -326,6 +342,18 @@ void IntelliPhotoGui::createActions(){ actionCreateLineTool = new QAction(tr("&Line"), this); connect(actionCreateLineTool, SIGNAL(triggered()), this, SLOT(slotCreateLineTool())); + actionCreateCircleTool = new QAction(tr("&Circle"), this); + connect(actionCreateCircleTool, SIGNAL(triggered()), this, SLOT(slotCreateCircleTool())); + + actionCreateRectangleTool = new QAction(tr("&Rectangle"), this); + connect(actionCreateRectangleTool, SIGNAL(triggered()), this, SLOT(slotCreateRectangleTool())); + + actionCreatePolygonTool = new QAction(tr("&Polygon"), this); + connect(actionCreatePolygonTool, SIGNAL(triggered()), this, SLOT(slotCreatePolygonTool())); + + actionCreateFloodFillTool = new QAction(tr("&FloodFill"), this); + connect(actionCreateFloodFillTool, SIGNAL(triggered()), this, SLOT(slotCreateFloodFillTool())); + // Create about action and tie to IntelliPhotoGui::about() actionAboutDialog = new QAction(tr("&About"), this); connect(actionAboutDialog, SIGNAL(triggered()), this, SLOT(slotAboutDialog())); @@ -377,6 +405,10 @@ void IntelliPhotoGui::createMenus(){ toolMenu->addAction(actionCreatePenTool); toolMenu->addAction(actionCreatePlainTool); toolMenu->addAction(actionCreateLineTool); + toolMenu->addAction(actionCreateRectangleTool); + toolMenu->addAction(actionCreateCircleTool); + toolMenu->addAction(actionCreatePolygonTool); + toolMenu->addAction(actionCreateFloodFillTool); toolMenu->addSeparator(); toolMenu->addMenu(colorMenu); diff --git a/src/GUI/IntelliPhotoGui.h b/src/GUI/IntelliPhotoGui.h index 1b45375..787978c 100644 --- a/src/GUI/IntelliPhotoGui.h +++ b/src/GUI/IntelliPhotoGui.h @@ -55,6 +55,10 @@ private slots: void slotCreatePenTool(); void slotCreatePlainTool(); void slotCreateLineTool(); + void slotCreateRectangleTool(); + void slotCreateCircleTool(); + void slotCreatePolygonTool(); + void slotCreateFloodFillTool(); // slots for dialogs void slotAboutDialog(); @@ -99,6 +103,10 @@ private: QAction *actionCreatePenTool; QAction *actionCreatePlainTool; QAction *actionCreateLineTool; + QAction *actionCreateRectangleTool; + QAction *actionCreateCircleTool; + QAction *actionCreatePolygonTool; + QAction *actionCreateFloodFillTool; // dialog actions QAction *actionAboutDialog; diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index c835b24..2a0337d 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -20,7 +20,7 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent) :QWidget(parent){ - this->Tool = new IntelliToolPolygon(this, &colorPicker); + this->Tool = nullptr; this->setUp(maxWidth, maxHeight); this->addLayer(200,200,0,0,ImageType::Shaped_Image); layerBundle[0].image->drawPlain(QColor(0,0,255,255)); @@ -192,6 +192,25 @@ void PaintingArea::createLineTool(){ Tool = new IntelliToolLine(this, &colorPicker); } +void PaintingArea::createRectangleTool(){ + delete this->Tool; + Tool = new IntelliToolRectangle(this, &colorPicker); +} + +void PaintingArea::createCircleTool(){ + delete this->Tool; + Tool = new IntelliToolCircle(this, &colorPicker); +} +void PaintingArea::createPolygonTool(){ + delete this->Tool; + Tool = new IntelliToolPolygon(this, &colorPicker); +} + +void PaintingArea::createFloodFillTool(){ + delete this->Tool; + Tool = new IntelliToolFloodFill(this, &colorPicker); +} + int PaintingArea::getWidthOfActive(){ return this->layerBundle[activeLayer].width; } diff --git a/src/Layer/PaintingArea.h b/src/Layer/PaintingArea.h index 07b43a0..70d2b6e 100644 --- a/src/Layer/PaintingArea.h +++ b/src/Layer/PaintingArea.h @@ -55,6 +55,10 @@ public: void createPenTool(); void createPlainTool(); void createLineTool(); + void createRectangleTool(); + void createCircleTool(); + void createPolygonTool(); + void createFloodFillTool(); int getWidthOfActive(); int getHeightOfActive();