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 "Layer/PaintingArea.h"
#include "QEvent"
#include "QCloseEvent"
#include <QEvent>
#include <QCloseEvent>
#include <QDebug>
#include <string>
// IntelliPhotoGui constructor
IntelliPhotoGui::IntelliPhotoGui(){
@@ -50,6 +52,15 @@ void IntelliPhotoGui::slotOpen(){
// If we have a file name load the image and place
// it in the paintingArea
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);
UpdateGui();
}
@@ -356,6 +367,14 @@ void IntelliPhotoGui::createActions(){
actionSaveAs.append(pngSaveAction);
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()
actionExit = new QAction(tr("&Exit"), this);
actionExit->setShortcuts(QKeySequence::Quit);
@@ -817,6 +836,10 @@ bool IntelliPhotoGui::saveFile(const QByteArray &fileFormat){
return false;
} else {
// Call for the file to be saved
if(fileFormat == "idf"){
return IntelliDatamanager::saveProject(paintingArea, fileName);
}
return paintingArea->save(fileName, fileFormat.constData());
}
}

View File

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

View File

@@ -1,16 +1,28 @@
#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;
}
void IntelliDatamanager::loadProject(PaintingArea* Canvas, QString filePath){
return;
return false;
}

View File

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

View File

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

View File

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

View File

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