2018-06-22 22:21:20 +08:00
|
|
|
/*
|
|
|
|
* nextpnr -- Next Generation Place and Route
|
|
|
|
*
|
|
|
|
* Copyright (C) 2018 Miodrag Milanovic <miodrag@symbioticeda.com>
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-06-15 18:22:44 +08:00
|
|
|
#include <QAction>
|
2018-06-19 21:17:10 +08:00
|
|
|
#include <QFileDialog>
|
2018-06-15 18:22:44 +08:00
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QSplitter>
|
2018-06-15 02:03:59 +08:00
|
|
|
#include "designwidget.h"
|
|
|
|
#include "fpgaviewwidget.h"
|
2018-06-19 21:17:10 +08:00
|
|
|
#include "jsonparse.h"
|
|
|
|
#include "log.h"
|
2018-06-21 19:55:36 +08:00
|
|
|
#include "mainwindow.h"
|
2018-06-23 20:32:18 +08:00
|
|
|
|
|
|
|
#ifndef NO_PYTHON
|
2018-06-15 02:03:59 +08:00
|
|
|
#include "pythontab.h"
|
2018-06-23 20:32:18 +08:00
|
|
|
#endif
|
2018-06-21 21:41:40 +08:00
|
|
|
|
2018-06-22 19:10:27 +08:00
|
|
|
static void initBasenameResource() { Q_INIT_RESOURCE(base); }
|
|
|
|
|
|
|
|
NEXTPNR_NAMESPACE_BEGIN
|
|
|
|
|
2018-06-23 22:06:49 +08:00
|
|
|
BaseMainWindow::BaseMainWindow(Context *_ctx, QWidget *parent) : QMainWindow(parent), ctx(_ctx)
|
2018-06-15 00:37:57 +08:00
|
|
|
{
|
2018-06-22 19:10:27 +08:00
|
|
|
initBasenameResource();
|
2018-06-21 21:41:40 +08:00
|
|
|
qRegisterMetaType<std::string>();
|
2018-06-20 22:13:49 +08:00
|
|
|
|
2018-06-19 21:17:10 +08:00
|
|
|
log_files.clear();
|
|
|
|
log_streams.clear();
|
|
|
|
|
2018-06-21 19:41:16 +08:00
|
|
|
setObjectName(QStringLiteral("BaseMainWindow"));
|
2018-06-15 18:22:44 +08:00
|
|
|
resize(1024, 768);
|
2018-06-15 00:37:57 +08:00
|
|
|
|
2018-06-15 18:22:44 +08:00
|
|
|
createMenusAndBars();
|
|
|
|
|
|
|
|
QWidget *centralWidget = new QWidget(this);
|
|
|
|
|
|
|
|
QGridLayout *gridLayout = new QGridLayout(centralWidget);
|
|
|
|
gridLayout->setSpacing(6);
|
|
|
|
gridLayout->setContentsMargins(11, 11, 11, 11);
|
|
|
|
|
|
|
|
QSplitter *splitter_h = new QSplitter(Qt::Horizontal, centralWidget);
|
|
|
|
QSplitter *splitter_v = new QSplitter(Qt::Vertical, splitter_h);
|
|
|
|
splitter_h->addWidget(splitter_v);
|
|
|
|
|
|
|
|
gridLayout->addWidget(splitter_h, 0, 0, 1, 1);
|
|
|
|
|
|
|
|
setCentralWidget(centralWidget);
|
2018-06-15 00:37:57 +08:00
|
|
|
|
2018-06-18 20:06:37 +08:00
|
|
|
DesignWidget *designview = new DesignWidget(ctx);
|
2018-06-15 02:24:05 +08:00
|
|
|
designview->setMinimumWidth(300);
|
|
|
|
designview->setMaximumWidth(300);
|
2018-06-15 18:22:44 +08:00
|
|
|
splitter_h->addWidget(designview);
|
2018-06-15 02:24:05 +08:00
|
|
|
|
2018-06-23 22:06:49 +08:00
|
|
|
connect(designview, SIGNAL(info(std::string)), this, SLOT(writeInfo(std::string)));
|
2018-06-15 17:10:11 +08:00
|
|
|
|
2018-06-19 21:17:10 +08:00
|
|
|
tabWidget = new QTabWidget();
|
2018-06-23 20:32:18 +08:00
|
|
|
#ifndef NO_PYTHON
|
2018-06-15 00:37:57 +08:00
|
|
|
tabWidget->addTab(new PythonTab(), "Python");
|
2018-06-23 20:32:18 +08:00
|
|
|
#endif
|
2018-06-15 00:37:57 +08:00
|
|
|
info = new InfoTab();
|
|
|
|
tabWidget->addTab(info, "Info");
|
2018-06-21 20:12:02 +08:00
|
|
|
|
|
|
|
centralTabWidget = new QTabWidget();
|
|
|
|
centralTabWidget->addTab(new FPGAViewWidget(), "Graphics");
|
|
|
|
|
|
|
|
splitter_v->addWidget(centralTabWidget);
|
2018-06-15 18:22:44 +08:00
|
|
|
splitter_v->addWidget(tabWidget);
|
2018-06-15 00:37:57 +08:00
|
|
|
}
|
|
|
|
|
2018-06-21 19:41:16 +08:00
|
|
|
BaseMainWindow::~BaseMainWindow() {}
|
2018-06-15 17:10:11 +08:00
|
|
|
|
2018-06-21 19:41:16 +08:00
|
|
|
void BaseMainWindow::writeInfo(std::string text) { info->info(text); }
|
2018-06-15 18:22:44 +08:00
|
|
|
|
2018-06-21 19:41:16 +08:00
|
|
|
void BaseMainWindow::createMenusAndBars()
|
2018-06-15 18:22:44 +08:00
|
|
|
{
|
2018-06-26 20:17:17 +08:00
|
|
|
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()));
|
|
|
|
|
2018-06-15 18:22:44 +08:00
|
|
|
QAction *actionOpen = new QAction("Open", this);
|
2018-06-26 20:17:17 +08:00
|
|
|
QIcon iconOpen;
|
|
|
|
iconOpen.addFile(QStringLiteral(":/icons/resources/open.png"));
|
|
|
|
actionOpen->setIcon(iconOpen);
|
2018-06-19 21:17:10 +08:00
|
|
|
actionOpen->setShortcuts(QKeySequence::Open);
|
2018-06-26 20:17:17 +08:00
|
|
|
actionOpen->setStatusTip("Open an existing project file");
|
|
|
|
connect(actionOpen, SIGNAL(triggered()), this, SLOT(open_proj()));
|
2018-06-15 18:22:44 +08:00
|
|
|
|
|
|
|
QAction *actionSave = new QAction("Save", this);
|
2018-06-26 20:17:17 +08:00
|
|
|
QIcon iconSave;
|
|
|
|
iconSave.addFile(QStringLiteral(":/icons/resources/save.png"));
|
|
|
|
actionSave->setIcon(iconSave);
|
2018-06-19 21:17:10 +08:00
|
|
|
actionSave->setShortcuts(QKeySequence::Save);
|
2018-06-26 20:17:17 +08:00
|
|
|
actionSave->setStatusTip("Save existing project to disk");
|
|
|
|
connect(actionSave, SIGNAL(triggered()), this, SLOT(save_proj()));
|
2018-06-19 21:17:10 +08:00
|
|
|
actionSave->setEnabled(false);
|
2018-06-15 18:22:44 +08:00
|
|
|
|
|
|
|
QAction *actionExit = new QAction("Exit", this);
|
2018-06-26 20:17:17 +08:00
|
|
|
QIcon iconExit;
|
|
|
|
iconExit.addFile(QStringLiteral(":/icons/resources/exit.png"));
|
|
|
|
actionExit->setIcon(iconExit);
|
2018-06-19 21:17:10 +08:00
|
|
|
actionExit->setShortcuts(QKeySequence::Quit);
|
|
|
|
actionExit->setStatusTip("Exit the application");
|
|
|
|
connect(actionExit, SIGNAL(triggered()), this, SLOT(close()));
|
2018-06-15 18:22:44 +08:00
|
|
|
|
|
|
|
QAction *actionAbout = new QAction("About", this);
|
|
|
|
|
2018-06-21 19:41:16 +08:00
|
|
|
menuBar = new QMenuBar();
|
2018-06-15 18:22:44 +08:00
|
|
|
menuBar->setGeometry(QRect(0, 0, 1024, 27));
|
|
|
|
QMenu *menu_File = new QMenu("&File", menuBar);
|
|
|
|
QMenu *menu_Help = new QMenu("&Help", menuBar);
|
|
|
|
menuBar->addAction(menu_File->menuAction());
|
|
|
|
menuBar->addAction(menu_Help->menuAction());
|
|
|
|
setMenuBar(menuBar);
|
|
|
|
|
2018-06-21 19:41:16 +08:00
|
|
|
mainToolBar = new QToolBar();
|
2018-06-15 18:22:44 +08:00
|
|
|
addToolBar(Qt::TopToolBarArea, mainToolBar);
|
|
|
|
|
2018-06-21 19:41:16 +08:00
|
|
|
statusBar = new QStatusBar();
|
2018-06-15 18:22:44 +08:00
|
|
|
setStatusBar(statusBar);
|
|
|
|
|
2018-06-26 20:17:17 +08:00
|
|
|
menu_File->addAction(actionNew);
|
2018-06-15 18:22:44 +08:00
|
|
|
menu_File->addAction(actionOpen);
|
|
|
|
menu_File->addAction(actionSave);
|
|
|
|
menu_File->addSeparator();
|
|
|
|
menu_File->addAction(actionExit);
|
|
|
|
menu_Help->addAction(actionAbout);
|
|
|
|
|
2018-06-26 20:17:17 +08:00
|
|
|
mainToolBar->addAction(actionNew);
|
2018-06-15 18:22:44 +08:00
|
|
|
mainToolBar->addAction(actionOpen);
|
|
|
|
mainToolBar->addAction(actionSave);
|
2018-06-19 21:17:10 +08:00
|
|
|
}
|
2018-06-22 19:10:27 +08:00
|
|
|
|
|
|
|
NEXTPNR_NAMESPACE_END
|