Merge branch 'master' of gitlab.com:SymbioticEDA/nextpnr
This commit is contained in:
commit
2073403f41
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(), QString("*.json"));
|
||||
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("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");
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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>
|
||||
|
BIN
gui/ice40/resources/open_json.png
Normal file
BIN
gui/ice40/resources/open_json.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
BIN
gui/ice40/resources/save_asc.png
Normal file
BIN
gui/ice40/resources/save_asc.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user