final version
This commit is contained in:
parent
098766bb65
commit
042bae9089
8 changed files with 143 additions and 21 deletions
|
|
@ -102,6 +102,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
|
||||
// Connect menu actions
|
||||
connect(ui->actionLoad_Object_File, &QAction::triggered, this, &MainWindow::loadObjectFile);
|
||||
connect(ui->actionAbout, &QAction::triggered, this, &MainWindow::showAboutDialog);
|
||||
connect(ui->actionFrequency, &QAction::triggered, this, &MainWindow::showFrequencyDialog);
|
||||
|
||||
setupMemoryDisplay();
|
||||
setupDisassemblyDisplay();
|
||||
|
|
@ -978,3 +980,51 @@ void MainWindow::loadObjectFile()
|
|||
tr("Failed to load object file: %1").arg(e.what()));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::showAboutDialog()
|
||||
{
|
||||
QMessageBox::about(this, tr("About SIC/XE Simulator"),
|
||||
tr("SIC/XE Simulator\nby Zan Skvarca\n2025"));
|
||||
}
|
||||
|
||||
void MainWindow::showFrequencyDialog()
|
||||
{
|
||||
if (!m_machine) return;
|
||||
|
||||
QDialog dialog(this);
|
||||
dialog.setWindowTitle(tr("Set Frequency"));
|
||||
dialog.setModal(true);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(&dialog);
|
||||
|
||||
QLabel *currentLabel = new QLabel(tr("Current frequency: %1 Hz").arg(m_machine->getSpeed()), &dialog);
|
||||
layout->addWidget(currentLabel);
|
||||
|
||||
QLabel *newLabel = new QLabel(tr("New frequency (Hz):"), &dialog);
|
||||
layout->addWidget(newLabel);
|
||||
|
||||
QLineEdit *freqInput = new QLineEdit(&dialog);
|
||||
freqInput->setValidator(new QIntValidator(1, 1000000000, &dialog));
|
||||
freqInput->setText(QString::number(m_machine->getSpeed()));
|
||||
layout->addWidget(freqInput);
|
||||
|
||||
QHBoxLayout *buttonLayout = new QHBoxLayout();
|
||||
QPushButton *submitBtn = new QPushButton(tr("Submit"), &dialog);
|
||||
QPushButton *cancelBtn = new QPushButton(tr("Cancel"), &dialog);
|
||||
buttonLayout->addWidget(submitBtn);
|
||||
buttonLayout->addWidget(cancelBtn);
|
||||
layout->addLayout(buttonLayout);
|
||||
|
||||
connect(submitBtn, &QPushButton::clicked, &dialog, &QDialog::accept);
|
||||
connect(cancelBtn, &QPushButton::clicked, &dialog, &QDialog::reject);
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
bool ok;
|
||||
int newFreq = freqInput->text().toInt(&ok);
|
||||
if (ok && newFreq > 0) {
|
||||
m_machine->setSpeed(newFreq);
|
||||
QMessageBox::information(this, tr("Success"),
|
||||
tr("Frequency set to %1 Hz").arg(newFreq));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue