From 26f23e31212d41c713127d20e561d00260c80408 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 8 Mar 2023 11:54:53 +0100 Subject: Make small GUI changes --- gui/machxo2/mainwindow.cc | 78 ++++++++++++++++++++++++++++------ gui/machxo2/mainwindow.h | 8 +++- gui/machxo2/nextpnr.qrc | 5 +++ gui/machxo2/resources/open_base.png | Bin 0 -> 2175 bytes gui/machxo2/resources/open_lpf.png | Bin 0 -> 2117 bytes gui/machxo2/resources/save_config.png | Bin 0 -> 1645 bytes 6 files changed, 77 insertions(+), 14 deletions(-) create mode 100644 gui/machxo2/resources/open_base.png create mode 100644 gui/machxo2/resources/open_lpf.png create mode 100644 gui/machxo2/resources/save_config.png diff --git a/gui/machxo2/mainwindow.cc b/gui/machxo2/mainwindow.cc index 6302d9fa..2ecba910 100644 --- a/gui/machxo2/mainwindow.cc +++ b/gui/machxo2/mainwindow.cc @@ -18,16 +18,13 @@ */ #include "mainwindow.h" -#include +#include +#include "bitstream.h" +#include "log.h" + #include -#include -#include #include #include -#include -#include -#include "design_utils.h" -#include "log.h" static void initMainResource() { Q_INIT_RESOURCE(nextpnr); } @@ -38,7 +35,7 @@ MainWindow::MainWindow(std::unique_ptr context, CommandHandler *handler { initMainResource(); - std::string title = "nextpnr-xo2 - [EMPTY]"; + std::string title = "nextpnr-machxo2 - [EMPTY]"; setWindowTitle(title.c_str()); connect(this, &BaseMainWindow::contextChanged, this, &MainWindow::newContext); @@ -48,11 +45,35 @@ MainWindow::MainWindow(std::unique_ptr context, CommandHandler *handler MainWindow::~MainWindow() {} +void MainWindow::newContext(Context *ctx) +{ + std::string title = "nextpnr-machxo2 - " + ctx->getChipName() + " ( " + ctx->archArgs().package + " )"; + setWindowTitle(title.c_str()); +} + void MainWindow::createMenu() { // Add arch specific actions + actionLoadLPF = new QAction("Open LPF", this); + actionLoadLPF->setIcon(QIcon(":/icons/resources/open_lpf.png")); + actionLoadLPF->setStatusTip("Open LPF file"); + actionLoadLPF->setEnabled(false); + connect(actionLoadLPF, &QAction::triggered, this, &MainWindow::open_lpf); + + actionSaveConfig = new QAction("Save Bitstream", this); + actionSaveConfig->setIcon(QIcon(":/icons/resources/save_config.png")); + actionSaveConfig->setStatusTip("Save Bitstream config file"); + actionSaveConfig->setEnabled(false); + connect(actionSaveConfig, &QAction::triggered, this, &MainWindow::save_config); // Add actions in menus + mainActionBar->addSeparator(); + mainActionBar->addAction(actionLoadLPF); + mainActionBar->addAction(actionSaveConfig); + + menuDesign->addSeparator(); + menuDesign->addAction(actionLoadLPF); + menuDesign->addAction(actionSaveConfig); } void MainWindow::new_proj() @@ -94,14 +115,45 @@ void MainWindow::new_proj() } } -void MainWindow::newContext(Context *ctx) +void MainWindow::open_lpf() { - std::string title = "nextpnr-xo2 - " + ctx->getChipName(); - setWindowTitle(title.c_str()); + QString fileName = QFileDialog::getOpenFileName(this, QString("Open LPF"), QString(), QString("*.lpf")); + if (!fileName.isEmpty()) { + /*std::ifstream in(fileName.toStdString()); + if (ctx->apply_lpf(fileName.toStdString(), in)) { + log("Loading LPF successful.\n"); + actionPack->setEnabled(true); + actionLoadLPF->setEnabled(false); + } else { + actionLoadLPF->setEnabled(true); + log("Loading LPF failed.\n"); + }*/ + } } -void MainWindow::onDisableActions() {} +void MainWindow::save_config() +{ + QString fileName = QFileDialog::getSaveFileName(this, QString("Save Bitstream"), QString(), QString("*.config")); + if (!fileName.isEmpty()) { + std::string fn = fileName.toStdString(); + disableActions(); + write_bitstream(ctx.get(), fileName.toStdString()); + log("Saving Bitstream successful.\n"); + } +} -void MainWindow::onUpdateActions() {} +void MainWindow::onDisableActions() +{ + actionLoadLPF->setEnabled(false); + actionSaveConfig->setEnabled(false); +} + +void MainWindow::onUpdateActions() +{ + if (ctx->settings.find(ctx->id("pack")) == ctx->settings.end()) + actionLoadLPF->setEnabled(true); + if (ctx->settings.find(ctx->id("route")) != ctx->settings.end()) + actionSaveConfig->setEnabled(true); +} NEXTPNR_NAMESPACE_END diff --git a/gui/machxo2/mainwindow.h b/gui/machxo2/mainwindow.h index 2dcd052f..20d72c68 100644 --- a/gui/machxo2/mainwindow.h +++ b/gui/machxo2/mainwindow.h @@ -35,13 +35,19 @@ class MainWindow : public BaseMainWindow public: void createMenu(); + protected: void onDisableActions() override; void onUpdateActions() override; protected Q_SLOTS: void new_proj() override; - void newContext(Context *ctx); + void open_lpf(); + void save_config(); + + private: + QAction *actionLoadLPF; + QAction *actionSaveConfig; }; NEXTPNR_NAMESPACE_END diff --git a/gui/machxo2/nextpnr.qrc b/gui/machxo2/nextpnr.qrc index 03585ec0..ca7e5b1a 100644 --- a/gui/machxo2/nextpnr.qrc +++ b/gui/machxo2/nextpnr.qrc @@ -1,2 +1,7 @@ + + resources/open_lpf.png + resources/open_base.png + resources/save_config.png + diff --git a/gui/machxo2/resources/open_base.png b/gui/machxo2/resources/open_base.png new file mode 100644 index 00000000..b60cf25a Binary files /dev/null and b/gui/machxo2/resources/open_base.png differ diff --git a/gui/machxo2/resources/open_lpf.png b/gui/machxo2/resources/open_lpf.png new file mode 100644 index 00000000..54b6f6f9 Binary files /dev/null and b/gui/machxo2/resources/open_lpf.png differ diff --git a/gui/machxo2/resources/save_config.png b/gui/machxo2/resources/save_config.png new file mode 100644 index 00000000..63b5ab56 Binary files /dev/null and b/gui/machxo2/resources/save_config.png differ -- cgit v1.2.3