diff --git a/Components/8272/i8272.hpp b/Components/8272/i8272.hpp index 76fc33ee3..cb589343c 100644 --- a/Components/8272/i8272.hpp +++ b/Components/8272/i8272.hpp @@ -47,7 +47,7 @@ class i8272 : public Storage::Disk::MFMController { private: // The bus handler, for interrupt and DMA-driven usage. [TODO] - BusHandler &bus_handler_; + BusHandler &bus_handler_; std::unique_ptr allocated_bus_handler_; // Status registers. diff --git a/OSBindings/Qt/ClockSignal.pro b/OSBindings/Qt/ClockSignal.pro index 93a1b9352..61ded61de 100644 --- a/OSBindings/Qt/ClockSignal.pro +++ b/OSBindings/Qt/ClockSignal.pro @@ -122,7 +122,8 @@ SOURCES += \ ../../Storage/Tape/Parsers/*.cpp \ \ main.cpp \ - mainwindow.cpp + mainwindow.cpp \ + timer.cpp HEADERS += \ ../../Activity/*.hpp \ @@ -245,7 +246,8 @@ HEADERS += \ ../../Storage/Tape/Formats/*.hpp \ ../../Storage/Tape/Parsers/*.hpp \ \ - mainwindow.h + mainwindow.h \ + timer.h FORMS += \ mainwindow.ui diff --git a/OSBindings/Qt/main.cpp b/OSBindings/Qt/main.cpp index fd3e53341..1cd93da31 100644 --- a/OSBindings/Qt/main.cpp +++ b/OSBindings/Qt/main.cpp @@ -4,8 +4,8 @@ int main(int argc, char *argv[]) { - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); + QApplication a(argc, argv); + MainWindow w; + w.show(); + return a.exec(); } diff --git a/OSBindings/Qt/mainwindow.cpp b/OSBindings/Qt/mainwindow.cpp index 41a26bdf8..5da0b48bd 100644 --- a/OSBindings/Qt/mainwindow.cpp +++ b/OSBindings/Qt/mainwindow.cpp @@ -1,15 +1,57 @@ +#include +#include + #include "mainwindow.h" #include "ui_mainwindow.h" +#include "timer.h" + +Timer *t; MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) - , ui(new Ui::MainWindow) + : QMainWindow(parent) + , ui(new Ui::MainWindow) { - ui->setupUi(this); + ui->setupUi(this); + createActions(); + + // Start the emulation timer. TODO: not now. + timer = std::make_unique(this); + QThread *thread = new QThread(this); + timer->setInterval(1); + t = new Timer; + t->moveToThread(thread); + connect(timer.get(), SIGNAL(timeout()), t, SLOT(tick())); + connect(thread, SIGNAL(finished()), t, SLOT(deleteLater())); + thread->start(); + timer->start(); } -MainWindow::~MainWindow() -{ - delete ui; +void MainWindow::createActions() { + // Create a file menu. + QMenu *fileMenu = menuBar()->addMenu(tr("&File")); + +// QAction *newAct = new QAction(tr("&New"), this); +// newAct->setShortcuts(QKeySequence::New); +// newAct->setStatusTip(tr("Create a new file")); +// connect(newAct, &QAction::triggered, this, &MainWindow::newFile); +// fileMenu->addAction(newAct); + + // Add file option: 'Open..." + QAction *openAct = new QAction(tr("&Open..."), this); + openAct->setShortcuts(QKeySequence::Open); + openAct->setStatusTip(tr("Open an existing file")); + connect(openAct, &QAction::triggered, this, &MainWindow::open); + fileMenu->addAction(openAct); + +} + +void MainWindow::open() { + QString fileName = QFileDialog::getOpenFileName(this); +// if(!fileName.isEmpty()) +// loadFile(fileName); +} + +MainWindow::~MainWindow() { + // TODO: stop thread somehow? } diff --git a/OSBindings/Qt/mainwindow.h b/OSBindings/Qt/mainwindow.h index 4643e322a..a4d8c2b5c 100644 --- a/OSBindings/Qt/mainwindow.h +++ b/OSBindings/Qt/mainwindow.h @@ -2,20 +2,27 @@ #define MAINWINDOW_H #include +#include QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE -class MainWindow : public QMainWindow -{ - Q_OBJECT +class MainWindow : public QMainWindow { + Q_OBJECT -public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); + void createActions(); -private: - Ui::MainWindow *ui; + public: + MainWindow(QWidget *parent = nullptr); + ~MainWindow(); + + private: + std::unique_ptr ui; + std::unique_ptr timer; + + private slots: + void open(); }; + #endif // MAINWINDOW_H diff --git a/OSBindings/Qt/mainwindow.ui b/OSBindings/Qt/mainwindow.ui index b232854ba..6537e2903 100644 --- a/OSBindings/Qt/mainwindow.ui +++ b/OSBindings/Qt/mainwindow.ui @@ -10,11 +10,30 @@ 600 + + + 400 + 300 + + + + true + MainWindow - - + + + + + + 0 + 0 + 800 + 22 + + + diff --git a/OSBindings/Qt/timer.cpp b/OSBindings/Qt/timer.cpp new file mode 100644 index 000000000..74984f84f --- /dev/null +++ b/OSBindings/Qt/timer.cpp @@ -0,0 +1,14 @@ +#include "timer.h" + +#include "../../ClockReceiver/TimeTypes.hpp" + +#include + +Timer::Timer(QObject *parent) : QObject(parent) {} + +void Timer::tick() { +// static int64_t last = 0; +// const auto now = Time::nanos_now(); +// qDebug() << now - last; +// last = now; +} diff --git a/OSBindings/Qt/timer.h b/OSBindings/Qt/timer.h new file mode 100644 index 000000000..c137332b6 --- /dev/null +++ b/OSBindings/Qt/timer.h @@ -0,0 +1,17 @@ +#ifndef TIMER_H +#define TIMER_H + +#include + +class Timer : public QObject +{ + Q_OBJECT + + public: + explicit Timer(QObject *parent = nullptr); + + public slots: + void tick(); +}; + +#endif // TIMER_H