join python and info into one tab
This commit is contained in:
parent
98c5948856
commit
5216e48863
@ -54,6 +54,10 @@ find_package(Sanitizers)
|
|||||||
# List of Boost libraries to include
|
# List of Boost libraries to include
|
||||||
set(boost_libs filesystem thread program_options)
|
set(boost_libs filesystem thread program_options)
|
||||||
|
|
||||||
|
if (BUILD_GUI AND NOT BUILD_PYTHON)
|
||||||
|
message(FATAL_ERROR "GUI requires Python to build")
|
||||||
|
endif()
|
||||||
|
|
||||||
if (BUILD_PYTHON)
|
if (BUILD_PYTHON)
|
||||||
# TODO: sensible minimum Python version
|
# TODO: sensible minimum Python version
|
||||||
find_package(PythonInterp 3.5 REQUIRED)
|
find_package(PythonInterp 3.5 REQUIRED)
|
||||||
|
@ -27,10 +27,7 @@
|
|||||||
#include "jsonparse.h"
|
#include "jsonparse.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#ifndef NO_PYTHON
|
|
||||||
#include "pythontab.h"
|
#include "pythontab.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
static void initBasenameResource() { Q_INIT_RESOURCE(base); }
|
static void initBasenameResource() { Q_INIT_RESOURCE(base); }
|
||||||
|
|
||||||
@ -74,13 +71,10 @@ BaseMainWindow::BaseMainWindow(std::unique_ptr<Context> context, QWidget *parent
|
|||||||
connect(designview, SIGNAL(info(std::string)), this, SLOT(writeInfo(std::string)));
|
connect(designview, SIGNAL(info(std::string)), this, SLOT(writeInfo(std::string)));
|
||||||
|
|
||||||
tabWidget = new QTabWidget();
|
tabWidget = new QTabWidget();
|
||||||
#ifndef NO_PYTHON
|
|
||||||
PythonTab *pythontab = new PythonTab();
|
console = new PythonTab();
|
||||||
tabWidget->addTab(pythontab, "Console");
|
tabWidget->addTab(console, "Console");
|
||||||
connect(this, SIGNAL(contextChanged(Context *)), pythontab, SLOT(newContext(Context *)));
|
connect(this, SIGNAL(contextChanged(Context *)), console, SLOT(newContext(Context *)));
|
||||||
#endif
|
|
||||||
info = new InfoTab();
|
|
||||||
tabWidget->addTab(info, "Info");
|
|
||||||
|
|
||||||
centralTabWidget = new QTabWidget();
|
centralTabWidget = new QTabWidget();
|
||||||
FPGAViewWidget *fpgaView = new FPGAViewWidget();
|
FPGAViewWidget *fpgaView = new FPGAViewWidget();
|
||||||
@ -94,7 +88,7 @@ BaseMainWindow::BaseMainWindow(std::unique_ptr<Context> context, QWidget *parent
|
|||||||
|
|
||||||
BaseMainWindow::~BaseMainWindow() {}
|
BaseMainWindow::~BaseMainWindow() {}
|
||||||
|
|
||||||
void BaseMainWindow::writeInfo(std::string text) { info->info(text); }
|
void BaseMainWindow::writeInfo(std::string text) { console->info(text); }
|
||||||
|
|
||||||
void BaseMainWindow::createMenusAndBars()
|
void BaseMainWindow::createMenusAndBars()
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#ifndef BASEMAINWINDOW_H
|
#ifndef BASEMAINWINDOW_H
|
||||||
#define BASEMAINWINDOW_H
|
#define BASEMAINWINDOW_H
|
||||||
|
|
||||||
#include "infotab.h"
|
|
||||||
#include "nextpnr.h"
|
#include "nextpnr.h"
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
@ -35,6 +34,8 @@ Q_DECLARE_METATYPE(std::string)
|
|||||||
|
|
||||||
NEXTPNR_NAMESPACE_BEGIN
|
NEXTPNR_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
class PythonTab;
|
||||||
|
|
||||||
class BaseMainWindow : public QMainWindow
|
class BaseMainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -62,7 +63,7 @@ class BaseMainWindow : public QMainWindow
|
|||||||
std::unique_ptr<Context> ctx;
|
std::unique_ptr<Context> ctx;
|
||||||
QTabWidget *tabWidget;
|
QTabWidget *tabWidget;
|
||||||
QTabWidget *centralTabWidget;
|
QTabWidget *centralTabWidget;
|
||||||
InfoTab *info;
|
PythonTab *console;
|
||||||
|
|
||||||
QMenuBar *menuBar;
|
QMenuBar *menuBar;
|
||||||
QToolBar *mainToolBar;
|
QToolBar *mainToolBar;
|
||||||
|
@ -253,7 +253,6 @@ void MainWindow::new_proj()
|
|||||||
|
|
||||||
void MainWindow::load_json(std::string filename, std::string pcf)
|
void MainWindow::load_json(std::string filename, std::string pcf)
|
||||||
{
|
{
|
||||||
tabWidget->setCurrentWidget(info);
|
|
||||||
preload_pcf = pcf;
|
preload_pcf = pcf;
|
||||||
disableActions();
|
disableActions();
|
||||||
Q_EMIT task->loadfile(filename);
|
Q_EMIT task->loadfile(filename);
|
||||||
@ -261,8 +260,6 @@ void MainWindow::load_json(std::string filename, std::string pcf)
|
|||||||
|
|
||||||
void MainWindow::load_pcf(std::string filename)
|
void MainWindow::load_pcf(std::string filename)
|
||||||
{
|
{
|
||||||
tabWidget->setCurrentWidget(info);
|
|
||||||
|
|
||||||
disableActions();
|
disableActions();
|
||||||
Q_EMIT task->loadpcf(filename);
|
Q_EMIT task->loadpcf(filename);
|
||||||
}
|
}
|
||||||
@ -271,15 +268,12 @@ void MainWindow::newContext(Context *ctx)
|
|||||||
{
|
{
|
||||||
std::string title = "nextpnr-ice40 - " + ctx->getChipName() + " ( " + chipArgs.package + " )";
|
std::string title = "nextpnr-ice40 - " + ctx->getChipName() + " ( " + chipArgs.package + " )";
|
||||||
setWindowTitle(title.c_str());
|
setWindowTitle(title.c_str());
|
||||||
info->clearBuffer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::open_proj()
|
void MainWindow::open_proj()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getOpenFileName(this, QString("Open Project"), QString(), QString("*.proj"));
|
QString fileName = QFileDialog::getOpenFileName(this, QString("Open Project"), QString(), QString("*.proj"));
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
tabWidget->setCurrentWidget(info);
|
|
||||||
|
|
||||||
std::string fn = fileName.toStdString();
|
std::string fn = fileName.toStdString();
|
||||||
disableActions();
|
disableActions();
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NO_PYTHON
|
|
||||||
|
|
||||||
#include "line_editor.h"
|
#include "line_editor.h"
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QToolTip>
|
#include <QToolTip>
|
||||||
@ -131,5 +129,3 @@ void LineEditor::autocomplete()
|
|||||||
}
|
}
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
|
||||||
#endif // NO_PYTHON
|
|
||||||
|
@ -21,8 +21,6 @@
|
|||||||
#ifndef LINE_EDITOR_H
|
#ifndef LINE_EDITOR_H
|
||||||
#define LINE_EDITOR_H
|
#define LINE_EDITOR_H
|
||||||
|
|
||||||
#ifndef NO_PYTHON
|
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include "ParseHelper.h"
|
#include "ParseHelper.h"
|
||||||
@ -59,6 +57,4 @@ class LineEditor : public QLineEdit
|
|||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
|
||||||
#endif // NO_PYTHON
|
|
||||||
|
|
||||||
#endif // LINE_EDITOR_H
|
#endif // LINE_EDITOR_H
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NO_PYTHON
|
|
||||||
|
|
||||||
#include "pyconsole.h"
|
#include "pyconsole.h"
|
||||||
#include "pyinterpreter.h"
|
#include "pyinterpreter.h"
|
||||||
|
|
||||||
@ -68,6 +66,7 @@ void PythonConsole::displayString(QString text)
|
|||||||
setTextColor(NORMAL_COLOR);
|
setTextColor(NORMAL_COLOR);
|
||||||
cursor.insertText(text);
|
cursor.insertText(text);
|
||||||
cursor.movePosition(QTextCursor::EndOfLine);
|
cursor.movePosition(QTextCursor::EndOfLine);
|
||||||
|
moveCursorToEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PythonConsole::moveCursorToEnd()
|
void PythonConsole::moveCursorToEnd()
|
||||||
@ -78,5 +77,3 @@ void PythonConsole::moveCursorToEnd()
|
|||||||
}
|
}
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
|
|
||||||
#endif // NO_PYTHON
|
|
||||||
|
@ -21,8 +21,6 @@
|
|||||||
#ifndef PYCONSOLE_H
|
#ifndef PYCONSOLE_H
|
||||||
#define PYCONSOLE_H
|
#define PYCONSOLE_H
|
||||||
|
|
||||||
#ifndef NO_PYTHON
|
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
@ -53,6 +51,5 @@ class PythonConsole : public QTextEdit, public ParseListener
|
|||||||
};
|
};
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
#endif // NO_PYTHON
|
|
||||||
|
|
||||||
#endif // PYCONSOLE_H
|
#endif // PYCONSOLE_H
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#ifndef NO_PYTHON
|
|
||||||
|
|
||||||
#include "pythontab.h"
|
#include "pythontab.h"
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
@ -77,7 +76,6 @@ PythonTab::~PythonTab()
|
|||||||
void PythonTab::editLineReturnPressed(QString text)
|
void PythonTab::editLineReturnPressed(QString text)
|
||||||
{
|
{
|
||||||
console->displayString(prompt + text + "\n");
|
console->displayString(prompt + text + "\n");
|
||||||
console->moveCursorToEnd();
|
|
||||||
|
|
||||||
parseHelper.process(text.toStdString());
|
parseHelper.process(text.toStdString());
|
||||||
|
|
||||||
@ -114,6 +112,6 @@ void PythonTab::showContextMenu(const QPoint &pt) { contextMenu->exec(mapToGloba
|
|||||||
|
|
||||||
void PythonTab::clearBuffer() { console->clear(); }
|
void PythonTab::clearBuffer() { console->clear(); }
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
void PythonTab::info(std::string str) { console->displayString(str.c_str()); }
|
||||||
|
|
||||||
#endif // NO_PYTHON
|
NEXTPNR_NAMESPACE_END
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
#ifndef PYTHONTAB_H
|
#ifndef PYTHONTAB_H
|
||||||
#define PYTHONTAB_H
|
#define PYTHONTAB_H
|
||||||
|
|
||||||
#ifndef NO_PYTHON
|
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
@ -42,10 +40,11 @@ class PythonTab : public QWidget
|
|||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void showContextMenu(const QPoint &pt);
|
void showContextMenu(const QPoint &pt);
|
||||||
void clearBuffer();
|
|
||||||
void editLineReturnPressed(QString text);
|
void editLineReturnPressed(QString text);
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void newContext(Context *ctx);
|
void newContext(Context *ctx);
|
||||||
|
void info(std::string str);
|
||||||
|
void clearBuffer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PythonConsole *console;
|
PythonConsole *console;
|
||||||
@ -60,6 +59,5 @@ class PythonTab : public QWidget
|
|||||||
};
|
};
|
||||||
|
|
||||||
NEXTPNR_NAMESPACE_END
|
NEXTPNR_NAMESPACE_END
|
||||||
#endif // NO_PYTHON
|
|
||||||
|
|
||||||
#endif // PYTHONTAB_H
|
#endif // PYTHONTAB_H
|
||||||
|
Loading…
Reference in New Issue
Block a user