From 0c9f3744f0129a95e60bb886073b65144ba31a22 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Wed, 20 Jul 2011 19:52:10 +0000 Subject: [PATCH] Added auto-pause when going into/out of the file selector. --- src/gui/filepicker.cpp | 3 +++ src/gui/filepicker.h | 1 + src/gui/mainwin.cpp | 23 +++++++++++++++++++++-- src/gui/mainwin.h | 2 ++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/gui/filepicker.cpp b/src/gui/filepicker.cpp index a1694de..f6b546d 100644 --- a/src/gui/filepicker.cpp +++ b/src/gui/filepicker.cpp @@ -209,7 +209,10 @@ New sizes: 373x172 (label), 420x340 (cart) void FilePickerWindow::keyPressEvent(QKeyEvent * e) { if (e->key() == Qt::Key_Escape) + { hide(); + emit(FilePickerHiding()); + } else if (e->key() == Qt::Key_Return) LoadButtonPressed(); } diff --git a/src/gui/filepicker.h b/src/gui/filepicker.h index 8003aa8..e2f379f 100644 --- a/src/gui/filepicker.h +++ b/src/gui/filepicker.h @@ -31,6 +31,7 @@ class FilePickerWindow: public QWidget signals: void RequestLoad(QString); + void FilePickerHiding(void); protected: void keyPressEvent(QKeyEvent *); diff --git a/src/gui/mainwin.cpp b/src/gui/mainwin.cpp index 07f82d9..3cebc8a 100644 --- a/src/gui/mainwin.cpp +++ b/src/gui/mainwin.cpp @@ -79,7 +79,8 @@ // use, we can drop it in anywhere and use it as-is. MainWin::MainWin(): running(false), powerButtonOn(false), showUntunedTankCircuit(true), - cartridgeLoaded(false), CDActive(false)//, alpineLoadSuccessful(false) + cartridgeLoaded(false), CDActive(false),//, alpineLoadSuccessful(false), + pauseForFileSelector(false) { videoWidget = new GLWidget(this); setCentralWidget(videoWidget); @@ -178,6 +179,7 @@ MainWin::MainWin(): running(false), powerButtonOn(false), showUntunedTankCircuit // Misc. connections... connect(filePickWin, SIGNAL(RequestLoad(QString)), this, SLOT(LoadSoftware(QString))); + connect(filePickWin, SIGNAL(FilePickerHiding()), this, SLOT(Unpause())); // Create menus & toolbars @@ -534,12 +536,29 @@ void MainWin::ShowAboutWin(void) void MainWin::InsertCart(void) { + if (running) + { + ToggleRunState(); + pauseForFileSelector = true; + } + filePickWin->show(); } +void MainWin::Unpause(void) +{ + // Here we unpause the emulator if it was paused when we went into the file selector + if (pauseForFileSelector) + { + pauseForFileSelector = false; + ToggleRunState(); + } +} + void MainWin::LoadSoftware(QString file) { - running = false; // Prevent bad things(TM) from happening... + running = false; // Prevent bad things(TM) from happening... + pauseForFileSelector = false; // Reset the file selector pause flag SET32(jaguarMainRAM, 0, 0x00200000); // Set top of stack... cartridgeLoaded = (JaguarLoadFile(file.toAscii().data()) ? true : false); diff --git a/src/gui/mainwin.h b/src/gui/mainwin.h index fa1e976..e53515a 100644 --- a/src/gui/mainwin.h +++ b/src/gui/mainwin.h @@ -43,6 +43,7 @@ class MainWin: public QMainWindow void ToggleBlur(void); void ShowAboutWin(void); void InsertCart(void); + void Unpause(void); void LoadSoftware(QString); void ToggleCDUsage(void); @@ -65,6 +66,7 @@ class MainWin: public QMainWindow bool allowUnknownSoftware; bool CDActive; // bool alpineLoadSuccessful; + bool pauseForFileSelector; QMenu * fileMenu; QMenu * helpMenu; -- 2.37.2