Make small GUI changes
This commit is contained in:
parent
18ad718e53
commit
26f23e3121
@ -18,16 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include <QAction>
|
#include <fstream>
|
||||||
|
#include "bitstream.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QIcon>
|
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QSet>
|
|
||||||
#include <fstream>
|
|
||||||
#include "design_utils.h"
|
|
||||||
#include "log.h"
|
|
||||||
|
|
||||||
static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
|
static void initMainResource() { Q_INIT_RESOURCE(nextpnr); }
|
||||||
|
|
||||||
@ -38,7 +35,7 @@ MainWindow::MainWindow(std::unique_ptr<Context> context, CommandHandler *handler
|
|||||||
{
|
{
|
||||||
initMainResource();
|
initMainResource();
|
||||||
|
|
||||||
std::string title = "nextpnr-xo2 - [EMPTY]";
|
std::string title = "nextpnr-machxo2 - [EMPTY]";
|
||||||
setWindowTitle(title.c_str());
|
setWindowTitle(title.c_str());
|
||||||
|
|
||||||
connect(this, &BaseMainWindow::contextChanged, this, &MainWindow::newContext);
|
connect(this, &BaseMainWindow::contextChanged, this, &MainWindow::newContext);
|
||||||
@ -48,11 +45,35 @@ MainWindow::MainWindow(std::unique_ptr<Context> context, CommandHandler *handler
|
|||||||
|
|
||||||
MainWindow::~MainWindow() {}
|
MainWindow::~MainWindow() {}
|
||||||
|
|
||||||
|
void MainWindow::newContext(Context *ctx)
|
||||||
|
{
|
||||||
|
std::string title = "nextpnr-machxo2 - " + ctx->getChipName() + " ( " + ctx->archArgs().package + " )";
|
||||||
|
setWindowTitle(title.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::createMenu()
|
void MainWindow::createMenu()
|
||||||
{
|
{
|
||||||
// Add arch specific actions
|
// 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
|
// Add actions in menus
|
||||||
|
mainActionBar->addSeparator();
|
||||||
|
mainActionBar->addAction(actionLoadLPF);
|
||||||
|
mainActionBar->addAction(actionSaveConfig);
|
||||||
|
|
||||||
|
menuDesign->addSeparator();
|
||||||
|
menuDesign->addAction(actionLoadLPF);
|
||||||
|
menuDesign->addAction(actionSaveConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::new_proj()
|
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();
|
QString fileName = QFileDialog::getOpenFileName(this, QString("Open LPF"), QString(), QString("*.lpf"));
|
||||||
setWindowTitle(title.c_str());
|
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
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -35,13 +35,19 @@ class MainWindow : public BaseMainWindow
|
|||||||
public:
|
public:
|
||||||
void createMenu();
|
void createMenu();
|
||||||
|
|
||||||
|
protected:
|
||||||
void onDisableActions() override;
|
void onDisableActions() override;
|
||||||
void onUpdateActions() override;
|
void onUpdateActions() override;
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
void new_proj() override;
|
void new_proj() override;
|
||||||
|
|
||||||
void newContext(Context *ctx);
|
void newContext(Context *ctx);
|
||||||
|
void open_lpf();
|
||||||
|
void save_config();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QAction *actionLoadLPF;
|
||||||
|
QAction *actionSaveConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -1,2 +1,7 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
|
<qresource prefix="/icons">
|
||||||
|
<file>resources/open_lpf.png</file>
|
||||||
|
<file>resources/open_base.png</file>
|
||||||
|
<file>resources/save_config.png</file>
|
||||||
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
BIN
gui/machxo2/resources/open_base.png
Normal file
BIN
gui/machxo2/resources/open_base.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
gui/machxo2/resources/open_lpf.png
Normal file
BIN
gui/machxo2/resources/open_lpf.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.1 KiB |
BIN
gui/machxo2/resources/save_config.png
Normal file
BIN
gui/machxo2/resources/save_config.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
Loading…
Reference in New Issue
Block a user