This commit is contained in:
Mienek
2019-12-05 21:36:23 +01:00
parent fd1a6d2f9d
commit f2c56c27be
44 changed files with 5303 additions and 13 deletions

View File

@@ -9,7 +9,7 @@
// IntelliPhotoGui constructor
IntelliPhotoGui::IntelliPhotoGui()
{
//create Gui elemnts and lay them out
//create Gui elements and lay them out
createGui();
// Create actions
createActions();
@@ -101,6 +101,30 @@ void IntelliPhotoGui::penWidth()
paintingArea->setPenWidth(newWidth);
}
// Opens a dialog that allows the user to create a new Layer
void IntelliPhotoGui::newLayer()
{
// Stores button value
bool ok;
// tr("new Layer") is the title
// the next tr is the text to display
// Get the current pen width
// Define the min, max, step and ok button
int width = QInputDialog::getInt(this, tr("new Layer"),
tr("Width:"),
200,1, 500, 1, &ok);
int height = QInputDialog::getInt(this, tr("new Layer"),
tr("Height:"),
200,1, 500, 1, &ok);
// Change the pen width
if (ok)
{
int layer = paintingArea->addLayer(width,height,100,100);
paintingArea->activate(layer);
}
}
// Open an about dialog
void IntelliPhotoGui::about()
{
@@ -247,6 +271,10 @@ void IntelliPhotoGui::createActions()
connect(clearScreenAct, SIGNAL(triggered()),
this, SLOT(onClearedPressed()));
// Create New Layer action and tie to IntelliPhotoGui::newLayer()
newLayerAct = new QAction(tr("&new Layer..."), this);
connect(newLayerAct, SIGNAL(triggered()), this, SLOT(newLayer()));
// Create about action and tie to IntelliPhotoGui::about()
aboutAct = new QAction(tr("&About"), this);
connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
@@ -279,6 +307,10 @@ void IntelliPhotoGui::createMenus()
optionMenu->addSeparator();
optionMenu->addAction(clearScreenAct);
// Attach all actions to Layer
layerMenu = new QMenu(tr("&Layer"), this);
layerMenu->addAction(newLayerAct);
// Attach all actions to Help
helpMenu = new QMenu(tr("&Help"), this);
helpMenu->addAction(aboutAct);
@@ -287,6 +319,7 @@ void IntelliPhotoGui::createMenus()
// Add menu items to the menubar
menuBar()->addMenu(fileMenu);
menuBar()->addMenu(optionMenu);
menuBar()->addMenu(layerMenu);
menuBar()->addMenu(helpMenu);
}

View File

@@ -41,6 +41,7 @@ private slots:
void save();
void penColor();
void penWidth();
void newLayer();
void about();
void onClearedPressed();
@@ -77,6 +78,7 @@ private:
QMenu *saveAsMenu;
QMenu *fileMenu;
QMenu *optionMenu;
QMenu *layerMenu;
QMenu *helpMenu;
@@ -89,6 +91,7 @@ private:
QAction *penColorAct;
QAction *penWidthAct;
QAction *clearScreenAct;
QAction *newLayerAct;
QAction *aboutAct;
QAction *aboutQtAct;

View File

@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.10.2, 2019-12-05T18:54:17. -->
<!-- Written by QtCreator 4.10.2, 2019-12-05T21:34:14. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{87de10b7-9dd6-4379-8674-fd04613e186e}</value>
<value type="QByteArray">{925716f2-f0a7-494d-9759-615ec266a3b3}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
@@ -71,7 +71,7 @@
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/Jonas/Documents/GitHub/intelliphoto/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/Mienek/Documents/intelliphoto/src/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@@ -127,7 +127,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/Jonas/Documents/GitHub/intelliphoto/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/Mienek/Documents/intelliphoto/src/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@@ -183,7 +183,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/Jonas/Documents/GitHub/intelliphoto/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/Mienek/Documents/intelliphoto/src/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@@ -306,8 +306,8 @@
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">IntelliPhoto</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">IntelliPhoto2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Jonas/Documents/GitHub/intelliphoto/src/Painting/IntelliPhoto.pro</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:C:/Users/Mienek/Documents/intelliphoto/src/Painting/IntelliPhoto.pro</value>
<value type="QString" key="RunConfiguration.Arguments"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
@@ -317,7 +317,7 @@
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Users/Jonas/Documents/GitHub/intelliphoto/IntelliPhoto/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug</value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">C:/Users/Mienek/Documents/intelliphoto/src/build-IntelliPhoto-Desktop_Qt_5_12_5_MinGW_64_bit-Debug</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>

View File

@@ -27,6 +27,7 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget *parent)
this->addLayer(200,200,150,150);
layerStructure[1].image->floodFill(QColor(0,255,0,255));
layerStructure[1].alpha=200;
activeLayer=1;
}
@@ -50,7 +51,7 @@ void PaintingArea::setUp(int maxWidth, int maxHeight){
myPenColor = Qt::blue;
}
void PaintingArea::addLayer(int width, int height, int widthOffset, int heightOffset, ImageType type){
int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOffset, ImageType type){
LayerObject newLayer;
newLayer.width = width;
newLayer.height = height;
@@ -63,7 +64,7 @@ void PaintingArea::addLayer(int width, int height, int widthOffset, int heightOf
}
newLayer.alpha = 255;
this->layerStructure.push_back(newLayer);
return layerStructure.size()-1;
}
void PaintingArea::deleteLayer(int index){
@@ -180,7 +181,7 @@ void PaintingArea::getMoveLeft(int a){
}
void PaintingArea::getMoveLayerUp(){
if(activeLayer<layerStructure.size() && activeLayer>=0){
if(activeLayer<layerStructure.size()-1 && activeLayer>=0){
std::swap(layerStructure[activeLayer], layerStructure[activeLayer+1]);
activeLayer++;
}

View File

@@ -23,7 +23,7 @@ public:
bool openImage(const QString &fileName);
bool saveImage(const QString &fileName, const char *fileFormat);
void addLayer(int width, int height, int widthOffset=0, int heightOffset=0, ImageType type = ImageType::Raster_Image);
int addLayer(int width, int height, int widthOffset=0, int heightOffset=0, ImageType type = ImageType::Raster_Image);
void deleteLayer(int index);
void setLayerToActive(int index);
void setAlphaToLayer(int index, int alpha);