Disable other actions while autoclocking
MODIFY
src/processortab.cpp
src/processortab.cpp
@@ -95,7 +95,7 @@ ProcessorTab::ProcessorTab(QToolBar* controlToolbar, QToolBar* additionalToolbar
connect(ProcessorHandler::get(), &ProcessorHandler::procStateChangedNonRun, this,
&ProcessorTab::updateInstructionLabels);
connect(ProcessorHandler::get(), &ProcessorHandler::procStateChangedNonRun, this,
- [=] { m_reverseAction->setEnabled(m_vsrtlWidget->isReversible()); });
+ [=] { m_reverseAction->setEnabled(m_vsrtlWidget->isReversible() && !m_autoClockAction->isChecked()); });
setupSimulatorActions(controlToolbar);
@@ -193,34 +193,25 @@ void ProcessorTab::setupSimulatorActions(QToolBar* controlToolbar) {
m_clockAction->setToolTip("Clock the circuit (F5)");
controlToolbar->addAction(m_clockAction);
- QTimer* timer = new QTimer(this);
- connect(timer, &QTimer::timeout, this, [=] { ProcessorHandler::clock(); });
+ m_autoClockTimer = new QTimer(this);
+ connect(m_autoClockTimer, &QTimer::timeout, this, [=] { ProcessorHandler::clock(); });
const QIcon startAutoClockIcon = QIcon(":/icons/step-clock.svg");
- const QIcon stopAutoTimerIcon = QIcon(":/icons/stop-clock.svg");
m_autoClockAction = new QAction(startAutoClockIcon, "Auto clock (F6)", this);
m_autoClockAction->setShortcut(QKeySequence("F6"));
m_autoClockAction->setToolTip("Clock the circuit with the selected frequency (F6)");
m_autoClockAction->setCheckable(true);
- connect(m_autoClockAction, &QAction::toggled, this, [=](bool checked) {
- if (!checked) {
- timer->stop();
- m_autoClockAction->setIcon(startAutoClockIcon);
- } else {
- timer->start();
- m_autoClockAction->setIcon(stopAutoTimerIcon);
- }
- });
m_autoClockAction->setChecked(false);
+ connect(m_autoClockAction, &QAction::triggered, this, &ProcessorTab::autoClock);
controlToolbar->addAction(m_autoClockAction);
m_autoClockInterval = new QSpinBox(this);
m_autoClockInterval->setRange(1, 10000);
m_autoClockInterval->setSuffix(" ms");
m_autoClockInterval->setToolTip("Auto clock interval");
- connect(m_autoClockInterval, qOverload<int>(&QSpinBox::valueChanged), this, [timer](int msec) {
+ connect(m_autoClockInterval, qOverload<int>(&QSpinBox::valueChanged), this, [this](int msec) {
RipesSettings::setValue(RIPES_SETTING_AUTOCLOCK_INTERVAL, msec);
- timer->setInterval(msec);
+ m_autoClockTimer->setInterval(msec);
});
m_autoClockInterval->setValue(RipesSettings::value(RIPES_SETTING_AUTOCLOCK_INTERVAL).toInt());
controlToolbar->addWidget(m_autoClockInterval);
@@ -472,6 +463,27 @@ void ProcessorTab::runFinished() {
m_statUpdateTimer->stop();
}
+void ProcessorTab::autoClock(bool state) {
+ const QIcon startAutoClockIcon = QIcon(":/icons/step-clock.svg");
+ const QIcon stopAutoTimerIcon = QIcon(":/icons/stop-clock.svg");
+ if (!state) {
+ m_autoClockTimer->stop();
+ m_autoClockAction->setIcon(startAutoClockIcon);
+ } else {
+ m_autoClockTimer->start();
+ m_autoClockAction->setIcon(stopAutoTimerIcon);
+ }
+
+ // Enable/disable all other actions
+ m_selectProcessorAction->setEnabled(!state);
+ m_clockAction->setEnabled(!state);
+ m_reverseAction->setEnabled(!state);
+ m_resetAction->setEnabled(!state);
+ m_displayValuesAction->setEnabled(!state);
+ m_pipelineDiagramAction->setEnabled(!state);
+ m_runAction->setEnabled(!state);
+}
+
void ProcessorTab::run(bool state) {
// Stop any currently exeuting auto-clocking
if (m_autoClockAction->isChecked()) {

MODIFY
src/processortab.h
src/processortab.h
@@ -51,6 +51,7 @@ public slots:
private slots:
void run(bool state);
+ void autoClock(bool state);
void setInstructionViewCenterRow(int row);
void showPipelineDiagram();
@@ -82,6 +83,7 @@ private:
QAction* m_reverseAction = nullptr;
QAction* m_resetAction = nullptr;
QAction* m_darkmodeAction = nullptr;
+ QTimer* m_autoClockTimer = nullptr;
QSpinBox* m_autoClockInterval = nullptr;
};

Disable other actions while autoclocking