From 3ff896f8f0c738a39b5dbfe745fa6e209c920609 Mon Sep 17 00:00:00 2001
From: Anonymus Raccoon
Date: Tue, 25 Feb 2020 01:43:44 +0100
Subject: [PATCH] Creating a custom dialog for the goto
---
sources/Debugger/MemoryViewer.cpp | 19 +++---
sources/Debugger/MemoryViewer.hpp | 1 +
ui/gotoDialog.ui | 100 ++++++++++++++++++++++++++++++
3 files changed, 108 insertions(+), 12 deletions(-)
create mode 100644 ui/gotoDialog.ui
diff --git a/sources/Debugger/MemoryViewer.cpp b/sources/Debugger/MemoryViewer.cpp
index 2de4523..bb4eee8 100644
--- a/sources/Debugger/MemoryViewer.cpp
+++ b/sources/Debugger/MemoryViewer.cpp
@@ -105,22 +105,17 @@ namespace ComSquare::Debugger
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();
+ QDialog dialog(this);
+ Ui::GotoDialog dialogUI;
+ dialogUI.setupUi(&dialog);
+ QFont font = dialogUI.spinBox->font();
font.setCapitalization(QFont::AllUppercase);
- spinbox->setFont(font);
+ dialogUI.spinBox->setFont(font);
+ dialogUI.spinBox->selectAll();
if (dialog.exec() != QDialog::Accepted)
return;
- long value = std::strtol(spinbox->text().toStdString().c_str(), nullptr, 16);
+ long value = std::strtol(dialogUI.spinBox->text().toStdString().c_str() + 1, 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);
diff --git a/sources/Debugger/MemoryViewer.hpp b/sources/Debugger/MemoryViewer.hpp
index 1a94a24..d7cb568 100644
--- a/sources/Debugger/MemoryViewer.hpp
+++ b/sources/Debugger/MemoryViewer.hpp
@@ -7,6 +7,7 @@
#include
#include "../../ui/ui_ramView.h"
+#include "../../ui/ui_gotoDialog.h"
#include "../Ram/Ram.hpp"
#include
diff --git a/ui/gotoDialog.ui b/ui/gotoDialog.ui
new file mode 100644
index 0000000..e5e4248
--- /dev/null
+++ b/ui/gotoDialog.ui
@@ -0,0 +1,100 @@
+
+
+ GotoDialog
+
+
+
+ 0
+ 0
+ 236
+ 103
+
+
+
+ Go to:
+
+
+
+ :/resources/Logo.png:/resources/Logo.png
+
+
+ -
+
+
+ Address
+
+
+
+ -
+
+
+ Qt::ImhDigitsOnly
+
+
+ $
+
+
+ 16777215
+
+
+ 16
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+ -
+
+
+ Absolute
+
+
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ GotoDialog
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ GotoDialog
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+