2019-03-27 08:24:54 +00:00
|
|
|
#include "MemoryDockWidget.h"
|
2019-06-18 13:02:41 +00:00
|
|
|
#include "common/CutterSeekable.h"
|
2019-03-27 08:24:54 +00:00
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
|
|
|
MemoryDockWidget::MemoryDockWidget(CutterCore::MemoryWidgetType type, MainWindow *parent, QAction *action)
|
|
|
|
: CutterDockWidget(parent, action)
|
2019-06-18 13:02:41 +00:00
|
|
|
, mType(type), seekable(new CutterSeekable(this))
|
2019-03-27 08:24:54 +00:00
|
|
|
{
|
|
|
|
connect(Core(), &CutterCore::raisePrioritizedMemoryWidget, this, &MemoryDockWidget::handleRaiseMemoryWidget);
|
2019-06-18 13:02:41 +00:00
|
|
|
connect(seekable, &CutterSeekable::syncChanged, this, &MemoryDockWidget::updateWindowTitle);
|
2019-03-27 08:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MemoryDockWidget::handleRaiseMemoryWidget(CutterCore::MemoryWidgetType raiseType)
|
|
|
|
{
|
2019-06-18 22:59:24 +00:00
|
|
|
if (!seekable->isSynchronized()) {
|
|
|
|
return;
|
|
|
|
}
|
2019-03-27 08:24:54 +00:00
|
|
|
bool raisingEmptyGraph = (raiseType == CutterCore::MemoryWidgetType::Graph && Core()->isGraphEmpty());
|
|
|
|
if (raisingEmptyGraph) {
|
|
|
|
raiseType = CutterCore::MemoryWidgetType::Disassembly;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (raiseType == mType) {
|
2019-04-14 12:03:54 +00:00
|
|
|
if (getBoundAction()) {
|
|
|
|
getBoundAction()->setChecked(true);
|
|
|
|
}
|
2019-03-27 08:24:54 +00:00
|
|
|
|
|
|
|
show();
|
|
|
|
raise();
|
|
|
|
widgetToFocusOnRaise()->setFocus(Qt::FocusReason::TabFocusReason);
|
|
|
|
}
|
|
|
|
}
|
2019-06-18 13:02:41 +00:00
|
|
|
|
|
|
|
void MemoryDockWidget::updateWindowTitle()
|
|
|
|
{
|
|
|
|
if (seekable->isSynchronized()) {
|
|
|
|
setWindowTitle(getWindowTitle());
|
|
|
|
} else {
|
|
|
|
setWindowTitle(getWindowTitle() + CutterSeekable::tr(" (unsynced)"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CutterSeekable* MemoryDockWidget::getSeekable() const
|
|
|
|
{
|
|
|
|
return seekable;
|
|
|
|
}
|