2019-02-22 16:50:45 +00:00
|
|
|
#include "core/MainWindow.h"
|
2018-03-16 21:46:57 +00:00
|
|
|
#include "GraphWidget.h"
|
|
|
|
#include "DisassemblerGraphView.h"
|
2018-10-16 06:25:09 +00:00
|
|
|
#include "WidgetShortcuts.h"
|
2018-03-16 21:46:57 +00:00
|
|
|
|
2019-02-19 15:56:50 +00:00
|
|
|
GraphWidget::GraphWidget(MainWindow *main, QAction *action) :
|
2018-03-16 21:46:57 +00:00
|
|
|
CutterDockWidget(main, action)
|
|
|
|
{
|
|
|
|
this->setObjectName("Graph");
|
|
|
|
this->setAllowedAreas(Qt::AllDockWidgetAreas);
|
|
|
|
this->graphView = new DisassemblerGraphView(this);
|
|
|
|
this->setWidget(graphView);
|
|
|
|
|
2018-10-16 06:25:09 +00:00
|
|
|
// 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);
|
2018-10-16 14:49:26 +00:00
|
|
|
connect(toggle_shortcut, &QShortcut::activated, this, [ = ]() {
|
2018-10-16 06:25:09 +00:00
|
|
|
toggleDockWidget(true);
|
|
|
|
main->updateDockActionChecked(action);
|
2018-10-16 14:49:26 +00:00
|
|
|
});
|
2018-10-16 06:25:09 +00:00
|
|
|
|
2018-10-16 14:49:26 +00:00
|
|
|
connect(this, &QDockWidget::visibilityChanged, this, [ = ](bool visibility) {
|
2019-02-19 15:56:50 +00:00
|
|
|
main->toggleOverview(visibility, this);
|
2018-03-21 20:32:32 +00:00
|
|
|
if (visibility) {
|
2018-03-16 21:46:57 +00:00
|
|
|
Core()->setMemoryWidgetPriority(CutterCore::MemoryWidgetType::Graph);
|
2019-02-16 17:17:11 +00:00
|
|
|
this->graphView->refreshView();
|
2019-03-08 17:24:59 +00:00
|
|
|
this->graphView->onSeekChanged(Core()->getOffset());
|
2018-03-16 21:46:57 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-02-19 15:56:50 +00:00
|
|
|
connect(graphView, &DisassemblerGraphView::graphMoved, this, [ = ]() {
|
|
|
|
main->toggleOverview(true, this);
|
2019-01-24 17:13:04 +00:00
|
|
|
});
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
connect(Core(), &CutterCore::raisePrioritizedMemoryWidget,
|
|
|
|
this, [ = ](CutterCore::MemoryWidgetType type) {
|
2018-09-30 17:46:36 +00:00
|
|
|
bool emptyGraph = (type == CutterCore::MemoryWidgetType::Graph && Core()->isGraphEmpty());
|
|
|
|
if (type == CutterCore::MemoryWidgetType::Graph && !emptyGraph) {
|
2019-03-02 08:07:05 +00:00
|
|
|
this->raise();
|
2018-03-16 21:46:57 +00:00
|
|
|
this->graphView->setFocus();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
GraphWidget::~GraphWidget() {}
|
2019-02-24 07:15:40 +00:00
|
|
|
|
|
|
|
void GraphWidget::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
|
|
|
CutterDockWidget::closeEvent(event);
|
|
|
|
emit graphClose();
|
|
|
|
}
|