aboutsummaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2019-06-14 15:18:35 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2019-06-14 15:18:35 +0200
commit66ea9f39f7f5d6e1152105328f9a48a367bd8ce0 (patch)
treec00f2c07205988f67d24a4f6a22ee8f8f301ecf2 /gui
parentaca372de99b960ca808e49fec27d2aaf890574d3 (diff)
downloadnextpnr-66ea9f39f7f5d6e1152105328f9a48a367bd8ce0.tar.gz
nextpnr-66ea9f39f7f5d6e1152105328f9a48a367bd8ce0.tar.bz2
nextpnr-66ea9f39f7f5d6e1152105328f9a48a367bd8ce0.zip
enable lading of jsons and setting up context
Diffstat (limited to 'gui')
-rw-r--r--gui/basewindow.cc25
-rw-r--r--gui/basewindow.h6
-rw-r--r--gui/ecp5/mainwindow.cc8
-rw-r--r--gui/ecp5/mainwindow.h2
-rw-r--r--gui/generic/mainwindow.cc4
-rw-r--r--gui/generic/mainwindow.h2
-rw-r--r--gui/ice40/mainwindow.cc8
-rw-r--r--gui/ice40/mainwindow.h2
8 files changed, 24 insertions, 33 deletions
diff --git a/gui/basewindow.cc b/gui/basewindow.cc
index 59dd6f7b..5b03b667 100644
--- a/gui/basewindow.cc
+++ b/gui/basewindow.cc
@@ -38,8 +38,8 @@ static void initBasenameResource() { Q_INIT_RESOURCE(base); }
NEXTPNR_NAMESPACE_BEGIN
-BaseMainWindow::BaseMainWindow(std::unique_ptr<Context> context, ArchArgs args, QWidget *parent)
- : QMainWindow(parent), chipArgs(args), ctx(std::move(context)), timing_driven(false)
+BaseMainWindow::BaseMainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent)
+ : QMainWindow(parent), handler(handler), ctx(std::move(context)), timing_driven(false)
{
initBasenameResource();
qRegisterMetaType<std::string>();
@@ -293,25 +293,16 @@ void BaseMainWindow::createMenusAndBars()
setStatusBar(statusBar);
}
-void BaseMainWindow::load_json(std::string filename)
-{
- disableActions();
- std::ifstream f(filename);
- if (parse_json_file(f, filename, ctx.get())) {
- log("Loading design successful.\n");
- Q_EMIT updateTreeView();
- updateActions();
- } else {
- actionLoadJSON->setEnabled(true);
- log("Loading design failed.\n");
- }
-}
-
void BaseMainWindow::open_json()
{
QString fileName = QFileDialog::getOpenFileName(this, QString("Open JSON"), QString(), QString("*.json"));
if (!fileName.isEmpty()) {
- load_json(fileName.toStdString());
+ disableActions();
+ ctx = handler->load_json(fileName.toStdString());
+ Q_EMIT contextChanged(ctx.get());
+ Q_EMIT updateTreeView();
+ log("Loading design successful.\n");
+ updateActions();
}
}
diff --git a/gui/basewindow.h b/gui/basewindow.h
index d2640813..4276c401 100644
--- a/gui/basewindow.h
+++ b/gui/basewindow.h
@@ -22,6 +22,7 @@
#include "nextpnr.h"
#include "worker.h"
+#include "command.h"
#include <QMainWindow>
#include <QMenu>
@@ -45,7 +46,7 @@ class BaseMainWindow : public QMainWindow
Q_OBJECT
public:
- explicit BaseMainWindow(std::unique_ptr<Context> context, ArchArgs args, QWidget *parent = 0);
+ explicit BaseMainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent = 0);
virtual ~BaseMainWindow();
Context *getContext() { return ctx.get(); }
void updateActions();
@@ -55,7 +56,6 @@ class BaseMainWindow : public QMainWindow
protected:
void createMenusAndBars();
void disableActions();
- void load_json(std::string filename);
virtual void onDisableActions(){};
virtual void onUpdateActions(){};
@@ -88,7 +88,7 @@ class BaseMainWindow : public QMainWindow
protected:
// state variables
- ArchArgs chipArgs;
+ CommandHandler *handler;
std::unique_ptr<Context> ctx;
TaskManager *task;
bool timing_driven;
diff --git a/gui/ecp5/mainwindow.cc b/gui/ecp5/mainwindow.cc
index 913c2520..b06e10e9 100644
--- a/gui/ecp5/mainwindow.cc
+++ b/gui/ecp5/mainwindow.cc
@@ -30,8 +30,8 @@ static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
NEXTPNR_NAMESPACE_BEGIN
-MainWindow::MainWindow(std::unique_ptr<Context> context, ArchArgs args, QWidget *parent)
- : BaseMainWindow(std::move(context), args, parent)
+MainWindow::MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent)
+ : BaseMainWindow(std::move(context), handler, parent)
{
initMainResource();
@@ -47,7 +47,7 @@ MainWindow::~MainWindow() {}
void MainWindow::newContext(Context *ctx)
{
- std::string title = "nextpnr-ecp5 - " + ctx->getChipName() + " ( " + chipArgs.package + " )";
+ std::string title = "nextpnr-ecp5 - " + ctx->getChipName() + " ( " + ctx->archArgs().package + " )";
setWindowTitle(title.c_str());
}
@@ -113,7 +113,7 @@ void MainWindow::new_proj()
bool ok;
QString item = QInputDialog::getItem(this, "Select new context", "Chip:", arch.keys(), 0, false, &ok);
if (ok && !item.isEmpty()) {
-
+ ArchArgs chipArgs;
chipArgs.type = (ArchArgs::ArchArgsTypes)arch.value(item);
QString package = QInputDialog::getItem(this, "Select package", "Package:", getSupportedPackages(chipArgs.type),
diff --git a/gui/ecp5/mainwindow.h b/gui/ecp5/mainwindow.h
index 65493fbc..e60fc5b0 100644
--- a/gui/ecp5/mainwindow.h
+++ b/gui/ecp5/mainwindow.h
@@ -29,7 +29,7 @@ class MainWindow : public BaseMainWindow
Q_OBJECT
public:
- explicit MainWindow(std::unique_ptr<Context> context, ArchArgs args, QWidget *parent = 0);
+ explicit MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent = 0);
virtual ~MainWindow();
public:
diff --git a/gui/generic/mainwindow.cc b/gui/generic/mainwindow.cc
index eefff39c..f616ca1a 100644
--- a/gui/generic/mainwindow.cc
+++ b/gui/generic/mainwindow.cc
@@ -26,8 +26,8 @@ static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
NEXTPNR_NAMESPACE_BEGIN
-MainWindow::MainWindow(std::unique_ptr<Context> context, ArchArgs args, QWidget *parent)
- : BaseMainWindow(std::move(context), args, parent)
+MainWindow::MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent)
+ : BaseMainWindow(std::move(context), handler, parent)
{
initMainResource();
QMessageBox::critical(0, "Error - FIXME", "No GUI support for nextpnr-generic");
diff --git a/gui/generic/mainwindow.h b/gui/generic/mainwindow.h
index bb6a4cf1..4d1cf598 100644
--- a/gui/generic/mainwindow.h
+++ b/gui/generic/mainwindow.h
@@ -29,7 +29,7 @@ class MainWindow : public BaseMainWindow
Q_OBJECT
public:
- explicit MainWindow(std::unique_ptr<Context> context, ArchArgs args, QWidget *parent = 0);
+ explicit MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent = 0);
virtual ~MainWindow();
public:
diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc
index 7c8effac..c2ac264f 100644
--- a/gui/ice40/mainwindow.cc
+++ b/gui/ice40/mainwindow.cc
@@ -35,8 +35,8 @@ static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
NEXTPNR_NAMESPACE_BEGIN
-MainWindow::MainWindow(std::unique_ptr<Context> context, ArchArgs args, QWidget *parent)
- : BaseMainWindow(std::move(context), args, parent)
+MainWindow::MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent)
+ : BaseMainWindow(std::move(context), handler, parent)
{
initMainResource();
@@ -123,7 +123,7 @@ void MainWindow::new_proj()
bool ok;
QString item = QInputDialog::getItem(this, "Select new context", "Chip:", arch.keys(), 0, false, &ok);
if (ok && !item.isEmpty()) {
-
+ ArchArgs chipArgs;
chipArgs.type = (ArchArgs::ArchArgsTypes)arch.value(item);
QString package = QInputDialog::getItem(this, "Select package", "Package:", getSupportedPackages(chipArgs.type),
@@ -156,7 +156,7 @@ void MainWindow::load_pcf(std::string filename)
void MainWindow::newContext(Context *ctx)
{
- std::string title = "nextpnr-ice40 - " + ctx->getChipName() + " ( " + chipArgs.package + " )";
+ std::string title = "nextpnr-ice40 - " + ctx->getChipName() + " ( " + ctx->archArgs().package + " )";
setWindowTitle(title.c_str());
}
diff --git a/gui/ice40/mainwindow.h b/gui/ice40/mainwindow.h
index ed1b6aaf..6e725a16 100644
--- a/gui/ice40/mainwindow.h
+++ b/gui/ice40/mainwindow.h
@@ -29,7 +29,7 @@ class MainWindow : public BaseMainWindow
Q_OBJECT
public:
- explicit MainWindow(std::unique_ptr<Context> context, ArchArgs args, QWidget *parent = 0);
+ explicit MainWindow(std::unique_ptr<Context> context, CommandHandler *handler, QWidget *parent = 0);
virtual ~MainWindow();
public: