mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-22 21:06:10 +00:00
66 lines
1.9 KiB
C++
66 lines
1.9 KiB
C++
#include "core/MainWindow.h"
|
|
#include "GraphWidget.h"
|
|
#include "DisassemblerGraphView.h"
|
|
#include "WidgetShortcuts.h"
|
|
|
|
GraphWidget::GraphWidget(MainWindow *main, QAction *action) :
|
|
MemoryDockWidget(CutterCore::MemoryWidgetType::Graph, main, action)
|
|
{
|
|
setObjectName(main
|
|
? main->getUniqueObjectName(getWidgetType())
|
|
: getWidgetType());
|
|
|
|
setAllowedAreas(Qt::AllDockWidgetAreas);
|
|
graphView = new DisassemblerGraphView(this, seekable);
|
|
setWidget(graphView);
|
|
|
|
// getting the name of the class is implementation defined, and cannot be
|
|
// used reliably across different compilers.
|
|
//QShortcut *toggle_shortcut = new QShortcut(widgetShortcuts[typeid(this).name()], main);
|
|
QShortcut *toggle_shortcut = new QShortcut(widgetShortcuts["GraphWidget"], main);
|
|
connect(toggle_shortcut, &QShortcut::activated, this, [ = ]() {
|
|
toggleDockWidget(true);
|
|
main->updateDockActionChecked(action);
|
|
});
|
|
|
|
connect(graphView, &DisassemblerGraphView::nameChanged, this, &MemoryDockWidget::updateWindowTitle);
|
|
|
|
connect(this, &QDockWidget::visibilityChanged, this, [ = ](bool visibility) {
|
|
main->toggleOverview(visibility, this);
|
|
if (visibility) {
|
|
Core()->setMemoryWidgetPriority(CutterCore::MemoryWidgetType::Graph);
|
|
graphView->onSeekChanged(Core()->getOffset());
|
|
}
|
|
});
|
|
|
|
connect(graphView, &DisassemblerGraphView::graphMoved, this, [ = ]() {
|
|
main->toggleOverview(true, this);
|
|
});
|
|
}
|
|
|
|
QWidget *GraphWidget::widgetToFocusOnRaise()
|
|
{
|
|
return graphView;
|
|
}
|
|
|
|
void GraphWidget::closeEvent(QCloseEvent *event)
|
|
{
|
|
CutterDockWidget::closeEvent(event);
|
|
emit graphClosed();
|
|
}
|
|
|
|
QString GraphWidget::getWindowTitle() const
|
|
{
|
|
return graphView->windowTitle;
|
|
}
|
|
|
|
DisassemblerGraphView *GraphWidget::getGraphView() const
|
|
{
|
|
return graphView;
|
|
}
|
|
|
|
QString GraphWidget::getWidgetType()
|
|
{
|
|
return "Graph";
|
|
}
|