Added context menus for python and info tab
This commit is contained in:
parent
5ca4663294
commit
6d2f058f67
@ -9,6 +9,16 @@ InfoTab::InfoTab(QWidget *parent) : QWidget(parent)
|
|||||||
f.setStyleHint(QFont::Monospace);
|
f.setStyleHint(QFont::Monospace);
|
||||||
plainTextEdit->setFont(f);
|
plainTextEdit->setFont(f);
|
||||||
|
|
||||||
|
plainTextEdit->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
QAction *clearAction = new QAction("Clear &buffer", this);
|
||||||
|
clearAction->setStatusTip("Clears display buffer");
|
||||||
|
connect(clearAction, SIGNAL(triggered()), this, SLOT(clearBuffer()));
|
||||||
|
contextMenu = plainTextEdit->createStandardContextMenu();
|
||||||
|
contextMenu->addSeparator();
|
||||||
|
contextMenu->addAction(clearAction);
|
||||||
|
connect(plainTextEdit, SIGNAL(customContextMenuRequested(const QPoint)),
|
||||||
|
this, SLOT(showContextMenu(const QPoint)));
|
||||||
|
|
||||||
QGridLayout *mainLayout = new QGridLayout();
|
QGridLayout *mainLayout = new QGridLayout();
|
||||||
mainLayout->addWidget(plainTextEdit);
|
mainLayout->addWidget(plainTextEdit);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
@ -20,3 +30,10 @@ void InfoTab::info(std::string str)
|
|||||||
plainTextEdit->insertPlainText(str.c_str());
|
plainTextEdit->insertPlainText(str.c_str());
|
||||||
plainTextEdit->moveCursor(QTextCursor::End);
|
plainTextEdit->moveCursor(QTextCursor::End);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InfoTab::showContextMenu(const QPoint &pt)
|
||||||
|
{
|
||||||
|
contextMenu->exec(mapToGlobal(pt));
|
||||||
|
}
|
||||||
|
|
||||||
|
void InfoTab::clearBuffer() { plainTextEdit->clear(); }
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef INFOTAB_H
|
#ifndef INFOTAB_H
|
||||||
#define INFOTAB_H
|
#define INFOTAB_H
|
||||||
|
|
||||||
|
#include <QMenu>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include "nextpnr.h"
|
#include "nextpnr.h"
|
||||||
|
|
||||||
@ -14,9 +15,13 @@ class InfoTab : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit InfoTab(QWidget *parent = 0);
|
explicit InfoTab(QWidget *parent = 0);
|
||||||
void info(std::string str);
|
void info(std::string str);
|
||||||
|
private Q_SLOTS:
|
||||||
|
void showContextMenu(const QPoint &pt);
|
||||||
|
void clearBuffer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPlainTextEdit *plainTextEdit;
|
QPlainTextEdit *plainTextEdit;
|
||||||
|
QMenu *contextMenu;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INFOTAB_H
|
#endif // INFOTAB_H
|
||||||
|
@ -15,6 +15,16 @@ PythonTab::PythonTab(QWidget *parent) : QWidget(parent)
|
|||||||
f.setStyleHint(QFont::Monospace);
|
f.setStyleHint(QFont::Monospace);
|
||||||
plainTextEdit->setFont(f);
|
plainTextEdit->setFont(f);
|
||||||
|
|
||||||
|
plainTextEdit->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
QAction *clearAction = new QAction("Clear &buffer", this);
|
||||||
|
clearAction->setStatusTip("Clears display buffer");
|
||||||
|
connect(clearAction, SIGNAL(triggered()), this, SLOT(clearBuffer()));
|
||||||
|
contextMenu = plainTextEdit->createStandardContextMenu();
|
||||||
|
contextMenu->addSeparator();
|
||||||
|
contextMenu->addAction(clearAction);
|
||||||
|
connect(plainTextEdit, SIGNAL(customContextMenuRequested(const QPoint)),
|
||||||
|
this, SLOT(showContextMenu(const QPoint)));
|
||||||
|
|
||||||
lineEdit = new LineEditor();
|
lineEdit = new LineEditor();
|
||||||
lineEdit->setMinimumHeight(30);
|
lineEdit->setMinimumHeight(30);
|
||||||
lineEdit->setMaximumHeight(30);
|
lineEdit->setMaximumHeight(30);
|
||||||
@ -98,3 +108,10 @@ void PythonTab::editLineReturnPressed(QString text)
|
|||||||
print(std::string(">>> " + input + "\n"));
|
print(std::string(">>> " + input + "\n"));
|
||||||
int error = executePython(input);
|
int error = executePython(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PythonTab::showContextMenu(const QPoint &pt)
|
||||||
|
{
|
||||||
|
contextMenu->exec(mapToGlobal(pt));
|
||||||
|
}
|
||||||
|
|
||||||
|
void PythonTab::clearBuffer() { plainTextEdit->clear(); }
|
@ -2,6 +2,7 @@
|
|||||||
#define PYTHONTAB_H
|
#define PYTHONTAB_H
|
||||||
|
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
#include <QMenu>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include "emb.h"
|
#include "emb.h"
|
||||||
#include "line_editor.h"
|
#include "line_editor.h"
|
||||||
@ -22,10 +23,13 @@ class PythonTab : public QWidget
|
|||||||
int executePython(std::string &command);
|
int executePython(std::string &command);
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void editLineReturnPressed(QString text);
|
void editLineReturnPressed(QString text);
|
||||||
|
void showContextMenu(const QPoint &pt);
|
||||||
|
void clearBuffer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPlainTextEdit *plainTextEdit;
|
QPlainTextEdit *plainTextEdit;
|
||||||
LineEditor *lineEdit;
|
LineEditor *lineEdit;
|
||||||
|
QMenu *contextMenu;
|
||||||
emb::stdout_write_type write;
|
emb::stdout_write_type write;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user