Added initial window layout for Qt RAM Watch window.

This commit is contained in:
Matthew Budd 2020-10-07 20:35:52 -04:00
parent c5e39608c9
commit ab922df318
6 changed files with 333 additions and 10 deletions

View File

@ -443,6 +443,7 @@ set(SRC_DRIVERS_SDL
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/fceuWrapper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/ppuViewer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/NameTableViewer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/RamWatch.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/config.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/input.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drivers/Qt/nes_shm.cpp

View File

@ -36,14 +36,6 @@ GuiCheatsDialog_t::GuiCheatsDialog_t(QWidget *parent)
QLabel *lbl;
QGroupBox *groupBox;
QFrame *frame;
QScreen *screen = QGuiApplication::primaryScreen();
double devPixRatio = 1.0f;
if ( screen != NULL )
{
devPixRatio = (int)( screen->devicePixelRatio() + 0.50f);
//printf("Pix Ratio: %f \n", devPixRatio );
}
font.setFamily("Courier New");
font.setStyle( QFont::StyleNormal );
@ -51,8 +43,11 @@ GuiCheatsDialog_t::GuiCheatsDialog_t(QWidget *parent)
QFontMetrics fm(font);
//fontCharWidth = fm.boundingRect('X').width() * devPixRatio;
fontCharWidth = 2.00 * fm.averageCharWidth() * devPixRatio;
#if QT_VERSION > QT_VERSION_CHECK(5, 11, 0)
fontCharWidth = 2 * fm.horizontalAdvance(QLatin1Char('2'));
#else
fontCharWidth = 2 * fm.width(QLatin1Char('2'));
#endif
setWindowTitle("Cheat Search");

View File

@ -35,6 +35,7 @@
#include "Qt/fceuWrapper.h"
#include "Qt/ppuViewer.h"
#include "Qt/NameTableViewer.h"
#include "Qt/RamWatch.h"
#include "Qt/keyscan.h"
#include "Qt/nes_shm.h"
@ -483,6 +484,14 @@ void consoleWin_t::createMainMenu(void)
toolsMenu->addAction(cheatsAct);
// Tools -> RAM Watch
ramWatchAct = new QAction(tr("RAM Watch..."), this);
//ramWatchAct->setShortcut( QKeySequence(tr("Shift+F7")));
ramWatchAct->setStatusTip(tr("Open RAM Watch Window"));
connect(ramWatchAct, SIGNAL(triggered()), this, SLOT(openRamWatch(void)) );
toolsMenu->addAction(ramWatchAct);
//-----------------------------------------------------------------------
// Debug
debugMenu = menuBar()->addMenu(tr("Debug"));
@ -1017,6 +1026,17 @@ void consoleWin_t::openCheats(void)
cheatWin->show();
}
void consoleWin_t::openRamWatch(void)
{
RamWatchDialog_t *ramWatchWin;
//printf("Open GUI RAM Watch Window\n");
ramWatchWin = new RamWatchDialog_t(this);
ramWatchWin->show();
}
void consoleWin_t::openDebugWindow(void)
{
ConsoleDebugger *debugWin;

View File

@ -89,6 +89,7 @@ class consoleWin_t : public QMainWindow
QAction *fdsEjectAct;
QAction *fdsLoadBiosAct;
QAction *cheatsAct;
QAction *ramWatchAct;
QAction *debuggerAct;
QAction *codeDataLogAct;
QAction *traceLogAct;
@ -167,6 +168,7 @@ class consoleWin_t : public QMainWindow
void openPPUViewer(void);
void openNTViewer(void);
void openCheats(void);
void openRamWatch(void);
void openMovie(void);
void stopMovie(void);
void recordMovie(void);

254
src/drivers/Qt/RamWatch.cpp Normal file
View File

@ -0,0 +1,254 @@
// HotKeyConf.cpp
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <SDL.h>
#include <QMenuBar>
#include <QAction>
#include <QHeaderView>
#include <QCloseEvent>
#include <QGroupBox>
#include "Qt/main.h"
#include "Qt/dface.h"
#include "Qt/input.h"
#include "Qt/config.h"
#include "Qt/keyscan.h"
#include "Qt/fceuWrapper.h"
#include "Qt/RamWatch.h"
//----------------------------------------------------------------------------
RamWatchDialog_t::RamWatchDialog_t(QWidget *parent)
: QDialog( parent )
{
QMenuBar *menuBar;
QHBoxLayout *mainLayout;
QVBoxLayout *vbox, *vbox1;
QTreeWidgetItem *item;
QMenu *fileMenu, *watchMenu;
QAction *menuAct;
QGroupBox *frame;
int useNativeMenuBar;
font.setFamily("Courier New");
font.setStyle( QFont::StyleNormal );
font.setStyleHint( QFont::Monospace );
QFontMetrics fm(font);
#if QT_VERSION > QT_VERSION_CHECK(5, 11, 0)
fontCharWidth = 2 * fm.horizontalAdvance(QLatin1Char('2'));
#else
fontCharWidth = 2 * fm.width(QLatin1Char('2'));
#endif
setWindowTitle("RAM Watch");
resize( 512, 512 );
menuBar = new QMenuBar(this);
// This is needed for menu bar to show up on MacOS
g_config->getOption( "SDL.UseNativeMenuBar", &useNativeMenuBar );
menuBar->setNativeMenuBar( useNativeMenuBar ? true : false );
//-----------------------------------------------------------------------
// Menu
//-----------------------------------------------------------------------
// File
fileMenu = menuBar->addMenu(tr("File"));
// File -> New List
menuAct = new QAction(tr("New List"), this);
menuAct->setShortcut( QKeySequence(tr("Ctrl+N")) );
menuAct->setStatusTip(tr("New List"));
//connect(menuAct, SIGNAL(triggered()), this, SLOT(newListCB(void)) );
fileMenu->addAction(menuAct);
// File -> Open
menuAct = new QAction(tr("Open"), this);
menuAct->setShortcut( QKeySequence(tr("Ctrl+O")) );
menuAct->setStatusTip(tr("Open Watch File"));
//connect(menuAct, SIGNAL(triggered()), this, SLOT(newListCB(void)) );
fileMenu->addAction(menuAct);
// File -> Save
menuAct = new QAction(tr("Save"), this);
menuAct->setShortcut( QKeySequence(tr("Ctrl+S")) );
menuAct->setStatusTip(tr("Save Watch File"));
//connect(menuAct, SIGNAL(triggered()), this, SLOT(newListCB(void)) );
fileMenu->addAction(menuAct);
// File -> Save As
menuAct = new QAction(tr("Save As"), this);
menuAct->setShortcut( QKeySequence(tr("Ctrl+Shift+S")) );
menuAct->setStatusTip(tr("Save As Watch File"));
//connect(menuAct, SIGNAL(triggered()), this, SLOT(newListCB(void)) );
fileMenu->addAction(menuAct);
// File -> Append
menuAct = new QAction(tr("Append"), this);
//menuAct->setShortcut( QKeySequence(tr("Ctrl+A")) );
menuAct->setStatusTip(tr("Append to Watch File"));
//connect(menuAct, SIGNAL(triggered()), this, SLOT(newListCB(void)) );
fileMenu->addAction(menuAct);
fileMenu->addSeparator();
// File -> Append
menuAct = new QAction(tr("Close"), this);
menuAct->setShortcut( QKeySequence(tr("Alt+F4")) );
menuAct->setStatusTip(tr("Close Window"));
connect(menuAct, SIGNAL(triggered()), this, SLOT(closeWindow(void)) );
fileMenu->addAction(menuAct);
// Watch
watchMenu = menuBar->addMenu(tr("Watch"));
// Watch -> New Watch
menuAct = new QAction(tr("New Watch"), this);
menuAct->setShortcut( QKeySequence(tr("N")) );
menuAct->setStatusTip(tr("New Watch"));
//connect(menuAct, SIGNAL(triggered()), this, SLOT(newListCB(void)) );
watchMenu->addAction(menuAct);
// Watch -> Edit Watch
menuAct = new QAction(tr("Edit Watch"), this);
menuAct->setShortcut( QKeySequence(tr("E")) );
menuAct->setStatusTip(tr("Edit Watch"));
//connect(menuAct, SIGNAL(triggered()), this, SLOT(newListCB(void)) );
watchMenu->addAction(menuAct);
// Watch -> Remove Watch
menuAct = new QAction(tr("Remove Watch"), this);
menuAct->setShortcut( QKeySequence(tr("R")) );
menuAct->setStatusTip(tr("Remove Watch"));
//connect(menuAct, SIGNAL(triggered()), this, SLOT(newListCB(void)) );
watchMenu->addAction(menuAct);
// Watch -> Duplicate Watch
menuAct = new QAction(tr("Duplicate Watch"), this);
menuAct->setShortcut( QKeySequence(tr("A")) );
menuAct->setStatusTip(tr("Duplicate Watch"));
//connect(menuAct, SIGNAL(triggered()), this, SLOT(newListCB(void)) );
watchMenu->addAction(menuAct);
// Watch -> Add Separator
menuAct = new QAction(tr("Add Separator"), this);
menuAct->setShortcut( QKeySequence(tr("S")) );
menuAct->setStatusTip(tr("Add Separator"));
//connect(menuAct, SIGNAL(triggered()), this, SLOT(newListCB(void)) );
watchMenu->addAction(menuAct);
watchMenu->addSeparator();
// Watch -> Move Up
menuAct = new QAction(tr("Move Up"), this);
menuAct->setShortcut( QKeySequence(tr("U")) );
menuAct->setStatusTip(tr("Move Up"));
//connect(menuAct, SIGNAL(triggered()), this, SLOT(newListCB(void)) );
watchMenu->addAction(menuAct);
// Watch -> Move Down
menuAct = new QAction(tr("Move Down"), this);
menuAct->setShortcut( QKeySequence(tr("D")) );
menuAct->setStatusTip(tr("Move Down"));
//connect(menuAct, SIGNAL(triggered()), this, SLOT(newListCB(void)) );
watchMenu->addAction(menuAct);
//-----------------------------------------------------------------------
// End Menu
//-----------------------------------------------------------------------
mainLayout = new QHBoxLayout();
tree = new QTreeWidget();
tree->setColumnCount(3);
item = new QTreeWidgetItem();
item->setText( 0, QString::fromStdString( "Address" ) );
item->setText( 1, QString::fromStdString( "Value" ) );
item->setText( 2, QString::fromStdString( "Notes" ) );
item->setTextAlignment( 0, Qt::AlignLeft);
item->setTextAlignment( 1, Qt::AlignLeft);
item->setTextAlignment( 2, Qt::AlignLeft);
tree->setHeaderItem( item );
tree->header()->setSectionResizeMode( QHeaderView::ResizeToContents );
vbox1 = new QVBoxLayout();
vbox = new QVBoxLayout();
frame = new QGroupBox( tr("Watches") );
vbox1->addWidget( frame );
frame->setLayout( vbox );
up_btn = new QPushButton( tr("Up") );
vbox->addWidget( up_btn );
down_btn = new QPushButton( tr("Down") );
vbox->addWidget( down_btn );
edit_btn = new QPushButton( tr("Edit") );
vbox->addWidget( edit_btn );
del_btn = new QPushButton( tr("Remove") );
vbox->addWidget( del_btn );
new_btn = new QPushButton( tr("New") );
vbox->addWidget( new_btn );
dup_btn = new QPushButton( tr("Duplicate") );
vbox->addWidget( dup_btn );
sep_btn = new QPushButton( tr("Separator") );
vbox->addWidget( sep_btn );
mainLayout->addWidget( tree );
mainLayout->addLayout( vbox1 );
mainLayout->setMenuBar( menuBar );
cht_btn = new QPushButton( tr("Add Cheat") );
vbox1->addWidget( cht_btn );
setLayout( mainLayout );
}
//----------------------------------------------------------------------------
RamWatchDialog_t::~RamWatchDialog_t(void)
{
printf("Destroy RAM Watch Config Window\n");
}
//----------------------------------------------------------------------------
void RamWatchDialog_t::closeEvent(QCloseEvent *event)
{
printf("RAM Watch Close Window Event\n");
done(0);
deleteLater();
event->accept();
}
//----------------------------------------------------------------------------
void RamWatchDialog_t::closeWindow(void)
{
//printf("Close Window\n");
done(0);
deleteLater();
}
//----------------------------------------------------------------------------

51
src/drivers/Qt/RamWatch.h Normal file
View File

@ -0,0 +1,51 @@
// RamWatch.h
//
#pragma once
#include <QWidget>
#include <QDialog>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QComboBox>
#include <QCheckBox>
#include <QPushButton>
#include <QLabel>
#include <QFrame>
#include <QGroupBox>
#include <QTreeView>
#include <QTreeWidget>
#include "Qt/main.h"
class RamWatchDialog_t : public QDialog
{
Q_OBJECT
public:
RamWatchDialog_t(QWidget *parent = 0);
~RamWatchDialog_t(void);
protected:
void closeEvent(QCloseEvent *event);
QFont font;
QTreeWidget *tree;
QPushButton *up_btn;
QPushButton *down_btn;
QPushButton *edit_btn;
QPushButton *del_btn;
QPushButton *new_btn;
QPushButton *dup_btn;
QPushButton *sep_btn;
QPushButton *cht_btn;
int fontCharWidth;
private:
public slots:
void closeWindow(void);
private slots:
};