Ensure cache view is resized to screen size when first shown
MODIFY
src/cachetab.cpp
src/cachetab.cpp
@@ -28,6 +28,17 @@ CacheTab::CacheTab(QToolBar* toolbar, QWidget* parent) : RipesTab(toolbar, paren
m_ui->splitter->setSizes({1, 10000});
}
+void CacheTab::tabVisibilityChanged(bool visible) {
+ /**
+ * A hack to ensure that the cache view is resized to screen size _after_ Qt has calculated widget sizes when the
+ * cache tab is first shown.
+ */
+ if (!m_initialized && visible) {
+ QTimer::singleShot(100, [&] { m_ui->cacheTabWidget->flipTabs(); });
+ m_initialized = visible;
+ }
+}
+
CacheTab::~CacheTab() {
delete m_ui;
}

MODIFY
src/cachetab.h
src/cachetab.h
@@ -16,11 +16,14 @@ public:
explicit CacheTab(QToolBar* toolbar, QWidget* parent = nullptr);
~CacheTab() override;
+ void tabVisibilityChanged(bool visible) override;
+
signals:
void focusAddressChanged(uint32_t address);
private:
Ui::CacheTab* m_ui;
+ bool m_initialized = false;
};
} // namespace Ripes

MODIFY
src/cachetabwidget.cpp
src/cachetabwidget.cpp
@@ -23,6 +23,11 @@ public:
}
};
+void CacheTabWidget::flipTabs() {
+ m_ui->tabWidget->setCurrentIndex(1);
+ m_ui->tabWidget->setCurrentIndex(0);
+}
+
CacheTabWidget::CacheTabWidget(QWidget* parent) : QWidget(parent), m_ui(new Ui::CacheTabWidget) {
m_ui->setupUi(this);

MODIFY
src/cachetabwidget.h
src/cachetabwidget.h
@@ -17,6 +17,13 @@ public:
explicit CacheTabWidget(QWidget* parent = nullptr);
~CacheTabWidget();
+ /**
+ * @brief flipTabs
+ * switches the active tabs from 0->1->0. This is a "hack" to resize the cache view to the screen size, when
+ * initially starting the application.
+ */
+ void flipTabs();
+
signals:
void focusAddressChanged(unsigned address);
void cacheFocusChanged(CacheWidget* cacheInFocus);

MODIFY
src/mainwindow.cpp
src/mainwindow.cpp
@@ -156,7 +156,7 @@ void MainWindow::tabChanged(int index) {
}
void MainWindow::fitToView() {
- static_cast<ProcessorTab*>(m_tabWidgets.at(ProcessorTabID).tab)->fitToView();
+ static_cast<ProcessorTab*>(m_tabWidgets.at(ProcessorTabID).tab)->fitToScreen();
}
void MainWindow::setupMenus() {

MODIFY
src/processortab.cpp
src/processortab.cpp
@@ -302,7 +302,7 @@ void ProcessorTab::pause() {
m_reverseAction->setEnabled(m_vsrtlWidget->isReversible());
}
-void ProcessorTab::fitToView() {
+void ProcessorTab::fitToScreen() {
m_vsrtlWidget->zoomToFit();
}
@@ -323,7 +323,7 @@ void ProcessorTab::loadProcessorToWidget(const Layout* layout) {
loadLayout(*layout);
}
updateInstructionLabels();
- fitToView();
+ fitToScreen();
}
void ProcessorTab::processorSelection() {

MODIFY
src/processortab.h
src/processortab.h
@@ -46,7 +46,7 @@ public slots:
void runFinished();
void updateStatistics();
void updateInstructionLabels();
- void fitToView();
+ void fitToScreen();
void processorSelection();

Ensure cache view is resized to screen size when first shown