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);
28 QHBoxLayout *layClk = new QHBoxLayout;
29 QLabel* clkLab1 = new QLabel(tr("Main clock freq."));
30 QLabel* clkLab2 = new QLabel(tr("MHz"));
31 clkEdit = new QLineEdit("100");
32 layClk->addWidget(clkLab1);
33 layClk->addWidget(clkEdit);
34 layClk->addWidget(clkLab2);
36 QHBoxLayout *layAuto = new QHBoxLayout;
37 autoConnClkCheck = new QCheckBox("Auto-connect blocks to main clock");
38 autoConnClkCheck->setChecked(true);
39 layAuto->addWidget(autoConnClkCheck);
42 QVBoxLayout *layAll = new QVBoxLayout;
43 layAll->addLayout(layNameProj);
44 layAll->addLayout(layDirProj);
45 layAll->addLayout(layClk);
46 layAll->addLayout(layAuto);
50 connect(dirProjButton,SIGNAL(clicked()),this,SLOT(chooseProjectPath()));
51 connect(nameProjEdit,SIGNAL(textChanged(QString)),this,SLOT(checkProjectName(QString)));
52 connect(dirProjEdit,SIGNAL(textChanged(QString)),this,SLOT(checkProjectPath(QString)));
56 void NewProjectDialog::checkBeforeAccept() {
58 if ((nameProjEdit->text().isEmpty()) || (!pathOk)) {
60 int ret = QMessageBox::warning(this,"Cannot create the project","Invalid project path");
65 freq = clkEdit->text().toDouble(&ok);
67 int ret = QMessageBox::warning(this,"Cannot create the project","Invalid main clock frequency (in MHz)");
71 //cout << "all ok" << endl;
72 params->projectPath = dirProjEdit->text();
73 params->projectFile = params->projectPath + "/" + params->projectName + ".xml";
74 params->clocks.append(freq);
75 if (autoConnClkCheck->isChecked()) {
76 params->autoConnMainClk = true;
79 params->autoConnMainClk = false;
86 void NewProjectDialog::chooseProjectPath() {
89 where = QDir::currentPath();
90 QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"),where);
91 dirProjEdit->setText(dir);
94 void NewProjectDialog::checkProjectPath(QString name) {
104 void NewProjectDialog::checkProjectName(QString name) {
105 params->projectName = Parameters::normalizeName(name);
106 if (name != params->projectName) {
107 nameProjEdit->setText(params->projectName);