2019-03-27 08:24:54 +00:00
|
|
|
#include "MemoryDockWidget.h"
|
2019-06-18 13:02:41 +00:00
|
|
|
#include "common/CutterSeekable.h"
|
2019-07-19 19:21:12 +00:00
|
|
|
#include "MainWindow.h"
|
2019-03-27 08:24:54 +00:00
|
|
|
#include <QAction>
|
2019-07-19 19:21:12 +00:00
|
|
|
#include <QEvent>
|
2019-03-27 08:24:54 +00:00
|
|
|
|
2019-07-19 19:21:12 +00:00
|
|
|
MemoryDockWidget::MemoryDockWidget(MemoryWidgetType type, MainWindow *parent, QAction *action)
|
2019-03-27 08:24:54 +00:00
|
|
|
: 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
|
|
|
{
|
2019-07-19 19:21:12 +00:00
|
|
|
if (parent) {
|
|
|
|
parent->addMemoryDockWidget(this);
|
|
|
|
}
|
2019-06-18 13:02:41 +00:00
|
|
|
connect(seekable, &CutterSeekable::syncChanged, this, &MemoryDockWidget::updateWindowTitle);
|
2019-03-27 08:24:54 +00:00
|
|
|
}
|
|
|
|
|
2019-07-19 19:21:12 +00:00
|
|
|
bool MemoryDockWidget::tryRaiseMemoryWidget()
|
2019-03-27 08:24:54 +00:00
|
|
|
{
|
2019-06-18 22:59:24 +00:00
|
|
|
if (!seekable->isSynchronized()) {
|
2019-07-19 19:21:12 +00:00
|
|
|
return false;
|
2019-06-18 22:59:24 +00:00
|
|
|
}
|
2019-07-19 19:21:12 +00:00
|
|
|
|
|
|
|
if (mType == MemoryWidgetType::Graph && Core()->isGraphEmpty()) {
|
|
|
|
return false;
|
2019-03-27 08:24:54 +00:00
|
|
|
}
|
2019-07-19 19:21:12 +00:00
|
|
|
raiseMemoryWidget();
|
2019-03-27 08:24:54 +00:00
|
|
|
|
2019-07-19 19:21:12 +00:00
|
|
|
return true;
|
|
|
|
}
|
2019-03-27 08:24:54 +00:00
|
|
|
|
2019-07-19 19:21:12 +00:00
|
|
|
void MemoryDockWidget::raiseMemoryWidget()
|
|
|
|
{
|
|
|
|
|
|
|
|
if (getBoundAction()) {
|
|
|
|
getBoundAction()->setChecked(true);
|
2019-03-27 08:24:54 +00:00
|
|
|
}
|
2019-07-19 19:21:12 +00:00
|
|
|
|
|
|
|
show();
|
|
|
|
raise();
|
|
|
|
widgetToFocusOnRaise()->setFocus(Qt::FocusReason::TabFocusReason);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MemoryDockWidget::eventFilter(QObject *object, QEvent *event)
|
|
|
|
{
|
|
|
|
if (event->type() == QEvent::FocusIn) {
|
|
|
|
mainWindow->setCurrentMemoryWidget(this);
|
|
|
|
}
|
|
|
|
return CutterDockWidget::eventFilter(object, event);
|
2019-03-27 08:24:54 +00:00
|
|
|
}
|
2019-06-18 13:02:41 +00:00
|
|
|
|
|
|
|
void MemoryDockWidget::updateWindowTitle()
|
|
|
|
{
|
2019-07-19 19:21:12 +00:00
|
|
|
QString name = getWindowTitle();
|
|
|
|
QString id = getDockNumber();
|
|
|
|
if (!id.isEmpty()) {
|
|
|
|
name += " " + id;
|
|
|
|
}
|
|
|
|
if (!seekable->isSynchronized()) {
|
|
|
|
name += CutterSeekable::tr(" (unsynced)");
|
2019-06-18 13:02:41 +00:00
|
|
|
}
|
2019-07-19 19:21:12 +00:00
|
|
|
setWindowTitle(name);
|
2019-06-18 13:02:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CutterSeekable* MemoryDockWidget::getSeekable() const
|
|
|
|
{
|
|
|
|
return seekable;
|
|
|
|
}
|