From 74d2d30fe0febb25e8a90c0d2f6342658ca8b269 Mon Sep 17 00:00:00 2001 From: AshBastian Date: Fri, 10 Jan 2020 12:28:55 +0100 Subject: [PATCH 01/12] Update --- src/GUI/IntelliPhotoGui.cpp | 56 +++++++++++++++++++------------ src/GUI/IntelliPhotoGui.h | 5 ++- src/Tool/IntelliTool.cpp | 3 +- src/Tool/IntelliToolRectangle.cpp | 4 +-- 4 files changed, 43 insertions(+), 25 deletions(-) diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 1c4e009..64fd586 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -12,11 +12,11 @@ IntelliPhotoGui::IntelliPhotoGui(){ // create Menus createMenus(); // set style of the gui - setIntelliStyle(); - // Size the app - resize(600,600); - showMaximized(); - setDefaultToolValue(); + setIntelliStyle(); + // Size the app + resize(600,600); + showMaximized(); + setDefaultToolValue(); } // User tried to close the app @@ -46,7 +46,7 @@ void IntelliPhotoGui::slotOpen(){ // If we have a file name load the image and place // it in the paintingArea - if (!fileName.isEmpty()){ + if (!fileName.isEmpty()) paintingArea->open(fileName); UpdateGui(); } @@ -194,11 +194,11 @@ void IntelliPhotoGui::slotSetActiveLayer(){ // "Layer to set on" is the title of the window // the next tr is the text to display - // Define the standard Value, min, max, step and ok button - int layer = QInputDialog::getInt(this, tr("Layer to set on"), - tr("Layer:"), + // Define the standard Value, min, max, step and ok button + int layer = QInputDialog::getInt(this, tr("Layer to set on"), + tr("Layer:"), 1,1,500,1, &ok1); - if (ok1) + if (ok1) { paintingArea->setLayerActive(layer-1); UpdateGui(); @@ -587,9 +587,9 @@ void IntelliPhotoGui::createGui(){ preview = QPixmap(":/Icons/Buttons/icons/circle-tool.svg"); CircleButton = new QPushButton(); - CircleButton->setFixedSize(Buttonsize); + CircleButton->setFixedSize(Buttonsize); CircleButton->setIcon(preview); - CircleButton->setIconSize(Buttonsize); + CircleButton->setIconSize(Buttonsize); CircleButton->setCheckable(true); preview = QPixmap(":/Icons/Buttons/icons/flood-fill-tool.svg"); @@ -636,10 +636,10 @@ void IntelliPhotoGui::createGui(){ WidthLine = new QLabel(); WidthLine->setText("Width"); - WidthLine->setFixedSize(Buttonsize.width(),Buttonsize.height()/3); + WidthLine->setFixedSize(Buttonsize.width()*2,(Buttonsize.height()*2)/3); EditLineWidth = new QLineEdit(); - EditLineWidth->setFixedSize(Buttonsize.width(),Buttonsize.height()/3); + EditLineWidth->setFixedSize(Buttonsize.width()*2,(Buttonsize.height()*2)/3); EditLineWidth->setText("5"); ValidatorLineWidth = new QIntValidator(); ValidatorLineWidth->setTop(99); @@ -648,10 +648,10 @@ void IntelliPhotoGui::createGui(){ innerAlphaLine = new QLabel(); innerAlphaLine->setText("Inner Alpha"); - innerAlphaLine->setFixedSize(Buttonsize.width(),Buttonsize.height()/3); + innerAlphaLine->setFixedSize(Buttonsize.width()*2,(Buttonsize.height()*2)/3); EditLineInnerAlpha = new QLineEdit(); - EditLineInnerAlpha->setFixedSize(Buttonsize.width(),Buttonsize.height()/3); + EditLineInnerAlpha->setFixedSize(Buttonsize.width()*2,(Buttonsize.height()*2)/3); EditLineInnerAlpha->setText("255"); ValidatorInnerAlpha = new QIntValidator(); ValidatorInnerAlpha->setTop(999); @@ -659,21 +659,21 @@ void IntelliPhotoGui::createGui(){ EditLineInnerAlpha->setValidator(ValidatorInnerAlpha); FirstColorButton = new QPushButton(); - FirstColorButton->setFixedSize(Buttonsize/2); + FirstColorButton->setFixedSize(Buttonsize); SecondColorButton = new QPushButton(); - SecondColorButton->setFixedSize(Buttonsize/2); + SecondColorButton->setFixedSize(Buttonsize); preview = QPixmap(":/Icons/Buttons/icons/Wechselpfeile.png"); SwitchColorButton = new QPushButton(); - SwitchColorButton->setFixedSize(Buttonsize.width(),Buttonsize.height()/2); + SwitchColorButton->setFixedSize(Buttonsize.width()*2,Buttonsize.height()); SwitchColorButton->setIcon(preview); - SwitchColorButton->setIconSize(QSize(Buttonsize.width(),Buttonsize.height()/2)); + SwitchColorButton->setIconSize(QSize(Buttonsize.width()*2,Buttonsize.height())); ActiveLayerLine = new QLabel(); QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer() + 1); ActiveLayerLine->setText(string); - ActiveLayerLine->setFixedSize(Buttonsize.width()+10,Buttonsize.height()/3); + ActiveLayerLine->setFixedSize(Buttonsize.width()*2+10,(Buttonsize.height()*2)/3); IntelliImage* activePicture = paintingArea->getImageOfActiveLayer(); if(activePicture){ @@ -707,6 +707,7 @@ void IntelliPhotoGui::createGui(){ mainLayout->addWidget(SwitchColorButton,13,2,1,2); mainLayout->addWidget(ActiveLayerLine,14,2,1,2); mainLayout->addWidget(ActiveLayerImageLine,15,2,1,2); + mainLayout->setHorizontalSpacing(0); } void IntelliPhotoGui::setIntelliStyle(){ @@ -799,6 +800,19 @@ void IntelliPhotoGui::setDefaultToolValue(){ slotEnterPressed(); } +void IntelliPhotoGui::setToolWidth(int value){ + if(value < 1){ + value = 1; + }else if(value > 50){ + value = 50; + } + EditLineWidth->setText(QString("%1").arg(value)); +} + +int IntelliPhotoGui::getToolWidth(){ + return EditLineWidth->text().toInt(); +} + void IntelliPhotoGui::UpdateGui(){ QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer() + 1); ActiveLayerLine->setText(string); diff --git a/src/GUI/IntelliPhotoGui.h b/src/GUI/IntelliPhotoGui.h index 43aa03e..c9b43e8 100644 --- a/src/GUI/IntelliPhotoGui.h +++ b/src/GUI/IntelliPhotoGui.h @@ -34,6 +34,9 @@ IntelliPhotoGui(); void UpdateGui(); +void setToolWidth(int value); +int getToolWidth(); + protected: // Function used to close an event void closeEvent(QCloseEvent*event) override; @@ -103,7 +106,7 @@ void setDefaultToolValue(); // What we'll draw on PaintingArea* paintingArea; -const QSize Buttonsize = QSize(70,70); +const QSize Buttonsize = QSize(35,35); QPixmap preview; QPushButton* CircleButton; QPushButton* FloodFillButton; diff --git a/src/Tool/IntelliTool.cpp b/src/Tool/IntelliTool.cpp index 2dd2272..0779a8f 100644 --- a/src/Tool/IntelliTool.cpp +++ b/src/Tool/IntelliTool.cpp @@ -45,7 +45,8 @@ void IntelliTool::onMouseMoved(int x, int y){ } void IntelliTool::onWheelScrolled(int value){ - //if needed for future general tasks implement in here + //if needed for future general tasks implement in here + Area->DummyGui->setToolWidth(value+Area->DummyGui->getToolWidth()); } bool IntelliTool::createToolLayer(){ diff --git a/src/Tool/IntelliToolRectangle.cpp b/src/Tool/IntelliToolRectangle.cpp index 29fa038..4fe86f7 100644 --- a/src/Tool/IntelliToolRectangle.cpp +++ b/src/Tool/IntelliToolRectangle.cpp @@ -58,6 +58,6 @@ void IntelliToolRectangle::onMouseMoved(int x, int y){ } void IntelliToolRectangle::onWheelScrolled(int value){ - IntelliTool::onWheelScrolled(value); - Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value); + IntelliTool::onWheelScrolled(value); + Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value); } From ea7316cb0bd5bbd82f299758536cea9c269e1aad Mon Sep 17 00:00:00 2001 From: AshBastian Date: Fri, 10 Jan 2020 12:39:01 +0100 Subject: [PATCH 02/12] Buttonsize Updated --- src/GUI/IntelliPhotoGui.cpp | 46 +++++++++++++++++-------------------- src/GUI/IntelliPhotoGui.h | 3 +-- src/Tool/IntelliTool.cpp | 2 +- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 64fd586..17b02c1 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -46,7 +46,7 @@ void IntelliPhotoGui::slotOpen(){ // If we have a file name load the image and place // it in the paintingArea - if (!fileName.isEmpty()) + if (!fileName.isEmpty()){ paintingArea->open(fileName); UpdateGui(); } @@ -684,29 +684,29 @@ void IntelliPhotoGui::createGui(){ preview = preview.fromImage(tmp); } - ActiveLayerImageLine = new QLabel(); - ActiveLayerImageLine->setFixedSize(Buttonsize); - ActiveLayerImageLine->setPixmap(preview.scaled(Buttonsize)); + ActiveLayerImageLabel = new QLabel(); + ActiveLayerImageLabel->setFixedSize(Buttonsize*2); + ActiveLayerImageLabel->setPixmap(preview.scaled(Buttonsize*2)); // set gui elements mainLayout->addWidget(paintingArea,1,1,20,1); - mainLayout->addWidget(CircleButton,1,2,1,2); - mainLayout->addWidget(FloodFillButton,2,2,1,2); - mainLayout->addWidget(LineButton,3,2,1,2); - mainLayout->addWidget(PenButton,4,2,1,2); - mainLayout->addWidget(PlainButton,5,2,1,2); - mainLayout->addWidget(PolygonButton,6,2,1,2); - mainLayout->addWidget(RectangleButton,7,2,1,2); - mainLayout->addWidget(WidthLine,8,2,1,2); - mainLayout->addWidget(EditLineWidth,9,2,1,2); - mainLayout->addWidget(innerAlphaLine,10,2,1,2); - mainLayout->addWidget(EditLineInnerAlpha,11,2,1,2); - mainLayout->addWidget(FirstColorButton,12,2,1,1); - mainLayout->addWidget(SecondColorButton,12,3,1,1); - mainLayout->addWidget(SwitchColorButton,13,2,1,2); - mainLayout->addWidget(ActiveLayerLine,14,2,1,2); - mainLayout->addWidget(ActiveLayerImageLine,15,2,1,2); + mainLayout->addWidget(CircleButton,1,2,1,1); + mainLayout->addWidget(FloodFillButton,1,3,1,1); + mainLayout->addWidget(LineButton,2,2,1,1); + mainLayout->addWidget(PenButton,2,3,1,1); + mainLayout->addWidget(PlainButton,3,2,1,1); + mainLayout->addWidget(PolygonButton,3,3,1,1); + mainLayout->addWidget(RectangleButton,4,2,1,1); + mainLayout->addWidget(WidthLine,5,2,1,2); + mainLayout->addWidget(EditLineWidth,6,2,1,2); + mainLayout->addWidget(innerAlphaLine,7,2,1,2); + mainLayout->addWidget(EditLineInnerAlpha,8,2,1,2); + mainLayout->addWidget(FirstColorButton,9,2,1,1); + mainLayout->addWidget(SecondColorButton,9,3,1,1); + mainLayout->addWidget(SwitchColorButton,10,2,1,2); + mainLayout->addWidget(ActiveLayerLine,11,2,1,2); + mainLayout->addWidget(ActiveLayerImageLabel,12,2,1,2); mainLayout->setHorizontalSpacing(0); } @@ -809,10 +809,6 @@ void IntelliPhotoGui::setToolWidth(int value){ EditLineWidth->setText(QString("%1").arg(value)); } -int IntelliPhotoGui::getToolWidth(){ - return EditLineWidth->text().toInt(); -} - void IntelliPhotoGui::UpdateGui(){ QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer() + 1); ActiveLayerLine->setText(string); @@ -825,7 +821,7 @@ void IntelliPhotoGui::UpdateGui(){ tmp.fill(Qt::transparent); preview = preview.fromImage(tmp); } - ActiveLayerImageLine->setPixmap(preview.scaled(Buttonsize)); + ActiveLayerImageLabel->setPixmap(preview.scaled(Buttonsize*2)); string = QString("background-color: %1").arg(paintingArea->colorPicker.getFirstColor().name()); FirstColorButton->setStyleSheet(string); diff --git a/src/GUI/IntelliPhotoGui.h b/src/GUI/IntelliPhotoGui.h index c9b43e8..55920ff 100644 --- a/src/GUI/IntelliPhotoGui.h +++ b/src/GUI/IntelliPhotoGui.h @@ -35,7 +35,6 @@ IntelliPhotoGui(); void UpdateGui(); void setToolWidth(int value); -int getToolWidth(); protected: // Function used to close an event @@ -127,7 +126,7 @@ QPushButton* SecondColorButton; QPushButton* SwitchColorButton; QLabel* ActiveLayerLine; -QLabel* ActiveLayerImageLine; +QLabel* ActiveLayerImageLabel; QPalette Palette; diff --git a/src/Tool/IntelliTool.cpp b/src/Tool/IntelliTool.cpp index 0779a8f..520ad1c 100644 --- a/src/Tool/IntelliTool.cpp +++ b/src/Tool/IntelliTool.cpp @@ -46,7 +46,7 @@ void IntelliTool::onMouseMoved(int x, int y){ void IntelliTool::onWheelScrolled(int value){ //if needed for future general tasks implement in here - Area->DummyGui->setToolWidth(value+Area->DummyGui->getToolWidth()); + Area->DummyGui->setToolWidth(value+Toolsettings->getLineWidth()); } bool IntelliTool::createToolLayer(){ From dbf1cda101d529fef836e59a037b8e5d4fc06c88 Mon Sep 17 00:00:00 2001 From: AshBastian Date: Fri, 10 Jan 2020 14:15:59 +0100 Subject: [PATCH 03/12] Update --- src/GUI/IntelliInputDialog.cpp | 45 ++++++++++++++++++++++++++++++++++ src/GUI/IntelliInputDialog.h | 25 +++++++++++++++++++ src/GUI/IntelliPhotoGui.cpp | 10 +++----- src/IntelliPhoto.pro | 2 ++ 4 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 src/GUI/IntelliInputDialog.cpp create mode 100644 src/GUI/IntelliInputDialog.h diff --git a/src/GUI/IntelliInputDialog.cpp b/src/GUI/IntelliInputDialog.cpp new file mode 100644 index 0000000..1e35545 --- /dev/null +++ b/src/GUI/IntelliInputDialog.cpp @@ -0,0 +1,45 @@ +#include "IntelliInputDialog.h" + +IntelliInputDialog::IntelliInputDialog() +{ + setValuesOfPalette(); +} + +void IntelliInputDialog::Input(){ + QDialog* Dialog = new QDialog(); + QGridLayout* Layout = new QGridLayout(); + QDialogButtonBox* ButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + + QPushButton* Button = new QPushButton(); + Button->setFixedSize(Buttonsize); + + QPushButton* okButton = ButtonBox->button(QDialogButtonBox::Ok); + okButton->setAutoDefault(false); + okButton->setDefault(false); + + QPushButton* cancelButton = ButtonBox->button(QDialogButtonBox::Cancel); + cancelButton->setAutoDefault(false); + cancelButton->setDefault(false); + + Button->setPalette(Palette); + okButton->setPalette(Palette); + cancelButton->setPalette(Palette); + + Layout->addWidget(Button); + Layout->addWidget(ButtonBox); + Dialog->setLayout(Layout); + Dialog->setStyleSheet("background-color:rgb(64,64,64)"); + connect(okButton, SIGNAL(clicked()),Dialog,SLOT(slotCloseEvent())); +} + +void IntelliInputDialog::setValuesOfPalette(){ + Palette.setBrush(QPalette::HighlightedText, QColor(200, 10, 10)); + Palette.setBrush(QPalette::Highlight, QColor(100, 5, 5)); + Palette.setBrush(QPalette::ButtonText, QColor(255, 255, 255)); + Palette.setBrush(QPalette::Button, QColor(64, 64, 64)); + Palette.setBrush(QPalette::Window, QColor(64, 64, 64)); + Palette.setBrush(QPalette::WindowText, QColor(255, 255, 255)); + Palette.setBrush(QPalette::PlaceholderText, QColor(255, 255, 255)); + Palette.setBrush(QPalette::ToolTipText, QColor(255, 255, 255)); + Palette.setBrush(QPalette::Text, QColor(255, 255, 255)); +} diff --git a/src/GUI/IntelliInputDialog.h b/src/GUI/IntelliInputDialog.h new file mode 100644 index 0000000..49af2b5 --- /dev/null +++ b/src/GUI/IntelliInputDialog.h @@ -0,0 +1,25 @@ +#ifndef INTELLIINPUTDIALOG_H +#define INTELLIINPUTDIALOG_H + +#include + +#include "IntelliPhotoGui.h" + +class IntelliInputDialog +{ +public: + IntelliInputDialog(); + + void Input(); + +private slots: + void slotCloseEvent(); + +private: + IntelliPhotoGui* DummyGui; + const QSize Buttonsize = QSize(35,35); + QPalette Palette; + void setValuesOfPalette(); +}; + +#endif // INTELLIINPUTDIALOG_H diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 17b02c1..9f3b4b4 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -73,10 +73,9 @@ void IntelliPhotoGui::slotCreateNewLayer(){ // "New Layer" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button - QInputDialog Input; - Input.setPalette(Palette); - int width = Input.getInt(this, tr("New Layer"), + + /*int width = QInputDialog::getInt(this, tr("New Layer"), tr("Width:"), 200,1, 500, 1, &ok1); @@ -87,7 +86,7 @@ void IntelliPhotoGui::slotCreateNewLayer(){ if (ok1&&ok2){ paintingArea->addLayer(width,height,0,0); UpdateGui(); - } + }*/ } // Opens a dialog that allows the user to delete a Layer @@ -689,7 +688,6 @@ void IntelliPhotoGui::createGui(){ ActiveLayerImageLabel->setPixmap(preview.scaled(Buttonsize*2)); // set gui elements - mainLayout->addWidget(paintingArea,1,1,20,1); mainLayout->addWidget(CircleButton,1,2,1,1); mainLayout->addWidget(FloodFillButton,1,3,1,1); @@ -717,7 +715,7 @@ void IntelliPhotoGui::setIntelliStyle(){ Palette.setBrush(QPalette::Highlight, QColor(100, 5, 5)); Palette.setBrush(QPalette::ButtonText, QColor(255, 255, 255)); Palette.setBrush(QPalette::Button, QColor(64, 64, 64)); - Palette.setBrush(QPalette::Window, QColor(0, 0, 0)); + Palette.setBrush(QPalette::Window, QColor(64, 64, 64)); Palette.setBrush(QPalette::WindowText, QColor(255, 255, 255)); Palette.setBrush(QPalette::PlaceholderText, QColor(255, 255, 255)); Palette.setBrush(QPalette::ToolTipText, QColor(255, 255, 255)); diff --git a/src/IntelliPhoto.pro b/src/IntelliPhoto.pro index 13b6975..f3c669a 100644 --- a/src/IntelliPhoto.pro +++ b/src/IntelliPhoto.pro @@ -16,6 +16,7 @@ DEFINES += QT_DEPRECATED_WARNINGS #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ + GUI/IntelliInputDialog.cpp \ GUI/IntelliPhotoGui.cpp \ Image/IntelliImage.cpp \ Image/IntelliRasterImage.cpp \ @@ -36,6 +37,7 @@ SOURCES += \ main.cpp HEADERS += \ + GUI/IntelliInputDialog.h \ GUI/IntelliPhotoGui.h \ Image/IntelliImage.h \ Image/IntelliRasterImage.h \ From 7491472962e55924f4f94ddf2d77876ff5ad2152 Mon Sep 17 00:00:00 2001 From: AshBastian Date: Fri, 10 Jan 2020 21:10:49 +0100 Subject: [PATCH 04/12] Schluss --- src/GUI/IntelliInputDialog.cpp | 84 ++++++++++++++++++++++++++++------ src/GUI/IntelliInputDialog.h | 37 +++++++++++---- src/GUI/IntelliPhotoGui.cpp | 25 +++++----- src/GUI/IntelliPhotoGui.h | 8 +++- src/main.cpp | 7 ++- 5 files changed, 121 insertions(+), 40 deletions(-) diff --git a/src/GUI/IntelliInputDialog.cpp b/src/GUI/IntelliInputDialog.cpp index 1e35545..7afa6b1 100644 --- a/src/GUI/IntelliInputDialog.cpp +++ b/src/GUI/IntelliInputDialog.cpp @@ -1,35 +1,71 @@ #include "IntelliInputDialog.h" -IntelliInputDialog::IntelliInputDialog() +IntelliInputDialog::IntelliInputDialog(Speichereinheit &Speicher, QEventLoop* Loop, IntelliInputDialog* Dialog, QString Title, QString Label, int value, int minValue, int maxValue, int step) { + this->Dialog = Dialog; + createInputBox(Title, Label, value, minValue, maxValue, step); + createConnections(Loop); setValuesOfPalette(); + setInputBoxStyle(); } -void IntelliInputDialog::Input(){ - QDialog* Dialog = new QDialog(); - QGridLayout* Layout = new QGridLayout(); - QDialogButtonBox* ButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); +void IntelliInputDialog::createInputBox(QString Title, QString Label, int value, int minValue, int maxValue, int step){ + this->Dialog = new QDialog(); + Dialog->setWindowFlags(Dialog->windowFlags() & ~Qt::WindowContextHelpButtonHint); + if(Title == nullptr){ + Dialog->setWindowTitle("Input Box"); + } + else{ + Dialog->setWindowTitle(Title); + } + Layout = new QGridLayout(); + ButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - QPushButton* Button = new QPushButton(); - Button->setFixedSize(Buttonsize); + InputLabel = new QLabel(); + if(Label == nullptr){ + InputLabel->setText("Width:"); + } + else{ + InputLabel->setText(Label); + } + InputLabel->setFixedSize(Linesize); - QPushButton* okButton = ButtonBox->button(QDialogButtonBox::Ok); + Input = new QSpinBox(); + Input->setFixedSize(Linesize); + Input->setRange(minValue,maxValue); + Input->setValue(value); + + okButton = ButtonBox->button(QDialogButtonBox::Ok); + okButton->setFixedSize(Buttonsize); okButton->setAutoDefault(false); okButton->setDefault(false); - QPushButton* cancelButton = ButtonBox->button(QDialogButtonBox::Cancel); + cancelButton = ButtonBox->button(QDialogButtonBox::Cancel); + cancelButton->setFixedSize(Buttonsize); cancelButton->setAutoDefault(false); cancelButton->setDefault(false); - Button->setPalette(Palette); + Layout->addWidget(InputLabel,1,1,1,1); + Layout->addWidget(Input,2,1,1,1); + Layout->addWidget(ButtonBox,3,1,1,1); + Dialog->setLayout(Layout); + Dialog->resize(172,94); + Dialog->show(); +} + +void IntelliInputDialog::createConnections(QEventLoop* Loop){ + connect(okButton, SIGNAL(clicked()), this, SLOT(slotEingabe(Speicher))); + connect(okButton, SIGNAL(clicked()), Loop, SLOT(quit())); + connect(cancelButton, SIGNAL(clicked()), this, SLOT(slotCloseEvent())); + connect(cancelButton, SIGNAL(clicked()), Loop, SLOT(quit())); +} + +void IntelliInputDialog::setInputBoxStyle(){ + InputLabel->setPalette(Palette); + Input->setPalette(Palette); okButton->setPalette(Palette); cancelButton->setPalette(Palette); - - Layout->addWidget(Button); - Layout->addWidget(ButtonBox); - Dialog->setLayout(Layout); Dialog->setStyleSheet("background-color:rgb(64,64,64)"); - connect(okButton, SIGNAL(clicked()),Dialog,SLOT(slotCloseEvent())); } void IntelliInputDialog::setValuesOfPalette(){ @@ -43,3 +79,21 @@ void IntelliInputDialog::setValuesOfPalette(){ Palette.setBrush(QPalette::ToolTipText, QColor(255, 255, 255)); Palette.setBrush(QPalette::Text, QColor(255, 255, 255)); } + +void IntelliInputDialog::slotCloseEvent(){ + Dialog->close(); +} + +void IntelliInputDialog::slotEingabe(Speichereinheit &Speicher){ + qDebug() << Input->value(); + SetValueToGUI(); + Dialog->close(); +} + +void IntelliInputDialog::SetValueToGUI(){ + Input->value(); +} + +void IntelliInputDialog::getIntInput(Speichereinheit &Speicher, QEventLoop* Loop, IntelliInputDialog* Dialog, QString Title, QString Label, int value, int minValue, int maxValue, int step){ + this->Dialog = new IntelliInputDialog(Speicher, Loop, Dialog, Title, Label, value, minValue, maxValue, step); +} diff --git a/src/GUI/IntelliInputDialog.h b/src/GUI/IntelliInputDialog.h index 49af2b5..bcc9a12 100644 --- a/src/GUI/IntelliInputDialog.h +++ b/src/GUI/IntelliInputDialog.h @@ -2,24 +2,45 @@ #define INTELLIINPUTDIALOG_H #include - +#include #include "IntelliPhotoGui.h" -class IntelliInputDialog +class Speichereinheit{ + int value; +}; + +class IntelliInputDialog : public QDialog { +Q_OBJECT public: - IntelliInputDialog(); + IntelliInputDialog(Speichereinheit &Speicher, QEventLoop* Loop = nullptr, IntelliInputDialog* Dialog = nullptr, QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); - void Input(); + void getIntInput(Speichereinheit &Speicher, QEventLoop* Loop = nullptr, IntelliInputDialog* Dialog = nullptr, QString Title = "InputBox", QString Label = "Weight:", int value = 0, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); -private slots: +public slots: void slotCloseEvent(); + void slotEingabe(Speichereinheit &Speicher); private: - IntelliPhotoGui* DummyGui; - const QSize Buttonsize = QSize(35,35); - QPalette Palette; + void createInputBox(QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); + void createConnections(QEventLoop* Loop = nullptr); void setValuesOfPalette(); + void setInputBoxStyle(); + + void SetValueToGUI(); + + QDialog* Dialog; + + QGridLayout* Layout; + QDialogButtonBox* ButtonBox; + + const QSize Linesize = QSize(150,20); + const QSize Buttonsize = QSize(72,20); + QPalette Palette; + QLabel* InputLabel; + QSpinBox* Input; + QPushButton* okButton; + QPushButton* cancelButton; }; #endif // INTELLIINPUTDIALOG_H diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 9f3b4b4..7297c47 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -4,7 +4,8 @@ #include "Layer/PaintingArea.h" // IntelliPhotoGui constructor -IntelliPhotoGui::IntelliPhotoGui(){ +IntelliPhotoGui::IntelliPhotoGui(IntelliInputDialog* InputDialog){ + //this->InputDialog = InputDialog; // create Gui elements and lay them out createGui(); // Create actions @@ -15,7 +16,7 @@ IntelliPhotoGui::IntelliPhotoGui(){ setIntelliStyle(); // Size the app resize(600,600); - showMaximized(); + //showMaximized(); setDefaultToolValue(); } @@ -68,25 +69,22 @@ void IntelliPhotoGui::slotSave(){ // Opens a dialog that allows the user to create a New Layer void IntelliPhotoGui::slotCreateNewLayer(){ // Stores button value - bool ok1, ok2; // "New Layer" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button + Speichereinheit Speicher; + this->InputDialog->getIntInput(Speicher, &Loop, this->InputDialog, "New Layer", "Width:", 5, 0, 5000, 1); + int width = returnValueOfInputDialog; - /*int width = QInputDialog::getInt(this, tr("New Layer"), - tr("Width:"), - 200,1, 500, 1, &ok1); + qDebug() << width; + + int height = 25;//QInputDialog::getInt(this, tr("New Layer"),tr("Height:"),200,1, 500, 1, &ok2); - int height = QInputDialog::getInt(this, tr("New Layer"), - tr("Height:"), - 200,1, 500, 1, &ok2); // Create New Layer - if (ok1&&ok2){ - paintingArea->addLayer(width,height,0,0); - UpdateGui(); - }*/ + paintingArea->addLayer(width,height,0,0); + UpdateGui(); } // Opens a dialog that allows the user to delete a Layer @@ -496,7 +494,6 @@ void IntelliPhotoGui::createMenus(){ foreach (QAction *action, actionSaveAs) saveAsMenu->addAction(action); - // Attach all actions to File fileMenu = new QMenu(tr("&File"), this); fileMenu->addAction(actionOpen); diff --git a/src/GUI/IntelliPhotoGui.h b/src/GUI/IntelliPhotoGui.h index 55920ff..27909ee 100644 --- a/src/GUI/IntelliPhotoGui.h +++ b/src/GUI/IntelliPhotoGui.h @@ -11,6 +11,9 @@ #include #include +#include "IntelliInputDialog.h" + + // PaintingArea used to paint the image class PaintingArea; @@ -30,11 +33,12 @@ public: /*! * \brief The IntelliPhotoGui method is the constructor and is used to create a new instance of the main program window */ -IntelliPhotoGui(); +IntelliPhotoGui(IntelliInputDialog* InputDialog); void UpdateGui(); void setToolWidth(int value); +int returnValueOfInputDialog = 5; protected: // Function used to close an event @@ -104,6 +108,8 @@ void setDefaultToolValue(); // What we'll draw on PaintingArea* paintingArea; +IntelliInputDialog* InputDialog; +QEventLoop Loop; const QSize Buttonsize = QSize(35,35); QPixmap preview; diff --git a/src/main.cpp b/src/main.cpp index 30adab2..d6a8dd3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,5 @@ #include "GUI/IntelliPhotoGui.h" +#include "GUI/IntelliInputDialog.h" #include #include #include @@ -7,9 +8,11 @@ int main(int argc, char*argv[]){ // The main application QApplication app(argc, argv); + IntelliInputDialog* InputDialog; + // Create and open the main window - IntelliPhotoGui window; - window.show(); + IntelliPhotoGui window(InputDialog); + window.show(); return app.exec(); } From cc56f61247ad67709cf376022752d6f9fcedbacb Mon Sep 17 00:00:00 2001 From: Conrad Date: Mon, 13 Jan 2020 19:37:22 +0100 Subject: [PATCH 05/12] Uncrustifyed Status --- src/GUI/IntelliInputDialog.cpp | 130 +++--- src/GUI/IntelliInputDialog.h | 42 +- src/GUI/IntelliPhotoGui.cpp | 414 ++++++++++---------- src/Image/IntelliImage.cpp | 136 +++---- src/Image/IntelliRasterImage.cpp | 18 +- src/Image/IntelliShapedImage.cpp | 36 +- src/IntelliHelper/IntelliRenderSettings.cpp | 4 +- src/Layer/PaintingArea.cpp | 62 +-- src/Layer/PaintingArea.h | 250 ++++++------ src/Tool/IntelliTool.cpp | 36 +- src/Tool/IntelliToolCircle.cpp | 14 +- src/Tool/IntelliToolLine.cpp | 2 +- src/Tool/IntelliToolRectangle.cpp | 4 +- src/main.cpp | 6 +- 14 files changed, 577 insertions(+), 577 deletions(-) diff --git a/src/GUI/IntelliInputDialog.cpp b/src/GUI/IntelliInputDialog.cpp index 7afa6b1..e62b091 100644 --- a/src/GUI/IntelliInputDialog.cpp +++ b/src/GUI/IntelliInputDialog.cpp @@ -2,98 +2,98 @@ IntelliInputDialog::IntelliInputDialog(Speichereinheit &Speicher, QEventLoop* Loop, IntelliInputDialog* Dialog, QString Title, QString Label, int value, int minValue, int maxValue, int step) { - this->Dialog = Dialog; - createInputBox(Title, Label, value, minValue, maxValue, step); - createConnections(Loop); - setValuesOfPalette(); - setInputBoxStyle(); + this->Dialog = Dialog; + createInputBox(Title, Label, value, minValue, maxValue, step); + createConnections(Loop); + setValuesOfPalette(); + setInputBoxStyle(); } void IntelliInputDialog::createInputBox(QString Title, QString Label, int value, int minValue, int maxValue, int step){ - this->Dialog = new QDialog(); - Dialog->setWindowFlags(Dialog->windowFlags() & ~Qt::WindowContextHelpButtonHint); - if(Title == nullptr){ - Dialog->setWindowTitle("Input Box"); - } - else{ - Dialog->setWindowTitle(Title); - } - Layout = new QGridLayout(); - ButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + this->Dialog = new QDialog(); + Dialog->setWindowFlags(Dialog->windowFlags() & ~Qt::WindowContextHelpButtonHint); + if(Title == nullptr) { + Dialog->setWindowTitle("Input Box"); + } + else{ + Dialog->setWindowTitle(Title); + } + Layout = new QGridLayout(); + ButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - InputLabel = new QLabel(); - if(Label == nullptr){ - InputLabel->setText("Width:"); - } - else{ - InputLabel->setText(Label); - } - InputLabel->setFixedSize(Linesize); + InputLabel = new QLabel(); + if(Label == nullptr) { + InputLabel->setText("Width:"); + } + else{ + InputLabel->setText(Label); + } + InputLabel->setFixedSize(Linesize); - Input = new QSpinBox(); - Input->setFixedSize(Linesize); - Input->setRange(minValue,maxValue); - Input->setValue(value); + Input = new QSpinBox(); + Input->setFixedSize(Linesize); + Input->setRange(minValue,maxValue); + Input->setValue(value); - okButton = ButtonBox->button(QDialogButtonBox::Ok); - okButton->setFixedSize(Buttonsize); - okButton->setAutoDefault(false); - okButton->setDefault(false); + okButton = ButtonBox->button(QDialogButtonBox::Ok); + okButton->setFixedSize(Buttonsize); + okButton->setAutoDefault(false); + okButton->setDefault(false); - cancelButton = ButtonBox->button(QDialogButtonBox::Cancel); - cancelButton->setFixedSize(Buttonsize); - cancelButton->setAutoDefault(false); - cancelButton->setDefault(false); + cancelButton = ButtonBox->button(QDialogButtonBox::Cancel); + cancelButton->setFixedSize(Buttonsize); + cancelButton->setAutoDefault(false); + cancelButton->setDefault(false); - Layout->addWidget(InputLabel,1,1,1,1); - Layout->addWidget(Input,2,1,1,1); - Layout->addWidget(ButtonBox,3,1,1,1); - Dialog->setLayout(Layout); - Dialog->resize(172,94); - Dialog->show(); + Layout->addWidget(InputLabel,1,1,1,1); + Layout->addWidget(Input,2,1,1,1); + Layout->addWidget(ButtonBox,3,1,1,1); + Dialog->setLayout(Layout); + Dialog->resize(172,94); + Dialog->show(); } void IntelliInputDialog::createConnections(QEventLoop* Loop){ - connect(okButton, SIGNAL(clicked()), this, SLOT(slotEingabe(Speicher))); - connect(okButton, SIGNAL(clicked()), Loop, SLOT(quit())); - connect(cancelButton, SIGNAL(clicked()), this, SLOT(slotCloseEvent())); - connect(cancelButton, SIGNAL(clicked()), Loop, SLOT(quit())); + connect(okButton, SIGNAL(clicked()), this, SLOT(slotEingabe(Speicher))); + connect(okButton, SIGNAL(clicked()), Loop, SLOT(quit())); + connect(cancelButton, SIGNAL(clicked()), this, SLOT(slotCloseEvent())); + connect(cancelButton, SIGNAL(clicked()), Loop, SLOT(quit())); } void IntelliInputDialog::setInputBoxStyle(){ - InputLabel->setPalette(Palette); - Input->setPalette(Palette); - okButton->setPalette(Palette); - cancelButton->setPalette(Palette); - Dialog->setStyleSheet("background-color:rgb(64,64,64)"); + InputLabel->setPalette(Palette); + Input->setPalette(Palette); + okButton->setPalette(Palette); + cancelButton->setPalette(Palette); + Dialog->setStyleSheet("background-color:rgb(64,64,64)"); } void IntelliInputDialog::setValuesOfPalette(){ - Palette.setBrush(QPalette::HighlightedText, QColor(200, 10, 10)); - Palette.setBrush(QPalette::Highlight, QColor(100, 5, 5)); - Palette.setBrush(QPalette::ButtonText, QColor(255, 255, 255)); - Palette.setBrush(QPalette::Button, QColor(64, 64, 64)); - Palette.setBrush(QPalette::Window, QColor(64, 64, 64)); - Palette.setBrush(QPalette::WindowText, QColor(255, 255, 255)); - Palette.setBrush(QPalette::PlaceholderText, QColor(255, 255, 255)); - Palette.setBrush(QPalette::ToolTipText, QColor(255, 255, 255)); - Palette.setBrush(QPalette::Text, QColor(255, 255, 255)); + Palette.setBrush(QPalette::HighlightedText, QColor(200, 10, 10)); + Palette.setBrush(QPalette::Highlight, QColor(100, 5, 5)); + Palette.setBrush(QPalette::ButtonText, QColor(255, 255, 255)); + Palette.setBrush(QPalette::Button, QColor(64, 64, 64)); + Palette.setBrush(QPalette::Window, QColor(64, 64, 64)); + Palette.setBrush(QPalette::WindowText, QColor(255, 255, 255)); + Palette.setBrush(QPalette::PlaceholderText, QColor(255, 255, 255)); + Palette.setBrush(QPalette::ToolTipText, QColor(255, 255, 255)); + Palette.setBrush(QPalette::Text, QColor(255, 255, 255)); } void IntelliInputDialog::slotCloseEvent(){ - Dialog->close(); + Dialog->close(); } void IntelliInputDialog::slotEingabe(Speichereinheit &Speicher){ - qDebug() << Input->value(); - SetValueToGUI(); - Dialog->close(); + qDebug() << Input->value(); + SetValueToGUI(); + Dialog->close(); } void IntelliInputDialog::SetValueToGUI(){ - Input->value(); + Input->value(); } void IntelliInputDialog::getIntInput(Speichereinheit &Speicher, QEventLoop* Loop, IntelliInputDialog* Dialog, QString Title, QString Label, int value, int minValue, int maxValue, int step){ - this->Dialog = new IntelliInputDialog(Speicher, Loop, Dialog, Title, Label, value, minValue, maxValue, step); + this->Dialog = new IntelliInputDialog(Speicher, Loop, Dialog, Title, Label, value, minValue, maxValue, step); } diff --git a/src/GUI/IntelliInputDialog.h b/src/GUI/IntelliInputDialog.h index bcc9a12..c78f63b 100644 --- a/src/GUI/IntelliInputDialog.h +++ b/src/GUI/IntelliInputDialog.h @@ -5,42 +5,42 @@ #include #include "IntelliPhotoGui.h" -class Speichereinheit{ - int value; +class Speichereinheit { +int value; }; class IntelliInputDialog : public QDialog { Q_OBJECT public: - IntelliInputDialog(Speichereinheit &Speicher, QEventLoop* Loop = nullptr, IntelliInputDialog* Dialog = nullptr, QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); +IntelliInputDialog(Speichereinheit &Speicher, QEventLoop* Loop = nullptr, IntelliInputDialog* Dialog = nullptr, QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); - void getIntInput(Speichereinheit &Speicher, QEventLoop* Loop = nullptr, IntelliInputDialog* Dialog = nullptr, QString Title = "InputBox", QString Label = "Weight:", int value = 0, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); +void getIntInput(Speichereinheit &Speicher, QEventLoop* Loop = nullptr, IntelliInputDialog* Dialog = nullptr, QString Title = "InputBox", QString Label = "Weight:", int value = 0, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); public slots: - void slotCloseEvent(); - void slotEingabe(Speichereinheit &Speicher); +void slotCloseEvent(); +void slotEingabe(Speichereinheit &Speicher); private: - void createInputBox(QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); - void createConnections(QEventLoop* Loop = nullptr); - void setValuesOfPalette(); - void setInputBoxStyle(); +void createInputBox(QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); +void createConnections(QEventLoop* Loop = nullptr); +void setValuesOfPalette(); +void setInputBoxStyle(); - void SetValueToGUI(); +void SetValueToGUI(); - QDialog* Dialog; +QDialog* Dialog; - QGridLayout* Layout; - QDialogButtonBox* ButtonBox; +QGridLayout* Layout; +QDialogButtonBox* ButtonBox; - const QSize Linesize = QSize(150,20); - const QSize Buttonsize = QSize(72,20); - QPalette Palette; - QLabel* InputLabel; - QSpinBox* Input; - QPushButton* okButton; - QPushButton* cancelButton; +const QSize Linesize = QSize(150,20); +const QSize Buttonsize = QSize(72,20); +QPalette Palette; +QLabel* InputLabel; +QSpinBox* Input; +QPushButton* okButton; +QPushButton* cancelButton; }; #endif // INTELLIINPUTDIALOG_H diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 7297c47..88b0a4f 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -5,7 +5,7 @@ // IntelliPhotoGui constructor IntelliPhotoGui::IntelliPhotoGui(IntelliInputDialog* InputDialog){ - //this->InputDialog = InputDialog; + //this->InputDialog = InputDialog; // create Gui elements and lay them out createGui(); // Create actions @@ -13,11 +13,11 @@ IntelliPhotoGui::IntelliPhotoGui(IntelliInputDialog* InputDialog){ // create Menus createMenus(); // set style of the gui - setIntelliStyle(); - // Size the app - resize(600,600); - //showMaximized(); - setDefaultToolValue(); + setIntelliStyle(); + // Size the app + resize(600,600); + //showMaximized(); + setDefaultToolValue(); } // User tried to close the app @@ -47,10 +47,10 @@ void IntelliPhotoGui::slotOpen(){ // If we have a file name load the image and place // it in the paintingArea - if (!fileName.isEmpty()){ + if (!fileName.isEmpty()) { paintingArea->open(fileName); - UpdateGui(); - } + UpdateGui(); + } } } @@ -73,18 +73,18 @@ void IntelliPhotoGui::slotCreateNewLayer(){ // "New Layer" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button - Speichereinheit Speicher; - this->InputDialog->getIntInput(Speicher, &Loop, this->InputDialog, "New Layer", "Width:", 5, 0, 5000, 1); + Speichereinheit Speicher; + this->InputDialog->getIntInput(Speicher, &Loop, this->InputDialog, "New Layer", "Width:", 5, 0, 5000, 1); - int width = returnValueOfInputDialog; + int width = returnValueOfInputDialog; - qDebug() << width; + qDebug() << width; - int height = 25;//QInputDialog::getInt(this, tr("New Layer"),tr("Height:"),200,1, 500, 1, &ok2); + int height = 25;//QInputDialog::getInt(this, tr("New Layer"),tr("Height:"),200,1, 500, 1, &ok2); // Create New Layer - paintingArea->addLayer(width,height,0,0); - UpdateGui(); + paintingArea->addLayer(width,height,0,0); + UpdateGui(); } // Opens a dialog that allows the user to delete a Layer @@ -97,10 +97,10 @@ void IntelliPhotoGui::slotDeleteLayer(){ // Define the standard Value, min, max, step and ok button int layerNumber = QInputDialog::getInt(this, tr("delete Layer"), tr("Number:"), - paintingArea->getNumberOfActiveLayer()+1,1, 501, 1, &ok); + paintingArea->getNumberOfActiveLayer()+1,1, 501, 1, &ok); // Create New Layer if (ok) { - paintingArea->deleteLayer(layerNumber-1); + paintingArea->deleteLayer(layerNumber-1); UpdateGui(); } } @@ -114,14 +114,14 @@ void IntelliPhotoGui::slotSetActiveAlpha(){ // Define the standard Value, min, max, step and ok button int layer = QInputDialog::getInt(this, tr("Layer to set on"), tr("Layer:"), - 1,1,500,1, &ok1); + 1,1,500,1, &ok1); // "New Alpha" is the title of the window int alpha = QInputDialog::getInt(this, tr("New Alpha"), tr("Alpha:"), 255,0, 255, 1, &ok2); if (ok1&&ok2) { - paintingArea->setLayerAlpha(layer-1,alpha); + paintingArea->setLayerAlpha(layer-1,alpha); UpdateGui(); } } @@ -194,22 +194,22 @@ void IntelliPhotoGui::slotSetActiveLayer(){ // Define the standard Value, min, max, step and ok button int layer = QInputDialog::getInt(this, tr("Layer to set on"), tr("Layer:"), - 1,1,500,1, &ok1); + 1,1,500,1, &ok1); if (ok1) { - paintingArea->setLayerActive(layer-1); + paintingArea->setLayerActive(layer-1); UpdateGui(); } } void IntelliPhotoGui::slotUpdateRenderSettingsOn(){ - paintingArea->setRenderSettings(true); - UpdateGui(); + paintingArea->setRenderSettings(true); + UpdateGui(); } void IntelliPhotoGui::slotUpdateRenderSettingsOff(){ - paintingArea->setRenderSettings(false); - UpdateGui(); + paintingArea->setRenderSettings(false); + UpdateGui(); } void IntelliPhotoGui::slotSetFirstColor(){ @@ -266,7 +266,7 @@ void IntelliPhotoGui::slotCreateFloodFillTool(){ void IntelliPhotoGui::slotAboutDialog(){ // Window title and text to display QMessageBox::about(this, tr("About Painting"), - tr("

IntelliPhoto - A Pretty basic editor.


Developed by Team 7.")); + tr("

IntelliPhoto - A Pretty basic editor.


Developed by Team 7.")); } void IntelliPhotoGui::slotEnterPressed(){ @@ -293,13 +293,13 @@ void IntelliPhotoGui::slotResetTools(){ } void IntelliPhotoGui::slotSetWidth(){ - paintingArea->Toolsettings.setLineWidth(); - EditLineWidth->setText(QString("%1").arg(paintingArea->Toolsettings.getLineWidth())); + paintingArea->Toolsettings.setLineWidth(); + EditLineWidth->setText(QString("%1").arg(paintingArea->Toolsettings.getLineWidth())); } void IntelliPhotoGui::slotSetInnerAlpha(){ - paintingArea->Toolsettings.setInnerAlpha(); - EditLineInnerAlpha->setText(QString("%1").arg(paintingArea->Toolsettings.getInnerAlpha())); + paintingArea->Toolsettings.setInnerAlpha(); + EditLineInnerAlpha->setText(QString("%1").arg(paintingArea->Toolsettings.getInnerAlpha())); } // Define menu actions that call functions @@ -329,7 +329,7 @@ void IntelliPhotoGui::createActions(){ connect(pngSaveAction, SIGNAL(triggered()), this, SLOT(slotSave())); // Attach each PNG in save Menu actionSaveAs.append(pngSaveAction); - pngSaveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S)); + pngSaveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S)); // Create exit action and tie to IntelliPhotoGui::close() actionExit = new QAction(tr("&Exit"), this); @@ -347,15 +347,15 @@ void IntelliPhotoGui::createActions(){ // Delete New Layer action and tie to IntelliPhotoGui::deleteLayer() actionDeleteLayer = new QAction(tr("&Delete Layer..."), this); - actionDeleteLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_D)); + actionDeleteLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_D)); connect(actionDeleteLayer, SIGNAL(triggered()), this, SLOT(slotDeleteLayer())); actionSetActiveLayer = new QAction(tr("&set Active"), this); - actionSetActiveLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_A)); + actionSetActiveLayer->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_A)); connect(actionSetActiveLayer, SIGNAL(triggered()), this, SLOT(slotSetActiveLayer())); - actionSetActiveAlpha = new QAction(tr("&set Alpha"), this); - actionSetActiveAlpha->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_A)); + actionSetActiveAlpha = new QAction(tr("&set Alpha"), this); + actionSetActiveAlpha->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_A)); connect(actionSetActiveAlpha, SIGNAL(triggered()), this, SLOT(slotSetActiveAlpha())); actionMovePositionUp = new QAction(tr("&move Up"), this); @@ -382,76 +382,76 @@ void IntelliPhotoGui::createActions(){ actionMoveLayerDown->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Down)); connect(actionMoveLayerDown, SIGNAL(triggered()), this, SLOT(slotMoveLayerDown())); - //Create Update RenderSettings Actions here - actionUpdateRenderSettingsOn = new QAction(tr("&On"), this); - actionUpdateRenderSettingsOn->setShortcut(QKeySequence(Qt::ALT +Qt::SHIFT + +Qt::Key_A)); - connect(actionUpdateRenderSettingsOn, SIGNAL(triggered()),this, SLOT(slotUpdateRenderSettingsOn())); + //Create Update RenderSettings Actions here + actionUpdateRenderSettingsOn = new QAction(tr("&On"), this); + actionUpdateRenderSettingsOn->setShortcut(QKeySequence(Qt::ALT +Qt::SHIFT + +Qt::Key_A)); + connect(actionUpdateRenderSettingsOn, SIGNAL(triggered()),this, SLOT(slotUpdateRenderSettingsOn())); - actionUpdateRenderSettingsOff = new QAction(tr("&Off"), this); - actionUpdateRenderSettingsOff->setShortcut(QKeySequence(Qt::ALT +Qt::SHIFT + +Qt::Key_D)); - connect(actionUpdateRenderSettingsOff, SIGNAL(triggered()),this, SLOT(slotUpdateRenderSettingsOff())); + actionUpdateRenderSettingsOff = new QAction(tr("&Off"), this); + actionUpdateRenderSettingsOff->setShortcut(QKeySequence(Qt::ALT +Qt::SHIFT + +Qt::Key_D)); + connect(actionUpdateRenderSettingsOff, SIGNAL(triggered()),this, SLOT(slotUpdateRenderSettingsOff())); //Create Color Actions here actionColorPickerFirstColor = new QAction(tr("&Main"), this); - actionColorPickerFirstColor->setShortcut(QKeySequence(Qt::ALT + Qt::Key_N)); + actionColorPickerFirstColor->setShortcut(QKeySequence(Qt::ALT + Qt::Key_N)); connect(actionColorPickerFirstColor, SIGNAL(triggered()), this, SLOT(slotSetFirstColor())); connect(FirstColorButton, SIGNAL(clicked()), this, SLOT(slotSetFirstColor())); actionColorPickerSecondColor = new QAction(tr("&Secondary"), this); - actionColorPickerSecondColor->setShortcut(QKeySequence(Qt::ALT + Qt::Key_M)); + actionColorPickerSecondColor->setShortcut(QKeySequence(Qt::ALT + Qt::Key_M)); connect(actionColorPickerSecondColor, SIGNAL(triggered()), this, SLOT(slotSetSecondColor())); connect(SecondColorButton, SIGNAL(clicked()), this, SLOT(slotSetSecondColor())); actionColorSwap = new QAction(tr("&Switch"), this); - actionColorSwap->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_S)); + actionColorSwap->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_S)); connect(actionColorSwap, SIGNAL(triggered()), this, SLOT(slotSwapColor())); connect(SwitchColorButton, SIGNAL(clicked()), this, SLOT(slotSwapColor())); //Create Tool actions down here actionCreatePlainTool = new QAction(tr("&Plain"), this); - actionCreatePlainTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_P)); + actionCreatePlainTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_P)); connect(actionCreatePlainTool, SIGNAL(triggered()), this, SLOT(slotResetTools())); connect(actionCreatePlainTool, SIGNAL(triggered()), this, SLOT(slotCreatePlainTool())); actionCreatePenTool = new QAction(tr("&Pen"),this); - actionCreatePenTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_S)); + actionCreatePenTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_S)); connect(actionCreatePenTool, SIGNAL(triggered()), this, SLOT(slotResetTools())); connect(actionCreatePenTool, SIGNAL(triggered()), this, SLOT(slotCreatePenTool())); actionCreateLineTool = new QAction(tr("&Line"), this); - actionCreateLineTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_L)); + actionCreateLineTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_L)); connect(actionCreateLineTool, SIGNAL(triggered()), this, SLOT(slotResetTools())); connect(actionCreateLineTool, SIGNAL(triggered()), this, SLOT(slotCreateLineTool())); actionCreateCircleTool = new QAction(tr("&Circle"), this); - actionCreateCircleTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_C)); + actionCreateCircleTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_C)); connect(actionCreateCircleTool, SIGNAL(triggered()), this, SLOT(slotResetTools())); connect(actionCreateCircleTool, SIGNAL(triggered()), this, SLOT(slotCreateCircleTool())); actionCreateRectangleTool = new QAction(tr("&Rectangle"), this); - actionCreateRectangleTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_R)); + actionCreateRectangleTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_R)); connect(actionCreateRectangleTool, SIGNAL(triggered()), this, SLOT(slotResetTools())); connect(actionCreateRectangleTool, SIGNAL(triggered()), this, SLOT(slotCreateRectangleTool())); actionCreatePolygonTool = new QAction(tr("&Polygon"), this); - actionCreatePolygonTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_V)); + actionCreatePolygonTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_V)); connect(actionCreatePolygonTool, SIGNAL(triggered()), this, SLOT(slotResetTools())); connect(actionCreatePolygonTool, SIGNAL(triggered()), this, SLOT(slotCreatePolygonTool())); actionCreateFloodFillTool = new QAction(tr("&FloodFill"), this); - actionCreateFloodFillTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_F)); + actionCreateFloodFillTool->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::SHIFT +Qt::Key_F)); connect(actionCreateFloodFillTool, SIGNAL(triggered()), this, SLOT(slotResetTools())); connect(actionCreateFloodFillTool, SIGNAL(triggered()), this, SLOT(slotCreateFloodFillTool())); // Create about action and tie to IntelliPhotoGui::about() actionAboutDialog = new QAction(tr("&About"), this); - actionAboutDialog->setShortcut(Qt::Key_F2); + actionAboutDialog->setShortcut(Qt::Key_F2); connect(actionAboutDialog, SIGNAL(triggered()), this, SLOT(slotAboutDialog())); // Create about Qt action and tie to IntelliPhotoGui::aboutQt() actionAboutQtDialog = new QAction(tr("About &Qt"), this); - actionAboutQtDialog->setShortcut(Qt::Key_F3); + actionAboutQtDialog->setShortcut(Qt::Key_F3); connect(actionAboutQtDialog, SIGNAL(triggered()), qApp, SLOT(aboutQt())); connect(EditLineWidth, SIGNAL(returnPressed()), this, SLOT(slotEnterPressed())); @@ -478,13 +478,13 @@ void IntelliPhotoGui::createActions(){ connect(RectangleButton,SIGNAL(pressed()), this, SLOT(slotResetTools())); connect(RectangleButton, SIGNAL(clicked()), this, SLOT(slotCreateRectangleTool())); - actionSetWidth = new QAction(tr("&Set Width"),this); - actionSetWidth->setShortcut(QKeySequence(Qt::ALT + Qt::Key_W)); - connect(actionSetWidth, SIGNAL(triggered()), this, SLOT(slotSetWidth())); + actionSetWidth = new QAction(tr("&Set Width"),this); + actionSetWidth->setShortcut(QKeySequence(Qt::ALT + Qt::Key_W)); + connect(actionSetWidth, SIGNAL(triggered()), this, SLOT(slotSetWidth())); - actionSetInnerAlpha = new QAction(tr("&Set Inner Alpha"),this); - actionSetInnerAlpha->setShortcut(QKeySequence(Qt::ALT + Qt::Key_A)); - connect(actionSetInnerAlpha, SIGNAL(triggered()), this, SLOT(slotSetInnerAlpha())); + actionSetInnerAlpha = new QAction(tr("&Set Inner Alpha"),this); + actionSetInnerAlpha->setShortcut(QKeySequence(Qt::ALT + Qt::Key_A)); + connect(actionSetInnerAlpha, SIGNAL(triggered()), this, SLOT(slotSetInnerAlpha())); } // Create the menubar @@ -501,61 +501,61 @@ void IntelliPhotoGui::createMenus(){ fileMenu->addSeparator(); fileMenu->addAction(actionExit); - //Attach all actions to Render Settings - renderMenu = new QMenu(tr("&Fast Renderer"), this); - renderMenu->addAction(actionUpdateRenderSettingsOn); - renderMenu->addAction(actionUpdateRenderSettingsOff); + //Attach all actions to Render Settings + renderMenu = new QMenu(tr("&Fast Renderer"), this); + renderMenu->addAction(actionUpdateRenderSettingsOn); + renderMenu->addAction(actionUpdateRenderSettingsOff); - // Attach all actions to Layer - layerMenu = new QMenu(tr("&Layer"), this); - layerMenu->addAction(actionCreateNewLayer); - layerMenu->addSeparator(); - layerMenu->addAction(actionSetActiveAlpha); - layerMenu->addAction(actionSetActiveLayer); - layerMenu->addSeparator(); - layerMenu->addAction(actionMovePositionUp); - layerMenu->addAction(actionMovePositionDown); - layerMenu->addAction(actionMovePositionLeft); - layerMenu->addAction(actionMovePositionRight); - layerMenu->addAction(actionMoveLayerUp); - layerMenu->addAction(actionMoveLayerDown); - layerMenu->addSeparator(); - layerMenu->addAction(actionDeleteLayer); + // Attach all actions to Layer + layerMenu = new QMenu(tr("&Layer"), this); + layerMenu->addAction(actionCreateNewLayer); + layerMenu->addSeparator(); + layerMenu->addAction(actionSetActiveAlpha); + layerMenu->addAction(actionSetActiveLayer); + layerMenu->addSeparator(); + layerMenu->addAction(actionMovePositionUp); + layerMenu->addAction(actionMovePositionDown); + layerMenu->addAction(actionMovePositionLeft); + layerMenu->addAction(actionMovePositionRight); + layerMenu->addAction(actionMoveLayerUp); + layerMenu->addAction(actionMoveLayerDown); + layerMenu->addSeparator(); + layerMenu->addAction(actionDeleteLayer); - //Attach all Color Options - colorMenu = new QMenu(tr("&Color"), this); - colorMenu->addAction(actionColorPickerFirstColor); - colorMenu->addAction(actionColorPickerSecondColor); - colorMenu->addAction(actionColorSwap); + //Attach all Color Options + colorMenu = new QMenu(tr("&Color"), this); + colorMenu->addAction(actionColorPickerFirstColor); + colorMenu->addAction(actionColorPickerSecondColor); + colorMenu->addAction(actionColorSwap); - //Attach all Tool Creation Actions - toolCreationMenu = new QMenu(tr("&Drawingtools"), this); - toolCreationMenu->addAction(actionCreateCircleTool); - toolCreationMenu->addAction(actionCreateFloodFillTool); - toolCreationMenu->addAction(actionCreateLineTool); - toolCreationMenu->addAction(actionCreatePenTool); - toolCreationMenu->addAction(actionCreatePlainTool); - toolCreationMenu->addAction(actionCreatePolygonTool); - toolCreationMenu->addAction(actionCreateRectangleTool); + //Attach all Tool Creation Actions + toolCreationMenu = new QMenu(tr("&Drawingtools"), this); + toolCreationMenu->addAction(actionCreateCircleTool); + toolCreationMenu->addAction(actionCreateFloodFillTool); + toolCreationMenu->addAction(actionCreateLineTool); + toolCreationMenu->addAction(actionCreatePenTool); + toolCreationMenu->addAction(actionCreatePlainTool); + toolCreationMenu->addAction(actionCreatePolygonTool); + toolCreationMenu->addAction(actionCreateRectangleTool); - //Attach all Tool Setting Actions - toolSettingsMenu = new QMenu(tr("&Toolsettings"), this); - toolSettingsMenu->addAction(actionSetWidth); - toolSettingsMenu->addAction(actionSetInnerAlpha); + //Attach all Tool Setting Actions + toolSettingsMenu = new QMenu(tr("&Toolsettings"), this); + toolSettingsMenu->addAction(actionSetWidth); + toolSettingsMenu->addAction(actionSetInnerAlpha); - //Attach all Tool Options - toolMenu = new QMenu(tr("&Tools"), this); - toolMenu->addMenu(toolCreationMenu); - toolMenu->addMenu(toolSettingsMenu); - toolMenu->addSeparator(); - toolMenu->addMenu(colorMenu); + //Attach all Tool Options + toolMenu = new QMenu(tr("&Tools"), this); + toolMenu->addMenu(toolCreationMenu); + toolMenu->addMenu(toolSettingsMenu); + toolMenu->addSeparator(); + toolMenu->addMenu(colorMenu); // Attach all actions to Options optionMenu = new QMenu(tr("&Options"), this); - optionMenu->addMenu(layerMenu); - optionMenu->addMenu(toolMenu); - optionMenu->addSeparator(); - optionMenu->addMenu(renderMenu); + optionMenu->addMenu(layerMenu); + optionMenu->addMenu(toolMenu); + optionMenu->addSeparator(); + optionMenu->addMenu(renderMenu); // Attach all actions to Help helpMenu = new QMenu(tr("&Help"), this); @@ -579,63 +579,63 @@ void IntelliPhotoGui::createGui(){ // create Gui elements paintingArea = new PaintingArea(); - paintingArea->DummyGui = this; + paintingArea->DummyGui = this; - preview = QPixmap(":/Icons/Buttons/icons/circle-tool.svg"); + preview = QPixmap(":/Icons/Buttons/icons/circle-tool.svg"); CircleButton = new QPushButton(); - CircleButton->setFixedSize(Buttonsize); - CircleButton->setIcon(preview); - CircleButton->setIconSize(Buttonsize); + CircleButton->setFixedSize(Buttonsize); + CircleButton->setIcon(preview); + CircleButton->setIconSize(Buttonsize); CircleButton->setCheckable(true); - preview = QPixmap(":/Icons/Buttons/icons/flood-fill-tool.svg"); + preview = QPixmap(":/Icons/Buttons/icons/flood-fill-tool.svg"); FloodFillButton = new QPushButton(); FloodFillButton->setFixedSize(Buttonsize); - FloodFillButton->setIcon(preview); + FloodFillButton->setIcon(preview); FloodFillButton->setIconSize(Buttonsize); FloodFillButton->setCheckable(true); - preview = QPixmap(":/Icons/Buttons/icons/line-tool.svg"); + preview = QPixmap(":/Icons/Buttons/icons/line-tool.svg"); LineButton = new QPushButton(); LineButton->setFixedSize(Buttonsize); - LineButton->setIcon(preview); + LineButton->setIcon(preview); LineButton->setIconSize(Buttonsize); LineButton->setCheckable(true); - preview = QPixmap(":/Icons/Buttons/icons/pen-tool.svg"); + preview = QPixmap(":/Icons/Buttons/icons/pen-tool.svg"); PenButton = new QPushButton(); PenButton->setFixedSize(Buttonsize); - PenButton->setIcon(preview); + PenButton->setIcon(preview); PenButton->setIconSize(Buttonsize); PenButton->setCheckable(true); - preview = QPixmap(":/Icons/Buttons/icons/plain-tool.svg"); + preview = QPixmap(":/Icons/Buttons/icons/plain-tool.svg"); PlainButton = new QPushButton(); PlainButton->setFixedSize(Buttonsize); - PlainButton->setIcon(preview); + PlainButton->setIcon(preview); PlainButton->setIconSize(Buttonsize); PlainButton->setCheckable(true); - preview = QPixmap(":/Icons/Buttons/icons/polygon-tool.svg"); + preview = QPixmap(":/Icons/Buttons/icons/polygon-tool.svg"); PolygonButton = new QPushButton(); PolygonButton->setFixedSize(Buttonsize); - PolygonButton->setIcon(preview); + PolygonButton->setIcon(preview); PolygonButton->setIconSize(Buttonsize); PolygonButton->setCheckable(true); - preview = QPixmap(":/Icons/Buttons/icons/rectangle-tool.svg"); + preview = QPixmap(":/Icons/Buttons/icons/rectangle-tool.svg"); RectangleButton = new QPushButton(); RectangleButton->setFixedSize(Buttonsize); - RectangleButton->setIcon(preview); + RectangleButton->setIcon(preview); RectangleButton->setIconSize(Buttonsize); RectangleButton->setCheckable(true); WidthLine = new QLabel(); WidthLine->setText("Width"); - WidthLine->setFixedSize(Buttonsize.width()*2,(Buttonsize.height()*2)/3); + WidthLine->setFixedSize(Buttonsize.width()*2,(Buttonsize.height()*2)/3); EditLineWidth = new QLineEdit(); - EditLineWidth->setFixedSize(Buttonsize.width()*2,(Buttonsize.height()*2)/3); + EditLineWidth->setFixedSize(Buttonsize.width()*2,(Buttonsize.height()*2)/3); EditLineWidth->setText("5"); ValidatorLineWidth = new QIntValidator(); ValidatorLineWidth->setTop(99); @@ -644,10 +644,10 @@ void IntelliPhotoGui::createGui(){ innerAlphaLine = new QLabel(); innerAlphaLine->setText("Inner Alpha"); - innerAlphaLine->setFixedSize(Buttonsize.width()*2,(Buttonsize.height()*2)/3); + innerAlphaLine->setFixedSize(Buttonsize.width()*2,(Buttonsize.height()*2)/3); EditLineInnerAlpha = new QLineEdit(); - EditLineInnerAlpha->setFixedSize(Buttonsize.width()*2,(Buttonsize.height()*2)/3); + EditLineInnerAlpha->setFixedSize(Buttonsize.width()*2,(Buttonsize.height()*2)/3); EditLineInnerAlpha->setText("255"); ValidatorInnerAlpha = new QIntValidator(); ValidatorInnerAlpha->setTop(999); @@ -655,87 +655,87 @@ void IntelliPhotoGui::createGui(){ EditLineInnerAlpha->setValidator(ValidatorInnerAlpha); FirstColorButton = new QPushButton(); - FirstColorButton->setFixedSize(Buttonsize); + FirstColorButton->setFixedSize(Buttonsize); SecondColorButton = new QPushButton(); - SecondColorButton->setFixedSize(Buttonsize); + SecondColorButton->setFixedSize(Buttonsize); - preview = QPixmap(":/Icons/Buttons/icons/Wechselpfeile.png"); + preview = QPixmap(":/Icons/Buttons/icons/Wechselpfeile.png"); SwitchColorButton = new QPushButton(); - SwitchColorButton->setFixedSize(Buttonsize.width()*2,Buttonsize.height()); - SwitchColorButton->setIcon(preview); - SwitchColorButton->setIconSize(QSize(Buttonsize.width()*2,Buttonsize.height())); + SwitchColorButton->setFixedSize(Buttonsize.width()*2,Buttonsize.height()); + SwitchColorButton->setIcon(preview); + SwitchColorButton->setIconSize(QSize(Buttonsize.width()*2,Buttonsize.height())); ActiveLayerLine = new QLabel(); - QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer() + 1); + QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer() + 1); ActiveLayerLine->setText(string); - ActiveLayerLine->setFixedSize(Buttonsize.width()*2+10,(Buttonsize.height()*2)/3); + ActiveLayerLine->setFixedSize(Buttonsize.width()*2+10,(Buttonsize.height()*2)/3); - IntelliImage* activePicture = paintingArea->getImageOfActiveLayer(); - if(activePicture){ - preview = preview.fromImage(activePicture->getImageData()); - }else{ - QImage tmp(1,1,QImage::Format_ARGB32); - tmp.fill(Qt::transparent); - preview = preview.fromImage(tmp); - } + IntelliImage* activePicture = paintingArea->getImageOfActiveLayer(); + if(activePicture) { + preview = preview.fromImage(activePicture->getImageData()); + }else{ + QImage tmp(1,1,QImage::Format_ARGB32); + tmp.fill(Qt::transparent); + preview = preview.fromImage(tmp); + } - ActiveLayerImageLabel = new QLabel(); - ActiveLayerImageLabel->setFixedSize(Buttonsize*2); - ActiveLayerImageLabel->setPixmap(preview.scaled(Buttonsize*2)); + ActiveLayerImageLabel = new QLabel(); + ActiveLayerImageLabel->setFixedSize(Buttonsize*2); + ActiveLayerImageLabel->setPixmap(preview.scaled(Buttonsize*2)); // set gui elements mainLayout->addWidget(paintingArea,1,1,20,1); - mainLayout->addWidget(CircleButton,1,2,1,1); - mainLayout->addWidget(FloodFillButton,1,3,1,1); - mainLayout->addWidget(LineButton,2,2,1,1); - mainLayout->addWidget(PenButton,2,3,1,1); - mainLayout->addWidget(PlainButton,3,2,1,1); - mainLayout->addWidget(PolygonButton,3,3,1,1); - mainLayout->addWidget(RectangleButton,4,2,1,1); - mainLayout->addWidget(WidthLine,5,2,1,2); - mainLayout->addWidget(EditLineWidth,6,2,1,2); - mainLayout->addWidget(innerAlphaLine,7,2,1,2); - mainLayout->addWidget(EditLineInnerAlpha,8,2,1,2); - mainLayout->addWidget(FirstColorButton,9,2,1,1); - mainLayout->addWidget(SecondColorButton,9,3,1,1); - mainLayout->addWidget(SwitchColorButton,10,2,1,2); - mainLayout->addWidget(ActiveLayerLine,11,2,1,2); - mainLayout->addWidget(ActiveLayerImageLabel,12,2,1,2); - mainLayout->setHorizontalSpacing(0); + mainLayout->addWidget(CircleButton,1,2,1,1); + mainLayout->addWidget(FloodFillButton,1,3,1,1); + mainLayout->addWidget(LineButton,2,2,1,1); + mainLayout->addWidget(PenButton,2,3,1,1); + mainLayout->addWidget(PlainButton,3,2,1,1); + mainLayout->addWidget(PolygonButton,3,3,1,1); + mainLayout->addWidget(RectangleButton,4,2,1,1); + mainLayout->addWidget(WidthLine,5,2,1,2); + mainLayout->addWidget(EditLineWidth,6,2,1,2); + mainLayout->addWidget(innerAlphaLine,7,2,1,2); + mainLayout->addWidget(EditLineInnerAlpha,8,2,1,2); + mainLayout->addWidget(FirstColorButton,9,2,1,1); + mainLayout->addWidget(SecondColorButton,9,3,1,1); + mainLayout->addWidget(SwitchColorButton,10,2,1,2); + mainLayout->addWidget(ActiveLayerLine,11,2,1,2); + mainLayout->addWidget(ActiveLayerImageLabel,12,2,1,2); + mainLayout->setHorizontalSpacing(0); } void IntelliPhotoGui::setIntelliStyle(){ // Set the title setWindowTitle("IntelliPhoto Prototype"); - Palette.setBrush(QPalette::HighlightedText, QColor(200, 10, 10)); - Palette.setBrush(QPalette::Highlight, QColor(100, 5, 5)); - Palette.setBrush(QPalette::ButtonText, QColor(255, 255, 255)); - Palette.setBrush(QPalette::Button, QColor(64, 64, 64)); - Palette.setBrush(QPalette::Window, QColor(64, 64, 64)); - Palette.setBrush(QPalette::WindowText, QColor(255, 255, 255)); - Palette.setBrush(QPalette::PlaceholderText, QColor(255, 255, 255)); - Palette.setBrush(QPalette::ToolTipText, QColor(255, 255, 255)); - Palette.setBrush(QPalette::Text, QColor(255, 255, 255)); + Palette.setBrush(QPalette::HighlightedText, QColor(200, 10, 10)); + Palette.setBrush(QPalette::Highlight, QColor(100, 5, 5)); + Palette.setBrush(QPalette::ButtonText, QColor(255, 255, 255)); + Palette.setBrush(QPalette::Button, QColor(64, 64, 64)); + Palette.setBrush(QPalette::Window, QColor(64, 64, 64)); + Palette.setBrush(QPalette::WindowText, QColor(255, 255, 255)); + Palette.setBrush(QPalette::PlaceholderText, QColor(255, 255, 255)); + Palette.setBrush(QPalette::ToolTipText, QColor(255, 255, 255)); + Palette.setBrush(QPalette::Text, QColor(255, 255, 255)); // Set style sheet - this->setStyleSheet("background-color:rgb(64,64,64)"); - this->menuBar()->setPalette(Palette); - this->fileMenu->setPalette(Palette); - this->saveAsMenu->setPalette(Palette); - this->optionMenu->setPalette(Palette); - this->helpMenu->setPalette(Palette); - this->renderMenu->setPalette(Palette); - this->toolMenu->setPalette(Palette); - this->layerMenu->setPalette(Palette); - this->colorMenu->setPalette(Palette); - this->toolCreationMenu->setPalette(Palette); - this->toolSettingsMenu->setPalette(Palette); + this->setStyleSheet("background-color:rgb(64,64,64)"); + this->menuBar()->setPalette(Palette); + this->fileMenu->setPalette(Palette); + this->saveAsMenu->setPalette(Palette); + this->optionMenu->setPalette(Palette); + this->helpMenu->setPalette(Palette); + this->renderMenu->setPalette(Palette); + this->toolMenu->setPalette(Palette); + this->layerMenu->setPalette(Palette); + this->colorMenu->setPalette(Palette); + this->toolCreationMenu->setPalette(Palette); + this->toolSettingsMenu->setPalette(Palette); - this->WidthLine->setPalette(Palette); - this->EditLineWidth->setPalette(Palette); - this->innerAlphaLine->setPalette(Palette); - this->EditLineInnerAlpha->setPalette(Palette); - this->ActiveLayerLine->setPalette(Palette); + this->WidthLine->setPalette(Palette); + this->EditLineWidth->setPalette(Palette); + this->innerAlphaLine->setPalette(Palette); + this->EditLineInnerAlpha->setPalette(Palette); + this->ActiveLayerLine->setPalette(Palette); QString string = QString("background-color: %1").arg(paintingArea->colorPicker.getFirstColor().name()); FirstColorButton->setStyleSheet(string); @@ -796,27 +796,27 @@ void IntelliPhotoGui::setDefaultToolValue(){ } void IntelliPhotoGui::setToolWidth(int value){ - if(value < 1){ - value = 1; - }else if(value > 50){ - value = 50; - } - EditLineWidth->setText(QString("%1").arg(value)); + if(value < 1) { + value = 1; + }else if(value > 50) { + value = 50; + } + EditLineWidth->setText(QString("%1").arg(value)); } void IntelliPhotoGui::UpdateGui(){ - QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer() + 1); + QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer() + 1); ActiveLayerLine->setText(string); - IntelliImage* activePicture = paintingArea->getImageOfActiveLayer(); - if(activePicture){ - preview = preview.fromImage(activePicture->getImageData()); - }else{ - QImage tmp(1,1,QImage::Format_ARGB32); - tmp.fill(Qt::transparent); - preview = preview.fromImage(tmp); - } - ActiveLayerImageLabel->setPixmap(preview.scaled(Buttonsize*2)); + IntelliImage* activePicture = paintingArea->getImageOfActiveLayer(); + if(activePicture) { + preview = preview.fromImage(activePicture->getImageData()); + }else{ + QImage tmp(1,1,QImage::Format_ARGB32); + tmp.fill(Qt::transparent); + preview = preview.fromImage(tmp); + } + ActiveLayerImageLabel->setPixmap(preview.scaled(Buttonsize*2)); string = QString("background-color: %1").arg(paintingArea->colorPicker.getFirstColor().name()); FirstColorButton->setStyleSheet(string); diff --git a/src/Image/IntelliImage.cpp b/src/Image/IntelliImage.cpp index 0fa97b2..aa12450 100644 --- a/src/Image/IntelliImage.cpp +++ b/src/Image/IntelliImage.cpp @@ -3,15 +3,15 @@ #include IntelliImage::IntelliImage(int width, int height, bool fastRendererOn) - : imageData(QSize(width, height), fastRendererOn ? QImage::Format_Indexed8 : QImage::Format_ARGB32){ - if(fastRendererOn){ - imageData = imageData.convertToFormat(QImage::Format_ARGB32); - } - imageData.fill(QColor(255,255,255,255)); - if(fastRendererOn){ - imageData = imageData.convertToFormat(QImage::Format_Indexed8); - } - this->fastRenderering = fastRendererOn; + : imageData(QSize(width, height), fastRendererOn ? QImage::Format_Indexed8 : QImage::Format_ARGB32){ + if(fastRendererOn) { + imageData = imageData.convertToFormat(QImage::Format_ARGB32); + } + imageData.fill(QColor(255,255,255,255)); + if(fastRendererOn) { + imageData = imageData.convertToFormat(QImage::Format_Indexed8); + } + this->fastRenderering = fastRendererOn; } @@ -30,7 +30,7 @@ bool IntelliImage::loadImage(const QString &filePath){ // scaled Image to size of Layer loadedImage = loadedImage.scaled(imageData.size(),Qt::IgnoreAspectRatio); - imageData = loadedImage.convertToFormat(fastRenderering ? QImage::Format_Indexed8 : QImage::Format_ARGB32); + imageData = loadedImage.convertToFormat(fastRenderering ? QImage::Format_Indexed8 : QImage::Format_ARGB32); return true; } @@ -46,19 +46,19 @@ void IntelliImage::resizeImage(QImage*image, const QSize &newSize){ // Draw the image QPainter painter(&newImage); painter.drawImage(QPoint(0, 0), *image); - if(fastRenderering){ - *image = newImage.convertToFormat(QImage::Format_Indexed8); - } - else{ - *image = newImage; - } + if(fastRenderering) { + *image = newImage.convertToFormat(QImage::Format_Indexed8); + } + else{ + *image = newImage; + } } void IntelliImage::drawPixel(const QPoint &p1, const QColor& color){ - if(fastRenderering){ - this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32); - } - // Used to draw on the widget + if(fastRenderering) { + this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32); + } + // Used to draw on the widget QPainter painter(&imageData); // Set the current settings for the pen @@ -66,32 +66,32 @@ void IntelliImage::drawPixel(const QPoint &p1, const QColor& color){ // Draw a line from the last registered point to the current painter.drawPoint(p1); - if(fastRenderering){ - this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8); - } + if(fastRenderering) { + this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8); + } } void IntelliImage::drawPoint(const QPoint &p1, const QColor& color, const int& penWidth){ - if(fastRenderering){ - this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32); - } - // Used to draw on the widget + if(fastRenderering) { + this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32); + } + // Used to draw on the widget QPainter painter(&imageData); // Set the current settings for the pen painter.setPen(QPen(color, penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); // Draw a line from the last registered point to the current painter.drawPoint(p1); - if(fastRenderering){ - this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8); - } + if(fastRenderering) { + this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8); + } } void IntelliImage::drawLine(const QPoint &p1, const QPoint& p2, const QColor& color, const int& penWidth){ - if(fastRenderering){ - this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32); - } - // Used to draw on the widget + if(fastRenderering) { + this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32); + } + // Used to draw on the widget QPainter painter(&imageData); // Set the current settings for the pen @@ -99,53 +99,53 @@ void IntelliImage::drawLine(const QPoint &p1, const QPoint& p2, const QColor& co // Draw a line from the last registered point to the current painter.drawLine(p1, p2); - if(fastRenderering){ - this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8); - } + if(fastRenderering) { + this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8); + } } void IntelliImage::drawPlain(const QColor& color){ - if(fastRenderering){ - this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32); - } - imageData.fill(color); - if(fastRenderering){ - this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8); - } + if(fastRenderering) { + this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32); + } + imageData.fill(color); + if(fastRenderering) { + this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8); + } } QColor IntelliImage::getPixelColor(QPoint& point){ - if(fastRenderering){ - QImage copy = this->imageData.convertToFormat(QImage::Format_ARGB32); - return copy.pixelColor(point); - } - return imageData.pixelColor(point); + if(fastRenderering) { + QImage copy = this->imageData.convertToFormat(QImage::Format_ARGB32); + return copy.pixelColor(point); + } + return imageData.pixelColor(point); } QImage IntelliImage::getImageData(){ - QImage copy = imageData; - if(fastRenderering){ - copy = copy.convertToFormat(QImage::Format_ARGB32); - } - return copy; + QImage copy = imageData; + if(fastRenderering) { + copy = copy.convertToFormat(QImage::Format_ARGB32); + } + return copy; } void IntelliImage::setImageData(const QImage& newData){ - imageData = newData; - if(fastRenderering){ - this->imageData = imageData.convertToFormat(QImage::Format_Indexed8); - } - else { - this->imageData = imageData.convertToFormat(QImage::Format_ARGB32); - } + imageData = newData; + if(fastRenderering) { + this->imageData = imageData.convertToFormat(QImage::Format_Indexed8); + } + else { + this->imageData = imageData.convertToFormat(QImage::Format_ARGB32); + } } void IntelliImage::updateRendererSetting(bool fastRendererOn){ - this->fastRenderering = fastRendererOn; - if(fastRenderering){ - this->imageData = imageData.convertToFormat(QImage::Format_Indexed8); - } - else { - this->imageData = imageData.convertToFormat(QImage::Format_ARGB32); - } + this->fastRenderering = fastRendererOn; + if(fastRenderering) { + this->imageData = imageData.convertToFormat(QImage::Format_Indexed8); + } + else { + this->imageData = imageData.convertToFormat(QImage::Format_ARGB32); + } } diff --git a/src/Image/IntelliRasterImage.cpp b/src/Image/IntelliRasterImage.cpp index 8872cff..b055f3f 100644 --- a/src/Image/IntelliRasterImage.cpp +++ b/src/Image/IntelliRasterImage.cpp @@ -4,9 +4,9 @@ #include IntelliRasterImage::IntelliRasterImage(int width, int height, bool fastRendererOn) - : IntelliImage(width, height, fastRendererOn){ - TypeOfImage = IntelliImage::ImageType::RASTERIMAGE; - this->fastRenderering = fastRendererOn; + : IntelliImage(width, height, fastRendererOn){ + TypeOfImage = IntelliImage::ImageType::RASTERIMAGE; + this->fastRenderering = fastRendererOn; } IntelliRasterImage::~IntelliRasterImage(){ @@ -30,9 +30,9 @@ QImage IntelliRasterImage::getDisplayable(int alpha){ QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){ QImage copy = imageData; - if(fastRenderering){ - copy = copy.convertToFormat(QImage::Format_ARGB32); - } + if(fastRenderering) { + copy = copy.convertToFormat(QImage::Format_ARGB32); + } for(int y = 0; y IntelliShapedImage::IntelliShapedImage(int width, int height, bool fastRendererOn) - : IntelliRasterImage(width, height, fastRendererOn){ - TypeOfImage = IntelliImage::ImageType::SHAPEDIMAGE; - this->fastRenderering = fastRendererOn; + : IntelliRasterImage(width, height, fastRendererOn){ + TypeOfImage = IntelliImage::ImageType::SHAPEDIMAGE; + this->fastRenderering = fastRendererOn; } IntelliShapedImage::~IntelliShapedImage(){ @@ -27,9 +27,9 @@ IntelliImage* IntelliShapedImage::getDeepCopy(){ } void IntelliShapedImage::calculateVisiblity(){ - if(fastRenderering){ - this->imageData = imageData.convertToFormat(QImage::Format_ARGB32); - } + if(fastRenderering) { + this->imageData = imageData.convertToFormat(QImage::Format_ARGB32); + } if(polygonData.size()<=2) { QColor clr; @@ -40,9 +40,9 @@ void IntelliShapedImage::calculateVisiblity(){ imageData.setPixelColor(x,y,clr); } } - if(fastRenderering){ - this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8); - } + if(fastRenderering) { + this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8); + } return; } QColor clr; @@ -59,16 +59,16 @@ void IntelliShapedImage::calculateVisiblity(){ imageData.setPixelColor(x,y,clr); } } - if(fastRenderering){ - this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8); - } + if(fastRenderering) { + this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8); + } } QImage IntelliShapedImage::getDisplayable(const QSize& displaySize, int alpha){ QImage copy = imageData; - if(fastRenderering){ - copy = copy.convertToFormat(QImage::Format_ARGB32); - } + if(fastRenderering) { + copy = copy.convertToFormat(QImage::Format_ARGB32); + } for(int y = 0; yfastRenderering = Updatedsetting; + this->fastRenderering = Updatedsetting; } bool IntelliRenderSettings::isFastRenderering(){ - return fastRenderering; + return fastRenderering; } diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index 779c2bb..7b93abc 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -43,12 +43,12 @@ PaintingArea::~PaintingArea(){ } void PaintingArea::setRenderSettings(bool isFastRenderingOn){ - if(isFastRenderingOn != renderSettings.isFastRenderering()){ - renderSettings.setFastRendering(isFastRenderingOn); - for(auto& layer : layerBundle){ - layer.image->updateRendererSetting(isFastRenderingOn); - } - } + if(isFastRenderingOn != renderSettings.isFastRenderering()) { + renderSettings.setFastRendering(isFastRenderingOn); + for(auto& layer : layerBundle) { + layer.image->updateRendererSetting(isFastRenderingOn); + } + } } void PaintingArea::setLayerDimensions(int maxWidth, int maxHeight){ @@ -68,10 +68,10 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff newLayer.height = height; newLayer.widthOffset = widthOffset; newLayer.heightOffset = heightOffset; - if(type==IntelliImage::ImageType::RASTERIMAGE) { - newLayer.image = new IntelliRasterImage(width,height,renderSettings.isFastRenderering()); - }else if(type==IntelliImage::ImageType::SHAPEDIMAGE) { - newLayer.image = new IntelliShapedImage(width, height, renderSettings.isFastRenderering()); + if(type==IntelliImage::ImageType::RASTERIMAGE) { + newLayer.image = new IntelliRasterImage(width,height,renderSettings.isFastRenderering()); + }else if(type==IntelliImage::ImageType::SHAPEDIMAGE) { + newLayer.image = new IntelliShapedImage(width, height, renderSettings.isFastRenderering()); } newLayer.alpha = 255; this->layerBundle.push_back(newLayer); @@ -83,12 +83,12 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff void PaintingArea::deleteLayer(int idx){ if(idx(layerBundle.size())) { this->layerBundle.erase(layerBundle.begin()+idx); - if(activeLayer>=idx) { + if(activeLayer>=idx) { activeLayer--; } - if(activeLayer < 0 && layerBundle.size()){ - activeLayer=0; - } + if(activeLayer < 0 && layerBundle.size()) { + activeLayer=0; + } } } @@ -265,9 +265,9 @@ std::vector PaintingArea::getPolygonDataOfRealLayer(){ // left button and if so store the current position // Set that we are currently drawing void PaintingArea::mousePressEvent(QMouseEvent*event){ - if(this->activeLayer < 0){ - return; - } + if(this->activeLayer < 0) { + return; + } if(Tool == nullptr) return; int x = event->x()-layerBundle[static_cast(activeLayer)].widthOffset; @@ -284,9 +284,9 @@ void PaintingArea::mousePressEvent(QMouseEvent*event){ // we call the drawline function which draws a line // from the last position to the current void PaintingArea::mouseMoveEvent(QMouseEvent*event){ - if(this->activeLayer < 0){ - return; - } + if(this->activeLayer < 0) { + return; + } if(Tool == nullptr) return; int x = event->x()-layerBundle[static_cast(activeLayer)].widthOffset; @@ -297,9 +297,9 @@ void PaintingArea::mouseMoveEvent(QMouseEvent*event){ // If the button is released we set variables to stop drawing void PaintingArea::mouseReleaseEvent(QMouseEvent*event){ - if(this->activeLayer < 0) - return; - if(Tool == nullptr) + if(this->activeLayer < 0) + return; + if(Tool == nullptr) return; int x = event->x()-layerBundle[static_cast(activeLayer)].widthOffset; int y = event->y()-layerBundle[static_cast(activeLayer)].heightOffset; @@ -312,9 +312,9 @@ void PaintingArea::mouseReleaseEvent(QMouseEvent*event){ } void PaintingArea::wheelEvent(QWheelEvent*event){ - if(this->activeLayer < 0) - return; - if(this->Tool != nullptr) { + if(this->activeLayer < 0) + return; + if(this->Tool != nullptr) { QPoint numDegrees = event->angleDelta() / 8; if(!numDegrees.isNull()) { QPoint numSteps = numDegrees / 15; @@ -405,9 +405,9 @@ bool PaintingArea::createTempTopLayer(int idx){ newLayer.widthOffset = layerBundle[static_cast(idx)].widthOffset; newLayer.image = layerBundle[static_cast(idx)].image->getDeepCopy(); layerBundle.insert(layerBundle.begin()+idx+1,newLayer); - return true; + return true; } - return false; + return false; } IntelliTool* PaintingArea::copyActiveTool(){ @@ -428,8 +428,8 @@ int PaintingArea::getNumberOfActiveLayer(){ } IntelliImage* PaintingArea::getImageOfActiveLayer(){ - if(activeLayer<0){ - return nullptr; - } + if(activeLayer<0) { + return nullptr; + } return layerBundle[activeLayer].image; } diff --git a/src/Layer/PaintingArea.h b/src/Layer/PaintingArea.h index fad58dd..95eef55 100644 --- a/src/Layer/PaintingArea.h +++ b/src/Layer/PaintingArea.h @@ -43,142 +43,142 @@ Q_OBJECT friend IntelliTool; friend IntelliPhotoGui; public: - /*! - * \brief PaintingArea is the constructor of the PaintingArea class, which initiates the working environment - * \param maxWidth - The maximum amount of pixles that are inside painting area from left to right (default=600px) - * \param maxHeight - The maximum amount of pixles that are inside painting area from top to bottom (default=600px) - * \param parent - The parent window of the main window (default=nullptr) - */ - PaintingArea(int maxWidth=600, int maxHeight=600, QWidget *parent = nullptr); +/*! + * \brief PaintingArea is the constructor of the PaintingArea class, which initiates the working environment + * \param maxWidth - The maximum amount of pixles that are inside painting area from left to right (default=600px) + * \param maxHeight - The maximum amount of pixles that are inside painting area from top to bottom (default=600px) + * \param parent - The parent window of the main window (default=nullptr) + */ +PaintingArea(int maxWidth=600, int maxHeight=600, QWidget*parent = nullptr); - /*! - * \brief This deconstructor is used to clear up the memory and remove the currently active window - */ - ~PaintingArea() override; +/*! + * \brief This deconstructor is used to clear up the memory and remove the currently active window + */ +~PaintingArea() override; - // Handles all events +// Handles all events - /*! - * \brief setRenderSettings updates all Images to the new Rendersetting. - * \param isFastRenderingOn is the new given flag for the FastRenderer. - */ - void setRenderSettings(bool isFastRenderingOn); +/*! + * \brief setRenderSettings updates all Images to the new Rendersetting. + * \param isFastRenderingOn is the new given flag for the FastRenderer. + */ +void setRenderSettings(bool isFastRenderingOn); - /*! - * \brief The open method is used for loading a picture into the current layer - * \param fileName - Path and filename which are used to determine where the to-be-opened file is stored - * \return Returns a boolean variable whether the file was successfully opened or not - */ - bool open(const QString &filePath); - /*! - * \brief The save method is used for exporting the current project as one picture - * \param fileName - * \param fileFormat - * \return Returns a boolean variable, true if the file was saved successfully, false if not - */ - bool save(const QString &filePath, const char *fileFormat); +/*! + * \brief The open method is used for loading a picture into the current layer + * \param fileName - Path and filename which are used to determine where the to-be-opened file is stored + * \return Returns a boolean variable whether the file was successfully opened or not + */ +bool open(const QString &filePath); +/*! + * \brief The save method is used for exporting the current project as one picture + * \param fileName + * \param fileFormat + * \return Returns a boolean variable, true if the file was saved successfully, false if not + */ +bool save(const QString &filePath, const char*fileFormat); - /*! - * \brief The addLayer adds a layer to the current project/ painting area - * \param width - Width of the layer in pixles - * \param height - Height of the layer in pixles - * \param widthOffset - Offset of the layer measured to the left border of the painting area in pixles - * \param heightOffset - Offset of the layer measured to the top border of the painting area in pixles - * \param type - Defining the ImageType of the new layer - * \return Returns the number of layers in the project - */ - int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, IntelliImage::ImageType type = IntelliImage::ImageType::RASTERIMAGE); - /*! - * \brief The addLayerAt adds a layer to the current project/ painting area at a specific position in the layer stack - * \param idx - Index of the position the new layer should be added - * \param width - Width of the layer in pixles - * \param height - Height of the layer in pixles - * \param widthOffset - Offset of the layer measured to the left border of the painting area in pixles - * \param heightOffset - Offset of the layer measured to the top border of the painting area in pixles - * \param type - Defining the ImageType of the new layer - * \return Returns the id of the layer position - */ - int addLayerAt(int idx, int width, int height, int widthOffset=0, int heightOffset=0, IntelliImage::ImageType type = IntelliImage::ImageType::RASTERIMAGE); - /*! - * \brief The deleteLayer method removes a layer at a given idx - * \param idx - The index of the layer to be removed - */ - void deleteLayer(int idx); - /*! - * \brief The setLayerToActive method marks a specific layer as active - * \param idx - The index of the layer to be active - */ - void setLayerActive(int idx); - /*! - * \brief The setAlphaOfLayer method sets the alpha value of a specific layer - * \param idx - The index of the layer where the change should be applied - * \param alpha - New alpha value of the layer - */ - void setLayerAlpha(int idx, int alpha); - /*! - * \brief The floodFill method fills a the active layer with a given color - * \param r - Red value of the color the layer should be filled with - * \param g - Green value of the color the layer should be filled with - * \param b - Blue value of the color the layer should be filled with - * \param a - Alpha value of the color the layer should be filled with - */ - void floodFill(int r, int g, int b, int a); - /*! - * \brief The movePositionActive method moves the active layer to certain position - * \param x - The x value the new center of the layer should be at - * \param y - The y value the new center of the layer should be at - */ - void movePositionActive(int x, int y); - /*! - * \brief The moveActiveLayer moves the active layer to a specific position in the layer stack - * \param idx - The index of the new position the layer should be in - */ - void moveActiveLayer(int idx); +/*! + * \brief The addLayer adds a layer to the current project/ painting area + * \param width - Width of the layer in pixles + * \param height - Height of the layer in pixles + * \param widthOffset - Offset of the layer measured to the left border of the painting area in pixles + * \param heightOffset - Offset of the layer measured to the top border of the painting area in pixles + * \param type - Defining the ImageType of the new layer + * \return Returns the number of layers in the project + */ +int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, IntelliImage::ImageType type = IntelliImage::ImageType::RASTERIMAGE); +/*! + * \brief The addLayerAt adds a layer to the current project/ painting area at a specific position in the layer stack + * \param idx - Index of the position the new layer should be added + * \param width - Width of the layer in pixles + * \param height - Height of the layer in pixles + * \param widthOffset - Offset of the layer measured to the left border of the painting area in pixles + * \param heightOffset - Offset of the layer measured to the top border of the painting area in pixles + * \param type - Defining the ImageType of the new layer + * \return Returns the id of the layer position + */ +int addLayerAt(int idx, int width, int height, int widthOffset=0, int heightOffset=0, IntelliImage::ImageType type = IntelliImage::ImageType::RASTERIMAGE); +/*! + * \brief The deleteLayer method removes a layer at a given idx + * \param idx - The index of the layer to be removed + */ +void deleteLayer(int idx); +/*! + * \brief The setLayerToActive method marks a specific layer as active + * \param idx - The index of the layer to be active + */ +void setLayerActive(int idx); +/*! + * \brief The setAlphaOfLayer method sets the alpha value of a specific layer + * \param idx - The index of the layer where the change should be applied + * \param alpha - New alpha value of the layer + */ +void setLayerAlpha(int idx, int alpha); +/*! + * \brief The floodFill method fills a the active layer with a given color + * \param r - Red value of the color the layer should be filled with + * \param g - Green value of the color the layer should be filled with + * \param b - Blue value of the color the layer should be filled with + * \param a - Alpha value of the color the layer should be filled with + */ +void floodFill(int r, int g, int b, int a); +/*! + * \brief The movePositionActive method moves the active layer to certain position + * \param x - The x value the new center of the layer should be at + * \param y - The y value the new center of the layer should be at + */ +void movePositionActive(int x, int y); +/*! + * \brief The moveActiveLayer moves the active layer to a specific position in the layer stack + * \param idx - The index of the new position the layer should be in + */ +void moveActiveLayer(int idx); - //change properties of colorPicker - /*! - * \brief The colorPickerSetFirstColor calls the QTColorPicker to determine the primary drawing color - */ - void colorPickerSetFirstColor(); - /*! - * \brief The colorPickerSetSecondColor calls the QTColorPicker to determine the secondary drawing color - */ - void colorPickerSetSecondColor(); - /*! - * \brief The colorPickerSwitchColor swaps the primary color with the secondary drawing color - */ - void colorPickerSwapColors(); +//change properties of colorPicker +/*! + * \brief The colorPickerSetFirstColor calls the QTColorPicker to determine the primary drawing color + */ +void colorPickerSetFirstColor(); +/*! + * \brief The colorPickerSetSecondColor calls the QTColorPicker to determine the secondary drawing color + */ +void colorPickerSetSecondColor(); +/*! + * \brief The colorPickerSwitchColor swaps the primary color with the secondary drawing color + */ +void colorPickerSwapColors(); - // Create tools - void createPenTool(); - void createPlainTool(); - void createLineTool(); - void createRectangleTool(); - void createCircleTool(); - void createPolygonTool(); - void createFloodFillTool(); +// Create tools +void createPenTool(); +void createPlainTool(); +void createLineTool(); +void createRectangleTool(); +void createCircleTool(); +void createPolygonTool(); +void createFloodFillTool(); - /*! - * \brief The getWidthOfActive gets the horizontal dimensions of the active layer - * \return Returns the horizontal pixle count of the active layer - */ - int getWidthOfActive(); - /*! - * \brief The getHeightOfActive gets the vertical dimensions of the active layer - * \return Returns the vertical pixle count of the active layer - */ - int getHeightOfActive(); +/*! + * \brief The getWidthOfActive gets the horizontal dimensions of the active layer + * \return Returns the horizontal pixle count of the active layer + */ +int getWidthOfActive(); +/*! + * \brief The getHeightOfActive gets the vertical dimensions of the active layer + * \return Returns the vertical pixle count of the active layer + */ +int getHeightOfActive(); - IntelliImage::ImageType getTypeOfImageRealLayer(); +IntelliImage::ImageType getTypeOfImageRealLayer(); - std::vector getPolygonDataOfRealLayer(); +std::vector getPolygonDataOfRealLayer(); - int getNumberOfActiveLayer(); +int getNumberOfActiveLayer(); - IntelliImage* getImageOfActiveLayer(); +IntelliImage* getImageOfActiveLayer(); - IntelliToolsettings Toolsettings; - IntelliColorPicker colorPicker; +IntelliToolsettings Toolsettings; +IntelliColorPicker colorPicker; public slots: // Events to handle @@ -226,8 +226,8 @@ void drawLayers(bool forSaving=false); void resizeLayer(QImage*image_res, const QSize &newSize); - // Helper for Tool - bool createTempTopLayer(int idx); +// Helper for Tool +bool createTempTopLayer(int idx); }; #endif diff --git a/src/Tool/IntelliTool.cpp b/src/Tool/IntelliTool.cpp index 520ad1c..a9178e0 100644 --- a/src/Tool/IntelliTool.cpp +++ b/src/Tool/IntelliTool.cpp @@ -24,10 +24,10 @@ void IntelliTool::onMouseRightReleased(int x, int y){ } void IntelliTool::onMouseLeftPressed(int x, int y){ - this->isDrawing=this->createToolLayer(); - if(isDrawing){ - Canvas->image->calculateVisiblity(); - } + this->isDrawing=this->createToolLayer(); + if(isDrawing) { + Canvas->image->calculateVisiblity(); + } } void IntelliTool::onMouseLeftReleased(int x, int y){ @@ -45,27 +45,27 @@ void IntelliTool::onMouseMoved(int x, int y){ } void IntelliTool::onWheelScrolled(int value){ - //if needed for future general tasks implement in here - Area->DummyGui->setToolWidth(value+Toolsettings->getLineWidth()); + //if needed for future general tasks implement in here + Area->DummyGui->setToolWidth(value+Toolsettings->getLineWidth()); } bool IntelliTool::createToolLayer(){ - if(Area->createTempTopLayer(Area->activeLayer)){ - this->activeLayer=&Area->layerBundle[static_cast(Area->activeLayer)]; - this->Canvas=&Area->layerBundle[static_cast(Area->activeLayer+1)]; - return true; - } - return false; + if(Area->createTempTopLayer(Area->activeLayer)) { + this->activeLayer=&Area->layerBundle[static_cast(Area->activeLayer)]; + this->Canvas=&Area->layerBundle[static_cast(Area->activeLayer+1)]; + return true; + } + return false; } void IntelliTool::mergeToolLayer(){ QColor clr_0; QColor clr_1; - QImage updatedImage = activeLayer->image->getImageData(); + QImage updatedImage = activeLayer->image->getImageData(); for(int y=0; yheight; y++) { - for(int x=0; xwidth; x++) { - clr_0=updatedImage.pixelColor(x,y); + for(int x=0; xwidth; x++) { + clr_0=updatedImage.pixelColor(x,y); clr_1=Canvas->image->imageData.pixelColor(x,y); float t = static_cast(clr_1.alpha())/255.f; int r =static_cast(static_cast(clr_1.red())*(t)+static_cast(clr_0.red())*(1.f-t)+0.5f); @@ -77,11 +77,11 @@ void IntelliTool::mergeToolLayer(){ clr_0.setBlue(b); clr_0.setAlpha(a); - updatedImage.setPixelColor(x, y, clr_0); + updatedImage.setPixelColor(x, y, clr_0); } } - activeLayer->image->setImageData(updatedImage); - Area->DummyGui->UpdateGui(); + activeLayer->image->setImageData(updatedImage); + Area->DummyGui->UpdateGui(); } void IntelliTool::deleteToolLayer(){ diff --git a/src/Tool/IntelliToolCircle.cpp b/src/Tool/IntelliToolCircle.cpp index cde5da6..d2a09d1 100644 --- a/src/Tool/IntelliToolCircle.cpp +++ b/src/Tool/IntelliToolCircle.cpp @@ -26,7 +26,7 @@ void IntelliToolCircle::drawCircle(int radius){ } //TODO implement circle drawing algorithm bresenham - radius = static_cast(radius +(Toolsettings->getLineWidth()/2.)); + radius = static_cast(radius +(Toolsettings->getLineWidth()/2.)); yMin = (centerPoint.y()-radius); yMax = (centerPoint.y()+radius); for(int i=yMin; i<=yMax; i++) { @@ -56,12 +56,12 @@ void IntelliToolCircle::onMouseRightReleased(int x, int y){ void IntelliToolCircle::onMouseLeftPressed(int x, int y){ IntelliTool::onMouseLeftPressed(x,y); - if(this->isDrawing){ - this->centerPoint=QPoint(x,y); - int radius = 1; - drawCircle(radius); - Canvas->image->calculateVisiblity(); - } + if(this->isDrawing) { + this->centerPoint=QPoint(x,y); + int radius = 1; + drawCircle(radius); + Canvas->image->calculateVisiblity(); + } } void IntelliToolCircle::onMouseLeftReleased(int x, int y){ diff --git a/src/Tool/IntelliToolLine.cpp b/src/Tool/IntelliToolLine.cpp index 45194de..120d3a2 100644 --- a/src/Tool/IntelliToolLine.cpp +++ b/src/Tool/IntelliToolLine.cpp @@ -49,7 +49,7 @@ void IntelliToolLine::onMouseMoved(int x, int y){ QPoint p2 =lineStartingPoint.x() < next.x() ? next : lineStartingPoint; int m = static_cast(static_cast(p2.y()-p1.y())/static_cast(p2.x()-p1.x())+0.5f); int c = lineStartingPoint.y()-lineStartingPoint.x()*m; - //TODO implement dotted algorithm + //TODO implement dotted algorithm break; } } diff --git a/src/Tool/IntelliToolRectangle.cpp b/src/Tool/IntelliToolRectangle.cpp index 4fe86f7..29fa038 100644 --- a/src/Tool/IntelliToolRectangle.cpp +++ b/src/Tool/IntelliToolRectangle.cpp @@ -58,6 +58,6 @@ void IntelliToolRectangle::onMouseMoved(int x, int y){ } void IntelliToolRectangle::onWheelScrolled(int value){ - IntelliTool::onWheelScrolled(value); - Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value); + IntelliTool::onWheelScrolled(value); + Toolsettings->setLineWidth(Toolsettings->getLineWidth()+value); } diff --git a/src/main.cpp b/src/main.cpp index d6a8dd3..913370c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,11 +8,11 @@ int main(int argc, char*argv[]){ // The main application QApplication app(argc, argv); - IntelliInputDialog* InputDialog; + IntelliInputDialog* InputDialog; // Create and open the main window - IntelliPhotoGui window(InputDialog); - window.show(); + IntelliPhotoGui window(InputDialog); + window.show(); return app.exec(); } From b5e05a9c6a3c15c6ccbd5e0b1fd310862234eb24 Mon Sep 17 00:00:00 2001 From: AshBastian Date: Wed, 15 Jan 2020 15:48:38 +0100 Subject: [PATCH 06/12] Update InputBoxes --- src/GUI/IntelliInputDialog.cpp | 31 +++--- src/GUI/IntelliInputDialog.h | 13 +-- src/GUI/IntelliPhotoGui.cpp | 118 ++++++++++------------ src/GUI/IntelliPhotoGui.h | 3 +- src/IntelliHelper/IntelliToolsettings.cpp | 24 +---- src/IntelliHelper/IntelliToolsettings.h | 2 - src/IntelliPhoto.pro | 2 + 7 files changed, 79 insertions(+), 114 deletions(-) diff --git a/src/GUI/IntelliInputDialog.cpp b/src/GUI/IntelliInputDialog.cpp index e62b091..4e7bee6 100644 --- a/src/GUI/IntelliInputDialog.cpp +++ b/src/GUI/IntelliInputDialog.cpp @@ -1,8 +1,8 @@ #include "IntelliInputDialog.h" - -IntelliInputDialog::IntelliInputDialog(Speichereinheit &Speicher, QEventLoop* Loop, IntelliInputDialog* Dialog, QString Title, QString Label, int value, int minValue, int maxValue, int step) +#include +IntelliInputDialog::IntelliInputDialog(QEventLoop* Loop, IntelliInputDialog* Dialog, QString Title, QString Label, int value, int minValue, int maxValue, int step) { - this->Dialog = Dialog; + this->Dialog = Dialog; createInputBox(Title, Label, value, minValue, maxValue, step); createConnections(Loop); setValuesOfPalette(); @@ -54,7 +54,7 @@ void IntelliInputDialog::createInputBox(QString Title, QString Label, int value, } void IntelliInputDialog::createConnections(QEventLoop* Loop){ - connect(okButton, SIGNAL(clicked()), this, SLOT(slotEingabe(Speicher))); + connect(okButton, SIGNAL(clicked()), this, SLOT(slotEingabe())); connect(okButton, SIGNAL(clicked()), Loop, SLOT(quit())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(slotCloseEvent())); connect(cancelButton, SIGNAL(clicked()), Loop, SLOT(quit())); @@ -84,16 +84,21 @@ void IntelliInputDialog::slotCloseEvent(){ Dialog->close(); } -void IntelliInputDialog::slotEingabe(Speichereinheit &Speicher){ - qDebug() << Input->value(); - SetValueToGUI(); +void IntelliInputDialog::slotEingabe(){ + QFile File("test.txt"); + + if(!File.open(QIODevice::WriteOnly | QIODevice::Text)){ + qDebug() << "Error Write to File"; + } + std::string test = QString("%1").arg(Input->value()).toStdString(); + const char* p = test.c_str(); + File.write(p); + File.close(); + Dialog->close(); } -void IntelliInputDialog::SetValueToGUI(){ - Input->value(); -} - -void IntelliInputDialog::getIntInput(Speichereinheit &Speicher, QEventLoop* Loop, IntelliInputDialog* Dialog, QString Title, QString Label, int value, int minValue, int maxValue, int step){ - this->Dialog = new IntelliInputDialog(Speicher, Loop, Dialog, Title, Label, value, minValue, maxValue, step); +void IntelliInputDialog::getIntInput(QEventLoop* Loop, IntelliInputDialog* Dialog, QString Title, QString Label, int value, int minValue, int maxValue, int step){ + this->Dialog = new IntelliInputDialog(Loop, Dialog, Title, Label, value, minValue, maxValue, step); + Loop->exec(); } diff --git a/src/GUI/IntelliInputDialog.h b/src/GUI/IntelliInputDialog.h index c78f63b..d420e8b 100644 --- a/src/GUI/IntelliInputDialog.h +++ b/src/GUI/IntelliInputDialog.h @@ -3,23 +3,18 @@ #include #include -#include "IntelliPhotoGui.h" - -class Speichereinheit { -int value; -}; class IntelliInputDialog : public QDialog { Q_OBJECT public: -IntelliInputDialog(Speichereinheit &Speicher, QEventLoop* Loop = nullptr, IntelliInputDialog* Dialog = nullptr, QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); +IntelliInputDialog(QEventLoop* Loop = nullptr, IntelliInputDialog* Dialog = nullptr, QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); -void getIntInput(Speichereinheit &Speicher, QEventLoop* Loop = nullptr, IntelliInputDialog* Dialog = nullptr, QString Title = "InputBox", QString Label = "Weight:", int value = 0, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); +void getIntInput(QEventLoop* Loop = nullptr, IntelliInputDialog* Dialog = nullptr, QString Title = "InputBox", QString Label = "Weight:", int value = 0, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); public slots: void slotCloseEvent(); -void slotEingabe(Speichereinheit &Speicher); +void slotEingabe(); private: void createInputBox(QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); @@ -27,8 +22,6 @@ void createConnections(QEventLoop* Loop = nullptr); void setValuesOfPalette(); void setInputBoxStyle(); -void SetValueToGUI(); - QDialog* Dialog; QGridLayout* Layout; diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 88b0a4f..6281e92 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -5,7 +5,7 @@ // IntelliPhotoGui constructor IntelliPhotoGui::IntelliPhotoGui(IntelliInputDialog* InputDialog){ - //this->InputDialog = InputDialog; + this->InputDialog = InputDialog; // create Gui elements and lay them out createGui(); // Create actions @@ -68,19 +68,16 @@ void IntelliPhotoGui::slotSave(){ // Opens a dialog that allows the user to create a New Layer void IntelliPhotoGui::slotCreateNewLayer(){ - // Stores button value - // "New Layer" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button - Speichereinheit Speicher; - this->InputDialog->getIntInput(Speicher, &Loop, this->InputDialog, "New Layer", "Width:", 5, 0, 5000, 1); + this->InputDialog->getIntInput(&Loop, this->InputDialog, "New Layer", "Width:", 200, 0, 5000, 1); - int width = returnValueOfInputDialog; + int width = getReturnValueOfDialog(); - qDebug() << width; + this->InputDialog->getIntInput(&Loop, this->InputDialog, "New Layer", "Height:", 200, 0, 5000, 1); - int height = 25;//QInputDialog::getInt(this, tr("New Layer"),tr("Height:"),200,1, 500, 1, &ok2); + int height = getReturnValueOfDialog(); // Create New Layer paintingArea->addLayer(width,height,0,0); @@ -89,41 +86,29 @@ void IntelliPhotoGui::slotCreateNewLayer(){ // Opens a dialog that allows the user to delete a Layer void IntelliPhotoGui::slotDeleteLayer(){ - // Stores button value - bool ok; - // "delete Layer" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button - int layerNumber = QInputDialog::getInt(this, tr("delete Layer"), - tr("Number:"), - paintingArea->getNumberOfActiveLayer()+1,1, 501, 1, &ok); + this->InputDialog->getIntInput(&Loop, this->InputDialog, "Delete Layer", "Number:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1); + int layerNumber = getReturnValueOfDialog(); + // Create New Layer - if (ok) { - paintingArea->deleteLayer(layerNumber-1); - UpdateGui(); - } + paintingArea->deleteLayer(layerNumber-1); + UpdateGui(); } void IntelliPhotoGui::slotSetActiveAlpha(){ - // Stores button value - bool ok1, ok2; - // "Layer to set on" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button - int layer = QInputDialog::getInt(this, tr("Layer to set on"), - tr("Layer:"), - 1,1,500,1, &ok1); + this->InputDialog->getIntInput(&Loop, this->InputDialog, "Layer to set on", "Layer:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1); + int layer = getReturnValueOfDialog(); + // "New Alpha" is the title of the window - int alpha = QInputDialog::getInt(this, tr("New Alpha"), - tr("Alpha:"), - 255,0, 255, 1, &ok2); - if (ok1&&ok2) - { - paintingArea->setLayerAlpha(layer-1,alpha); - UpdateGui(); - } + this->InputDialog->getIntInput(&Loop, this->InputDialog, "New Alpha", "Alpha:", 255, 0, 255, 1); + int alpha = getReturnValueOfDialog(); + paintingArea->setLayerAlpha(layer-1,alpha); + UpdateGui(); } void IntelliPhotoGui::slotPositionMoveUp(){ @@ -157,49 +142,36 @@ void IntelliPhotoGui::slotMoveLayerDown(){ } void IntelliPhotoGui::slotClearActiveLayer(){ - // Stores button value - bool ok1, ok2, ok3, ok4; - // "Red Input" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button - int red = QInputDialog::getInt(this, tr("Red Input"), - tr("Red:"), - 255,0, 255,1, &ok1); + this->InputDialog->getIntInput(&Loop, this->InputDialog, "Red Input", "Red:", 255, 0, 255, 1); + int red = getReturnValueOfDialog(); + // "Green Input" is the title of the window - int green = QInputDialog::getInt(this, tr("Green Input"), - tr("Green:"), - 255,0, 255, 1, &ok2); + this->InputDialog->getIntInput(&Loop, this->InputDialog, "Green Input", "Green:", 255, 0, 255, 1); + int green = getReturnValueOfDialog(); + // "Blue Input" is the title of the window - int blue = QInputDialog::getInt(this, tr("Blue Input"), - tr("Blue:"), - 255,0, 255, 1, &ok3); + this->InputDialog->getIntInput(&Loop, this->InputDialog, "Blue Input", "Blue:", 255, 0, 255, 1); + int blue = getReturnValueOfDialog(); + // "Alpha Input" is the title of the window - int alpha = QInputDialog::getInt(this, tr("Alpha Input"), - tr("Alpha:"), - 255,0, 255, 1, &ok4); - if (ok1&&ok2&&ok3&&ok4) - { - paintingArea->floodFill(red, green, blue, alpha); - UpdateGui(); - } + this->InputDialog->getIntInput(&Loop, this->InputDialog, "Alpha Input", "Alpha:", 255, 0, 255, 1); + int alpha = getReturnValueOfDialog(); + + paintingArea->floodFill(red, green, blue, alpha); + UpdateGui(); } void IntelliPhotoGui::slotSetActiveLayer(){ - // Stores button value - bool ok1; - // "Layer to set on" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button - int layer = QInputDialog::getInt(this, tr("Layer to set on"), - tr("Layer:"), - 1,1,500,1, &ok1); - if (ok1) - { - paintingArea->setLayerActive(layer-1); - UpdateGui(); - } + this->InputDialog->getIntInput(&Loop, this->InputDialog, "Layer to set on", "Layer:", 1, 1, 501, 1); + int layer = getReturnValueOfDialog(); + paintingArea->setLayerActive(layer-1); + UpdateGui(); } void IntelliPhotoGui::slotUpdateRenderSettingsOn(){ @@ -293,12 +265,14 @@ void IntelliPhotoGui::slotResetTools(){ } void IntelliPhotoGui::slotSetWidth(){ - paintingArea->Toolsettings.setLineWidth(); + this->InputDialog->getIntInput(&Loop, this->InputDialog, "Toolsettings", "Width:", 5, 1, 50, 1); + paintingArea->Toolsettings.setLineWidth(getReturnValueOfDialog()); EditLineWidth->setText(QString("%1").arg(paintingArea->Toolsettings.getLineWidth())); } void IntelliPhotoGui::slotSetInnerAlpha(){ - paintingArea->Toolsettings.setInnerAlpha(); + this->InputDialog->getIntInput(&Loop, this->InputDialog, "Toolsettings", "Inner Alpha:", 255, 0, 255, 1); + paintingArea->Toolsettings.setInnerAlpha(getReturnValueOfDialog()); EditLineInnerAlpha->setText(QString("%1").arg(paintingArea->Toolsettings.getInnerAlpha())); } @@ -667,7 +641,7 @@ void IntelliPhotoGui::createGui(){ SwitchColorButton->setIconSize(QSize(Buttonsize.width()*2,Buttonsize.height())); ActiveLayerLine = new QLabel(); - QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer() + 1); + QString string = QString("Active Layer: %1").arg(paintingArea->getNumberOfActiveLayer() + 1); ActiveLayerLine->setText(string); ActiveLayerLine->setFixedSize(Buttonsize.width()*2+10,(Buttonsize.height()*2)/3); @@ -823,3 +797,15 @@ void IntelliPhotoGui::UpdateGui(){ string = QString("background-color: %1").arg(paintingArea->colorPicker.getSecondColor().name()); SecondColorButton->setStyleSheet(string); } + +int IntelliPhotoGui::getReturnValueOfDialog(){ + QFile File("test.txt"); + if(!File.open(QIODevice::ReadOnly | QIODevice::Text)){ + qDebug() << "Error Read from File"; + } + + QByteArray line = File.readLine(); + File.close(); + + return line.toInt(); +} diff --git a/src/GUI/IntelliPhotoGui.h b/src/GUI/IntelliPhotoGui.h index 27909ee..ee58016 100644 --- a/src/GUI/IntelliPhotoGui.h +++ b/src/GUI/IntelliPhotoGui.h @@ -38,7 +38,6 @@ IntelliPhotoGui(IntelliInputDialog* InputDialog); void UpdateGui(); void setToolWidth(int value); -int returnValueOfInputDialog = 5; protected: // Function used to close an event @@ -106,6 +105,8 @@ bool saveFile(const QByteArray &fileFormat); void setDefaultToolValue(); +int getReturnValueOfDialog(); + // What we'll draw on PaintingArea* paintingArea; IntelliInputDialog* InputDialog; diff --git a/src/IntelliHelper/IntelliToolsettings.cpp b/src/IntelliHelper/IntelliToolsettings.cpp index 7a4219c..2232cc0 100644 --- a/src/IntelliHelper/IntelliToolsettings.cpp +++ b/src/IntelliHelper/IntelliToolsettings.cpp @@ -16,36 +16,16 @@ int IntelliToolsettings::getLineWidth(){ return lineWidth; } -void IntelliToolsettings::setLineWidth(){ - lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1); -} - void IntelliToolsettings::setLineWidth(int LineWidth){ - if(LineWidth < 1) { - LineWidth = 1; - } - else if(LineWidth > 50) { - LineWidth = 50; - } - lineWidth = LineWidth; + lineWidth = LineWidth; } int IntelliToolsettings::getInnerAlpha(){ return this->innerAlpha; } -void IntelliToolsettings::setInnerAlpha(){ - this->innerAlpha = QInputDialog::getInt(nullptr,"Inner Aplha Input", "Value",0,0,255,1); -} - void IntelliToolsettings::setInnerAlpha(int innerAlpha){ - if(innerAlpha < 0) { - innerAlpha = 0; - } - else if(innerAlpha > 255) { - innerAlpha = 255; - } - this->innerAlpha = innerAlpha; + this->innerAlpha = innerAlpha; } IntelliToolsettings::LineStyle IntelliToolsettings::getLinestyle(){ diff --git a/src/IntelliHelper/IntelliToolsettings.h b/src/IntelliHelper/IntelliToolsettings.h index 1a63bbc..b96e953 100644 --- a/src/IntelliHelper/IntelliToolsettings.h +++ b/src/IntelliHelper/IntelliToolsettings.h @@ -13,10 +13,8 @@ enum class LineStyle { IntelliToolsettings(); virtual ~IntelliToolsettings(); int getLineWidth(); -void setLineWidth(); void setLineWidth(int LineWidth); int getInnerAlpha(); -void setInnerAlpha(); void setInnerAlpha(int innerAlpha); LineStyle getLinestyle(); diff --git a/src/IntelliPhoto.pro b/src/IntelliPhoto.pro index f3c669a..faf6c86 100644 --- a/src/IntelliPhoto.pro +++ b/src/IntelliPhoto.pro @@ -72,3 +72,5 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin RESOURCES += \ Bilder.qrc + +DISTFILES += From 2b433101c7cfd127ef319fd3a5f914f9685ba094 Mon Sep 17 00:00:00 2001 From: Jonas Mucke Date: Wed, 15 Jan 2020 18:19:02 +0100 Subject: [PATCH 07/12] =?UTF-8?q?kein=20debug=20wird=20ben=C3=B6tigt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/GUI/IntelliInputDialog.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/GUI/IntelliInputDialog.h b/src/GUI/IntelliInputDialog.h index d420e8b..9d03f51 100644 --- a/src/GUI/IntelliInputDialog.h +++ b/src/GUI/IntelliInputDialog.h @@ -2,7 +2,6 @@ #define INTELLIINPUTDIALOG_H #include -#include class IntelliInputDialog : public QDialog { From 72d55b2c8fec77f3f46f9f92052091122fc81fa9 Mon Sep 17 00:00:00 2001 From: Jonas Mucke Date: Wed, 15 Jan 2020 18:40:17 +0100 Subject: [PATCH 08/12] first Cleanup --- src/GUI/IntelliInputDialog.cpp | 66 ++++++++++++++++------------------ src/GUI/IntelliInputDialog.h | 5 +-- src/GUI/IntelliPhotoGui.cpp | 30 ++++++++-------- src/GUI/IntelliPhotoGui.h | 3 +- src/main.cpp | 5 +-- 5 files changed, 50 insertions(+), 59 deletions(-) diff --git a/src/GUI/IntelliInputDialog.cpp b/src/GUI/IntelliInputDialog.cpp index 4e7bee6..ebcc72c 100644 --- a/src/GUI/IntelliInputDialog.cpp +++ b/src/GUI/IntelliInputDialog.cpp @@ -1,56 +1,57 @@ #include "IntelliInputDialog.h" #include -IntelliInputDialog::IntelliInputDialog(QEventLoop* Loop, IntelliInputDialog* Dialog, QString Title, QString Label, int value, int minValue, int maxValue, int step) + + +IntelliInputDialog::IntelliInputDialog(QEventLoop* Loop, QString Title, QString Label, int value, int minValue, int maxValue, int step) { - this->Dialog = Dialog; createInputBox(Title, Label, value, minValue, maxValue, step); createConnections(Loop); setValuesOfPalette(); setInputBoxStyle(); + Loop->exec(); } void IntelliInputDialog::createInputBox(QString Title, QString Label, int value, int minValue, int maxValue, int step){ - this->Dialog = new QDialog(); - Dialog->setWindowFlags(Dialog->windowFlags() & ~Qt::WindowContextHelpButtonHint); + this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); if(Title == nullptr) { - Dialog->setWindowTitle("Input Box"); + this->setWindowTitle("Input Box"); } else{ - Dialog->setWindowTitle(Title); + this->setWindowTitle(Title); } - Layout = new QGridLayout(); - ButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + this->Layout = new QGridLayout(); + this->ButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - InputLabel = new QLabel(); + this->InputLabel = new QLabel(); if(Label == nullptr) { - InputLabel->setText("Width:"); + this->InputLabel->setText("Width:"); } else{ - InputLabel->setText(Label); + this->InputLabel->setText(Label); } - InputLabel->setFixedSize(Linesize); + this->InputLabel->setFixedSize(Linesize); - Input = new QSpinBox(); - Input->setFixedSize(Linesize); - Input->setRange(minValue,maxValue); - Input->setValue(value); + this->Input = new QSpinBox(); + this->Input->setFixedSize(Linesize); + this->Input->setRange(minValue,maxValue); + this->Input->setValue(value); - okButton = ButtonBox->button(QDialogButtonBox::Ok); - okButton->setFixedSize(Buttonsize); - okButton->setAutoDefault(false); - okButton->setDefault(false); + this->okButton = ButtonBox->button(QDialogButtonBox::Ok); + this->okButton->setFixedSize(Buttonsize); + this->okButton->setAutoDefault(false); + this->okButton->setDefault(false); - cancelButton = ButtonBox->button(QDialogButtonBox::Cancel); - cancelButton->setFixedSize(Buttonsize); - cancelButton->setAutoDefault(false); - cancelButton->setDefault(false); + this->cancelButton = ButtonBox->button(QDialogButtonBox::Cancel); + this->cancelButton->setFixedSize(Buttonsize); + this->cancelButton->setAutoDefault(false); + this->cancelButton->setDefault(false); Layout->addWidget(InputLabel,1,1,1,1); Layout->addWidget(Input,2,1,1,1); Layout->addWidget(ButtonBox,3,1,1,1); - Dialog->setLayout(Layout); - Dialog->resize(172,94); - Dialog->show(); + this->setLayout(Layout); + this->resize(172,94); + this->show(); } void IntelliInputDialog::createConnections(QEventLoop* Loop){ @@ -65,7 +66,7 @@ void IntelliInputDialog::setInputBoxStyle(){ Input->setPalette(Palette); okButton->setPalette(Palette); cancelButton->setPalette(Palette); - Dialog->setStyleSheet("background-color:rgb(64,64,64)"); + this->setStyleSheet("background-color:rgb(64,64,64)"); } void IntelliInputDialog::setValuesOfPalette(){ @@ -81,7 +82,7 @@ void IntelliInputDialog::setValuesOfPalette(){ } void IntelliInputDialog::slotCloseEvent(){ - Dialog->close(); + this->close(); } void IntelliInputDialog::slotEingabe(){ @@ -95,10 +96,5 @@ void IntelliInputDialog::slotEingabe(){ File.write(p); File.close(); - Dialog->close(); -} - -void IntelliInputDialog::getIntInput(QEventLoop* Loop, IntelliInputDialog* Dialog, QString Title, QString Label, int value, int minValue, int maxValue, int step){ - this->Dialog = new IntelliInputDialog(Loop, Dialog, Title, Label, value, minValue, maxValue, step); - Loop->exec(); + this->close(); } diff --git a/src/GUI/IntelliInputDialog.h b/src/GUI/IntelliInputDialog.h index 9d03f51..d02ecdb 100644 --- a/src/GUI/IntelliInputDialog.h +++ b/src/GUI/IntelliInputDialog.h @@ -7,9 +7,8 @@ class IntelliInputDialog : public QDialog { Q_OBJECT public: -IntelliInputDialog(QEventLoop* Loop = nullptr, IntelliInputDialog* Dialog = nullptr, QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); +IntelliInputDialog(QEventLoop* Loop = nullptr, QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); -void getIntInput(QEventLoop* Loop = nullptr, IntelliInputDialog* Dialog = nullptr, QString Title = "InputBox", QString Label = "Weight:", int value = 0, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); public slots: void slotCloseEvent(); @@ -21,8 +20,6 @@ void createConnections(QEventLoop* Loop = nullptr); void setValuesOfPalette(); void setInputBoxStyle(); -QDialog* Dialog; - QGridLayout* Layout; QDialogButtonBox* ButtonBox; diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 6281e92..b23feac 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -4,8 +4,7 @@ #include "Layer/PaintingArea.h" // IntelliPhotoGui constructor -IntelliPhotoGui::IntelliPhotoGui(IntelliInputDialog* InputDialog){ - this->InputDialog = InputDialog; +IntelliPhotoGui::IntelliPhotoGui(){ // create Gui elements and lay them out createGui(); // Create actions @@ -71,11 +70,11 @@ void IntelliPhotoGui::slotCreateNewLayer(){ // "New Layer" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button - this->InputDialog->getIntInput(&Loop, this->InputDialog, "New Layer", "Width:", 200, 0, 5000, 1); + IntelliInputDialog widthDialog(&Loop, "New Layer", "Width:", 200, 0, 5000, 1); int width = getReturnValueOfDialog(); - this->InputDialog->getIntInput(&Loop, this->InputDialog, "New Layer", "Height:", 200, 0, 5000, 1); + IntelliInputDialog heightDialog(&Loop, "New Layer", "Height:", 200, 0, 5000, 1); int height = getReturnValueOfDialog(); @@ -89,7 +88,7 @@ void IntelliPhotoGui::slotDeleteLayer(){ // "delete Layer" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button - this->InputDialog->getIntInput(&Loop, this->InputDialog, "Delete Layer", "Number:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1); + IntelliInputDialog dialog(&Loop, "Delete Layer", "Number:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1); int layerNumber = getReturnValueOfDialog(); // Create New Layer @@ -101,11 +100,12 @@ void IntelliPhotoGui::slotSetActiveAlpha(){ // "Layer to set on" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button - this->InputDialog->getIntInput(&Loop, this->InputDialog, "Layer to set on", "Layer:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1); + + IntelliInputDialog layerDialog(&Loop, "Layer to set on", "Layer:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1); int layer = getReturnValueOfDialog(); // "New Alpha" is the title of the window - this->InputDialog->getIntInput(&Loop, this->InputDialog, "New Alpha", "Alpha:", 255, 0, 255, 1); + IntelliInputDialog alphaDialog;(&Loop, "New Alpha", "Alpha:", 255, 0, 255, 1); int alpha = getReturnValueOfDialog(); paintingArea->setLayerAlpha(layer-1,alpha); UpdateGui(); @@ -145,19 +145,21 @@ void IntelliPhotoGui::slotClearActiveLayer(){ // "Red Input" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button - this->InputDialog->getIntInput(&Loop, this->InputDialog, "Red Input", "Red:", 255, 0, 255, 1); + + + IntelliInputDialog redDialog(&Loop, "Red Input", "Red:", 255, 0, 255, 1); int red = getReturnValueOfDialog(); // "Green Input" is the title of the window - this->InputDialog->getIntInput(&Loop, this->InputDialog, "Green Input", "Green:", 255, 0, 255, 1); + IntelliInputDialog greenDialog(&Loop, "Green Input", "Green:", 255, 0, 255, 1); int green = getReturnValueOfDialog(); // "Blue Input" is the title of the window - this->InputDialog->getIntInput(&Loop, this->InputDialog, "Blue Input", "Blue:", 255, 0, 255, 1); + IntelliInputDialog blueDialog(&Loop, "Blue Input", "Blue:", 255, 0, 255, 1); int blue = getReturnValueOfDialog(); // "Alpha Input" is the title of the window - this->InputDialog->getIntInput(&Loop, this->InputDialog, "Alpha Input", "Alpha:", 255, 0, 255, 1); + IntelliInputDialog alphaDialog(&Loop, "Alpha Input", "Alpha:", 255, 0, 255, 1); int alpha = getReturnValueOfDialog(); paintingArea->floodFill(red, green, blue, alpha); @@ -168,7 +170,7 @@ void IntelliPhotoGui::slotSetActiveLayer(){ // "Layer to set on" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button - this->InputDialog->getIntInput(&Loop, this->InputDialog, "Layer to set on", "Layer:", 1, 1, 501, 1); + IntelliInputDialog dialog(&Loop, "Layer to set on", "Layer:", 1, 1, 501, 1); int layer = getReturnValueOfDialog(); paintingArea->setLayerActive(layer-1); UpdateGui(); @@ -265,13 +267,13 @@ void IntelliPhotoGui::slotResetTools(){ } void IntelliPhotoGui::slotSetWidth(){ - this->InputDialog->getIntInput(&Loop, this->InputDialog, "Toolsettings", "Width:", 5, 1, 50, 1); + IntelliInputDialog dialog(&Loop, "Toolsettings", "Width:", 5, 1, 50, 1); paintingArea->Toolsettings.setLineWidth(getReturnValueOfDialog()); EditLineWidth->setText(QString("%1").arg(paintingArea->Toolsettings.getLineWidth())); } void IntelliPhotoGui::slotSetInnerAlpha(){ - this->InputDialog->getIntInput(&Loop, this->InputDialog, "Toolsettings", "Inner Alpha:", 255, 0, 255, 1); + IntelliInputDialog dialog(&Loop, "Toolsettings", "Inner Alpha:", 255, 0, 255, 1); paintingArea->Toolsettings.setInnerAlpha(getReturnValueOfDialog()); EditLineInnerAlpha->setText(QString("%1").arg(paintingArea->Toolsettings.getInnerAlpha())); } diff --git a/src/GUI/IntelliPhotoGui.h b/src/GUI/IntelliPhotoGui.h index ee58016..6aea72d 100644 --- a/src/GUI/IntelliPhotoGui.h +++ b/src/GUI/IntelliPhotoGui.h @@ -33,7 +33,7 @@ public: /*! * \brief The IntelliPhotoGui method is the constructor and is used to create a new instance of the main program window */ -IntelliPhotoGui(IntelliInputDialog* InputDialog); +IntelliPhotoGui(); void UpdateGui(); @@ -109,7 +109,6 @@ int getReturnValueOfDialog(); // What we'll draw on PaintingArea* paintingArea; -IntelliInputDialog* InputDialog; QEventLoop Loop; const QSize Buttonsize = QSize(35,35); diff --git a/src/main.cpp b/src/main.cpp index 913370c..9eec82f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,4 @@ #include "GUI/IntelliPhotoGui.h" -#include "GUI/IntelliInputDialog.h" #include #include #include @@ -8,10 +7,8 @@ int main(int argc, char*argv[]){ // The main application QApplication app(argc, argv); - IntelliInputDialog* InputDialog; - // Create and open the main window - IntelliPhotoGui window(InputDialog); + IntelliPhotoGui window; window.show(); return app.exec(); From 0e6ce309c9211e12e9e3e17d680e7ade1d9bb045 Mon Sep 17 00:00:00 2001 From: Jonas Mucke Date: Wed, 15 Jan 2020 19:04:51 +0100 Subject: [PATCH 09/12] code cleanup #2 --- src/GUI/IntelliInputDialog.cpp | 17 +++----- src/GUI/IntelliInputDialog.h | 5 +++ src/GUI/IntelliPhotoGui.cpp | 80 ++++++++++++---------------------- src/GUI/IntelliPhotoGui.h | 2 - 4 files changed, 38 insertions(+), 66 deletions(-) diff --git a/src/GUI/IntelliInputDialog.cpp b/src/GUI/IntelliInputDialog.cpp index ebcc72c..d12b1f1 100644 --- a/src/GUI/IntelliInputDialog.cpp +++ b/src/GUI/IntelliInputDialog.cpp @@ -11,6 +11,11 @@ IntelliInputDialog::IntelliInputDialog(QEventLoop* Loop, QString Title, QString Loop->exec(); } +int IntelliInputDialog::getInt(QEventLoop* Loop, QString Title, QString Label, int value, int minValue, int maxValue, int step){ + IntelliInputDialog dialog(Loop, Title, Label, value, minValue, maxValue, step); + return dialog.valueInt; +} + void IntelliInputDialog::createInputBox(QString Title, QString Label, int value, int minValue, int maxValue, int step){ this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); if(Title == nullptr) { @@ -86,15 +91,5 @@ void IntelliInputDialog::slotCloseEvent(){ } void IntelliInputDialog::slotEingabe(){ - QFile File("test.txt"); - - if(!File.open(QIODevice::WriteOnly | QIODevice::Text)){ - qDebug() << "Error Write to File"; - } - std::string test = QString("%1").arg(Input->value()).toStdString(); - const char* p = test.c_str(); - File.write(p); - File.close(); - - this->close(); + valueInt= QString("%1").arg(Input->value()).toInt(); } diff --git a/src/GUI/IntelliInputDialog.h b/src/GUI/IntelliInputDialog.h index d02ecdb..915473e 100644 --- a/src/GUI/IntelliInputDialog.h +++ b/src/GUI/IntelliInputDialog.h @@ -10,6 +10,8 @@ public: IntelliInputDialog(QEventLoop* Loop = nullptr, QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); +static int getInt(QEventLoop* Loop = nullptr, QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); + public slots: void slotCloseEvent(); void slotEingabe(); @@ -20,8 +22,11 @@ void createConnections(QEventLoop* Loop = nullptr); void setValuesOfPalette(); void setInputBoxStyle(); +int valueInt; + QGridLayout* Layout; QDialogButtonBox* ButtonBox; +QEventLoop loop; const QSize Linesize = QSize(150,20); const QSize Buttonsize = QSize(72,20); diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index b23feac..e6a5350 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -15,8 +15,8 @@ IntelliPhotoGui::IntelliPhotoGui(){ setIntelliStyle(); // Size the app resize(600,600); - //showMaximized(); - setDefaultToolValue(); + //showMaximized(); + setDefaultToolValue(); } // User tried to close the app @@ -70,13 +70,9 @@ void IntelliPhotoGui::slotCreateNewLayer(){ // "New Layer" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button - IntelliInputDialog widthDialog(&Loop, "New Layer", "Width:", 200, 0, 5000, 1); + int width = IntelliInputDialog::getInt(&Loop, "New Layer", "Width:", 200, 0, 5000, 1); - int width = getReturnValueOfDialog(); - - IntelliInputDialog heightDialog(&Loop, "New Layer", "Height:", 200, 0, 5000, 1); - - int height = getReturnValueOfDialog(); + int height = IntelliInputDialog::getInt(&Loop, "New Layer", "Height:", 200, 0, 5000, 1); // Create New Layer paintingArea->addLayer(width,height,0,0); @@ -88,8 +84,7 @@ void IntelliPhotoGui::slotDeleteLayer(){ // "delete Layer" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button - IntelliInputDialog dialog(&Loop, "Delete Layer", "Number:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1); - int layerNumber = getReturnValueOfDialog(); + int layerNumber = IntelliInputDialog::getInt(&Loop, "Delete Layer", "Number:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1); // Create New Layer paintingArea->deleteLayer(layerNumber-1); @@ -101,12 +96,10 @@ void IntelliPhotoGui::slotSetActiveAlpha(){ // the next tr is the text to display // Define the standard Value, min, max, step and ok button - IntelliInputDialog layerDialog(&Loop, "Layer to set on", "Layer:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1); - int layer = getReturnValueOfDialog(); + int layer = IntelliInputDialog::getInt(&Loop, "Layer to set on", "Layer:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1); // "New Alpha" is the title of the window - IntelliInputDialog alphaDialog;(&Loop, "New Alpha", "Alpha:", 255, 0, 255, 1); - int alpha = getReturnValueOfDialog(); + int alpha = IntelliInputDialog::getInt(&Loop, "Layer to set on", "Layer:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1); paintingArea->setLayerAlpha(layer-1,alpha); UpdateGui(); } @@ -146,21 +139,17 @@ void IntelliPhotoGui::slotClearActiveLayer(){ // the next tr is the text to display // Define the standard Value, min, max, step and ok button - - IntelliInputDialog redDialog(&Loop, "Red Input", "Red:", 255, 0, 255, 1); - int red = getReturnValueOfDialog(); + // "Red Input" is the title of the window + int red = IntelliInputDialog::getInt(&Loop, "Green Input", "Green:", 255, 0, 255, 1); // "Green Input" is the title of the window - IntelliInputDialog greenDialog(&Loop, "Green Input", "Green:", 255, 0, 255, 1); - int green = getReturnValueOfDialog(); + int green = IntelliInputDialog::getInt(&Loop, "Green Input", "Green:", 255, 0, 255, 1); // "Blue Input" is the title of the window - IntelliInputDialog blueDialog(&Loop, "Blue Input", "Blue:", 255, 0, 255, 1); - int blue = getReturnValueOfDialog(); + int blue = IntelliInputDialog::getInt(&Loop, "Blue Input", "Blue:", 255, 0, 255, 1); - // "Alpha Input" is the title of the window - IntelliInputDialog alphaDialog(&Loop, "Alpha Input", "Alpha:", 255, 0, 255, 1); - int alpha = getReturnValueOfDialog(); + // "Alpha Input" is the title of the window + int alpha = IntelliInputDialog::getInt(&Loop, "Alpha Input", "Alpha:", 255, 0, 255, 1); paintingArea->floodFill(red, green, blue, alpha); UpdateGui(); @@ -170,8 +159,7 @@ void IntelliPhotoGui::slotSetActiveLayer(){ // "Layer to set on" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button - IntelliInputDialog dialog(&Loop, "Layer to set on", "Layer:", 1, 1, 501, 1); - int layer = getReturnValueOfDialog(); + int layer = IntelliInputDialog::getInt(&Loop, "Layer to set on", "Layer:", 1, 1, 501, 1); paintingArea->setLayerActive(layer-1); UpdateGui(); } @@ -244,16 +232,16 @@ void IntelliPhotoGui::slotAboutDialog(){ } void IntelliPhotoGui::slotEnterPressed(){ - QString string = EditLineWidth->text(); - if(string.toInt() > 50) { - EditLineWidth->setText("50"); - } - paintingArea->Toolsettings.setLineWidth(string.toInt()); - string = EditLineInnerAlpha->text(); - if(string.toInt() > 255) { - EditLineInnerAlpha->setText("255"); - } - paintingArea->Toolsettings.setInnerAlpha(string.toInt()); + QString string = EditLineWidth->text(); + if(string.toInt() > 50) { + EditLineWidth->setText("50"); + } + paintingArea->Toolsettings.setLineWidth(string.toInt()); + string = EditLineInnerAlpha->text(); + if(string.toInt() > 255) { + EditLineInnerAlpha->setText("255"); + } + paintingArea->Toolsettings.setInnerAlpha(string.toInt()); } void IntelliPhotoGui::slotResetTools(){ @@ -267,14 +255,12 @@ void IntelliPhotoGui::slotResetTools(){ } void IntelliPhotoGui::slotSetWidth(){ - IntelliInputDialog dialog(&Loop, "Toolsettings", "Width:", 5, 1, 50, 1); - paintingArea->Toolsettings.setLineWidth(getReturnValueOfDialog()); + paintingArea->Toolsettings.setLineWidth(IntelliInputDialog::getInt(&Loop, "Toolsettings", "Width:", 5, 1, 50, 1)); EditLineWidth->setText(QString("%1").arg(paintingArea->Toolsettings.getLineWidth())); } void IntelliPhotoGui::slotSetInnerAlpha(){ - IntelliInputDialog dialog(&Loop, "Toolsettings", "Inner Alpha:", 255, 0, 255, 1); - paintingArea->Toolsettings.setInnerAlpha(getReturnValueOfDialog()); + paintingArea->Toolsettings.setInnerAlpha(IntelliInputDialog::getInt(&Loop, "Toolsettings", "Width:", 5, 1, 50, 1)); EditLineInnerAlpha->setText(QString("%1").arg(paintingArea->Toolsettings.getInnerAlpha())); } @@ -768,7 +754,7 @@ bool IntelliPhotoGui::saveFile(const QByteArray &fileFormat){ } void IntelliPhotoGui::setDefaultToolValue(){ - slotEnterPressed(); + slotEnterPressed(); } void IntelliPhotoGui::setToolWidth(int value){ @@ -799,15 +785,3 @@ void IntelliPhotoGui::UpdateGui(){ string = QString("background-color: %1").arg(paintingArea->colorPicker.getSecondColor().name()); SecondColorButton->setStyleSheet(string); } - -int IntelliPhotoGui::getReturnValueOfDialog(){ - QFile File("test.txt"); - if(!File.open(QIODevice::ReadOnly | QIODevice::Text)){ - qDebug() << "Error Read from File"; - } - - QByteArray line = File.readLine(); - File.close(); - - return line.toInt(); -} diff --git a/src/GUI/IntelliPhotoGui.h b/src/GUI/IntelliPhotoGui.h index 6aea72d..8f18180 100644 --- a/src/GUI/IntelliPhotoGui.h +++ b/src/GUI/IntelliPhotoGui.h @@ -105,8 +105,6 @@ bool saveFile(const QByteArray &fileFormat); void setDefaultToolValue(); -int getReturnValueOfDialog(); - // What we'll draw on PaintingArea* paintingArea; QEventLoop Loop; From 5f76f74cd5f5d2bb8ca1880e5a9ca78c4658d1bf Mon Sep 17 00:00:00 2001 From: Jan Schuffenhauer Date: Wed, 15 Jan 2020 20:35:51 +0100 Subject: [PATCH 10/12] Fix out of Range --- src/GUI/IntelliInputDialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/GUI/IntelliInputDialog.cpp b/src/GUI/IntelliInputDialog.cpp index d12b1f1..d778e59 100644 --- a/src/GUI/IntelliInputDialog.cpp +++ b/src/GUI/IntelliInputDialog.cpp @@ -4,6 +4,7 @@ IntelliInputDialog::IntelliInputDialog(QEventLoop* Loop, QString Title, QString Label, int value, int minValue, int maxValue, int step) { + this->valueInt = value; createInputBox(Title, Label, value, minValue, maxValue, step); createConnections(Loop); setValuesOfPalette(); @@ -91,5 +92,5 @@ void IntelliInputDialog::slotCloseEvent(){ } void IntelliInputDialog::slotEingabe(){ - valueInt= QString("%1").arg(Input->value()).toInt(); + valueInt = QString("%1").arg(Input->value()).toInt(); } From b695a25128688b00a8791ceb37a152b4dff7ed09 Mon Sep 17 00:00:00 2001 From: Jan Schuffenhauer Date: Thu, 16 Jan 2020 00:00:27 +0100 Subject: [PATCH 11/12] Fixed Inputboxes and Design Todo pls merge me. --- src/GUI/IntelliInputDialog.cpp | 42 ++++------ src/GUI/IntelliInputDialog.h | 9 +-- src/GUI/IntelliPhotoGui.cpp | 96 +++++++++++------------ src/GUI/IntelliPhotoGui.h | 3 - src/IntelliHelper/IntelliToolsettings.cpp | 12 +++ src/Layer/PaintingArea.cpp | 9 +++ src/Layer/PaintingArea.h | 4 + 7 files changed, 92 insertions(+), 83 deletions(-) diff --git a/src/GUI/IntelliInputDialog.cpp b/src/GUI/IntelliInputDialog.cpp index d778e59..8ed0465 100644 --- a/src/GUI/IntelliInputDialog.cpp +++ b/src/GUI/IntelliInputDialog.cpp @@ -2,18 +2,21 @@ #include -IntelliInputDialog::IntelliInputDialog(QEventLoop* Loop, QString Title, QString Label, int value, int minValue, int maxValue, int step) +IntelliInputDialog::IntelliInputDialog(QString Title, QString Label, int value, int minValue, int maxValue, int step, bool* ok) { this->valueInt = value; + this->notClosed = ok; + if(notClosed != nullptr){ + *notClosed = false; + } createInputBox(Title, Label, value, minValue, maxValue, step); - createConnections(Loop); - setValuesOfPalette(); + createConnections(); setInputBoxStyle(); - Loop->exec(); + this->exec(); } -int IntelliInputDialog::getInt(QEventLoop* Loop, QString Title, QString Label, int value, int minValue, int maxValue, int step){ - IntelliInputDialog dialog(Loop, Title, Label, value, minValue, maxValue, step); +int IntelliInputDialog::getInt(QString Title, QString Label, int value, int minValue, int maxValue, int step, bool* ok){ + IntelliInputDialog dialog(Title, Label, value, minValue, maxValue, step, ok); return dialog.valueInt; } @@ -40,6 +43,7 @@ void IntelliInputDialog::createInputBox(QString Title, QString Label, int value, this->Input = new QSpinBox(); this->Input->setFixedSize(Linesize); this->Input->setRange(minValue,maxValue); + this->Input->setSingleStep(step); this->Input->setValue(value); this->okButton = ButtonBox->button(QDialogButtonBox::Ok); @@ -60,31 +64,13 @@ void IntelliInputDialog::createInputBox(QString Title, QString Label, int value, this->show(); } -void IntelliInputDialog::createConnections(QEventLoop* Loop){ +void IntelliInputDialog::createConnections(){ connect(okButton, SIGNAL(clicked()), this, SLOT(slotEingabe())); - connect(okButton, SIGNAL(clicked()), Loop, SLOT(quit())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(slotCloseEvent())); - connect(cancelButton, SIGNAL(clicked()), Loop, SLOT(quit())); } void IntelliInputDialog::setInputBoxStyle(){ - InputLabel->setPalette(Palette); - Input->setPalette(Palette); - okButton->setPalette(Palette); - cancelButton->setPalette(Palette); - this->setStyleSheet("background-color:rgb(64,64,64)"); -} - -void IntelliInputDialog::setValuesOfPalette(){ - Palette.setBrush(QPalette::HighlightedText, QColor(200, 10, 10)); - Palette.setBrush(QPalette::Highlight, QColor(100, 5, 5)); - Palette.setBrush(QPalette::ButtonText, QColor(255, 255, 255)); - Palette.setBrush(QPalette::Button, QColor(64, 64, 64)); - Palette.setBrush(QPalette::Window, QColor(64, 64, 64)); - Palette.setBrush(QPalette::WindowText, QColor(255, 255, 255)); - Palette.setBrush(QPalette::PlaceholderText, QColor(255, 255, 255)); - Palette.setBrush(QPalette::ToolTipText, QColor(255, 255, 255)); - Palette.setBrush(QPalette::Text, QColor(255, 255, 255)); + this->setStyleSheet("color: white;" "background-color: rgb(64, 64, 64);" "selection-color: rgb(200, 10, 10);" "selection-background-color: rgb(64, 64, 64);"); } void IntelliInputDialog::slotCloseEvent(){ @@ -93,4 +79,8 @@ void IntelliInputDialog::slotCloseEvent(){ void IntelliInputDialog::slotEingabe(){ valueInt = QString("%1").arg(Input->value()).toInt(); + if(notClosed != nullptr){ + *notClosed = true; + } + this->close(); } diff --git a/src/GUI/IntelliInputDialog.h b/src/GUI/IntelliInputDialog.h index 915473e..a8b25da 100644 --- a/src/GUI/IntelliInputDialog.h +++ b/src/GUI/IntelliInputDialog.h @@ -7,10 +7,10 @@ class IntelliInputDialog : public QDialog { Q_OBJECT public: -IntelliInputDialog(QEventLoop* Loop = nullptr, QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); +IntelliInputDialog(QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1, bool* ok = nullptr); -static int getInt(QEventLoop* Loop = nullptr, QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); +static int getInt(QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1, bool* ok = nullptr); public slots: void slotCloseEvent(); @@ -18,8 +18,7 @@ void slotEingabe(); private: void createInputBox(QString Title = nullptr, QString Label = nullptr, int value = 5, int minValue = -2147483647, int maxValue = 2147483647, int step = 1); -void createConnections(QEventLoop* Loop = nullptr); -void setValuesOfPalette(); +void createConnections(); void setInputBoxStyle(); int valueInt; @@ -27,10 +26,10 @@ int valueInt; QGridLayout* Layout; QDialogButtonBox* ButtonBox; QEventLoop loop; +bool* notClosed; const QSize Linesize = QSize(150,20); const QSize Buttonsize = QSize(72,20); -QPalette Palette; QLabel* InputLabel; QSpinBox* Input; QPushButton* okButton; diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index e6a5350..e1a3d2c 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -67,41 +67,54 @@ void IntelliPhotoGui::slotSave(){ // Opens a dialog that allows the user to create a New Layer void IntelliPhotoGui::slotCreateNewLayer(){ + + bool ok1, ok2; // "New Layer" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button - int width = IntelliInputDialog::getInt(&Loop, "New Layer", "Width:", 200, 0, 5000, 1); + int width = IntelliInputDialog::getInt("New Layer", "Width:", 200, 1, paintingArea->getMaxWidth(), 1, &ok1); - int height = IntelliInputDialog::getInt(&Loop, "New Layer", "Height:", 200, 0, 5000, 1); + int height = IntelliInputDialog::getInt("New Layer", "Height:", 200, 1, paintingArea->getMaxHeight(), 1, &ok2); // Create New Layer - paintingArea->addLayer(width,height,0,0); - UpdateGui(); + if(ok1&&ok2){ + paintingArea->addLayer(width,height,0,0); + UpdateGui(); + } } // Opens a dialog that allows the user to delete a Layer void IntelliPhotoGui::slotDeleteLayer(){ + + bool ok1; // "delete Layer" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button - int layerNumber = IntelliInputDialog::getInt(&Loop, "Delete Layer", "Number:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1); + int layerNumber = IntelliInputDialog::getInt("Delete Layer", "Number:", paintingArea->getNumberOfActiveLayer()+1, 1, static_cast(paintingArea->layerBundle.size()), 1, &ok1); // Create New Layer - paintingArea->deleteLayer(layerNumber-1); - UpdateGui(); + if(ok1){ + paintingArea->deleteLayer(layerNumber-1); + UpdateGui(); + } } void IntelliPhotoGui::slotSetActiveAlpha(){ + + bool ok1, ok2; // "Layer to set on" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button - int layer = IntelliInputDialog::getInt(&Loop, "Layer to set on", "Layer:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1); + int layer = IntelliInputDialog::getInt("Layer to set on", "Layer:", paintingArea->getNumberOfActiveLayer()+1, 1, static_cast(paintingArea->layerBundle.size()), 1, &ok1); // "New Alpha" is the title of the window - int alpha = IntelliInputDialog::getInt(&Loop, "Layer to set on", "Layer:", paintingArea->getNumberOfActiveLayer()+1, 1, 501, 1); - paintingArea->setLayerAlpha(layer-1,alpha); - UpdateGui(); + int alpha = IntelliInputDialog::getInt("Layer to set on", "Alpha:", 255, 0, 255, 1, &ok2); + + if(ok1&&ok2){ + paintingArea->setLayerAlpha(layer-1,alpha); + UpdateGui(); + } } void IntelliPhotoGui::slotPositionMoveUp(){ @@ -140,28 +153,31 @@ void IntelliPhotoGui::slotClearActiveLayer(){ // Define the standard Value, min, max, step and ok button // "Red Input" is the title of the window - int red = IntelliInputDialog::getInt(&Loop, "Green Input", "Green:", 255, 0, 255, 1); + int red = IntelliInputDialog::getInt("Green Input", "Green:", 255, 0, 255, 1); // "Green Input" is the title of the window - int green = IntelliInputDialog::getInt(&Loop, "Green Input", "Green:", 255, 0, 255, 1); + int green = IntelliInputDialog::getInt("Green Input", "Green:", 255, 0, 255, 1); // "Blue Input" is the title of the window - int blue = IntelliInputDialog::getInt(&Loop, "Blue Input", "Blue:", 255, 0, 255, 1); + int blue = IntelliInputDialog::getInt("Blue Input", "Blue:", 255, 0, 255, 1); // "Alpha Input" is the title of the window - int alpha = IntelliInputDialog::getInt(&Loop, "Alpha Input", "Alpha:", 255, 0, 255, 1); + int alpha = IntelliInputDialog::getInt("Alpha Input", "Alpha:", 255, 0, 255, 1); paintingArea->floodFill(red, green, blue, alpha); UpdateGui(); } void IntelliPhotoGui::slotSetActiveLayer(){ + bool ok1; // "Layer to set on" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button - int layer = IntelliInputDialog::getInt(&Loop, "Layer to set on", "Layer:", 1, 1, 501, 1); - paintingArea->setLayerActive(layer-1); - UpdateGui(); + int layer = IntelliInputDialog::getInt("Layer to set on", "Layer:", 1, 1, static_cast(paintingArea->layerBundle.size()), 1, &ok1); + if(ok1){ + paintingArea->setLayerActive(layer-1); + UpdateGui(); + } } void IntelliPhotoGui::slotUpdateRenderSettingsOn(){ @@ -255,13 +271,21 @@ void IntelliPhotoGui::slotResetTools(){ } void IntelliPhotoGui::slotSetWidth(){ - paintingArea->Toolsettings.setLineWidth(IntelliInputDialog::getInt(&Loop, "Toolsettings", "Width:", 5, 1, 50, 1)); - EditLineWidth->setText(QString("%1").arg(paintingArea->Toolsettings.getLineWidth())); + bool ok1; + int temp = IntelliInputDialog::getInt("Toolsettings", "Width:", 5, 1, 50, 1, &ok1); + if(ok1){ + paintingArea->Toolsettings.setLineWidth(temp); + EditLineWidth->setText(QString("%1").arg(temp)); + } } void IntelliPhotoGui::slotSetInnerAlpha(){ - paintingArea->Toolsettings.setInnerAlpha(IntelliInputDialog::getInt(&Loop, "Toolsettings", "Width:", 5, 1, 50, 1)); - EditLineInnerAlpha->setText(QString("%1").arg(paintingArea->Toolsettings.getInnerAlpha())); + bool ok1; + int temp = IntelliInputDialog::getInt("Toolsettings", "Width:", 5, 1, 50, 1, &ok1); + if(ok1){ + paintingArea->Toolsettings.setInnerAlpha(temp); + EditLineInnerAlpha->setText(QString("%1").arg(temp)); + } } // Define menu actions that call functions @@ -670,34 +694,8 @@ void IntelliPhotoGui::createGui(){ void IntelliPhotoGui::setIntelliStyle(){ // Set the title setWindowTitle("IntelliPhoto Prototype"); - Palette.setBrush(QPalette::HighlightedText, QColor(200, 10, 10)); - Palette.setBrush(QPalette::Highlight, QColor(100, 5, 5)); - Palette.setBrush(QPalette::ButtonText, QColor(255, 255, 255)); - Palette.setBrush(QPalette::Button, QColor(64, 64, 64)); - Palette.setBrush(QPalette::Window, QColor(64, 64, 64)); - Palette.setBrush(QPalette::WindowText, QColor(255, 255, 255)); - Palette.setBrush(QPalette::PlaceholderText, QColor(255, 255, 255)); - Palette.setBrush(QPalette::ToolTipText, QColor(255, 255, 255)); - Palette.setBrush(QPalette::Text, QColor(255, 255, 255)); // Set style sheet - this->setStyleSheet("background-color:rgb(64,64,64)"); - this->menuBar()->setPalette(Palette); - this->fileMenu->setPalette(Palette); - this->saveAsMenu->setPalette(Palette); - this->optionMenu->setPalette(Palette); - this->helpMenu->setPalette(Palette); - this->renderMenu->setPalette(Palette); - this->toolMenu->setPalette(Palette); - this->layerMenu->setPalette(Palette); - this->colorMenu->setPalette(Palette); - this->toolCreationMenu->setPalette(Palette); - this->toolSettingsMenu->setPalette(Palette); - - this->WidthLine->setPalette(Palette); - this->EditLineWidth->setPalette(Palette); - this->innerAlphaLine->setPalette(Palette); - this->EditLineInnerAlpha->setPalette(Palette); - this->ActiveLayerLine->setPalette(Palette); + this->setStyleSheet("color: white;" "background-color: rgb(64, 64, 64);" "selection-color: rgb(200, 10, 10);" "selection-background-color: rgb(64, 64, 64);"); QString string = QString("background-color: %1").arg(paintingArea->colorPicker.getFirstColor().name()); FirstColorButton->setStyleSheet(string); diff --git a/src/GUI/IntelliPhotoGui.h b/src/GUI/IntelliPhotoGui.h index 8f18180..5142897 100644 --- a/src/GUI/IntelliPhotoGui.h +++ b/src/GUI/IntelliPhotoGui.h @@ -107,7 +107,6 @@ void setDefaultToolValue(); // What we'll draw on PaintingArea* paintingArea; -QEventLoop Loop; const QSize Buttonsize = QSize(35,35); QPixmap preview; @@ -132,8 +131,6 @@ QPushButton* SwitchColorButton; QLabel* ActiveLayerLine; QLabel* ActiveLayerImageLabel; -QPalette Palette; - // The menu widgets QMenu*saveAsMenu; QMenu*fileMenu; diff --git a/src/IntelliHelper/IntelliToolsettings.cpp b/src/IntelliHelper/IntelliToolsettings.cpp index 2232cc0..5436438 100644 --- a/src/IntelliHelper/IntelliToolsettings.cpp +++ b/src/IntelliHelper/IntelliToolsettings.cpp @@ -17,6 +17,12 @@ int IntelliToolsettings::getLineWidth(){ } void IntelliToolsettings::setLineWidth(int LineWidth){ + if(LineWidth < 1){ + LineWidth = 1; + } + else if(LineWidth > 50){ + LineWidth = 50; + } lineWidth = LineWidth; } @@ -25,6 +31,12 @@ int IntelliToolsettings::getInnerAlpha(){ } void IntelliToolsettings::setInnerAlpha(int innerAlpha){ + if(innerAlpha < 0){ + innerAlpha = 0; + } + else if(innerAlpha > 255){ + innerAlpha = 255; + } this->innerAlpha = innerAlpha; } diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index 7b93abc..d42d28f 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -182,6 +182,7 @@ void PaintingArea::moveActiveLayer(int idx){ }else if(idx==-1) { this->selectLayerDown(); } + DummyGui->UpdateGui(); } void PaintingArea::slotActivateLayer(int a){ @@ -253,6 +254,14 @@ int PaintingArea::getHeightOfActive(){ return this->layerBundle[static_cast(activeLayer)].height; } +int PaintingArea::getMaxWidth(){ + return this->maxWidth; +} + +int PaintingArea::getMaxHeight(){ + return this->maxHeight; +} + IntelliImage::ImageType PaintingArea::getTypeOfImageRealLayer(){ return this->layerBundle[static_cast(activeLayer)].image->getTypeOfImage(); } diff --git a/src/Layer/PaintingArea.h b/src/Layer/PaintingArea.h index 95eef55..df53a11 100644 --- a/src/Layer/PaintingArea.h +++ b/src/Layer/PaintingArea.h @@ -169,6 +169,10 @@ int getWidthOfActive(); */ int getHeightOfActive(); +int getMaxWidth(); + +int getMaxHeight(); + IntelliImage::ImageType getTypeOfImageRealLayer(); std::vector getPolygonDataOfRealLayer(); From c7046f3c066b7db837954bc056510fcef2660c96 Mon Sep 17 00:00:00 2001 From: Jan Schuffenhauer Date: Thu, 16 Jan 2020 00:32:42 +0100 Subject: [PATCH 12/12] Fixed some bugs, also its mergable now, without any known issues @DerAnonymos @AshBastian --- src/GUI/IntelliPhotoGui.cpp | 1 - src/Layer/PaintingArea.cpp | 3 ++- src/Tool/IntelliToolPolygon.cpp | 17 ++++++++++++----- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index 0d05d42..572de3e 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -89,7 +89,6 @@ void IntelliPhotoGui::slotCreateNewShapedLayer(){ // Stores button value bool ok1, ok2; - bool ok1, ok2; // "New Layer" is the title of the window // the next tr is the text to display // Define the standard Value, min, max, step and ok button diff --git a/src/Layer/PaintingArea.cpp b/src/Layer/PaintingArea.cpp index d85c84a..5505a3e 100644 --- a/src/Layer/PaintingArea.cpp +++ b/src/Layer/PaintingArea.cpp @@ -32,7 +32,7 @@ PaintingArea::~PaintingArea(){ } void PaintingArea::setRenderSettings(bool isFastRenderingOn){ - if(isFastRenderingOn != renderSettings.isFastRenderering()) { + if(isFastRenderingOn != renderSettings.isFastRenderering() && !Tool->getIsDrawing()) { renderSettings.setFastRendering(isFastRenderingOn); for(auto& layer : layerBundle) { layer.image->updateRendererSetting(isFastRenderingOn); @@ -110,6 +110,7 @@ void PaintingArea::setPolygon(int idx){ delete this->Tool; this->Tool = new IntelliToolPolygon(this,&colorPicker,&Toolsettings, true); isSettingPolygon = true; + this->DummyGui->setToolWidth(5); } } } diff --git a/src/Tool/IntelliToolPolygon.cpp b/src/Tool/IntelliToolPolygon.cpp index c784669..1782d14 100644 --- a/src/Tool/IntelliToolPolygon.cpp +++ b/src/Tool/IntelliToolPolygon.cpp @@ -10,6 +10,9 @@ IntelliToolPolygon::IntelliToolPolygon(PaintingArea* Area, IntelliColorPicker* c isDrawing = false; isInside = false; this->isSettingPolygon = isSettingPolygon; + if(isSettingPolygon){ + Toolsettings->setLineWidth(5); + } this->ActiveType = Tooltype::POLYGON; } @@ -121,14 +124,18 @@ void IntelliToolPolygon::onMouseRightReleased(int x, int y){ } void IntelliToolPolygon::onWheelScrolled(int value){ - IntelliTool::onWheelScrolled(value); - if(!isDrawing) { - Toolsettings->setLineWidth(Toolsettings->getLineWidth() + value); - } + if(!isSettingPolygon){ + IntelliTool::onWheelScrolled(value); + if(!isDrawing) { + Toolsettings->setLineWidth(Toolsettings->getLineWidth() + value); + } + } } void IntelliToolPolygon::onMouseMoved(int x, int y){ - IntelliTool::onMouseMoved(x,y); + if(!isSettingPolygon){ + IntelliTool::onMouseMoved(x,y); + } } bool IntelliToolPolygon::isNearStart(int x, int y, QPoint Startpoint){