Utilities/Memory Viewer: Add PageDown/PageUp scrolling

* F5 for single refresh.
This commit is contained in:
Eladash 2023-06-19 22:24:20 +03:00 committed by kd-11
parent 87d5f45277
commit c84d2d895e
2 changed files with 47 additions and 2 deletions

View File

@ -20,6 +20,7 @@
#include <QWheelEvent>
#include <QTimer>
#include <QThread>
#include <QKeyEvent>
#include "util/logs.hpp"
#include "util/asm.hpp"
@ -888,6 +889,47 @@ void memory_viewer_panel::SetPC(const uint pc)
m_addr = pc;
}
void memory_viewer_panel::keyPressEvent(QKeyEvent* event)
{
if (!isActiveWindow())
{
QDialog::keyPressEvent(event);
return;
}
if (event->modifiers() == Qt::ControlModifier)
{
switch (const auto key = event->key())
{
case Qt::Key_PageUp:
case Qt::Key_PageDown:
{
scroll(key == Qt::Key_PageDown ? m_rowcount : 0u - m_rowcount);
break;
}
case Qt::Key_F5:
{
if (event->isAutoRepeat())
{
break;
}
// Single refresh
ShowMemory();
break;
}
case Qt::Key_F:
{
m_addr_line->setFocus();
break;
}
default: break;
}
}
QDialog::keyPressEvent(event);
}
void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format format, u32 width, u32 height, bool flipv) const
{
// If exceeds 32-bits it is invalid as well, UINT32_MAX always fails checks

View File

@ -16,6 +16,7 @@ class QComboBox;
class QLabel;
class QThread;
class QHBoxLayout;
class QKeyEvent;
class cpu_thread;
class CPUDisAsm;
@ -43,7 +44,7 @@ enum search_mode : unsigned
search_mode_last = 256,
};
class memory_viewer_panel : public QDialog
class memory_viewer_panel final : public QDialog
{
Q_OBJECT
@ -112,10 +113,12 @@ private:
void* to_ptr(u32 addr, u32 size = 1) const;
void SetPC(const uint pc);
virtual void ShowMemory();
void ShowMemory();
void ShowImage(QWidget* parent, u32 addr, color_format format, u32 width, u32 height, bool flipv) const;
u64 OnSearch(std::string wstr, u32 mode);
void keyPressEvent(QKeyEvent* event) override;
};
// Lifetime management with IDM