diff options
author | David Shah <davey1576@gmail.com> | 2018-06-26 14:22:47 +0200 |
---|---|---|
committer | David Shah <davey1576@gmail.com> | 2018-06-26 14:22:47 +0200 |
commit | 2073403f41daa8d6f9d44e65dd70cd6308aaf2e6 (patch) | |
tree | 0510ef808123296754fedc76172d3bb9e1261692 /gui | |
parent | 962c566ffb6aa37ea1eb2e3bd8355feb73308ca4 (diff) | |
parent | 8344a21282ca63be467ae9c11e0f4dd000fff84c (diff) | |
download | nextpnr-2073403f41daa8d6f9d44e65dd70cd6308aaf2e6.tar.gz nextpnr-2073403f41daa8d6f9d44e65dd70cd6308aaf2e6.tar.bz2 nextpnr-2073403f41daa8d6f9d44e65dd70cd6308aaf2e6.zip |
Merge branch 'master' of gitlab.com:SymbioticEDA/nextpnr
Diffstat (limited to 'gui')
-rw-r--r-- | gui/basewindow.cc | 36 | ||||
-rw-r--r-- | gui/basewindow.h | 5 | ||||
-rw-r--r-- | gui/dummy/mainwindow.cc | 6 | ||||
-rw-r--r-- | gui/dummy/mainwindow.h | 5 | ||||
-rw-r--r-- | gui/ice40/mainwindow.cc | 73 | ||||
-rw-r--r-- | gui/ice40/mainwindow.h | 10 | ||||
-rw-r--r-- | gui/ice40/nextpnr.qrc | 2 | ||||
-rw-r--r-- | gui/ice40/resources/open_json.png | bin | 0 -> 2093 bytes | |||
-rw-r--r-- | gui/ice40/resources/save_asc.png | bin | 0 -> 1384 bytes | |||
-rw-r--r-- | gui/ice40/worker.cc | 15 | ||||
-rw-r--r-- | gui/ice40/worker.h | 4 |
11 files changed, 129 insertions, 27 deletions
diff --git a/gui/basewindow.cc b/gui/basewindow.cc index 8e90a8ea..20b48dd3 100644 --- a/gui/basewindow.cc +++ b/gui/basewindow.cc @@ -90,27 +90,35 @@ void BaseMainWindow::writeInfo(std::string text) { info->info(text); } void BaseMainWindow::createMenusAndBars()
{
+ QAction *actionNew = new QAction("New", this);
+ QIcon iconNew;
+ iconNew.addFile(QStringLiteral(":/icons/resources/new.png"));
+ actionNew->setIcon(iconNew);
+ actionNew->setShortcuts(QKeySequence::New);
+ actionNew->setStatusTip("New project file");
+ connect(actionNew, SIGNAL(triggered()), this, SLOT(new_proj()));
+
QAction *actionOpen = new QAction("Open", this);
- QIcon icon1;
- icon1.addFile(QStringLiteral(":/icons/resources/open.png"));
- actionOpen->setIcon(icon1);
+ QIcon iconOpen;
+ iconOpen.addFile(QStringLiteral(":/icons/resources/open.png"));
+ actionOpen->setIcon(iconOpen);
actionOpen->setShortcuts(QKeySequence::Open);
- actionOpen->setStatusTip("Open an existing JSON file");
- connect(actionOpen, SIGNAL(triggered()), this, SLOT(open()));
+ actionOpen->setStatusTip("Open an existing project file");
+ connect(actionOpen, SIGNAL(triggered()), this, SLOT(open_proj()));
QAction *actionSave = new QAction("Save", this);
- QIcon icon2;
- icon2.addFile(QStringLiteral(":/icons/resources/save.png"));
- actionSave->setIcon(icon2);
+ QIcon iconSave;
+ iconSave.addFile(QStringLiteral(":/icons/resources/save.png"));
+ actionSave->setIcon(iconSave);
actionSave->setShortcuts(QKeySequence::Save);
- actionSave->setStatusTip("Save the ASC to disk");
- connect(actionSave, SIGNAL(triggered()), this, SLOT(save()));
+ actionSave->setStatusTip("Save existing project to disk");
+ connect(actionSave, SIGNAL(triggered()), this, SLOT(save_proj()));
actionSave->setEnabled(false);
QAction *actionExit = new QAction("Exit", this);
- QIcon icon3;
- icon3.addFile(QStringLiteral(":/icons/resources/exit.png"));
- actionExit->setIcon(icon3);
+ QIcon iconExit;
+ iconExit.addFile(QStringLiteral(":/icons/resources/exit.png"));
+ actionExit->setIcon(iconExit);
actionExit->setShortcuts(QKeySequence::Quit);
actionExit->setStatusTip("Exit the application");
connect(actionExit, SIGNAL(triggered()), this, SLOT(close()));
@@ -131,12 +139,14 @@ void BaseMainWindow::createMenusAndBars() statusBar = new QStatusBar();
setStatusBar(statusBar);
+ menu_File->addAction(actionNew);
menu_File->addAction(actionOpen);
menu_File->addAction(actionSave);
menu_File->addSeparator();
menu_File->addAction(actionExit);
menu_Help->addAction(actionAbout);
+ mainToolBar->addAction(actionNew);
mainToolBar->addAction(actionOpen);
mainToolBar->addAction(actionSave);
}
diff --git a/gui/basewindow.h b/gui/basewindow.h index f4ca5129..038b82c5 100644 --- a/gui/basewindow.h +++ b/gui/basewindow.h @@ -49,8 +49,9 @@ class BaseMainWindow : public QMainWindow protected Q_SLOTS:
void writeInfo(std::string text);
- virtual void open() = 0;
- virtual bool save() = 0;
+ virtual void new_proj() = 0;
+ virtual void open_proj() = 0;
+ virtual bool save_proj() = 0;
protected:
Context *ctx;
diff --git a/gui/dummy/mainwindow.cc b/gui/dummy/mainwindow.cc index e72d4f96..c57d0db0 100644 --- a/gui/dummy/mainwindow.cc +++ b/gui/dummy/mainwindow.cc @@ -41,8 +41,10 @@ void MainWindow::createMenu() menuBar->addAction(menu_Custom->menuAction());
}
-void MainWindow::open() {}
+void MainWindow::new_proj() {}
-bool MainWindow::save() { return false; }
+void MainWindow::open_proj() {}
+
+bool MainWindow::save_proj() { return false; }
NEXTPNR_NAMESPACE_END
diff --git a/gui/dummy/mainwindow.h b/gui/dummy/mainwindow.h index f16b7ad3..b1b9598f 100644 --- a/gui/dummy/mainwindow.h +++ b/gui/dummy/mainwindow.h @@ -36,8 +36,9 @@ class MainWindow : public BaseMainWindow void createMenu();
protected Q_SLOTS:
- virtual void open();
- virtual bool save();
+ virtual void new_proj();
+ virtual void open_proj();
+ virtual bool save_proj();
};
NEXTPNR_NAMESPACE_END
diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc index 34769abe..61ceb3e6 100644 --- a/gui/ice40/mainwindow.cc +++ b/gui/ice40/mainwindow.cc @@ -48,6 +48,7 @@ MainWindow::MainWindow(Context *_ctx, QWidget *parent) : BaseMainWindow(_ctx, pa connect(task, SIGNAL(loadfile_finished(bool)), this, SLOT(loadfile_finished(bool)));
connect(task, SIGNAL(loadpcf_finished(bool)), this, SLOT(loadpcf_finished(bool)));
+ connect(task, SIGNAL(saveasc_finished(bool)), this, SLOT(saveasc_finished(bool)));
connect(task, SIGNAL(pack_finished(bool)), this, SLOT(pack_finished(bool)));
connect(task, SIGNAL(budget_finish(bool)), this, SLOT(budget_finish(bool)));
connect(task, SIGNAL(place_finished(bool)), this, SLOT(place_finished(bool)));
@@ -67,6 +68,14 @@ void MainWindow::createMenu() QMenu *menu_Design = new QMenu("&Design", menuBar);
menuBar->addAction(menu_Design->menuAction());
+ actionLoadJSON = new QAction("Open JSON", this);
+ QIcon iconLoadJSON;
+ iconLoadJSON.addFile(QStringLiteral(":/icons/resources/open_json.png"));
+ actionLoadJSON->setIcon(iconLoadJSON);
+ actionLoadJSON->setStatusTip("Open an existing JSON file");
+ connect(actionLoadJSON, SIGNAL(triggered()), this, SLOT(open_json()));
+ actionLoadJSON->setEnabled(false);
+
actionLoadPCF = new QAction("Open PCF", this);
QIcon iconLoadPCF;
iconLoadPCF.addFile(QStringLiteral(":/icons/resources/open_pcf.png"));
@@ -107,20 +116,32 @@ void MainWindow::createMenu() connect(actionRoute, SIGNAL(triggered()), task, SIGNAL(route()));
actionRoute->setEnabled(false);
+ actionSaveAsc = new QAction("Save ASC", this);
+ QIcon iconSaveAsc;
+ iconSaveAsc.addFile(QStringLiteral(":/icons/resources/save_asc.png"));
+ actionSaveAsc->setIcon(iconSaveAsc);
+ actionSaveAsc->setStatusTip("Save ASC file");
+ connect(actionSaveAsc, SIGNAL(triggered()), this, SLOT(save_asc()));
+ actionSaveAsc->setEnabled(false);
+
QToolBar *taskFPGABar = new QToolBar();
addToolBar(Qt::TopToolBarArea, taskFPGABar);
+ taskFPGABar->addAction(actionLoadJSON);
taskFPGABar->addAction(actionLoadPCF);
taskFPGABar->addAction(actionPack);
taskFPGABar->addAction(actionAssignBudget);
taskFPGABar->addAction(actionPlace);
taskFPGABar->addAction(actionRoute);
+ taskFPGABar->addAction(actionSaveAsc);
+ menu_Design->addAction(actionLoadJSON);
menu_Design->addAction(actionLoadPCF);
menu_Design->addAction(actionPack);
menu_Design->addAction(actionAssignBudget);
menu_Design->addAction(actionPlace);
menu_Design->addAction(actionRoute);
+ menu_Design->addAction(actionSaveAsc);
actionPlay = new QAction("Play", this);
QIcon iconPlay;
@@ -154,9 +175,26 @@ void MainWindow::createMenu() taskToolBar->addAction(actionStop);
}
-void MainWindow::open()
+void MainWindow::new_proj()
+{
+ disableActions();
+ actionLoadJSON->setEnabled(true);
+}
+
+void MainWindow::open_proj()
+{
+ QString fileName = QFileDialog::getOpenFileName(this, QString("Open Project"), QString(), QString("*.npnr"));
+ if (!fileName.isEmpty()) {
+ tabWidget->setCurrentWidget(info);
+
+ std::string fn = fileName.toStdString();
+ disableActions();
+ }
+}
+
+void MainWindow::open_json()
{
- QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(), QString("*.json"));
+ QString fileName = QFileDialog::getOpenFileName(this, QString("Open JSON"), QString(), QString("*.json"));
if (!fileName.isEmpty()) {
tabWidget->setCurrentWidget(info);
@@ -169,7 +207,7 @@ void MainWindow::open() void MainWindow::open_pcf()
{
- QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(), QString("*.pcf"));
+ QString fileName = QFileDialog::getOpenFileName(this, QString("Open PCF"), QString(), QString("*.pcf"));
if (!fileName.isEmpty()) {
tabWidget->setCurrentWidget(info);
@@ -179,15 +217,27 @@ void MainWindow::open_pcf() }
}
-bool MainWindow::save() { return false; }
+bool MainWindow::save_proj() { return false; }
+
+void MainWindow::save_asc()
+{
+ QString fileName = QFileDialog::getSaveFileName(this, QString("Save ASC"), QString(), QString("*.asc"));
+ if (!fileName.isEmpty()) {
+ std::string fn = fileName.toStdString();
+ disableActions();
+ Q_EMIT task->saveasc(fn);
+ }
+}
void MainWindow::disableActions()
{
+ actionLoadJSON->setEnabled(false);
actionLoadPCF->setEnabled(false);
actionPack->setEnabled(false);
actionAssignBudget->setEnabled(false);
actionPlace->setEnabled(false);
actionRoute->setEnabled(false);
+ actionSaveAsc->setEnabled(false);
actionPlay->setEnabled(false);
actionPause->setEnabled(false);
@@ -217,6 +267,16 @@ void MainWindow::loadpcf_finished(bool status) }
}
+void MainWindow::saveasc_finished(bool status)
+{
+ disableActions();
+ if (status) {
+ log("Saving ASC successful.\n");
+ } else {
+ log("Saving ASC failed.\n");
+ }
+}
+
void MainWindow::pack_finished(bool status)
{
disableActions();
@@ -253,9 +313,10 @@ void MainWindow::place_finished(bool status) void MainWindow::route_finished(bool status)
{
disableActions();
- if (status)
+ if (status) {
log("Routing design successful.\n");
- else
+ actionSaveAsc->setEnabled(true);
+ } else
log("Routing design failed.\n");
}
diff --git a/gui/ice40/mainwindow.h b/gui/ice40/mainwindow.h index 66814d32..f4037a47 100644 --- a/gui/ice40/mainwindow.h +++ b/gui/ice40/mainwindow.h @@ -37,15 +37,19 @@ class MainWindow : public BaseMainWindow void createMenu();
protected Q_SLOTS:
- virtual void open();
- virtual bool save();
+ virtual void new_proj();
+ virtual void open_proj();
+ virtual bool save_proj();
+ void open_json();
void open_pcf();
void budget();
void place();
+ void save_asc();
void loadfile_finished(bool status);
void loadpcf_finished(bool status);
+ void saveasc_finished(bool status);
void pack_finished(bool status);
void budget_finish(bool status);
void place_finished(bool status);
@@ -59,11 +63,13 @@ class MainWindow : public BaseMainWindow void disableActions();
TaskManager *task;
+ QAction *actionLoadJSON;
QAction *actionLoadPCF;
QAction *actionPack;
QAction *actionAssignBudget;
QAction *actionPlace;
QAction *actionRoute;
+ QAction *actionSaveAsc;
QAction *actionPlay;
QAction *actionPause;
QAction *actionStop;
diff --git a/gui/ice40/nextpnr.qrc b/gui/ice40/nextpnr.qrc index 4a73d791..3c86057d 100644 --- a/gui/ice40/nextpnr.qrc +++ b/gui/ice40/nextpnr.qrc @@ -8,5 +8,7 @@ <file>resources/route.png</file> <file>resources/time_add.png</file> <file>resources/open_pcf.png</file> + <file>resources/save_asc.png</file> + <file>resources/open_json.png</file> </qresource> </RCC> diff --git a/gui/ice40/resources/open_json.png b/gui/ice40/resources/open_json.png Binary files differnew file mode 100644 index 00000000..90c07267 --- /dev/null +++ b/gui/ice40/resources/open_json.png diff --git a/gui/ice40/resources/save_asc.png b/gui/ice40/resources/save_asc.png Binary files differnew file mode 100644 index 00000000..15b59ca1 --- /dev/null +++ b/gui/ice40/resources/save_asc.png diff --git a/gui/ice40/worker.cc b/gui/ice40/worker.cc index 9986ff3b..f6d6d261 100644 --- a/gui/ice40/worker.cc +++ b/gui/ice40/worker.cc @@ -80,6 +80,19 @@ void Worker::loadpcf(const std::string &filename) } } +void Worker::saveasc(const std::string &filename) +{ + Q_EMIT taskStarted(); + std::string fn = filename; + std::ofstream f(fn); + try { + write_asc(ctx, f); + Q_EMIT saveasc_finished(true); + } catch (WorkerInterruptionRequested) { + Q_EMIT taskCanceled(); + } +} + void Worker::pack() { Q_EMIT taskStarted(); @@ -132,6 +145,7 @@ TaskManager::TaskManager(Context *ctx) : toTerminate(false), toPause(false) connect(this, &TaskManager::loadfile, worker, &Worker::loadfile); connect(this, &TaskManager::loadpcf, worker, &Worker::loadpcf); + connect(this, &TaskManager::saveasc, worker, &Worker::saveasc); connect(this, &TaskManager::pack, worker, &Worker::pack); connect(this, &TaskManager::budget, worker, &Worker::budget); connect(this, &TaskManager::place, worker, &Worker::place); @@ -140,6 +154,7 @@ TaskManager::TaskManager(Context *ctx) : toTerminate(false), toPause(false) connect(worker, &Worker::log, this, &TaskManager::info); connect(worker, &Worker::loadfile_finished, this, &TaskManager::loadfile_finished); connect(worker, &Worker::loadpcf_finished, this, &TaskManager::loadpcf_finished); + connect(worker, &Worker::saveasc_finished, this, &TaskManager::saveasc_finished); connect(worker, &Worker::pack_finished, this, &TaskManager::pack_finished); connect(worker, &Worker::budget_finish, this, &TaskManager::budget_finish); connect(worker, &Worker::place_finished, this, &TaskManager::place_finished); diff --git a/gui/ice40/worker.h b/gui/ice40/worker.h index 2995a851..18f4b2c2 100644 --- a/gui/ice40/worker.h +++ b/gui/ice40/worker.h @@ -36,6 +36,7 @@ class Worker : public QObject public Q_SLOTS: void loadfile(const std::string &); void loadpcf(const std::string &); + void saveasc(const std::string &); void pack(); void budget(double freq); void place(bool timing_driven); @@ -44,6 +45,7 @@ class Worker : public QObject void log(const std::string &text); void loadfile_finished(bool status); void loadpcf_finished(bool status); + void saveasc_finished(bool status); void pack_finished(bool status); void budget_finish(bool status); void place_finished(bool status); @@ -76,6 +78,7 @@ class TaskManager : public QObject void terminate(); void loadfile(const std::string &); void loadpcf(const std::string &); + void saveasc(const std::string &); void pack(); void budget(double freq); void place(bool timing_driven); @@ -85,6 +88,7 @@ class TaskManager : public QObject void log(const std::string &text); void loadfile_finished(bool status); void loadpcf_finished(bool status); + void saveasc_finished(bool status); void pack_finished(bool status); void budget_finish(bool status); void place_finished(bool status); |