Resize peripheral view to peripheral size when changing periph. parameters
MODIFY
src/io/iobase.cpp
src/io/iobase.cpp
@@ -24,10 +24,10 @@ QString IOBase::name() const {
}
bool IOBase::setParameter(unsigned ID, const QVariant& value) {
- const auto preSize = size();
+ const auto preSize = byteSize();
m_parameters.at(ID).value = value;
parameterChanged(ID);
- const auto postSize = size();
+ const auto postSize = byteSize();
if (preSize != postSize) {
emit sizeChanged();
}

MODIFY
src/io/iodpad.cpp
src/io/iodpad.cpp
@@ -47,7 +47,7 @@ IODPad::IODPad(QWidget* parent) : IOBase(IOType::DPAD, parent) {
setLayout(gridLayout);
}
-uint32_t IODPad::size() const {
+uint32_t IODPad::byteSize() const {
return 4 * 4;
}

MODIFY
src/io/iodpad.h
src/io/iodpad.h
@@ -19,7 +19,7 @@ public:
IODPad(QWidget* parent);
~IODPad() { unregister(); };
- virtual uint32_t size() const override;
+ virtual uint32_t byteSize() const override;
virtual QString description() const override;
virtual QString baseName() const override { return "D-Pad"; };

MODIFY
src/io/ioledmatrix.cpp
src/io/ioledmatrix.cpp
@@ -21,7 +21,7 @@ IOLedMatrix::IOLedMatrix(QWidget* parent) : IOBase(IOType::LED_MATRIX, parent) {
updateLEDRegs();
}
-uint32_t IOLedMatrix::size() const {
+uint32_t IOLedMatrix::byteSize() const {
const int width = m_parameters.at(WIDTH).value.toInt();
const int height = m_parameters.at(HEIGHT).value.toInt();
const int nLEDs = width * height;
@@ -79,7 +79,6 @@ void IOLedMatrix::updateLEDRegs() {
}
updateGeometry();
- resize(minimumSize());
emit regMapChanged();
}

MODIFY
src/io/ioledmatrix.h
src/io/ioledmatrix.h
@@ -17,7 +17,7 @@ public:
IOLedMatrix(QWidget* parent);
~IOLedMatrix() { unregister(); };
- virtual uint32_t size() const override;
+ virtual uint32_t byteSize() const override;
virtual QString description() const override;
virtual QString baseName() const override { return "LED Matrix"; }

MODIFY
src/io/iomanager.cpp
src/io/iomanager.cpp
@@ -44,7 +44,7 @@ uint32_t IOManager::nextPeripheralAddress() const {
uint32_t IOManager::assignBaseAddress(IOBase* peripheral) {
unregisterPeripheralWithProcessor(peripheral);
const uint32_t base = nextPeripheralAddress();
- m_periphMMappings[peripheral] = {base, peripheral->size(), peripheral->name()};
+ m_periphMMappings[peripheral] = {base, peripheral->byteSize(), peripheral->name()};
registerPeripheralWithProcessor(peripheral);
return base;
}
@@ -67,7 +67,7 @@ void IOManager::peripheralSizeChanged(IOBase* peripheral) {
void IOManager::registerPeripheralWithProcessor(IOBase* peripheral) {
ProcessorHandler::get()->getMemory().addRegion(
- m_periphMMappings.at(peripheral).startAddr, peripheral->size(),
+ m_periphMMappings.at(peripheral).startAddr, peripheral->byteSize(),
vsrtl::core::IOFunctors{
[peripheral](uint32_t offset, uint32_t value, uint32_t size) { peripheral->ioWrite(offset, value, size); },
[peripheral](uint32_t offset, uint32_t size) { return peripheral->ioRead(offset, size); }});

MODIFY
src/io/ioswitches.cpp
src/io/ioswitches.cpp
@@ -188,7 +188,7 @@ void IOSwitches::updateSwitches() {
// this component.
m_regDescs = {RegDesc{"Switches", RegDesc::RW::R, nSwitches, 0, false}};
updateGeometry();
- resize(minimumSize());
+
emit regMapChanged();
}

MODIFY
src/io/ioswitches.h
src/io/ioswitches.h
@@ -63,7 +63,7 @@ public:
IOSwitches(QWidget* parent);
~IOSwitches() { unregister(); };
- virtual uint32_t size() const override { return 4; }
+ virtual uint32_t byteSize() const override { return 4; }
virtual QString description() const override;
virtual QString baseName() const override { return "Switches"; };

MODIFY
src/iotab.cpp
src/iotab.cpp
@@ -94,6 +94,18 @@ IOBase* IOTab::createPeripheral(IOType type, int forcedID) {
mdiw->setWindowTitle(peripheral->name());
peripheral->setFocus();
+ /* The following ensures that the MDI window which a peripheral is contained within is resized when the widget
+ * itself is resized. It seems a bit cumbersome, but this was the only way i wound to trigger both the QMainWindow
+ * and the outer MDIWindow to register that its child widget has changed in size, and adjust itself accordingly.
+ */
+ connect(peripheral, &IOBase::paramsChanged, [=] {
+ // Ensure that a peripheral resize event, as a result of a parameter being changed, as been processed, so that
+ // its new size has taken effect.
+ QApplication::processEvents();
+ mw->resize(mw->minimumSizeHint());
+ mdiw->resize(mdiw->minimumSizeHint());
+ });
+
m_subWindows[peripheralTab] = mdiw;
return peripheral;
}

Resize peripheral view to peripheral size when changing periph. parameters