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());
}
}