diff --git a/include/panda_qt/main_window.hpp b/include/panda_qt/main_window.hpp index 07b3a509..4e36dae5 100644 --- a/include/panda_qt/main_window.hpp +++ b/include/panda_qt/main_window.hpp @@ -5,6 +5,7 @@ #include <QMenuBar> #include <QPalette> #include <QtWidgets> +#include <atomic> #include <thread> #include "emulator.hpp" @@ -24,9 +25,11 @@ class MainWindow : public QMainWindow { Emulator* emu = nullptr; std::thread emuThread; + std::atomic<bool> appRunning = true; // Is the application itself running? + + ScreenWidget screen; QComboBox* themeSelect = nullptr; QMenuBar* menuBar = nullptr; - ScreenWidget screen; Theme currentTheme; void setTheme(Theme theme); diff --git a/src/panda_qt/main_window.cpp b/src/panda_qt/main_window.cpp index 2a73ac67..9f99a2b7 100644 --- a/src/panda_qt/main_window.cpp +++ b/src/panda_qt/main_window.cpp @@ -4,15 +4,21 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent) setWindowTitle("Alber"); // Enable drop events for loading ROMs setAcceptDrops(true); - resize(400, 240 * 2); + resize(800, 240 * 4); screen.show(); + appRunning = true; + // Set our menu bar up menuBar = new QMenuBar(this); setMenuBar(menuBar); - auto pandaMenu = menuBar->addMenu(tr("PANDA")); - auto pandaAction = pandaMenu->addAction(tr("panda...")); + auto fileMenu = menuBar->addMenu(tr("File")); + auto pandaAction = fileMenu->addAction(tr("panda...")); + + auto emulationMenu = menuBar->addMenu(tr("Emulation")); + auto helpMenu = menuBar->addMenu(tr("Help")); + auto aboutMenu = menuBar->addMenu(tr("About")); // Set up theme selection setTheme(Theme::Dark); @@ -53,7 +59,7 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent) Helpers::panic("Failed to load ROM"); } - while (true) { + while (appRunning) { emu->runFrame(); swapEmuBuffer(); } @@ -70,6 +76,9 @@ void MainWindow::swapEmuBuffer() { // Cleanup when the main window closes MainWindow::~MainWindow() { + appRunning = false; // Set our running atomic to false in order to make the emulator thread stop, and join it + emuThread.join(); + delete emu; delete menuBar; delete themeSelect; diff --git a/src/panda_qt/screen.cpp b/src/panda_qt/screen.cpp index 354a7f42..5a254e79 100644 --- a/src/panda_qt/screen.cpp +++ b/src/panda_qt/screen.cpp @@ -20,7 +20,7 @@ #ifdef PANDA3DS_ENABLE_OPENGL ScreenWidget::ScreenWidget(QWidget* parent) : QWidget(parent) { // Create a native window for use with our graphics API of choice - resize(400, 240 * 2); + resize(800, 240 * 4); setAutoFillBackground(false); setAttribute(Qt::WA_NativeWindow, true);