| 1 |
/****************************************************************************** |
| 2 |
This source file is part of the Avogadro project. |
| 3 |
This source code is released under the 3-Clause BSD License, (see "LICENSE"). |
| 4 |
******************************************************************************/ |
| 5 |
|
| 6 |
#include "inputgeneratordialog.h" |
| 7 |
#include "ui_inputgeneratordialog.h" |
| 8 |
|
| 9 |
#include "inputgeneratorwidget.h" |
| 10 |
|
| 11 |
namespace Avogadro::MoleQueue { |
| 12 |
|
| 13 |
using QtGui::Molecule; |
| 14 |
|
| 15 |
InputGeneratorDialog::InputGeneratorDialog(QWidget* parent_) |
| 16 |
: QDialog(parent_), ui(new Ui::InputGeneratorDialog) |
| 17 |
{ |
| 18 |
ui->setupUi(this); |
| 19 |
connect(ui->widget, SIGNAL(closeClicked()), SLOT(accept())); |
| 20 |
} |
| 21 |
|
| 22 |
InputGeneratorDialog::InputGeneratorDialog(const QString& scriptFileName, |
| 23 |
QWidget* parent_) |
| 24 |
: QDialog(parent_), ui(new Ui::InputGeneratorDialog) |
| 25 |
{ |
| 26 |
ui->setupUi(this); |
| 27 |
connect(ui->widget, SIGNAL(closeClicked()), SLOT(accept())); |
| 28 |
this->setInputGeneratorScript(scriptFileName); |
| 29 |
} |
| 30 |
|
| 31 |
InputGeneratorDialog::~InputGeneratorDialog() |
| 32 |
{ |
| 33 |
delete ui; |
| 34 |
} |
| 35 |
|
| 36 |
void InputGeneratorDialog::setInputGeneratorScript(const QString& scriptFile) |
| 37 |
{ |
| 38 |
ui->widget->setInputGeneratorScript(scriptFile); |
| 39 |
QString displayName(ui->widget->inputGenerator().displayName()); |
| 40 |
|
| 41 |
if (displayName.endsWith("…")) |
| 42 |
displayName.chop(1); |
| 43 |
else if (displayName.endsWith("...")) |
| 44 |
displayName.chop(3); |
| 45 |
|
| 46 |
if (ui->widget->inputGenerator().hasErrors()) |
| 47 |
setWindowTitle(tr("Input Generator (error)").arg(displayName)); |
| 48 |
else |
| 49 |
setWindowTitle(tr("%1 Input Generator").arg(displayName)); |
| 50 |
} |
| 51 |
|
| 52 |
InputGeneratorWidget& InputGeneratorDialog::widget() |
| 53 |
{ |
| 54 |
return *ui->widget; |
| 55 |
} |
| 56 |
|
| 57 |
const InputGeneratorWidget& InputGeneratorDialog::widget() const |
| 58 |
{ |
| 59 |
return *ui->widget; |
| 60 |
} |
| 61 |
|
| 62 |
bool InputGeneratorDialog::configureBatchJob(BatchJob& batch) |
| 63 |
{ |
| 64 |
ui->widget->setBatchMode(true); |
| 65 |
auto reply = static_cast<DialogCode>(exec()); |
| 66 |
if (reply != Accepted) |
| 67 |
return false; |
| 68 |
|
| 69 |
return ui->widget->configureBatchJob(batch); |
| 70 |
} |
| 71 |
|
| 72 |
void InputGeneratorDialog::setMolecule(Molecule* mol) |
| 73 |
{ |
| 74 |
ui->widget->setMolecule(mol); |
| 75 |
} |
| 76 |
|
| 77 |
} // namespace Avogadro::MoleQueue |