mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 00:50:40 +00:00
Add a right-click handle to show an annotation in the event browser
This commit is contained in:
@@ -23,7 +23,9 @@
|
||||
******************************************************************************/
|
||||
|
||||
#include "AnnotationDisplay.h"
|
||||
#include <QAction>
|
||||
#include <QHeaderView>
|
||||
#include <QMenu>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
AnnotationDisplay::AnnotationDisplay(ICaptureContext &ctx, bool standalone, QWidget *parent)
|
||||
@@ -49,6 +51,9 @@ AnnotationDisplay::AnnotationDisplay(ICaptureContext &ctx, bool standalone, QWid
|
||||
|
||||
setWindowTitle(tr("Annotation Viewer"));
|
||||
|
||||
QObject::connect(m_Tree, &RDTreeWidget::customContextMenu, this,
|
||||
&AnnotationDisplay::customContextMenu);
|
||||
|
||||
if(m_Standalone)
|
||||
m_Ctx.AddCaptureViewer(this);
|
||||
}
|
||||
@@ -141,3 +146,33 @@ void AnnotationDisplay::setAnnotationObject(const SDObject *annotation)
|
||||
|
||||
m_Tree->applyExpansion(m_Expansion, 0);
|
||||
}
|
||||
|
||||
void AnnotationDisplay::customContextMenu(QModelIndex index, QMenu *menu)
|
||||
{
|
||||
RDTreeWidgetItem *item = m_Tree->itemForIndex(index);
|
||||
const SDObject *obj = (const SDObject *)item->tag().value<void *>();
|
||||
|
||||
rdcstr path;
|
||||
// don't include the root node, it's not part of the path, so only iterate over nodes that have
|
||||
// parents themselves
|
||||
while(obj && obj->GetParent())
|
||||
{
|
||||
if(path.empty())
|
||||
path = obj->name;
|
||||
else
|
||||
path = obj->name + rdcstr(".") + path;
|
||||
obj = obj->GetParent();
|
||||
}
|
||||
|
||||
if(path.empty())
|
||||
return;
|
||||
|
||||
QAction *sep = menu->insertSeparator(menu->actions()[0]);
|
||||
|
||||
QAction *showInEventBrowser = new QAction(tr("&Highlight in Event Browser"), menu);
|
||||
|
||||
QObject::connect(showInEventBrowser, &QAction::triggered,
|
||||
[this, path]() { m_Ctx.GetEventBrowser()->SetHighlightedAnnotation(path); });
|
||||
|
||||
menu->insertAction(sep, showInEventBrowser);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,8 @@ public:
|
||||
|
||||
void setAnnotationObject(const SDObject *annotation);
|
||||
|
||||
signals:
|
||||
private slots:
|
||||
void customContextMenu(QModelIndex index, QMenu *menu);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -360,6 +360,8 @@ void RDTreeView::contextMenuEvent(QContextMenuEvent *event)
|
||||
|
||||
QObject::connect(©, &QAction::triggered, [this, index, pos]() { copyIndex(pos, index); });
|
||||
|
||||
emit customContextMenu(index, &contextMenu);
|
||||
|
||||
RDDialog::show(&contextMenu, viewport()->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
|
||||
@@ -183,6 +183,7 @@ public:
|
||||
signals:
|
||||
void leave(QEvent *e);
|
||||
void keyPress(QKeyEvent *e);
|
||||
void customContextMenu(QModelIndex index, QMenu *menu);
|
||||
|
||||
protected:
|
||||
void mouseMoveEvent(QMouseEvent *e) override;
|
||||
|
||||
Reference in New Issue
Block a user