Use flow layout to reduce min. width of MemoryViewerWidget
MODIFY
src/memoryviewerwidget.cpp
src/memoryviewerwidget.cpp
#include "memoryviewerwidget.h"
#include "ui_memoryviewerwidget.h"
+#include <QHBoxLayout>
+#include <QLabel>
#include <QTableView>
+#include "flowlayout.h"
#include "gotocombobox.h"
#include "memorymodel.h"
+#include "radixselectorwidget.h"
namespace Ripes {
MemoryViewerWidget::MemoryViewerWidget(QWidget* parent) : QWidget(parent), m_ui(new Ui::MemoryViewerWidget) {
m_ui->setupUi(this);
+
+ setupNavigationWidgets();
+
updateModel();
}
@@ -17,6 +24,30 @@ MemoryViewerWidget::~MemoryViewerWidget() {
delete m_ui;
}
+void MemoryViewerWidget::setupNavigationWidgets() {
+ // Navigation widgets are placed in a flow layout to allow minimzation of the memory widget
+
+ auto* flowLayout = new FlowLayout(this);
+
+ m_radixSelector = new RadixSelectorWidget(this);
+ m_goToSection = new GoToSectionComboBox(this);
+ m_goToRegister = new GoToRegisterComboBox(this);
+
+ flowLayout->addWidget(m_radixSelector);
+
+ QHBoxLayout* layout = new QHBoxLayout();
+ layout->addWidget(new QLabel("Go to register: ", this));
+ layout->addWidget(m_goToRegister);
+ flowLayout->addItem(layout);
+
+ layout = new QHBoxLayout();
+ layout->addWidget(new QLabel("Go to section:", this));
+ layout->addWidget(m_goToSection);
+ flowLayout->addItem(layout);
+
+ m_ui->flowParentLayout->addItem(flowLayout);
+}
+
void MemoryViewerWidget::setCentralAddress(uint32_t address) {
m_memoryModel->setCentralAddress(address);
}
@@ -30,8 +61,8 @@ void MemoryViewerWidget::updateModel() {
m_memoryModel = new MemoryModel(this);
m_ui->memoryView->setModel(m_memoryModel);
- m_ui->radixSelector->setRadix(m_memoryModel->getRadix());
- connect(m_ui->radixSelector, &RadixSelectorWidget::radixChanged, m_memoryModel, &MemoryModel::setRadix);
+ m_radixSelector->setRadix(m_memoryModel->getRadix());
+ connect(m_radixSelector, &RadixSelectorWidget::radixChanged, m_memoryModel, &MemoryModel::setRadix);
// Connect scroll events on the view to modify the center address of the model
connect(m_ui->memoryView, &MemoryView::scrolled, [=](bool dir) {
@@ -47,8 +78,8 @@ void MemoryViewerWidget::updateModel() {
const auto rows = m_ui->memoryView->height() / m_ui->memoryView->rowHeight(0);
m_memoryModel->setRowsVisible(rows);
});
- connect(m_ui->goToSection, &GoToComboBox::jumpToAddress, m_memoryModel, &MemoryModel::setCentralAddress);
- connect(m_ui->goToRegister, &GoToComboBox::jumpToAddress, m_memoryModel, &MemoryModel::setCentralAddress);
+ connect(m_goToSection, &GoToComboBox::jumpToAddress, m_memoryModel, &MemoryModel::setCentralAddress);
+ connect(m_goToRegister, &GoToComboBox::jumpToAddress, m_memoryModel, &MemoryModel::setCentralAddress);
m_ui->memoryView->horizontalHeader()->setSectionResizeMode(MemoryModel::Address, QHeaderView::Stretch);

MODIFY
src/memoryviewerwidget.h
src/memoryviewerwidget.h
namespace Ripes {
+class RadixSelectorWidget;
+class GoToComboBox;
+
namespace Ui {
class MemoryViewerWidget;
}
@@ -26,6 +29,12 @@ public slots:
void setCentralAddress(uint32_t address);
private:
+ void setupNavigationWidgets();
+
Ui::MemoryViewerWidget* m_ui = nullptr;
+
+ RadixSelectorWidget* m_radixSelector = nullptr;
+ GoToComboBox* m_goToSection = nullptr;
+ GoToComboBox* m_goToRegister = nullptr;
};
} // namespace Ripes

MODIFY
src/memoryviewerwidget.ui
src/memoryviewerwidget.ui
</widget>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="RadixSelectorWidget" name="radixSelector" native="true"/>
- </item>
- <item>
- <spacer name="horizontalSpacer_2">
- <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="QLabel" name="label_2">
- <property name="text">
- <string>Go to register:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="GoToRegisterComboBox" name="goToRegister"/>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Minimum</enum>
+ <layout class="QHBoxLayout" name="flowParentLayout">
+ <property name="spacing">
+ <number>0</number>
</property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Go to section:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="GoToSectionComboBox" name="goToSection"/>
- </item>
</layout>
</item>
</layout>
</layout>
</widget>
<customwidgets>
- <customwidget>
- <class>RadixSelectorWidget</class>
- <extends>QWidget</extends>
- <header>radixselectorwidget.h</header>
- <container>1</container>
- </customwidget>
<customwidget>
<class>MemoryView</class>
<extends>QTableView</extends>
<header>memoryview.h</header>
</customwidget>
- <customwidget>
- <class>GoToSectionComboBox</class>
- <extends>QComboBox</extends>
- <header>gotocombobox.h</header>
- </customwidget>
- <customwidget>
- <class>GoToRegisterComboBox</class>
- <extends>QComboBox</extends>
- <header>gotocombobox.h</header>
- </customwidget>
</customwidgets>
<resources/>
<connections/>

Use flow layout to reduce min. width of MemoryViewerWidget