aboutsummaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/basewindow.cc11
-rw-r--r--gui/designwidget.cc58
-rw-r--r--gui/designwidget.h6
-rw-r--r--gui/fpgaviewwidget.cc6
-rw-r--r--gui/fpgaviewwidget.h1
5 files changed, 54 insertions, 28 deletions
diff --git a/gui/basewindow.cc b/gui/basewindow.cc
index 0c7632ee..a57d3ef1 100644
--- a/gui/basewindow.cc
+++ b/gui/basewindow.cc
@@ -81,7 +81,8 @@ BaseMainWindow::BaseMainWindow(std::unique_ptr<Context> context, QWidget *parent
centralTabWidget->addTab(fpgaView, "Graphics");
connect(this, SIGNAL(contextChanged(Context *)), fpgaView, SLOT(newContext(Context *)));
- connect(designview, SIGNAL(selected(std::vector<DecalXY>)), fpgaView, SLOT(onSelectedArchItem(std::vector<DecalXY>)));
+ connect(designview, SIGNAL(selected(std::vector<DecalXY>)), fpgaView,
+ SLOT(onSelectedArchItem(std::vector<DecalXY>)));
splitter_v->addWidget(centralTabWidget);
splitter_v->addWidget(tabWidget);
@@ -93,26 +94,26 @@ void BaseMainWindow::writeInfo(std::string text) { console->info(text); }
void BaseMainWindow::createMenusAndBars()
{
- actionNew = new QAction("New", this);
+ actionNew = new QAction("New", this);
actionNew->setIcon(QIcon(":/icons/resources/new.png"));
actionNew->setShortcuts(QKeySequence::New);
actionNew->setStatusTip("New project file");
connect(actionNew, SIGNAL(triggered()), this, SLOT(new_proj()));
- actionOpen = new QAction("Open", this);
+ actionOpen = new QAction("Open", this);
actionOpen->setIcon(QIcon(":/icons/resources/open.png"));
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);
+ QAction *actionSave = new QAction("Save", this);
actionSave->setIcon(QIcon(":/icons/resources/save.png"));
actionSave->setShortcuts(QKeySequence::Save);
actionSave->setStatusTip("Save existing project to disk");
actionSave->setEnabled(false);
connect(actionSave, SIGNAL(triggered()), this, SLOT(save_proj()));
- QAction *actionExit = new QAction("Exit", this);
+ QAction *actionExit = new QAction("Exit", this);
actionExit->setIcon(QIcon(":/icons/resources/exit.png"));
actionExit->setShortcuts(QKeySequence::Quit);
actionExit->setStatusTip("Exit the application");
diff --git a/gui/designwidget.cc b/gui/designwidget.cc
index 553171ab..cfcdc9fc 100644
--- a/gui/designwidget.cc
+++ b/gui/designwidget.cc
@@ -77,9 +77,8 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net
propertyEditor = new QtTreePropertyBrowser(this);
propertyEditor->setFactoryForManager(variantManager, variantFactory);
propertyEditor->setPropertiesWithoutValueMarked(true);
- connect(propertyEditor, SIGNAL(currentItemChanged(QtBrowserItem *)), this,
- SLOT(onCurrentPropertyChanged(QtBrowserItem *)));
propertyEditor->show();
+ propertyEditor->treeWidget()->setContextMenuPolicy(Qt::CustomContextMenu);
QLineEdit *lineEdit = new QLineEdit();
lineEdit->setClearButtonEnabled(true);
@@ -144,7 +143,9 @@ DesignWidget::DesignWidget(QWidget *parent) : QWidget(parent), ctx(nullptr), net
setLayout(mainLayout);
// Connection
- connect(treeWidget, &QTreeWidget::customContextMenuRequested, this, &DesignWidget::prepareMenu);
+ connect(propertyEditor->treeWidget(), &QTreeWidget::customContextMenuRequested, this,
+ &DesignWidget::prepareMenuProperty);
+ connect(propertyEditor->treeWidget(), &QTreeWidget::itemDoubleClicked, this, &DesignWidget::onItemDoubleClicked);
connect(treeWidget, SIGNAL(itemSelectionChanged()), SLOT(onItemSelectionChanged()));
}
@@ -312,33 +313,41 @@ void DesignWidget::clearProperties()
idToProperty.clear();
}
-void DesignWidget::onCurrentPropertyChanged(QtBrowserItem *_item)
+void DesignWidget::onCurrentPropertySelected(QtBrowserItem *_item)
{
if (_item) {
QtProperty *selectedProperty = _item->property();
- QString type = selectedProperty->propertyId();
+ ElementType type = getElementTypeByName(selectedProperty->propertyId());
IdString value = ctx->id(selectedProperty->valueText().toStdString());
std::vector<DecalXY> decals;
- if (type == "BEL") {
+ switch (type) {
+ case ElementType::BEL: {
BelId bel = ctx->getBelByName(value);
if (bel != BelId()) {
decals.push_back(ctx->getBelDecal(bel));
Q_EMIT selected(decals);
}
- } else if (type == "WIRE") {
+ } break;
+ case ElementType::WIRE: {
WireId wire = ctx->getWireByName(value);
if (wire != WireId()) {
decals.push_back(ctx->getWireDecal(wire));
Q_EMIT selected(decals);
}
- } else if (type == "PIP") {
+ } break;
+ case ElementType::PIP: {
PipId pip = ctx->getPipByName(value);
if (pip != PipId()) {
decals.push_back(ctx->getPipDecal(pip));
Q_EMIT selected(decals);
}
- } else if (type == "NET") {
- } else if (type == "CELL") {
+ } break;
+ case ElementType::NET: {
+ } break;
+ case ElementType::CELL: {
+ } break;
+ default:
+ break;
}
}
}
@@ -596,23 +605,38 @@ void DesignWidget::onItemSelectionChanged()
}
}
-void DesignWidget::prepareMenu(const QPoint &pos)
+void DesignWidget::prepareMenuProperty(const QPoint &pos)
{
- QTreeWidget *tree = treeWidget;
+ QTreeWidget *tree = propertyEditor->treeWidget();
itemContextMenu = tree->itemAt(pos);
+ if (itemContextMenu->parent() == nullptr)
+ return;
- QAction *selectAction = new QAction("&Select", this);
- selectAction->setStatusTip("Select item on view");
-
- connect(selectAction, SIGNAL(triggered()), this, SLOT(selectObject()));
+ QtBrowserItem *browserItem = propertyEditor->itemToBrowserItem(itemContextMenu);
+ // if (((ElementTreeItem*)itemContextMenu)->getType() == ElementType::NONE) return;
QMenu menu(this);
+ QAction *selectAction = new QAction("&Select", this);
+ connect(selectAction, &QAction::triggered, this, [this, browserItem] { onCurrentPropertySelected(browserItem); });
+
menu.addAction(selectAction);
menu.exec(tree->mapToGlobal(pos));
}
-void DesignWidget::selectObject() { Q_EMIT info("selected " + itemContextMenu->text(0).toStdString() + "\n"); }
+void DesignWidget::onItemDoubleClicked(QTreeWidgetItem *item, int column)
+{
+ QtProperty *selectedProperty = propertyEditor->itemToBrowserItem(item)->property();
+ ElementType type = getElementTypeByName(selectedProperty->propertyId());
+ IdString value = ctx->id(selectedProperty->valueText().toStdString());
+ switch (type) {
+ case ElementType::NONE:
+ return;
+ default:
+ Q_EMIT info("double clicked " + std::string(value.c_str(ctx)) + "\n");
+ break;
+ }
+}
NEXTPNR_NAMESPACE_END
diff --git a/gui/designwidget.h b/gui/designwidget.h
index a4940213..50f00bbe 100644
--- a/gui/designwidget.h
+++ b/gui/designwidget.h
@@ -61,10 +61,10 @@ class DesignWidget : public QWidget
void selected(std::vector<DecalXY> decal);
private Q_SLOTS:
- void prepareMenu(const QPoint &pos);
+ void prepareMenuProperty(const QPoint &pos);
void onItemSelectionChanged();
- void selectObject();
- void onCurrentPropertyChanged(QtBrowserItem *_item);
+ void onItemDoubleClicked(QTreeWidgetItem *item, int column);
+ void onCurrentPropertySelected(QtBrowserItem *_item);
public Q_SLOTS:
void newContext(Context *ctx);
void updateTree();
diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc
index ad62d38f..cb60bc76 100644
--- a/gui/fpgaviewwidget.cc
+++ b/gui/fpgaviewwidget.cc
@@ -240,7 +240,8 @@ void LineShader::draw(const LineShaderData &line, const QColor &color, float thi
vao_.release();
}
-FPGAViewWidget::FPGAViewWidget(QWidget *parent) : QOpenGLWidget(parent), lineShader_(this), zoom_(500.f), ctx_(nullptr), selectedItemsChanged(false)
+FPGAViewWidget::FPGAViewWidget(QWidget *parent)
+ : QOpenGLWidget(parent), lineShader_(this), zoom_(500.f), ctx_(nullptr), selectedItemsChanged(false)
{
backgroundColor_ = QColor("#000000");
gridColor_ = QColor("#333");
@@ -412,8 +413,7 @@ void FPGAViewWidget::paintGL()
drawDecal(shaders, ctx_->getGroupDecal(group));
}
- if (selectedItemsChanged)
- {
+ if (selectedItemsChanged) {
selectedItemsChanged = false;
selectedShader_.clear();
for (auto decal : selectedItems_) {
diff --git a/gui/fpgaviewwidget.h b/gui/fpgaviewwidget.h
index dd86277e..ea4a17cf 100644
--- a/gui/fpgaviewwidget.h
+++ b/gui/fpgaviewwidget.h
@@ -245,6 +245,7 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions
public Q_SLOTS:
void newContext(Context *ctx);
void onSelectedArchItem(std::vector<DecalXY> decals);
+
private:
QPoint lastPos_;
LineShader lineShader_;