gui for json write and proper statuses
This commit is contained in:
parent
053bd48bef
commit
0d8c80ad5d
@ -255,7 +255,7 @@ int CommandHandler::executeMain(std::unique_ptr<Context> ctx)
|
|||||||
|
|
||||||
customAfterLoad(w.getContext());
|
customAfterLoad(w.getContext());
|
||||||
w.notifyChangeContext();
|
w.notifyChangeContext();
|
||||||
w.updateLoaded();
|
w.updateActions();
|
||||||
} else
|
} else
|
||||||
w.notifyChangeContext();
|
w.notifyChangeContext();
|
||||||
} catch (log_execution_error_exception) {
|
} catch (log_execution_error_exception) {
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
<file>resources/route.png</file>
|
<file>resources/route.png</file>
|
||||||
<file>resources/time_add.png</file>
|
<file>resources/time_add.png</file>
|
||||||
<file>resources/open_json.png</file>
|
<file>resources/open_json.png</file>
|
||||||
|
<file>resources/save_json.png</file>
|
||||||
<file>resources/py.png</file>
|
<file>resources/py.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "designwidget.h"
|
#include "designwidget.h"
|
||||||
#include "fpgaviewwidget.h"
|
#include "fpgaviewwidget.h"
|
||||||
#include "jsonparse.h"
|
#include "jsonparse.h"
|
||||||
|
#include "jsonwrite.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "pythontab.h"
|
#include "pythontab.h"
|
||||||
@ -138,13 +139,26 @@ void BaseMainWindow::createMenusAndBars()
|
|||||||
// Help menu actions
|
// Help menu actions
|
||||||
QAction *actionAbout = new QAction("About", this);
|
QAction *actionAbout = new QAction("About", this);
|
||||||
|
|
||||||
// Design menu options
|
// Gile menu options
|
||||||
|
actionNew = new QAction("New", this);
|
||||||
|
actionNew->setIcon(QIcon(":/icons/resources/new.png"));
|
||||||
|
actionNew->setShortcuts(QKeySequence::New);
|
||||||
|
actionNew->setStatusTip("New project");
|
||||||
|
connect(actionNew, &QAction::triggered, this, &BaseMainWindow::new_proj);
|
||||||
|
|
||||||
actionLoadJSON = new QAction("Open JSON", this);
|
actionLoadJSON = new QAction("Open JSON", this);
|
||||||
actionLoadJSON->setIcon(QIcon(":/icons/resources/open_json.png"));
|
actionLoadJSON->setIcon(QIcon(":/icons/resources/open_json.png"));
|
||||||
actionLoadJSON->setStatusTip("Open an existing JSON file");
|
actionLoadJSON->setStatusTip("Open an existing JSON file");
|
||||||
actionLoadJSON->setEnabled(true);
|
actionLoadJSON->setEnabled(true);
|
||||||
connect(actionLoadJSON, &QAction::triggered, this, &BaseMainWindow::open_json);
|
connect(actionLoadJSON, &QAction::triggered, this, &BaseMainWindow::open_json);
|
||||||
|
|
||||||
|
actionSaveJSON = new QAction("Save JSON", this);
|
||||||
|
actionSaveJSON->setIcon(QIcon(":/icons/resources/save_json.png"));
|
||||||
|
actionSaveJSON->setStatusTip("Write to JSON file");
|
||||||
|
actionSaveJSON->setEnabled(true);
|
||||||
|
connect(actionSaveJSON, &QAction::triggered, this, &BaseMainWindow::save_json);
|
||||||
|
|
||||||
|
// Design menu options
|
||||||
actionPack = new QAction("Pack", this);
|
actionPack = new QAction("Pack", this);
|
||||||
actionPack->setIcon(QIcon(":/icons/resources/pack.png"));
|
actionPack->setIcon(QIcon(":/icons/resources/pack.png"));
|
||||||
actionPack->setStatusTip("Pack current design");
|
actionPack->setStatusTip("Pack current design");
|
||||||
@ -223,10 +237,13 @@ void BaseMainWindow::createMenusAndBars()
|
|||||||
menuBar->addAction(menuHelp->menuAction());
|
menuBar->addAction(menuHelp->menuAction());
|
||||||
|
|
||||||
// Add File menu actions
|
// Add File menu actions
|
||||||
|
menuFile->addAction(actionNew);
|
||||||
|
menuFile->addAction(actionLoadJSON);
|
||||||
|
menuFile->addAction(actionSaveJSON);
|
||||||
|
menuFile->addSeparator();
|
||||||
menuFile->addAction(actionExit);
|
menuFile->addAction(actionExit);
|
||||||
|
|
||||||
// Add Design menu actions
|
// Add Design menu actions
|
||||||
menuDesign->addAction(actionLoadJSON);
|
|
||||||
menuDesign->addAction(actionPack);
|
menuDesign->addAction(actionPack);
|
||||||
menuDesign->addAction(actionAssignBudget);
|
menuDesign->addAction(actionAssignBudget);
|
||||||
menuDesign->addAction(actionPlace);
|
menuDesign->addAction(actionPlace);
|
||||||
@ -240,7 +257,10 @@ void BaseMainWindow::createMenusAndBars()
|
|||||||
// Main action bar
|
// Main action bar
|
||||||
mainActionBar = new QToolBar("Main");
|
mainActionBar = new QToolBar("Main");
|
||||||
addToolBar(Qt::TopToolBarArea, mainActionBar);
|
addToolBar(Qt::TopToolBarArea, mainActionBar);
|
||||||
|
mainActionBar->addAction(actionNew);
|
||||||
mainActionBar->addAction(actionLoadJSON);
|
mainActionBar->addAction(actionLoadJSON);
|
||||||
|
mainActionBar->addAction(actionSaveJSON);
|
||||||
|
mainActionBar->addSeparator();
|
||||||
mainActionBar->addAction(actionPack);
|
mainActionBar->addAction(actionPack);
|
||||||
mainActionBar->addAction(actionAssignBudget);
|
mainActionBar->addAction(actionAssignBudget);
|
||||||
mainActionBar->addAction(actionPlace);
|
mainActionBar->addAction(actionPlace);
|
||||||
@ -280,7 +300,7 @@ void BaseMainWindow::load_json(std::string filename)
|
|||||||
if (parse_json_file(f, filename, ctx.get())) {
|
if (parse_json_file(f, filename, ctx.get())) {
|
||||||
log("Loading design successful.\n");
|
log("Loading design successful.\n");
|
||||||
Q_EMIT updateTreeView();
|
Q_EMIT updateTreeView();
|
||||||
updateLoaded();
|
updateActions();
|
||||||
} else {
|
} else {
|
||||||
actionLoadJSON->setEnabled(true);
|
actionLoadJSON->setEnabled(true);
|
||||||
log("Loading design failed.\n");
|
log("Loading design failed.\n");
|
||||||
@ -295,15 +315,26 @@ void BaseMainWindow::open_json()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BaseMainWindow::save_json()
|
||||||
|
{
|
||||||
|
QString fileName = QFileDialog::getSaveFileName(this, QString("Save JSON"), QString(), QString("*.json"));
|
||||||
|
if (!fileName.isEmpty()) {
|
||||||
|
std::string fn = fileName.toStdString();
|
||||||
|
std::ofstream f(fn);
|
||||||
|
if (write_json_file(f, fn, ctx.get()))
|
||||||
|
log("Saving JSON successful.\n");
|
||||||
|
else
|
||||||
|
log("Saving JSON failed.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BaseMainWindow::pack_finished(bool status)
|
void BaseMainWindow::pack_finished(bool status)
|
||||||
{
|
{
|
||||||
disableActions();
|
disableActions();
|
||||||
if (status) {
|
if (status) {
|
||||||
log("Packing design successful.\n");
|
log("Packing design successful.\n");
|
||||||
Q_EMIT updateTreeView();
|
Q_EMIT updateTreeView();
|
||||||
actionPlace->setEnabled(true);
|
updateActions();
|
||||||
actionAssignBudget->setEnabled(true);
|
|
||||||
onPackFinished();
|
|
||||||
} else {
|
} else {
|
||||||
log("Packing design failed.\n");
|
log("Packing design failed.\n");
|
||||||
}
|
}
|
||||||
@ -313,9 +344,8 @@ void BaseMainWindow::budget_finish(bool status)
|
|||||||
{
|
{
|
||||||
disableActions();
|
disableActions();
|
||||||
if (status) {
|
if (status) {
|
||||||
log("Assigning timing budget successful.\n");
|
log("Assigning timing budget successful.\n");
|
||||||
actionPlace->setEnabled(true);
|
updateActions();
|
||||||
onBudgetFinished();
|
|
||||||
} else {
|
} else {
|
||||||
log("Assigning timing budget failed.\n");
|
log("Assigning timing budget failed.\n");
|
||||||
}
|
}
|
||||||
@ -327,8 +357,7 @@ void BaseMainWindow::place_finished(bool status)
|
|||||||
if (status) {
|
if (status) {
|
||||||
log("Placing design successful.\n");
|
log("Placing design successful.\n");
|
||||||
Q_EMIT updateTreeView();
|
Q_EMIT updateTreeView();
|
||||||
actionRoute->setEnabled(true);
|
updateActions();
|
||||||
onPlaceFinished();
|
|
||||||
} else {
|
} else {
|
||||||
log("Placing design failed.\n");
|
log("Placing design failed.\n");
|
||||||
}
|
}
|
||||||
@ -339,7 +368,7 @@ void BaseMainWindow::route_finished(bool status)
|
|||||||
if (status) {
|
if (status) {
|
||||||
log("Routing design successful.\n");
|
log("Routing design successful.\n");
|
||||||
Q_EMIT updateTreeView();
|
Q_EMIT updateTreeView();
|
||||||
onRouteFinished();
|
updateActions();
|
||||||
} else
|
} else
|
||||||
log("Routing design failed.\n");
|
log("Routing design failed.\n");
|
||||||
}
|
}
|
||||||
@ -379,11 +408,12 @@ void BaseMainWindow::place() { Q_EMIT task->place(timing_driven); }
|
|||||||
|
|
||||||
void BaseMainWindow::disableActions()
|
void BaseMainWindow::disableActions()
|
||||||
{
|
{
|
||||||
actionLoadJSON->setEnabled(false);
|
actionLoadJSON->setEnabled(true);
|
||||||
actionPack->setEnabled(false);
|
actionPack->setEnabled(false);
|
||||||
actionAssignBudget->setEnabled(false);
|
actionAssignBudget->setEnabled(false);
|
||||||
actionPlace->setEnabled(false);
|
actionPlace->setEnabled(false);
|
||||||
actionRoute->setEnabled(false);
|
actionRoute->setEnabled(false);
|
||||||
|
|
||||||
actionExecutePy->setEnabled(true);
|
actionExecutePy->setEnabled(true);
|
||||||
|
|
||||||
actionPlay->setEnabled(false);
|
actionPlay->setEnabled(false);
|
||||||
@ -393,11 +423,18 @@ void BaseMainWindow::disableActions()
|
|||||||
onDisableActions();
|
onDisableActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseMainWindow::updateLoaded()
|
void BaseMainWindow::updateActions()
|
||||||
{
|
{
|
||||||
disableActions();
|
if (ctx->settings.find(ctx->id("pack"))==ctx->settings.end())
|
||||||
actionPack->setEnabled(true);
|
actionPack->setEnabled(true);
|
||||||
onJsonLoaded();
|
else if (ctx->settings.find(ctx->id("place"))==ctx->settings.end()) {
|
||||||
|
actionAssignBudget->setEnabled(true);
|
||||||
|
actionPlace->setEnabled(true);
|
||||||
|
}
|
||||||
|
else if (ctx->settings.find(ctx->id("route"))==ctx->settings.end())
|
||||||
|
actionRoute->setEnabled(true);
|
||||||
|
|
||||||
|
onUpdateActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseMainWindow::execute_python()
|
void BaseMainWindow::execute_python()
|
||||||
|
@ -48,7 +48,8 @@ class BaseMainWindow : public QMainWindow
|
|||||||
explicit BaseMainWindow(std::unique_ptr<Context> context, ArchArgs args, QWidget *parent = 0);
|
explicit BaseMainWindow(std::unique_ptr<Context> context, ArchArgs args, QWidget *parent = 0);
|
||||||
virtual ~BaseMainWindow();
|
virtual ~BaseMainWindow();
|
||||||
Context *getContext() { return ctx.get(); }
|
Context *getContext() { return ctx.get(); }
|
||||||
void updateLoaded();
|
void updateActions();
|
||||||
|
|
||||||
void notifyChangeContext();
|
void notifyChangeContext();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -57,11 +58,7 @@ class BaseMainWindow : public QMainWindow
|
|||||||
void load_json(std::string filename);
|
void load_json(std::string filename);
|
||||||
|
|
||||||
virtual void onDisableActions(){};
|
virtual void onDisableActions(){};
|
||||||
virtual void onJsonLoaded(){};
|
virtual void onUpdateActions(){};
|
||||||
virtual void onPackFinished(){};
|
|
||||||
virtual void onBudgetFinished(){};
|
|
||||||
virtual void onPlaceFinished(){};
|
|
||||||
virtual void onRouteFinished(){};
|
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
void writeInfo(std::string text);
|
void writeInfo(std::string text);
|
||||||
@ -70,6 +67,7 @@ class BaseMainWindow : public QMainWindow
|
|||||||
virtual void new_proj() = 0;
|
virtual void new_proj() = 0;
|
||||||
|
|
||||||
void open_json();
|
void open_json();
|
||||||
|
void save_json();
|
||||||
void budget();
|
void budget();
|
||||||
void place();
|
void place();
|
||||||
|
|
||||||
@ -110,7 +108,10 @@ class BaseMainWindow : public QMainWindow
|
|||||||
QToolBar *mainActionBar;
|
QToolBar *mainActionBar;
|
||||||
QProgressBar *progressBar;
|
QProgressBar *progressBar;
|
||||||
|
|
||||||
|
QAction *actionNew;
|
||||||
QAction *actionLoadJSON;
|
QAction *actionLoadJSON;
|
||||||
|
QAction *actionSaveJSON;
|
||||||
|
|
||||||
QAction *actionPack;
|
QAction *actionPack;
|
||||||
QAction *actionAssignBudget;
|
QAction *actionAssignBudget;
|
||||||
QAction *actionPlace;
|
QAction *actionPlace;
|
||||||
|
@ -2,5 +2,6 @@ convert -font helvetica -fill red -pointsize 8 -gravity center -draw "text 2,8 '
|
|||||||
convert -font helvetica -fill red -pointsize 8 -gravity center -draw "text 2,8 'PCF'" resources/open.png ice40/resources/open_pcf.png
|
convert -font helvetica -fill red -pointsize 8 -gravity center -draw "text 2,8 'PCF'" resources/open.png ice40/resources/open_pcf.png
|
||||||
convert -font helvetica -fill red -pointsize 8 -gravity center -draw "text 2,8 'BASE'" resources/open.png ecp5/resources/open_base.png
|
convert -font helvetica -fill red -pointsize 8 -gravity center -draw "text 2,8 'BASE'" resources/open.png ecp5/resources/open_base.png
|
||||||
convert -font helvetica -fill red -pointsize 8 -gravity center -draw "text 2,8 'LPF'" resources/open.png ecp5/resources/open_lpf.png
|
convert -font helvetica -fill red -pointsize 8 -gravity center -draw "text 2,8 'LPF'" resources/open.png ecp5/resources/open_lpf.png
|
||||||
convert -font helvetica -fill red -pointsize 8 -gravity center -draw "text 2,8 'ASC'" resources/save.png ice40/resources/save_asc.png
|
convert -font helvetica -fill red -pointsize 8 -gravity center -draw "text 2,8 'ASC'" resources/save.png ice40/resources/save_asc.png
|
||||||
convert -font helvetica -fill red -pointsize 7 -gravity center -draw "text 2,8 'CONFIG'" resources/save.png ecp5/resources/save_config.png
|
convert -font helvetica -fill red -pointsize 7 -gravity center -draw "text 2,8 'CONFIG'" resources/save.png ecp5/resources/save_config.png
|
||||||
|
convert -font helvetica -fill red -pointsize 8 -gravity center -draw "text 2,8 'JSON'" resources/save.png resources/save_json.png
|
@ -188,8 +188,13 @@ void MainWindow::onDisableActions()
|
|||||||
actionSaveConfig->setEnabled(false);
|
actionSaveConfig->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onJsonLoaded() { actionLoadLPF->setEnabled(true); }
|
void MainWindow::onUpdateActions() {
|
||||||
|
if (ctx->settings.find(ctx->id("pack"))==ctx->settings.end())
|
||||||
void MainWindow::onRouteFinished() { actionLoadBase->setEnabled(true); }
|
actionLoadLPF->setEnabled(true);
|
||||||
|
if (ctx->settings.find(ctx->id("pack"))==ctx->settings.end())
|
||||||
|
actionLoadBase->setEnabled(true);
|
||||||
|
if (ctx->settings.find(ctx->id("route"))!=ctx->settings.end())
|
||||||
|
actionSaveConfig->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -38,8 +38,7 @@ class MainWindow : public BaseMainWindow
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onDisableActions() override;
|
void onDisableActions() override;
|
||||||
void onJsonLoaded() override;
|
void onUpdateActions() override;
|
||||||
void onRouteFinished() override;
|
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
void new_proj() override;
|
void new_proj() override;
|
||||||
|
@ -186,7 +186,11 @@ void MainWindow::onDisableActions()
|
|||||||
actionSaveAsc->setEnabled(false);
|
actionSaveAsc->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onJsonLoaded() { actionLoadPCF->setEnabled(true); }
|
void MainWindow::onUpdateActions() {
|
||||||
void MainWindow::onRouteFinished() { actionSaveAsc->setEnabled(true); }
|
if (ctx->settings.find(ctx->id("pack"))==ctx->settings.end())
|
||||||
|
actionLoadPCF->setEnabled(true);
|
||||||
|
if (ctx->settings.find(ctx->id("route"))!=ctx->settings.end())
|
||||||
|
actionSaveAsc->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -39,8 +39,7 @@ class MainWindow : public BaseMainWindow
|
|||||||
void load_pcf(std::string filename);
|
void load_pcf(std::string filename);
|
||||||
|
|
||||||
void onDisableActions() override;
|
void onDisableActions() override;
|
||||||
void onJsonLoaded() override;
|
void onUpdateActions() override;
|
||||||
void onRouteFinished() override;
|
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
void new_proj() override;
|
void new_proj() override;
|
||||||
|
BIN
gui/resources/save_json.png
Normal file
BIN
gui/resources/save_json.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
@ -740,7 +740,8 @@ void json_import(Context *ctx, string modname, JsonNode *node)
|
|||||||
for (int attrid = 0; attrid < GetSize(attr_node->data_dict_keys); attrid++) {
|
for (int attrid = 0; attrid < GetSize(attr_node->data_dict_keys); attrid++) {
|
||||||
json_import_top_attrib(ctx, modname, attr_node, &ctx->attrs, attrid);
|
json_import_top_attrib(ctx, modname, attr_node, &ctx->attrs, attrid);
|
||||||
}
|
}
|
||||||
|
ctx->settings[ctx->id("synth")] = "1";
|
||||||
|
|
||||||
JsonNode *ports_parent = nullptr;
|
JsonNode *ports_parent = nullptr;
|
||||||
if (node->data_dict.count("ports") > 0)
|
if (node->data_dict.count("ports") > 0)
|
||||||
ports_parent = node->data_dict.at("ports");
|
ports_parent = node->data_dict.at("ports");
|
||||||
|
Loading…
Reference in New Issue
Block a user