Qt: Revamp memory view layout

This commit is contained in:
Vicki Pfau 2025-01-11 19:47:21 -08:00
parent 87bf982338
commit 511437312c
2 changed files with 221 additions and 270 deletions

View File

@ -133,20 +133,10 @@ MemoryView::MemoryView(std::shared_ptr<CoreController> controller, QWidget* pare
}
}
connect(m_ui.width8, &QAbstractButton::clicked, [this]() {
m_ui.hexfield->setAlignment(1);
m_sintValidator.setWidth(1);
m_uintValidator.setWidth(1);
});
connect(m_ui.width16, &QAbstractButton::clicked, [this]() {
m_ui.hexfield->setAlignment(2);
m_sintValidator.setWidth(2);
m_uintValidator.setWidth(2);
});
connect(m_ui.width32, &QAbstractButton::clicked, [this]() {
m_ui.hexfield->setAlignment(4);
m_sintValidator.setWidth(4);
m_uintValidator.setWidth(4);
connect(m_ui.width, &QComboBox::currentIndexChanged, [this](int index) {
m_ui.hexfield->setAlignment(1 << index);
m_sintValidator.setWidth(1 << index);
m_uintValidator.setWidth(1 << index);
});
connect(m_ui.setAddress, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
this, static_cast<void (MemoryView::*)(uint32_t)>(&MemoryView::jumpToAddress));
@ -258,7 +248,7 @@ void MemoryView::updateStatus() {
mCore* core = m_controller->thread()->core;
QByteArray selection(m_ui.hexfield->serialize());
QString text(m_ui.hexfield->decodeText(selection));
m_ui.stringVal->setText(text);
m_ui.stringVal->setPlainText(text);
if (m_selection.first & (align - 1) || m_selection.second - m_selection.first != align) {
m_ui.sintVal->clear();

View File

@ -6,167 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>874</width>
<height>900</height>
<width>708</width>
<height>549</height>
</rect>
</property>
<property name="windowTitle">
<string>Memory</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="regions"/>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Inspect Address:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="segments">
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>0</number>
</property>
<property name="displayIntegerBase">
<number>16</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="segmentColon">
<property name="text">
<string notr="true">:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="setAddress">
<property name="accelerated">
<bool>true</bool>
</property>
<property name="prefix">
<string notr="true">0x</string>
</property>
<property name="maximum">
<number>268435455</number>
</property>
<property name="singleStep">
<number>16</number>
</property>
<property name="displayIntegerBase">
<number>16</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Set Alignment:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QRadioButton" name="width8">
<property name="text">
<string>&amp;1 Byte</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QRadioButton" name="width16">
<property name="text">
<string>&amp;2 Bytes</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QRadioButton" name="width32">
<property name="text">
<string>&amp;4 Bytes</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<layout class="QHBoxLayout" name="horizontalLayout_7" stretch="1,0">
<item>
<widget class="QGBA::MemoryModel" name="hexfield" native="true">
<property name="sizePolicy">
@ -175,72 +22,255 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QComboBox" name="regions"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="label">
<property name="text">
<string>Unsigned Integer:</string>
<string>Address:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="uintVal">
<property name="maxLength">
<number>10</number>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="readOnly">
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="segments">
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>0</number>
</property>
<property name="displayIntegerBase">
<number>16</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="segmentColon">
<property name="text">
<string notr="true">:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="setAddress">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="accelerated">
<bool>true</bool>
</property>
<property name="prefix">
<string notr="true">0x</string>
</property>
<property name="maximum">
<number>268435455</number>
</property>
<property name="singleStep">
<number>16</number>
</property>
<property name="displayIntegerBase">
<number>16</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Signed Integer:</string>
<string>Alignment:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="sintVal">
<property name="maxLength">
<number>11</number>
</property>
<property name="readOnly">
<bool>true</bool>
<widget class="QComboBox" name="width">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>1 Byte</string>
</property>
</item>
<item>
<property name="text">
<string>2 Bytes</string>
</property>
</item>
<item>
<property name="text">
<string>4 Bytes</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_5">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Signed:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="sintVal">
<property name="maxLength">
<number>11</number>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string notr="true"/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Unsigned:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="uintVal">
<property name="maxLength">
<number>10</number>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string notr="true"/>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>String:</string>
</property>
</widget>
</item>
<item row="2" column="1" alignment="Qt::AlignRight">
<widget class="QPushButton" name="loadTBL">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Load TBL</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QPlainTextEdit" name="stringVal">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="plainText">
<string notr="true"/>
</property>
<property name="placeholderText">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="copy">
<property name="text">
<string>String:</string>
<string>Copy Selection</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="stringVal">
<property name="readOnly">
<bool>true</bool>
<item row="0" column="1">
<widget class="QPushButton" name="save">
<property name="text">
<string>Save Selection</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="loadTBL">
<item row="1" column="0">
<widget class="QPushButton" name="paste">
<property name="text">
<string>Load TBL</string>
<string>Paste</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="saveRange">
<property name="text">
<string>Save Range</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QPushButton" name="load">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Load</string>
</property>
</widget>
</item>
@ -248,58 +278,6 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPushButton" name="copy">
<property name="text">
<string>Copy Selection</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="paste">
<property name="text">
<string>Paste</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="save">
<property name="text">
<string>Save Selection</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="saveRange">
<property name="text">
<string>Save Range</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="load">
<property name="text">
<string>Load</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
@ -310,23 +288,6 @@
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>regions</tabstop>
<tabstop>segments</tabstop>
<tabstop>setAddress</tabstop>
<tabstop>width8</tabstop>
<tabstop>width16</tabstop>
<tabstop>width32</tabstop>
<tabstop>sintVal</tabstop>
<tabstop>uintVal</tabstop>
<tabstop>stringVal</tabstop>
<tabstop>loadTBL</tabstop>
<tabstop>copy</tabstop>
<tabstop>paste</tabstop>
<tabstop>save</tabstop>
<tabstop>saveRange</tabstop>
<tabstop>load</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>