Skip to content

Commit

Permalink
Fix the loader dialog acception logic
Browse files Browse the repository at this point in the history
  • Loading branch information
psycha0s committed Apr 13, 2015
1 parent c44e6d9 commit 745dd4b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/manager/forms/loaderdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QGridLayout>
#include <QIcon>
#include <QLabel>
#include <QMessageBox>
#include "core/application.h"
#include "forms/filedialog.h"
#include "models/loadersmodel.h"
Expand Down Expand Up @@ -99,16 +100,28 @@ void LoaderDialog::setItem(LoaderItem* item)

void LoaderDialog::accept()
{
QString name = nameEdit_->text();
QString message = QString("The loader with name '%1' is already exist.").arg(name);

if(!item_) {
if(!qApp->loaders()->createLoader(nameEdit_->text(), pathEdit_->text())) {
// TODO messagebox
QMessageBox::critical(this, "Error", message);
return;
}
}
else {
else if(name != item_->name()) {
Storage::Loader loader = qApp->storage()->loader(name.toStdString());
if(!loader.isNull()) {
QMessageBox::critical(this, "Error", message);
return;
}

item_->setName(nameEdit_->text());
item_->setPath(pathEdit_->text());
}
else {
item_->setPath(pathEdit_->text());
}

QDialog::accept();
}

0 comments on commit 745dd4b

Please sign in to comment.