Small gui improvements and open json functionality
This commit is contained in:
parent
3a505638a6
commit
b5c1b09079
@ -33,6 +33,7 @@ NEXTPNR_NAMESPACE_BEGIN
|
||||
std::vector<FILE *> log_files;
|
||||
std::vector<std::ostream *> log_streams;
|
||||
FILE *log_errfile = NULL;
|
||||
log_write_type log_write_function = nullptr;
|
||||
|
||||
bool log_error_stderr = false;
|
||||
bool log_cmd_error_throw = false;
|
||||
@ -99,6 +100,8 @@ void logv(const char *format, va_list ap)
|
||||
|
||||
for (auto f : log_streams)
|
||||
*f << str;
|
||||
if (log_write_function)
|
||||
log_write_function(str);
|
||||
}
|
||||
|
||||
void logv_info(const char *format, va_list ap)
|
||||
|
@ -20,6 +20,7 @@
|
||||
#ifndef LOG_H
|
||||
#define LOG_H
|
||||
|
||||
#include <functional>
|
||||
#include <ostream>
|
||||
#include <set>
|
||||
#include <stdarg.h>
|
||||
@ -36,6 +37,8 @@
|
||||
|
||||
NEXTPNR_NAMESPACE_BEGIN
|
||||
|
||||
typedef std::function<void(std::string)> log_write_type;
|
||||
|
||||
struct log_cmd_error_exception
|
||||
{
|
||||
};
|
||||
@ -43,6 +46,7 @@ struct log_cmd_error_exception
|
||||
extern std::vector<FILE *> log_files;
|
||||
extern std::vector<std::ostream *> log_streams;
|
||||
extern FILE *log_errfile;
|
||||
extern log_write_type log_write_function;
|
||||
|
||||
extern bool log_quiet_warnings;
|
||||
extern int log_verbose_level;
|
||||
|
@ -5,6 +5,9 @@ InfoTab::InfoTab(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
plainTextEdit = new QPlainTextEdit();
|
||||
plainTextEdit->setReadOnly(true);
|
||||
QFont f("unexistent");
|
||||
f.setStyleHint(QFont::Monospace);
|
||||
plainTextEdit->setFont(f);
|
||||
|
||||
QGridLayout *mainLayout = new QGridLayout();
|
||||
mainLayout->addWidget(plainTextEdit);
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
#include <QGridLayout>
|
||||
#include <QIcon>
|
||||
#include <QMenu>
|
||||
@ -7,13 +8,27 @@
|
||||
#include <QSplitter>
|
||||
#include <QStatusBar>
|
||||
#include <QToolBar>
|
||||
#include <fstream>
|
||||
#include "designwidget.h"
|
||||
#include "fpgaviewwidget.h"
|
||||
#include "jsonparse.h"
|
||||
#include "log.h"
|
||||
#include "pythontab.h"
|
||||
//#include "pack.h"
|
||||
//#include "pcf.h"
|
||||
#include "place_sa.h"
|
||||
#include "pybindings.h"
|
||||
#include "route.h"
|
||||
//#include "bitstream.h"
|
||||
#include "design_utils.h"
|
||||
|
||||
MainWindow::MainWindow(Context *_ctx, QWidget *parent)
|
||||
: QMainWindow(parent), ctx(_ctx)
|
||||
{
|
||||
log_files.clear();
|
||||
log_streams.clear();
|
||||
log_write_function = [this](std::string text) { info->info(text); };
|
||||
|
||||
std::string title = "nextpnr-ice40 - " + ctx->getChipName();
|
||||
setWindowTitle(title.c_str());
|
||||
setObjectName(QStringLiteral("MainWindow"));
|
||||
@ -43,7 +58,7 @@ MainWindow::MainWindow(Context *_ctx, QWidget *parent)
|
||||
connect(designview, SIGNAL(info(std::string)), this,
|
||||
SLOT(writeInfo(std::string)));
|
||||
|
||||
QTabWidget *tabWidget = new QTabWidget();
|
||||
tabWidget = new QTabWidget();
|
||||
tabWidget->addTab(new PythonTab(), "Python");
|
||||
info = new InfoTab();
|
||||
tabWidget->addTab(info, "Info");
|
||||
@ -57,30 +72,30 @@ void MainWindow::writeInfo(std::string text) { info->info(text); }
|
||||
|
||||
void MainWindow::createMenusAndBars()
|
||||
{
|
||||
QAction *actionNew = new QAction("New", this);
|
||||
QIcon icon;
|
||||
icon.addFile(QStringLiteral(":/icons/resources/new.png"));
|
||||
actionNew->setIcon(icon);
|
||||
|
||||
QAction *actionOpen = new QAction("Open", this);
|
||||
QIcon icon1;
|
||||
icon1.addFile(QStringLiteral(":/icons/resources/open.png"));
|
||||
actionOpen->setIcon(icon1);
|
||||
actionOpen->setShortcuts(QKeySequence::Open);
|
||||
actionOpen->setStatusTip("Open an existing JSON file");
|
||||
connect(actionOpen, SIGNAL(triggered()), this, SLOT(open()));
|
||||
|
||||
QAction *actionSave = new QAction("Save", this);
|
||||
QIcon icon2;
|
||||
icon2.addFile(QStringLiteral(":/icons/resources/save.png"));
|
||||
actionSave->setIcon(icon2);
|
||||
|
||||
QAction *actionSave_as = new QAction("Save as ...", this);
|
||||
|
||||
QAction *actionClose = new QAction("Close", this);
|
||||
actionSave->setShortcuts(QKeySequence::Save);
|
||||
actionSave->setStatusTip("Save the ASC to disk");
|
||||
connect(actionSave, SIGNAL(triggered()), this, SLOT(save()));
|
||||
actionSave->setEnabled(false);
|
||||
|
||||
QAction *actionExit = new QAction("Exit", this);
|
||||
|
||||
QIcon icon3;
|
||||
icon3.addFile(QStringLiteral(":/icons/resources/exit.png"));
|
||||
actionExit->setIcon(icon3);
|
||||
actionExit->setShortcuts(QKeySequence::Quit);
|
||||
actionExit->setStatusTip("Exit the application");
|
||||
connect(actionExit, SIGNAL(triggered()), this, SLOT(close()));
|
||||
|
||||
QAction *actionAbout = new QAction("About", this);
|
||||
|
||||
@ -98,18 +113,31 @@ void MainWindow::createMenusAndBars()
|
||||
QStatusBar *statusBar = new QStatusBar();
|
||||
setStatusBar(statusBar);
|
||||
|
||||
menu_File->addAction(actionNew);
|
||||
menu_File->addAction(actionOpen);
|
||||
menu_File->addAction(actionSave);
|
||||
menu_File->addAction(actionSave_as);
|
||||
menu_File->addAction(actionClose);
|
||||
menu_File->addSeparator();
|
||||
menu_File->addAction(actionExit);
|
||||
menu_Help->addAction(actionAbout);
|
||||
|
||||
mainToolBar->addAction(actionNew);
|
||||
mainToolBar->addAction(actionOpen);
|
||||
mainToolBar->addAction(actionSave);
|
||||
|
||||
connect(actionExit, SIGNAL(triggered()), this, SLOT(close()));
|
||||
}
|
||||
|
||||
void MainWindow::open()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, QString(), QString(),
|
||||
QString("*.json"));
|
||||
if (!fileName.isEmpty()) {
|
||||
tabWidget->setCurrentWidget(info);
|
||||
|
||||
std::string fn = fileName.toStdString();
|
||||
std::istream *f = new std::ifstream(fn);
|
||||
|
||||
parse_json_file(f, fn, ctx);
|
||||
|
||||
// pack_design(ctx);
|
||||
print_utilisation(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
bool MainWindow::save() { return false; }
|
||||
|
@ -24,9 +24,12 @@ class MainWindow : public QMainWindow
|
||||
|
||||
private Q_SLOTS:
|
||||
void writeInfo(std::string text);
|
||||
void open();
|
||||
bool save();
|
||||
|
||||
private:
|
||||
Context *ctx;
|
||||
QTabWidget *tabWidget;
|
||||
InfoTab *info;
|
||||
};
|
||||
|
||||
|
@ -11,9 +11,14 @@ PythonTab::PythonTab(QWidget *parent) : QWidget(parent)
|
||||
plainTextEdit = new QPlainTextEdit();
|
||||
plainTextEdit->setReadOnly(true);
|
||||
plainTextEdit->setMinimumHeight(100);
|
||||
QFont f("unexistent");
|
||||
f.setStyleHint(QFont::Monospace);
|
||||
plainTextEdit->setFont(f);
|
||||
|
||||
lineEdit = new QLineEdit();
|
||||
lineEdit->setMinimumHeight(30);
|
||||
lineEdit->setMaximumHeight(30);
|
||||
lineEdit->setFont(f);
|
||||
|
||||
QGridLayout *mainLayout = new QGridLayout();
|
||||
mainLayout->addWidget(plainTextEdit, 0, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user