1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
/*
* 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.
*
*/
#include <QAction>
#include <QFileDialog>
#include <QGridLayout>
#include <QIcon>
#include <QSplitter>
#include "designwidget.h"
#include "fpgaviewwidget.h"
#include "jsonparse.h"
#include "log.h"
#include "mainwindow.h"
#ifndef NO_PYTHON
#include "pythontab.h"
#endif
static void initBasenameResource() { Q_INIT_RESOURCE(base); }
NEXTPNR_NAMESPACE_BEGIN
BaseMainWindow::BaseMainWindow(QWidget *parent) : QMainWindow(parent), ctx(nullptr)
{
initBasenameResource();
qRegisterMetaType<std::string>();
log_files.clear();
log_streams.clear();
setObjectName(QStringLiteral("BaseMainWindow"));
resize(1024, 768);
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();
designview->setMinimumWidth(300);
designview->setMaximumWidth(300);
splitter_h->addWidget(designview);
connect(this, SIGNAL(contextChanged(Context *)), designview, SLOT(newContext(Context *)));
connect(this, SIGNAL(updateTreeView()), designview, SLOT(updateTree()));
connect(designview, SIGNAL(info(std::string)), this, SLOT(writeInfo(std::string)));
tabWidget = new QTabWidget();
#ifndef NO_PYTHON
PythonTab *pythontab = new PythonTab();
tabWidget->addTab(pythontab, "Python");
connect(this, SIGNAL(contextChanged(Context *)), pythontab, SLOT(newContext(Context *)));
#endif
info = new InfoTab();
tabWidget->addTab(info, "Info");
centralTabWidget = new QTabWidget();
FPGAViewWidget *fpgaView = new FPGAViewWidget();
centralTabWidget->addTab(fpgaView, "Graphics");
connect(this, SIGNAL(contextChanged(Context *)), fpgaView, SLOT(newContext(Context *)));
splitter_v->addWidget(centralTabWidget);
splitter_v->addWidget(tabWidget);
}
BaseMainWindow::~BaseMainWindow() {}
void BaseMainWindow::writeInfo(std::string text) { info->info(text); }
void BaseMainWindow::createMenusAndBars()
{
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()));
actionOpen = new QAction("Open", this);
QIcon iconOpen;
iconOpen.addFile(QStringLiteral(":/icons/resources/open.png"));
actionOpen->setIcon(iconOpen);
actionOpen->setShortcuts(QKeySequence::Open);
actionOpen->setStatusTip("Open an existing project file");
connect(actionOpen, SIGNAL(triggered()), this, SLOT(open_proj()));
QAction *actionSave = new QAction("Save", this);
QIcon iconSave;
iconSave.addFile(QStringLiteral(":/icons/resources/save.png"));
actionSave->setIcon(iconSave);
actionSave->setShortcuts(QKeySequence::Save);
actionSave->setStatusTip("Save existing project to disk");
connect(actionSave, SIGNAL(triggered()), this, SLOT(save_proj()));
actionSave->setEnabled(false);
QAction *actionExit = new QAction("Exit", this);
QIcon iconExit;
iconExit.addFile(QStringLiteral(":/icons/resources/exit.png"));
actionExit->setIcon(iconExit);
actionExit->setShortcuts(QKeySequence::Quit);
actionExit->setStatusTip("Exit the application");
connect(actionExit, SIGNAL(triggered()), this, SLOT(close()));
QAction *actionAbout = new QAction("About", this);
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);
mainToolBar = new QToolBar();
addToolBar(Qt::TopToolBarArea, mainToolBar);
statusBar = new QStatusBar();
setStatusBar(statusBar);
menu_File->addAction(actionNew);
menu_File->addAction(actionOpen);
menu_File->addAction(actionSave);
menu_File->addSeparator();
menu_File->addAction(actionExit);
menu_Help->addAction(actionAbout);
mainToolBar->addAction(actionNew);
mainToolBar->addAction(actionOpen);
mainToolBar->addAction(actionSave);
}
NEXTPNR_NAMESPACE_END
|