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) :
|
2019-03-27 08:24:54 +00:00
|
|
|
MemoryDockWidget(CutterCore::MemoryWidgetType::Graph, main, action)
|
2018-03-16 21:46:57 +00:00
|
|
|
{
|
2019-06-20 14:28:35 +00:00
|
|
|
setObjectName(main
|
|
|
|
? main->getUniqueObjectName(getWidgetType())
|
|
|
|
: getWidgetType());
|
2019-06-18 17:57:07 +00:00
|
|
|
|
2019-03-18 06:44:14 +00:00
|
|
|
setAllowedAreas(Qt::AllDockWidgetAreas);
|
2019-06-18 13:02:41 +00:00
|
|
|
graphView = new DisassemblerGraphView(this, seekable);
|
2019-03-18 06:44:14 +00:00
|
|
|
setWidget(graphView);
|
2018-03-16 21:46:57 +00:00
|
|
|
|
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
|
|
|
|
2019-06-18 13:02:41 +00:00
|
|
|
connect(graphView, &DisassemblerGraphView::nameChanged, this, &MemoryDockWidget::updateWindowTitle);
|
|
|
|
|
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-03-18 06:44:14 +00:00
|
|
|
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-16 21:46:57 +00:00
|
|
|
}
|
|
|
|
|
2019-03-27 08:24:54 +00:00
|
|
|
QWidget *GraphWidget::widgetToFocusOnRaise()
|
|
|
|
{
|
|
|
|
return graphView;
|
|
|
|
}
|
2019-02-24 07:15:40 +00:00
|
|
|
|
|
|
|
void GraphWidget::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
|
|
|
CutterDockWidget::closeEvent(event);
|
2019-04-14 12:18:24 +00:00
|
|
|
emit graphClosed();
|
2019-02-24 07:15:40 +00:00
|
|
|
}
|
2019-03-27 08:24:54 +00:00
|
|
|
|
2019-06-18 13:02:41 +00:00
|
|
|
QString GraphWidget::getWindowTitle() const
|
|
|
|
{
|
|
|
|
return graphView->windowTitle;
|
|
|
|
}
|
|
|
|
|
2019-03-27 08:24:54 +00:00
|
|
|
DisassemblerGraphView *GraphWidget::getGraphView() const
|
|
|
|
{
|
|
|
|
return graphView;
|
|
|
|
}
|
2019-06-18 13:02:41 +00:00
|
|
|
|
|
|
|
QString GraphWidget::getWidgetType()
|
|
|
|
{
|
|
|
|
return "Graph";
|
|
|
|
}
|