Create all without ui file, enables more control
This commit is contained in:
parent
fe4d56a45a
commit
3c6f1548d6
@ -21,10 +21,6 @@ set(GENERATED_MOC_FILES
|
|||||||
${CMAKE_CURRENT_BINARY_DIR}/generated/moc_designwidget.cc
|
${CMAKE_CURRENT_BINARY_DIR}/generated/moc_designwidget.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
set(UI_SOURCES
|
|
||||||
gui/mainwindow.ui
|
|
||||||
)
|
|
||||||
qt5_wrap_ui_custom(GENERATED_UI_HEADERS ${UI_SOURCES})
|
|
||||||
qt5_add_resources_custom(GUI_RESOURCE_FILES gui/nextpnr.qrc)
|
qt5_add_resources_custom(GUI_RESOURCE_FILES gui/nextpnr.qrc)
|
||||||
|
|
||||||
aux_source_directory(gui/ GUI_ALL_SOURCE_FILES)
|
aux_source_directory(gui/ GUI_ALL_SOURCE_FILES)
|
||||||
|
@ -1,34 +1,115 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
#include <QAction>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QIcon>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QMenuBar>
|
||||||
|
#include <QSplitter>
|
||||||
|
#include <QStatusBar>
|
||||||
|
#include <QToolBar>
|
||||||
#include "designwidget.h"
|
#include "designwidget.h"
|
||||||
#include "fpgaviewwidget.h"
|
#include "fpgaviewwidget.h"
|
||||||
#include "pythontab.h"
|
#include "pythontab.h"
|
||||||
#include "ui_mainwindow.h"
|
|
||||||
|
|
||||||
MainWindow::MainWindow(Design *_design, QWidget *parent)
|
MainWindow::MainWindow(Design *_design, QWidget *parent)
|
||||||
: QMainWindow(parent), ui(new Ui::MainWindow), design(_design)
|
: QMainWindow(parent), design(_design)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
|
||||||
std::string title = "nextpnr-ice40 - " + design->chip.getChipName();
|
std::string title = "nextpnr-ice40 - " + design->chip.getChipName();
|
||||||
setWindowTitle(title.c_str());
|
setWindowTitle(title.c_str());
|
||||||
|
setObjectName(QStringLiteral("MainWindow"));
|
||||||
|
resize(1024, 768);
|
||||||
|
|
||||||
ui->splitter->addWidget(new FPGAViewWidget());
|
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);
|
||||||
|
|
||||||
DesignWidget *designview = new DesignWidget(design);
|
DesignWidget *designview = new DesignWidget(design);
|
||||||
designview->setMinimumWidth(300);
|
designview->setMinimumWidth(300);
|
||||||
designview->setMaximumWidth(300);
|
designview->setMaximumWidth(300);
|
||||||
|
splitter_h->addWidget(designview);
|
||||||
|
|
||||||
connect(designview, SIGNAL(info(std::string)), this,
|
connect(designview, SIGNAL(info(std::string)), this,
|
||||||
SLOT(writeInfo(std::string)));
|
SLOT(writeInfo(std::string)));
|
||||||
|
|
||||||
ui->splitter_2->addWidget(designview);
|
QTabWidget *tabWidget = new QTabWidget();
|
||||||
|
|
||||||
tabWidget = new QTabWidget();
|
|
||||||
tabWidget->addTab(new PythonTab(), "Python");
|
tabWidget->addTab(new PythonTab(), "Python");
|
||||||
info = new InfoTab();
|
info = new InfoTab();
|
||||||
tabWidget->addTab(info, "Info");
|
tabWidget->addTab(info, "Info");
|
||||||
ui->splitter->addWidget(tabWidget);
|
splitter_v->addWidget(new FPGAViewWidget());
|
||||||
|
splitter_v->addWidget(tabWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() { delete ui; }
|
MainWindow::~MainWindow() {}
|
||||||
|
|
||||||
void MainWindow::writeInfo(std::string text) { info->info(text); }
|
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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
QAction *actionExit = new QAction("Exit", this);
|
||||||
|
|
||||||
|
QIcon icon3;
|
||||||
|
icon3.addFile(QStringLiteral(":/icons/resources/exit.png"));
|
||||||
|
actionExit->setIcon(icon3);
|
||||||
|
|
||||||
|
QAction *actionAbout = new QAction("About", this);
|
||||||
|
|
||||||
|
QMenuBar *menuBar = new QMenuBar();
|
||||||
|
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);
|
||||||
|
|
||||||
|
QToolBar *mainToolBar = new QToolBar();
|
||||||
|
addToolBar(Qt::TopToolBarArea, mainToolBar);
|
||||||
|
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
@ -10,10 +10,6 @@
|
|||||||
// FIXME
|
// FIXME
|
||||||
USING_NEXTPNR_NAMESPACE
|
USING_NEXTPNR_NAMESPACE
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class MainWindow;
|
|
||||||
}
|
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -23,14 +19,14 @@ class MainWindow : public QMainWindow
|
|||||||
~MainWindow();
|
~MainWindow();
|
||||||
Design *getDesign() { return design; }
|
Design *getDesign() { return design; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
void createMenusAndBars();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void writeInfo(std::string text);
|
void writeInfo(std::string text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
|
||||||
Design *design;
|
Design *design;
|
||||||
|
|
||||||
QTabWidget *tabWidget;
|
|
||||||
InfoTab *info;
|
InfoTab *info;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,153 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>MainWindow</class>
|
|
||||||
<widget class="QMainWindow" name="MainWindow">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>969</width>
|
|
||||||
<height>629</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>nextpnr</string>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="centralWidget">
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QSplitter" name="splitter_3">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<widget class="QSplitter" name="splitter">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QSplitter" name="splitter_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<widget class="QMenuBar" name="menuBar">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>969</width>
|
|
||||||
<height>27</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<widget class="QMenu" name="menu_File">
|
|
||||||
<property name="title">
|
|
||||||
<string>&File</string>
|
|
||||||
</property>
|
|
||||||
<addaction name="actionNew"/>
|
|
||||||
<addaction name="actionOpen"/>
|
|
||||||
<addaction name="actionSave"/>
|
|
||||||
<addaction name="actionSave_as"/>
|
|
||||||
<addaction name="actionClose"/>
|
|
||||||
<addaction name="separator"/>
|
|
||||||
<addaction name="actionExit"/>
|
|
||||||
</widget>
|
|
||||||
<widget class="QMenu" name="menu_Help">
|
|
||||||
<property name="title">
|
|
||||||
<string>&Help</string>
|
|
||||||
</property>
|
|
||||||
<addaction name="actionAbout"/>
|
|
||||||
</widget>
|
|
||||||
<addaction name="menu_File"/>
|
|
||||||
<addaction name="menu_Help"/>
|
|
||||||
</widget>
|
|
||||||
<widget class="QToolBar" name="mainToolBar">
|
|
||||||
<attribute name="toolBarArea">
|
|
||||||
<enum>TopToolBarArea</enum>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="toolBarBreak">
|
|
||||||
<bool>false</bool>
|
|
||||||
</attribute>
|
|
||||||
<addaction name="actionNew"/>
|
|
||||||
<addaction name="actionOpen"/>
|
|
||||||
<addaction name="actionSave"/>
|
|
||||||
</widget>
|
|
||||||
<widget class="QStatusBar" name="statusBar"/>
|
|
||||||
<action name="actionNew">
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="nextpnr.qrc">
|
|
||||||
<normaloff>:/icons/resources/new.png</normaloff>:/icons/resources/new.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>New</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionOpen">
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="nextpnr.qrc">
|
|
||||||
<normaloff>:/icons/resources/open.png</normaloff>:/icons/resources/open.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Open</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionSave">
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="nextpnr.qrc">
|
|
||||||
<normaloff>:/icons/resources/save.png</normaloff>:/icons/resources/save.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Save</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionSave_as">
|
|
||||||
<property name="text">
|
|
||||||
<string>Save as ...</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionClose">
|
|
||||||
<property name="text">
|
|
||||||
<string>Close</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionExit">
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="nextpnr.qrc">
|
|
||||||
<normaloff>:/icons/resources/exit.png</normaloff>:/icons/resources/exit.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Exit</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionAbout">
|
|
||||||
<property name="text">
|
|
||||||
<string>About</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
</widget>
|
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
|
||||||
<resources>
|
|
||||||
<include location="nextpnr.qrc"/>
|
|
||||||
</resources>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>actionExit</sender>
|
|
||||||
<signal>triggered()</signal>
|
|
||||||
<receiver>MainWindow</receiver>
|
|
||||||
<slot>close()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>-1</x>
|
|
||||||
<y>-1</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>484</x>
|
|
||||||
<y>314</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
Loading…
Reference in New Issue
Block a user