Made save project work as well
This commit is contained in:
parent
ec4fc0f830
commit
fe239366b5
@ -116,7 +116,7 @@ void BaseMainWindow::createMenusAndBars()
|
|||||||
actionOpen->setStatusTip("Open an existing project file");
|
actionOpen->setStatusTip("Open an existing project file");
|
||||||
connect(actionOpen, SIGNAL(triggered()), this, SLOT(open_proj()));
|
connect(actionOpen, SIGNAL(triggered()), this, SLOT(open_proj()));
|
||||||
|
|
||||||
QAction *actionSave = new QAction("Save", this);
|
actionSave = new QAction("Save", this);
|
||||||
actionSave->setIcon(QIcon(":/icons/resources/save.png"));
|
actionSave->setIcon(QIcon(":/icons/resources/save.png"));
|
||||||
actionSave->setShortcuts(QKeySequence::Save);
|
actionSave->setShortcuts(QKeySequence::Save);
|
||||||
actionSave->setStatusTip("Save existing project to disk");
|
actionSave->setStatusTip("Save existing project to disk");
|
||||||
|
@ -73,6 +73,7 @@ class BaseMainWindow : public QMainWindow
|
|||||||
QStatusBar *statusBar;
|
QStatusBar *statusBar;
|
||||||
QAction *actionNew;
|
QAction *actionNew;
|
||||||
QAction *actionOpen;
|
QAction *actionOpen;
|
||||||
|
QAction *actionSave;
|
||||||
QProgressBar *progressBar;
|
QProgressBar *progressBar;
|
||||||
DesignWidget *designview;
|
DesignWidget *designview;
|
||||||
};
|
};
|
||||||
|
@ -224,7 +224,9 @@ void MainWindow::new_proj()
|
|||||||
|
|
||||||
if (ok && !item.isEmpty()) {
|
if (ok && !item.isEmpty()) {
|
||||||
disableActions();
|
disableActions();
|
||||||
preload_pcf = "";
|
currentProj = "";
|
||||||
|
currentJson = "";
|
||||||
|
currentPCF = "";
|
||||||
chipArgs.package = package.toStdString().c_str();
|
chipArgs.package = package.toStdString().c_str();
|
||||||
ctx = std::unique_ptr<Context>(new Context(chipArgs));
|
ctx = std::unique_ptr<Context>(new Context(chipArgs));
|
||||||
actionLoadJSON->setEnabled(true);
|
actionLoadJSON->setEnabled(true);
|
||||||
@ -236,14 +238,16 @@ void MainWindow::new_proj()
|
|||||||
|
|
||||||
void MainWindow::load_json(std::string filename, std::string pcf)
|
void MainWindow::load_json(std::string filename, std::string pcf)
|
||||||
{
|
{
|
||||||
preload_pcf = pcf;
|
|
||||||
disableActions();
|
disableActions();
|
||||||
|
currentJson = filename;
|
||||||
|
currentPCF = pcf;
|
||||||
Q_EMIT task->loadfile(filename);
|
Q_EMIT task->loadfile(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::load_pcf(std::string filename)
|
void MainWindow::load_pcf(std::string filename)
|
||||||
{
|
{
|
||||||
disableActions();
|
disableActions();
|
||||||
|
currentPCF = filename;
|
||||||
Q_EMIT task->loadpcf(filename);
|
Q_EMIT task->loadpcf(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,6 +277,7 @@ void MainWindow::open_proj()
|
|||||||
namespace pt = boost::property_tree;
|
namespace pt = boost::property_tree;
|
||||||
|
|
||||||
std::string fn = fileName.toStdString();
|
std::string fn = fileName.toStdString();
|
||||||
|
currentProj = fn;
|
||||||
disableActions();
|
disableActions();
|
||||||
|
|
||||||
pt::ptree root;
|
pt::ptree root;
|
||||||
@ -346,7 +351,35 @@ void MainWindow::open_pcf()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::save_proj() { return false; }
|
bool MainWindow::save_proj()
|
||||||
|
{
|
||||||
|
if (currentProj.empty()) {
|
||||||
|
QString fileName = QFileDialog::getSaveFileName(this, QString("Save Project"), QString(), QString("*.proj"));
|
||||||
|
if (fileName.isEmpty())
|
||||||
|
return false;
|
||||||
|
currentProj = fileName.toStdString();
|
||||||
|
}
|
||||||
|
if (!currentProj.empty()) {
|
||||||
|
namespace pt = boost::property_tree;
|
||||||
|
QFileInfo fi(currentProj.c_str());
|
||||||
|
QDir dir(fi.absoluteDir().absolutePath());
|
||||||
|
std::ofstream f(currentProj);
|
||||||
|
pt::ptree root;
|
||||||
|
root.put("project.version", 1);
|
||||||
|
root.put("project.name", fi.baseName().toStdString());
|
||||||
|
root.put("project.arch.name", ctx->archId().c_str(ctx.get()));
|
||||||
|
root.put("project.arch.type", ctx->archArgsToId(chipArgs).c_str(ctx.get()));
|
||||||
|
root.put("project.arch.package", chipArgs.package);
|
||||||
|
if (!currentJson.empty())
|
||||||
|
root.put("project.input.json", dir.relativeFilePath(currentJson.c_str()).toStdString());
|
||||||
|
if (!currentPCF.empty())
|
||||||
|
root.put("project.input.pcf", dir.relativeFilePath(currentPCF.c_str()).toStdString());
|
||||||
|
pt::write_json(f, root);
|
||||||
|
log_info("Project %s saved...\n", fi.baseName().toStdString().c_str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::save_asc()
|
void MainWindow::save_asc()
|
||||||
{
|
{
|
||||||
@ -374,6 +407,7 @@ void MainWindow::disableActions()
|
|||||||
|
|
||||||
actionNew->setEnabled(true);
|
actionNew->setEnabled(true);
|
||||||
actionOpen->setEnabled(true);
|
actionOpen->setEnabled(true);
|
||||||
|
actionSave->setEnabled(!currentJson.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::loadfile_finished(bool status)
|
void MainWindow::loadfile_finished(bool status)
|
||||||
@ -383,12 +417,12 @@ void MainWindow::loadfile_finished(bool status)
|
|||||||
log("Loading design successful.\n");
|
log("Loading design successful.\n");
|
||||||
actionLoadPCF->setEnabled(true);
|
actionLoadPCF->setEnabled(true);
|
||||||
actionPack->setEnabled(true);
|
actionPack->setEnabled(true);
|
||||||
if (!preload_pcf.empty())
|
if (!currentPCF.empty())
|
||||||
load_pcf(preload_pcf);
|
load_pcf(currentPCF);
|
||||||
Q_EMIT updateTreeView();
|
Q_EMIT updateTreeView();
|
||||||
} else {
|
} else {
|
||||||
log("Loading design failed.\n");
|
log("Loading design failed.\n");
|
||||||
preload_pcf = "";
|
currentPCF = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,10 @@ class MainWindow : public BaseMainWindow
|
|||||||
|
|
||||||
bool timing_driven;
|
bool timing_driven;
|
||||||
ArchArgs chipArgs;
|
ArchArgs chipArgs;
|
||||||
std::string preload_pcf;
|
|
||||||
|
std::string currentProj;
|
||||||
|
std::string currentJson;
|
||||||
|
std::string currentPCF;
|
||||||
};
|
};
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -10,9 +10,6 @@
|
|||||||
"input": {
|
"input": {
|
||||||
"json": "blinky.json",
|
"json": "blinky.json",
|
||||||
"pcf": "blinky.pcf"
|
"pcf": "blinky.pcf"
|
||||||
},
|
|
||||||
"params": {
|
|
||||||
"freq": "50"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user