Bug with getting the filetype

This commit is contained in:
Jan Schuffenhauer
2020-01-23 14:15:22 +01:00
parent ede3f512cd
commit 083368dcab
7 changed files with 57 additions and 21 deletions

View File

@@ -3,8 +3,10 @@
#include "IntelliPhotoGui.h" #include "IntelliPhotoGui.h"
#include "Layer/PaintingArea.h" #include "Layer/PaintingArea.h"
#include "QEvent" #include <QEvent>
#include "QCloseEvent" #include <QCloseEvent>
#include <QDebug>
#include <string>
// IntelliPhotoGui constructor // IntelliPhotoGui constructor
IntelliPhotoGui::IntelliPhotoGui(){ IntelliPhotoGui::IntelliPhotoGui(){
@@ -50,6 +52,15 @@ void IntelliPhotoGui::slotOpen(){
// If we have a file name load the image and place // If we have a file name load the image and place
// it in the paintingArea // it in the paintingArea
if (!fileName.isEmpty()) { if (!fileName.isEmpty()) {
if(fileName.length()>3){
if(*(fileName.rend()+1)==QChar('f') &&
*(fileName.rend()+2)==QChar('d') &&
*(fileName.rend()+3)==QChar('i') &&
*(fileName.rend()+4)==QChar('.')){
qDebug() << "works.";
IntelliDatamanager::loadProject(paintingArea,fileName);
}
}
paintingArea->open(fileName); paintingArea->open(fileName);
UpdateGui(); UpdateGui();
} }
@@ -356,6 +367,14 @@ void IntelliPhotoGui::createActions(){
actionSaveAs.append(pngSaveAction); actionSaveAs.append(pngSaveAction);
pngSaveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S)); pngSaveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S));
QAction*projectSaveAction = new QAction("Projekt", this);
projectSaveAction->setData("idf");
// When clicked call IntelliPhotoGui::save()
connect(projectSaveAction, SIGNAL(triggered()), this, SLOT(slotSave()));
// Attach each PNG in save Menu
actionSaveAs.append(projectSaveAction);
projectSaveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
// Create exit action and tie to IntelliPhotoGui::close() // Create exit action and tie to IntelliPhotoGui::close()
actionExit = new QAction(tr("&Exit"), this); actionExit = new QAction(tr("&Exit"), this);
actionExit->setShortcuts(QKeySequence::Quit); actionExit->setShortcuts(QKeySequence::Quit);
@@ -817,6 +836,10 @@ bool IntelliPhotoGui::saveFile(const QByteArray &fileFormat){
return false; return false;
} else { } else {
// Call for the file to be saved // Call for the file to be saved
if(fileFormat == "idf"){
return IntelliDatamanager::saveProject(paintingArea, fileName);
}
return paintingArea->save(fileName, fileFormat.constData()); return paintingArea->save(fileName, fileFormat.constData());
} }
} }

View File

@@ -15,6 +15,7 @@
#include <QLabel> #include <QLabel>
#include <QLineEdit> #include <QLineEdit>
#include "IntelliInputDialog.h" #include "IntelliInputDialog.h"
#include "IntelliHelper/IntelliDatamanager.h"
//for unit testing //for unit testing
class UnitTest; class UnitTest;

View File

@@ -1,16 +1,28 @@
#include "IntelliDatamanager.h" #include "IntelliDatamanager.h"
#include "Layer/PaintingArea.h"
IntelliDatamanager::IntelliDatamanager()
{
bool IntelliDatamanager::saveProject(PaintingArea* Canvas, QString filePath){
QFile openFile(filePath);
if(openFile.open(QIODevice::WriteOnly)){
qDebug() << "works.";
openFile.write("Hahaha");
openFile.close();
return true;
}
return false;
} }
void IntelliDatamanager::saveProject(PaintingArea* Canvas, QString filePath){ bool IntelliDatamanager::loadProject(PaintingArea* Canvas, QString filePath){
QFile openFile(filePath);
if(openFile.open(QIODevice::ReadOnly)){
qDebug() << openFile.readAll();
openFile.close();
return true;
}
return; return false;
}
void IntelliDatamanager::loadProject(PaintingArea* Canvas, QString filePath){
return;
} }

View File

@@ -1,17 +1,16 @@
#ifndef INTELLIDATAMANAGER_H #ifndef INTELLIDATAMANAGER_H
#define INTELLIDATAMANAGER_H #define INTELLIDATAMANAGER_H
#include "Layer/PaintingArea.h"
#include <QFile> #include <QFile>
#include <QDebug>
class IntelliDatamanager class PaintingArea;
{
private:
public: namespace IntelliDatamanager{
void loadProject(PaintingArea* Canvas, QString filePath = "unnamed.idf");
void saveProject(PaintingArea* Canvas, QString filePath = "unnamed.idf"); bool loadProject(PaintingArea* Canvas, QString filePath = "unnamed.idf");
IntelliDatamanager(); bool saveProject(PaintingArea* Canvas, QString filePath = "unnamed.idf");
};
}
#endif // INTELLIDATAMANAGER_H #endif // INTELLIDATAMANAGER_H

View File

@@ -17,6 +17,7 @@
#include "Tool/IntelliToolRectangle.h" #include "Tool/IntelliToolRectangle.h"
#include "Tool/IntelliToolFloodFill.h" #include "Tool/IntelliToolFloodFill.h"
#include "Tool/IntelliToolPolygon.h" #include "Tool/IntelliToolPolygon.h"
#include "GUI/IntelliPhotoGui.h"
PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent) PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)

View File

@@ -7,7 +7,6 @@
#include <QPoint> #include <QPoint>
#include <QWidget> #include <QWidget>
#include <QList> #include <QList>
#include "GUI/IntelliPhotoGui.h"
#include "Image/IntelliImage.h" #include "Image/IntelliImage.h"
#include "Image/IntelliRasterImage.h" #include "Image/IntelliRasterImage.h"
#include "Image/IntelliShapedImage.h" #include "Image/IntelliShapedImage.h"
@@ -16,7 +15,7 @@
//for unit testing //for unit testing
class UnitTest; class UnitTest;
class IntelliPhotoGui;
/*! /*!
* \brief The LayerObject struct holds all the information needed to construct a layer * \brief The LayerObject struct holds all the information needed to construct a layer
*/ */

View File

@@ -1,5 +1,6 @@
#include "IntelliTool.h" #include "IntelliTool.h"
#include "Layer/PaintingArea.h" #include "Layer/PaintingArea.h"
#include "GUI/IntelliPhotoGui.h"
IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings){ IntelliTool::IntelliTool(PaintingArea* Area, IntelliColorPicker* colorPicker, IntelliToolsettings* Toolsettings){
this->Area = Area; this->Area = Area;