diff --git a/main.cpp b/main.cpp index 01aa3e1..a2bb748 100644 --- a/main.cpp +++ b/main.cpp @@ -19,7 +19,6 @@ void usage(char *bin) void parseArguments(int argc, char **argv, SNES &snes) { while (true) { - int this_option_optind = optind ? optind : 1; int option_index = 0; static struct option long_options[] = { {"cpu", no_argument, 0, 'c' }, @@ -57,6 +56,7 @@ int main(int argc, char **argv) return 1; } QApplication app(argc, argv); + QApplication::setAttribute(Qt::AA_DisableWindowContextHelpButton); Renderer::QtSFML renderer(600, 800); SNES snes(std::make_shared(), argv[1], renderer); renderer.createWindow(snes, 60); diff --git a/sources/Debugger/MemoryViewer.cpp b/sources/Debugger/MemoryViewer.cpp index e94d950..2de4523 100644 --- a/sources/Debugger/MemoryViewer.cpp +++ b/sources/Debugger/MemoryViewer.cpp @@ -4,6 +4,8 @@ #include #include +#include +#include #include "MemoryViewer.hpp" #include "../SNES.hpp" #include "../Utility/Utility.hpp" @@ -58,7 +60,6 @@ void MemoryViewerModel::setMemory(std::shared_ptr memory) emit this->layoutChanged(); } - namespace ComSquare::Debugger { MemoryViewer::MemoryViewer(ComSquare::SNES &snes) : @@ -77,6 +78,7 @@ namespace ComSquare::Debugger this->_ui.tabs->addTab("&SRam"); this->_ui.tabs->addTab("&Rom"); // this->_ui.tabs->addTab("&VRam"); + QMainWindow::connect(this->_ui.actionGoto, &QAction::triggered, this, &MemoryViewer::gotoAddr); QObject::connect(this->_ui.tabs, &QTabBar::currentChanged, this, &MemoryViewer::changeRam); this->show(); } @@ -99,4 +101,28 @@ namespace ComSquare::Debugger // break; } } + + + void MemoryViewer::gotoAddr() + { + QInputDialog dialog(this, Qt::WindowFlags()); + dialog.setWindowTitle("Go to:"); + dialog.setLabelText("Address"); + dialog.setIntRange(0, 0xFFFFFF); + dialog.setIntValue(0); + dialog.setIntStep(1); + dialog.setWindowModality(Qt::WindowModal); + QSpinBox *spinbox = dialog.findChild(); + spinbox->setDisplayIntegerBase(16); + QFont font = spinbox->font(); + font.setCapitalization(QFont::AllUppercase); + spinbox->setFont(font); + + if (dialog.exec() != QDialog::Accepted) + return; + long value = std::strtol(spinbox->text().toStdString().c_str(), nullptr, 16); + QModelIndex index = this->_ui.tableView->model()->index(value >> 4, value & 0x0000000F); + this->_ui.tableView->scrollTo(index); + this->_ui.tableView->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect); + } } \ No newline at end of file diff --git a/sources/Debugger/MemoryViewer.hpp b/sources/Debugger/MemoryViewer.hpp index 4e4611b..1a94a24 100644 --- a/sources/Debugger/MemoryViewer.hpp +++ b/sources/Debugger/MemoryViewer.hpp @@ -58,6 +58,8 @@ namespace ComSquare public: //! @brief Callback called when a memory tab is selected. void changeRam(int id); + //! @brief Create a popup asking you where you want to jump to. + void gotoAddr(); explicit MemoryViewer(SNES &snes); MemoryViewer(const MemoryViewer &) = delete; diff --git a/ui/ramView.ui b/ui/ramView.ui index 9e88f07..6171f04 100644 --- a/ui/ramView.ui +++ b/ui/ramView.ui @@ -19,6 +19,9 @@ + + + @@ -29,12 +32,39 @@ - - - + + + toolBar + + + TopToolBarArea + + + false + + + + + + Goto + + + Go to an address + + + Ctrl+G + + + + + QTabBar + QWidget +
qtabbar.h
+
+