mirror of
https://github.com/YosysHQ/nextpnr.git
synced 2026-05-05 07:33:27 +00:00
Use command line parameters settings for GUI as well.
This commit is contained in:
@@ -36,7 +36,8 @@ static void initBasenameResource() { Q_INIT_RESOURCE(base); }
|
||||
|
||||
NEXTPNR_NAMESPACE_BEGIN
|
||||
|
||||
BaseMainWindow::BaseMainWindow(QWidget *parent) : QMainWindow(parent), ctx(nullptr)
|
||||
BaseMainWindow::BaseMainWindow(std::unique_ptr<Context> context, QWidget *parent)
|
||||
: QMainWindow(parent), ctx(std::move(context))
|
||||
{
|
||||
initBasenameResource();
|
||||
qRegisterMetaType<std::string>();
|
||||
|
||||
@@ -40,9 +40,9 @@ class BaseMainWindow : public QMainWindow
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BaseMainWindow(QWidget *parent = 0);
|
||||
explicit BaseMainWindow(std::unique_ptr<Context> context, QWidget *parent = 0);
|
||||
virtual ~BaseMainWindow();
|
||||
Context *getContext() { return ctx; }
|
||||
Context *getContext() { return ctx.get(); }
|
||||
|
||||
protected:
|
||||
void createMenusAndBars();
|
||||
@@ -59,7 +59,7 @@ class BaseMainWindow : public QMainWindow
|
||||
void updateTreeView();
|
||||
|
||||
protected:
|
||||
Context *ctx;
|
||||
std::unique_ptr<Context> ctx;
|
||||
QTabWidget *tabWidget;
|
||||
QTabWidget *centralTabWidget;
|
||||
InfoTab *info;
|
||||
|
||||
@@ -23,7 +23,7 @@ static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
|
||||
|
||||
NEXTPNR_NAMESPACE_BEGIN
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) : BaseMainWindow(parent)
|
||||
MainWindow::MainWindow(std::unique_ptr<Context> context, QWidget *parent) : BaseMainWindow(std::move(context), parent)
|
||||
{
|
||||
initMainResource();
|
||||
|
||||
@@ -31,6 +31,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseMainWindow(parent)
|
||||
setWindowTitle(title.c_str());
|
||||
|
||||
createMenu();
|
||||
Q_EMIT contextChanged(ctx.get());
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {}
|
||||
|
||||
@@ -29,7 +29,7 @@ class MainWindow : public BaseMainWindow
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
explicit MainWindow(std::unique_ptr<Context> context, QWidget *parent = 0);
|
||||
virtual ~MainWindow();
|
||||
|
||||
public:
|
||||
|
||||
@@ -23,7 +23,7 @@ static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
|
||||
|
||||
NEXTPNR_NAMESPACE_BEGIN
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) : BaseMainWindow(parent)
|
||||
MainWindow::MainWindow(std::unique_ptr<Context> context, QWidget *parent) : BaseMainWindow(std::move(context), parent)
|
||||
{
|
||||
initMainResource();
|
||||
|
||||
@@ -31,6 +31,7 @@ MainWindow::MainWindow(QWidget *parent) : BaseMainWindow(parent)
|
||||
setWindowTitle(title.c_str());
|
||||
|
||||
createMenu();
|
||||
Q_EMIT contextChanged(ctx.get());
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {}
|
||||
|
||||
@@ -29,7 +29,7 @@ class MainWindow : public BaseMainWindow
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
explicit MainWindow(std::unique_ptr<Context> context, QWidget *parent = 0);
|
||||
virtual ~MainWindow();
|
||||
|
||||
public:
|
||||
|
||||
@@ -34,7 +34,8 @@ static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
|
||||
|
||||
NEXTPNR_NAMESPACE_BEGIN
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) : BaseMainWindow(parent), timing_driven(false)
|
||||
MainWindow::MainWindow(std::unique_ptr<Context> context, QWidget *parent)
|
||||
: BaseMainWindow(std::move(context), parent), timing_driven(false)
|
||||
{
|
||||
initMainResource();
|
||||
|
||||
@@ -60,6 +61,8 @@ MainWindow::MainWindow(QWidget *parent) : BaseMainWindow(parent), timing_driven(
|
||||
connect(this, SIGNAL(contextChanged(Context *)), task, SIGNAL(contextChanged(Context *)));
|
||||
|
||||
createMenu();
|
||||
|
||||
Q_EMIT contextChanged(ctx.get());
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() { delete task; }
|
||||
@@ -75,7 +78,7 @@ void MainWindow::createMenu()
|
||||
actionLoadJSON->setIcon(iconLoadJSON);
|
||||
actionLoadJSON->setStatusTip("Open an existing JSON file");
|
||||
connect(actionLoadJSON, SIGNAL(triggered()), this, SLOT(open_json()));
|
||||
actionLoadJSON->setEnabled(false);
|
||||
actionLoadJSON->setEnabled(true);
|
||||
|
||||
actionLoadPCF = new QAction("Open PCF", this);
|
||||
QIcon iconLoadPCF;
|
||||
@@ -239,22 +242,36 @@ void MainWindow::new_proj()
|
||||
|
||||
if (ok && !item.isEmpty()) {
|
||||
disableActions();
|
||||
preload_pcf = "";
|
||||
chipArgs.package = package.toStdString().c_str();
|
||||
if (ctx)
|
||||
delete ctx;
|
||||
ctx = new Context(chipArgs);
|
||||
ctx = std::unique_ptr<Context>(new Context(chipArgs));
|
||||
|
||||
Q_EMIT contextChanged(ctx);
|
||||
|
||||
actionLoadJSON->setEnabled(true);
|
||||
Q_EMIT contextChanged(ctx.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::load_json(std::string filename, std::string pcf)
|
||||
{
|
||||
tabWidget->setCurrentWidget(info);
|
||||
preload_pcf = pcf;
|
||||
disableActions();
|
||||
Q_EMIT task->loadfile(filename);
|
||||
}
|
||||
|
||||
void MainWindow::load_pcf(std::string filename)
|
||||
{
|
||||
tabWidget->setCurrentWidget(info);
|
||||
|
||||
disableActions();
|
||||
Q_EMIT task->loadpcf(filename);
|
||||
}
|
||||
|
||||
void MainWindow::newContext(Context *ctx)
|
||||
{
|
||||
std::string title = "nextpnr-ice40 - " + ctx->getChipName() + " ( " + chipArgs.package + " )";
|
||||
setWindowTitle(title.c_str());
|
||||
info->clearBuffer();
|
||||
}
|
||||
|
||||
void MainWindow::open_proj()
|
||||
@@ -272,12 +289,7 @@ void MainWindow::open_json()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, QString("Open JSON"), QString(), QString("*.json"));
|
||||
if (!fileName.isEmpty()) {
|
||||
tabWidget->setCurrentWidget(info);
|
||||
|
||||
std::string fn = fileName.toStdString();
|
||||
disableActions();
|
||||
timing_driven = false;
|
||||
Q_EMIT task->loadfile(fn);
|
||||
load_json(fileName.toStdString(), "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,11 +297,7 @@ void MainWindow::open_pcf()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, QString("Open PCF"), QString(), QString("*.pcf"));
|
||||
if (!fileName.isEmpty()) {
|
||||
tabWidget->setCurrentWidget(info);
|
||||
|
||||
std::string fn = fileName.toStdString();
|
||||
disableActions();
|
||||
Q_EMIT task->loadpcf(fn);
|
||||
load_pcf(fileName.toStdString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,9 +338,12 @@ void MainWindow::loadfile_finished(bool status)
|
||||
log("Loading design successful.\n");
|
||||
actionLoadPCF->setEnabled(true);
|
||||
actionPack->setEnabled(true);
|
||||
if (!preload_pcf.empty())
|
||||
load_pcf(preload_pcf);
|
||||
Q_EMIT updateTreeView();
|
||||
} else {
|
||||
log("Loading design failed.\n");
|
||||
preload_pcf = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,12 +30,13 @@ class MainWindow : public BaseMainWindow
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
explicit MainWindow(std::unique_ptr<Context> context, QWidget *parent = 0);
|
||||
virtual ~MainWindow();
|
||||
|
||||
public:
|
||||
void createMenu();
|
||||
|
||||
void load_json(std::string filename, std::string pcf);
|
||||
void load_pcf(std::string filename);
|
||||
protected Q_SLOTS:
|
||||
virtual void new_proj();
|
||||
virtual void open_proj();
|
||||
@@ -78,6 +79,7 @@ class MainWindow : public BaseMainWindow
|
||||
|
||||
bool timing_driven;
|
||||
ArchArgs chipArgs;
|
||||
std::string preload_pcf;
|
||||
};
|
||||
|
||||
NEXTPNR_NAMESPACE_END
|
||||
|
||||
@@ -33,9 +33,10 @@ class InfoTab : public QWidget
|
||||
public:
|
||||
explicit InfoTab(QWidget *parent = 0);
|
||||
void info(std::string str);
|
||||
public Q_SLOTS:
|
||||
void clearBuffer();
|
||||
private Q_SLOTS:
|
||||
void showContextMenu(const QPoint &pt);
|
||||
void clearBuffer();
|
||||
|
||||
private:
|
||||
QPlainTextEdit *plainTextEdit;
|
||||
|
||||
Reference in New Issue
Block a user