1 #include "NewProjectDialog.h"
3 NewProjectDialog::NewProjectDialog(Parameters *_params, QWidget *parent) : CustomDialog(tr("Create a new project"),tr("Location"), parent) {
7 QHBoxLayout *layNameProj = new QHBoxLayout;
8 QLabel *nameProjLab = new QLabel(tr("Name :"));
9 nameProjEdit = new QLineEdit();
10 nameProjEdit->setMaxLength(100);
11 nameProjEdit->setText("");
13 layNameProj->addWidget(nameProjLab);
14 layNameProj->addWidget(nameProjEdit);
16 QHBoxLayout *layDirProj = new QHBoxLayout;
17 QLabel *dirProjLab = new QLabel(tr("Path :"));
18 dirProjEdit = new QLineEdit("");
19 dirProjEdit->setMaxLength(500);
20 dirProjButton = new QPushButton(QIcon(":/images/filefind.png"),"");
21 dirProjButton->setFixedWidth(30);
24 layDirProj->addWidget(dirProjLab);
25 layDirProj->addWidget(dirProjEdit);
26 layDirProj->addWidget(dirProjButton);
29 QVBoxLayout *layAll = new QVBoxLayout;
30 layAll->addLayout(layNameProj);
31 layAll->addLayout(layDirProj);
35 connect(dirProjButton,SIGNAL(clicked()),this,SLOT(chooseProjectPath()));
36 connect(nameProjEdit,SIGNAL(textChanged(QString)),this,SLOT(checkProjectName(QString)));
37 connect(dirProjEdit,SIGNAL(textChanged(QString)),this,SLOT(checkProjectPath(QString)));
41 void NewProjectDialog::checkBeforeAccept() {
43 if ((!nameProjEdit->text().isEmpty()) && (pathOk)) {
44 //cout << "all ok" << endl;
45 params->projectPath = dirProjEdit->text();
46 params->projectFile = params->projectPath + "/" + params->projectName + ".xml";
51 int ret = QMessageBox::warning(this,"Cannot create the project","Invalid project path");
56 void NewProjectDialog::chooseProjectPath() {
59 where = QDir::currentPath();
60 QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),where);
61 dirProjEdit->setText(dir);
64 void NewProjectDialog::checkProjectPath(QString name) {
74 void NewProjectDialog::checkProjectName(QString name) {
75 params->projectName = Parameters::normalizeName(name);
76 if (name != params->projectName) {
77 nameProjEdit->setText(params->projectName);