aboutsummaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2018-06-20 12:34:06 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2018-06-20 12:35:43 +0200
commit6d2f058f678761e90fc451af48f4e0ed0f504603 (patch)
treeb10cae980644e156eea3b6b1e1ab5e666c267400 /gui
parent5ca4663294aff1f4af45e9abfffa20c1e44ea017 (diff)
downloadnextpnr-6d2f058f678761e90fc451af48f4e0ed0f504603.tar.gz
nextpnr-6d2f058f678761e90fc451af48f4e0ed0f504603.tar.bz2
nextpnr-6d2f058f678761e90fc451af48f4e0ed0f504603.zip
Added context menus for python and info tab
Diffstat (limited to 'gui')
-rw-r--r--gui/infotab.cc17
-rw-r--r--gui/infotab.h5
-rw-r--r--gui/pythontab.cc17
-rw-r--r--gui/pythontab.h4
4 files changed, 43 insertions, 0 deletions
diff --git a/gui/infotab.cc b/gui/infotab.cc
index a5659569..7690b83c 100644
--- a/gui/infotab.cc
+++ b/gui/infotab.cc
@@ -9,6 +9,16 @@ InfoTab::InfoTab(QWidget *parent) : QWidget(parent)
f.setStyleHint(QFont::Monospace);
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();
mainLayout->addWidget(plainTextEdit);
setLayout(mainLayout);
@@ -20,3 +30,10 @@ void InfoTab::info(std::string str)
plainTextEdit->insertPlainText(str.c_str());
plainTextEdit->moveCursor(QTextCursor::End);
}
+
+void InfoTab::showContextMenu(const QPoint &pt)
+{
+ contextMenu->exec(mapToGlobal(pt));
+}
+
+void InfoTab::clearBuffer() { plainTextEdit->clear(); }
diff --git a/gui/infotab.h b/gui/infotab.h
index e3c58ba5..d7f1408c 100644
--- a/gui/infotab.h
+++ b/gui/infotab.h
@@ -1,6 +1,7 @@
#ifndef INFOTAB_H
#define INFOTAB_H
+#include <QMenu>
#include <QPlainTextEdit>
#include "nextpnr.h"
@@ -14,9 +15,13 @@ class InfoTab : public QWidget
public:
explicit InfoTab(QWidget *parent = 0);
void info(std::string str);
+ private Q_SLOTS:
+ void showContextMenu(const QPoint &pt);
+ void clearBuffer();
private:
QPlainTextEdit *plainTextEdit;
+ QMenu *contextMenu;
};
#endif // INFOTAB_H
diff --git a/gui/pythontab.cc b/gui/pythontab.cc
index 04db056d..96a6c4b9 100644
--- a/gui/pythontab.cc
+++ b/gui/pythontab.cc
@@ -15,6 +15,16 @@ PythonTab::PythonTab(QWidget *parent) : QWidget(parent)
f.setStyleHint(QFont::Monospace);
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->setMinimumHeight(30);
lineEdit->setMaximumHeight(30);
@@ -98,3 +108,10 @@ void PythonTab::editLineReturnPressed(QString text)
print(std::string(">>> " + input + "\n"));
int error = executePython(input);
}
+
+void PythonTab::showContextMenu(const QPoint &pt)
+{
+ contextMenu->exec(mapToGlobal(pt));
+}
+
+void PythonTab::clearBuffer() { plainTextEdit->clear(); } \ No newline at end of file
diff --git a/gui/pythontab.h b/gui/pythontab.h
index 3876b3df..5aed8b0b 100644
--- a/gui/pythontab.h
+++ b/gui/pythontab.h
@@ -2,6 +2,7 @@
#define PYTHONTAB_H
#include <QLineEdit>
+#include <QMenu>
#include <QPlainTextEdit>
#include "emb.h"
#include "line_editor.h"
@@ -22,10 +23,13 @@ class PythonTab : public QWidget
int executePython(std::string &command);
private Q_SLOTS:
void editLineReturnPressed(QString text);
+ void showContextMenu(const QPoint &pt);
+ void clearBuffer();
private:
QPlainTextEdit *plainTextEdit;
LineEditor *lineEdit;
+ QMenu *contextMenu;
emb::stdout_write_type write;
};