From a99ad09e8cc67fc8771c28e1881e746487d6427a Mon Sep 17 00:00:00 2001 From: AshBastian Date: Wed, 8 Jan 2020 19:55:34 +0100 Subject: [PATCH] Dummy Gui --- src/Bilder.qrc | 5 ++ src/GUI/IntelliPhotoGui.cpp | 93 ++++++++++++++++++++++++++++++++++--- src/GUI/IntelliPhotoGui.h | 23 ++++++++- src/IntelliPhoto.pro | 3 ++ src/Layer/PaintingArea.h | 3 +- 5 files changed, 118 insertions(+), 9 deletions(-) create mode 100644 src/Bilder.qrc diff --git a/src/Bilder.qrc b/src/Bilder.qrc new file mode 100644 index 0000000..f755a3d --- /dev/null +++ b/src/Bilder.qrc @@ -0,0 +1,5 @@ + + + icons/icon.png + + diff --git a/src/GUI/IntelliPhotoGui.cpp b/src/GUI/IntelliPhotoGui.cpp index f605ad3..a686e5f 100644 --- a/src/GUI/IntelliPhotoGui.cpp +++ b/src/GUI/IntelliPhotoGui.cpp @@ -1,8 +1,5 @@ // ---------- IntelliPhotoGui.cpp ---------- -#include -#include - #include "IntelliPhotoGui.h" #include "Layer/PaintingArea.h" @@ -19,7 +16,7 @@ IntelliPhotoGui::IntelliPhotoGui(){ // Size the app resize(600,600); showMaximized(); - + setDefaultToolValue(); } // User tried to close the app @@ -245,6 +242,11 @@ void IntelliPhotoGui::slotAboutDialog(){ tr("

IntelliPhotoPretty basic editor.

")); } +void IntelliPhotoGui::slotEnterPressed(){ + QString string = EditLineWidth->text(); + paintingArea->Toolsettings.setLineWidth(string.toInt()); +} + // Define menu actions that call functions void IntelliPhotoGui::createActions(){ // Get a list of the supported file formats @@ -361,6 +363,9 @@ void IntelliPhotoGui::createActions(){ // Create about Qt action and tie to IntelliPhotoGui::aboutQt() actionAboutQtDialog = new QAction(tr("About &Qt"), this); connect(actionAboutQtDialog, SIGNAL(triggered()), qApp, SLOT(aboutQt())); + + actionPressEnter = new QAction(); + connect(EditLineWidth, SIGNAL(returnPressed()), this, SLOT(slotEnterPressed())); } // Create the menubar @@ -436,11 +441,81 @@ void IntelliPhotoGui::createGui(){ // create Gui elements paintingArea = new PaintingArea(); - Push + + QPixmap p(":/Icons/Buttons/icons/icon.png"); + + CircleButton = new QPushButton(); + CircleButton->setFixedSize(Buttonsize); + CircleButton->setIcon(p); + CircleButton->setIconSize(Buttonsize); + + FloodFillButton = new QPushButton(); + FloodFillButton->setFixedSize(Buttonsize); + FloodFillButton->setIcon(p); + FloodFillButton->setIconSize(Buttonsize); + + LineButton = new QPushButton(); + LineButton->setFixedSize(Buttonsize); + LineButton->setIcon(p); + LineButton->setIconSize(Buttonsize); + + PenButton = new QPushButton(); + PenButton->setFixedSize(Buttonsize); + PenButton->setIcon(p); + PenButton->setIconSize(Buttonsize); + + PlainButton = new QPushButton(); + PlainButton->setFixedSize(Buttonsize); + PlainButton->setIcon(p); + PlainButton->setIconSize(Buttonsize); + + PolygonButton = new QPushButton(); + PolygonButton->setFixedSize(Buttonsize); + PolygonButton->setIcon(p); + PolygonButton->setIconSize(Buttonsize); + + RectangleButton = new QPushButton(); + RectangleButton->setFixedSize(Buttonsize); + RectangleButton->setIcon(p); + RectangleButton->setIconSize(Buttonsize); + + WidthLine = new QLabel(); + WidthLine->setText("Width"); + WidthLine->setFixedSize(QSize(100,20)); + + EditLineWidth = new QLineEdit(); + EditLineWidth->setFixedSize(QSize(50,20)); + EditLineWidth->setText("5"); + ValidatorLineWidth = new QIntValidator(); + ValidatorLineWidth->setTop(50); + ValidatorLineWidth->setBottom(1); + EditLineWidth->setValidator(ValidatorLineWidth); + + innerAlphaLine = new QLabel(); + innerAlphaLine->setText("Inner Alpha"); + innerAlphaLine->setFixedSize(QSize(100,20)); + + EditLineInnerAlpha = new QLineEdit(); + EditLineInnerAlpha->setFixedSize(QSize(50,20)); + EditLineInnerAlpha->setText("255"); + ValidatorInnerAlpha = new QIntValidator(); + ValidatorInnerAlpha->setTop(255); + ValidatorInnerAlpha->setBottom(0); + EditLineInnerAlpha->setValidator(ValidatorInnerAlpha); // set gui elements - mainLayout->addWidget(paintingArea,1,1,10,10); - mainLayout->addWiget(); + mainLayout->addWidget(paintingArea,1,1,20,1); + mainLayout->addWidget(CircleButton,1,2,1,1); + mainLayout->addWidget(FloodFillButton,2,2,1,1); + mainLayout->addWidget(LineButton,3,2,1,1); + mainLayout->addWidget(PenButton,4,2,1,1); + mainLayout->addWidget(PlainButton,5,2,1,1); + mainLayout->addWidget(PolygonButton,6,2,1,1); + mainLayout->addWidget(RectangleButton,7,2,1,1); + mainLayout->addWidget(WidthLine,8,2,1,1); + mainLayout->addWidget(EditLineWidth,9,2,1,1); + mainLayout->addWidget(innerAlphaLine,10,2,1,1); + mainLayout->addWidget(EditLineInnerAlpha,11,2,1,1); } void IntelliPhotoGui::setIntelliStyle(){ @@ -499,3 +574,7 @@ bool IntelliPhotoGui::saveFile(const QByteArray &fileFormat){ return paintingArea->save(fileName, fileFormat.constData()); } } + +void IntelliPhotoGui::setDefaultToolValue(){ + slotEnterPressed(); +} diff --git a/src/GUI/IntelliPhotoGui.h b/src/GUI/IntelliPhotoGui.h index 6d478be..0cb9173 100644 --- a/src/GUI/IntelliPhotoGui.h +++ b/src/GUI/IntelliPhotoGui.h @@ -1,6 +1,8 @@ #ifndef IntelliPhotoGui_H #define IntelliPhotoGui_H +#include +#include #include #include #include @@ -69,6 +71,8 @@ void slotCreateFloodFillTool(); // slots for dialogs void slotAboutDialog(); +void slotEnterPressed(); + private: // Will tie user actions to functions void createActions(); @@ -83,10 +87,25 @@ bool maybeSave(); // Opens the Save dialog and saves bool saveFile(const QByteArray &fileFormat); +void setDefaultToolValue(); + // What we'll draw on PaintingArea* paintingArea; -QPushButton* PushButton; +const QSize Buttonsize = QSize(50,50); +QPushButton* CircleButton; +QPushButton* FloodFillButton; +QPushButton* LineButton; +QPushButton* PenButton; +QPushButton* PlainButton; +QPushButton* PolygonButton; +QPushButton* RectangleButton; +QLabel* WidthLine; +QLabel* innerAlphaLine; +QLineEdit* EditLineWidth; +QLineEdit* EditLineInnerAlpha; +QIntValidator* ValidatorLineWidth; +QIntValidator* ValidatorInnerAlpha; // The menu widgets QMenu*saveAsMenu; @@ -116,6 +135,8 @@ QAction*actionCreateCircleTool; QAction*actionCreatePolygonTool; QAction*actionCreateFloodFillTool; +QAction*actionPressEnter; + // dialog actions QAction*actionAboutDialog; QAction*actionAboutQtDialog; diff --git a/src/IntelliPhoto.pro b/src/IntelliPhoto.pro index 9b8d9c0..65bbd9f 100644 --- a/src/IntelliPhoto.pro +++ b/src/IntelliPhoto.pro @@ -65,3 +65,6 @@ ICON = icon.icns qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target + +RESOURCES += \ + Bilder.qrc diff --git a/src/Layer/PaintingArea.h b/src/Layer/PaintingArea.h index 4d0f99b..8b65d5b 100644 --- a/src/Layer/PaintingArea.h +++ b/src/Layer/PaintingArea.h @@ -165,6 +165,8 @@ public: std::vector getPolygonDataOfRealLayer(); + IntelliToolsettings Toolsettings; + public slots: // Events to handle /*! @@ -202,7 +204,6 @@ private: IntelliTool* Tool; IntelliColorPicker colorPicker; - IntelliToolsettings Toolsettings; std::vector layerBundle; int activeLayer=-1;