summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2015-04-17 00:35:09 +0200
committerbunnei <bunneidev@gmail.com>2015-05-02 00:26:58 +0200
commit762c1a9ff5406afc4c6b1a3eb74dae2dc2fb0daf (patch)
tree74ac7be2a6f1b3dfd09986b598844440af9e2f8f /src
parentMerge pull request #717 from linkmauve/useless-auto (diff)
downloadyuzu-762c1a9ff5406afc4c6b1a3eb74dae2dc2fb0daf.tar
yuzu-762c1a9ff5406afc4c6b1a3eb74dae2dc2fb0daf.tar.gz
yuzu-762c1a9ff5406afc4c6b1a3eb74dae2dc2fb0daf.tar.bz2
yuzu-762c1a9ff5406afc4c6b1a3eb74dae2dc2fb0daf.tar.lz
yuzu-762c1a9ff5406afc4c6b1a3eb74dae2dc2fb0daf.tar.xz
yuzu-762c1a9ff5406afc4c6b1a3eb74dae2dc2fb0daf.tar.zst
yuzu-762c1a9ff5406afc4c6b1a3eb74dae2dc2fb0daf.zip
Diffstat (limited to '')
-rw-r--r--src/citra_qt/bootmanager.cpp27
-rw-r--r--src/citra_qt/bootmanager.h14
-rw-r--r--src/citra_qt/debugger/disassembler.cpp18
-rw-r--r--src/citra_qt/debugger/disassembler.h6
-rw-r--r--src/citra_qt/main.cpp55
-rw-r--r--src/citra_qt/main.h6
6 files changed, 57 insertions, 69 deletions
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp
index b81bd6167..50c8fed1e 100644
--- a/src/citra_qt/bootmanager.cpp
+++ b/src/citra_qt/bootmanager.cpp
@@ -10,6 +10,7 @@
#include "common/common.h"
#include "bootmanager.h"
+#include "main.h"
#include "core/core.h"
#include "core/settings.h"
@@ -30,6 +31,7 @@ EmuThread::EmuThread(GRenderWindow* render_window) :
filename(""), exec_cpu_step(false), cpu_running(false),
stop_run(false), render_window(render_window)
{
+ connect(this, SIGNAL(started()), render_window, SLOT(moveContext()));
}
void EmuThread::SetFilename(std::string filename)
@@ -133,13 +135,9 @@ private:
GRenderWindow* parent;
};
-EmuThread& GRenderWindow::GetEmuThread()
-{
- return emu_thread;
-}
+GRenderWindow::GRenderWindow(QWidget* parent, GMainWindow& main_window) :
+ QWidget(parent), main_window(main_window), keyboard_id(0) {
-GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this), keyboard_id(0)
-{
std::string window_title = Common::StringFromFormat("Citra | %s-%s", Common::g_scm_branch, Common::g_scm_desc);
setWindowTitle(QString::fromStdString(window_title));
@@ -160,7 +158,6 @@ GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this
layout->addWidget(child);
layout->setMargin(0);
setLayout(layout);
- connect(&emu_thread, SIGNAL(started()), this, SLOT(moveContext()));
OnMinimalClientAreaChangeRequest(GetActiveConfig().min_client_area_size);
@@ -180,29 +177,17 @@ void GRenderWindow::moveContext()
// We need to move GL context to the swapping thread in Qt5
#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
// If the thread started running, move the GL Context to the new thread. Otherwise, move it back.
- child->context()->moveToThread((QThread::currentThread() == qApp->thread()) ? &emu_thread : qApp->thread());
+ auto thread = QThread::currentThread() == qApp->thread() ? main_window.GetEmuThread() : qApp->thread();
+ child->context()->moveToThread(thread);
#endif
}
-GRenderWindow::~GRenderWindow()
-{
- if (emu_thread.isRunning())
- emu_thread.Stop();
-}
-
void GRenderWindow::SwapBuffers()
{
// MakeCurrent is already called in renderer_opengl
child->swapBuffers();
}
-void GRenderWindow::closeEvent(QCloseEvent* event)
-{
- if (emu_thread.isRunning())
- emu_thread.Stop();
- QWidget::closeEvent(event);
-}
-
void GRenderWindow::MakeCurrent()
{
child->makeCurrent();
diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h
index 288da45a1..d3eab6ec1 100644
--- a/src/citra_qt/bootmanager.h
+++ b/src/citra_qt/bootmanager.h
@@ -14,6 +14,7 @@ class QScreen;
class QKeyEvent;
class GRenderWindow;
+class GMainWindow;
class EmuThread : public QThread
{
@@ -67,7 +68,7 @@ public slots:
void Stop();
private:
- friend class GRenderWindow;
+ friend class GMainWindow;
EmuThread(GRenderWindow* render_window);
@@ -100,10 +101,7 @@ class GRenderWindow : public QWidget, public EmuWindow
Q_OBJECT
public:
- GRenderWindow(QWidget* parent = NULL);
- ~GRenderWindow();
-
- void closeEvent(QCloseEvent*) override;
+ GRenderWindow(QWidget* parent, GMainWindow& main_window);
// EmuWindow implementation
void SwapBuffers() override;
@@ -116,8 +114,6 @@ public:
void restoreGeometry(const QByteArray& geometry); // overridden
QByteArray saveGeometry(); // overridden
- EmuThread& GetEmuThread();
-
void keyPressEvent(QKeyEvent* event) override;
void keyReleaseEvent(QKeyEvent* event) override;
@@ -139,10 +135,10 @@ private:
QGLWidget* child;
- EmuThread emu_thread;
-
QByteArray geometry;
+ GMainWindow& main_window;
+
/// Device id of keyboard for use with KeyMap
int keyboard_id;
};
diff --git a/src/citra_qt/debugger/disassembler.cpp b/src/citra_qt/debugger/disassembler.cpp
index f620687ae..b58edafe7 100644
--- a/src/citra_qt/debugger/disassembler.cpp
+++ b/src/citra_qt/debugger/disassembler.cpp
@@ -4,6 +4,7 @@
#include "disassembler.h"
+#include "../main.h"
#include "../bootmanager.h"
#include "../hotkeys.h"
@@ -158,8 +159,9 @@ void DisassemblerModel::SetNextInstruction(unsigned int address) {
emit dataChanged(prev_index, prev_index);
}
-DisassemblerWidget::DisassemblerWidget(QWidget* parent, EmuThread& emu_thread) : QDockWidget(parent), base_addr(0), emu_thread(emu_thread)
-{
+DisassemblerWidget::DisassemblerWidget(QWidget* parent, GMainWindow& main_window) :
+ QDockWidget(parent), main_window(main_window), base_addr(0) {
+
disasm_ui.setupUi(this);
model = new DisassemblerModel(this);
@@ -199,7 +201,7 @@ void DisassemblerWidget::Init()
void DisassemblerWidget::OnContinue()
{
- emu_thread.SetCpuRunning(true);
+ main_window.GetEmuThread()->SetCpuRunning(true);
}
void DisassemblerWidget::OnStep()
@@ -209,13 +211,13 @@ void DisassemblerWidget::OnStep()
void DisassemblerWidget::OnStepInto()
{
- emu_thread.SetCpuRunning(false);
- emu_thread.ExecStep();
+ main_window.GetEmuThread()->SetCpuRunning(false);
+ main_window.GetEmuThread()->ExecStep();
}
void DisassemblerWidget::OnPause()
{
- emu_thread.SetCpuRunning(false);
+ main_window.GetEmuThread()->SetCpuRunning(false);
// TODO: By now, the CPU might not have actually stopped...
if (Core::g_app_core) {
@@ -225,7 +227,7 @@ void DisassemblerWidget::OnPause()
void DisassemblerWidget::OnToggleStartStop()
{
- emu_thread.SetCpuRunning(!emu_thread.IsCpuRunning());
+ main_window.GetEmuThread()->SetCpuRunning(!main_window.GetEmuThread()->IsCpuRunning());
}
void DisassemblerWidget::OnDebugModeEntered()
@@ -233,7 +235,7 @@ void DisassemblerWidget::OnDebugModeEntered()
ARMword next_instr = Core::g_app_core->GetPC();
if (model->GetBreakPoints().IsAddressBreakPoint(next_instr))
- emu_thread.SetCpuRunning(false);
+ main_window.GetEmuThread()->SetCpuRunning(false);
model->SetNextInstruction(next_instr);
diff --git a/src/citra_qt/debugger/disassembler.h b/src/citra_qt/debugger/disassembler.h
index 5e19d7c51..d9e32dbdf 100644
--- a/src/citra_qt/debugger/disassembler.h
+++ b/src/citra_qt/debugger/disassembler.h
@@ -13,7 +13,7 @@
#include "common/break_points.h"
class QAction;
-class EmuThread;
+class GMainWindow;
class DisassemblerModel : public QAbstractListModel
{
@@ -51,7 +51,7 @@ class DisassemblerWidget : public QDockWidget
Q_OBJECT
public:
- DisassemblerWidget(QWidget* parent, EmuThread& emu_thread);
+ DisassemblerWidget(QWidget* parent, GMainWindow& main_window);
void Init();
@@ -75,5 +75,5 @@ private:
u32 base_addr;
- EmuThread& emu_thread;
+ GMainWindow& main_window;
};
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index e5ca04124..0e57d9e18 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -46,7 +46,7 @@
#include "version.h"
-GMainWindow::GMainWindow()
+GMainWindow::GMainWindow() : emu_thread(nullptr)
{
Pica::g_debug_context = Pica::DebugContext::Construct();
@@ -55,14 +55,15 @@ GMainWindow::GMainWindow()
ui.setupUi(this);
statusBar()->hide();
- render_window = new GRenderWindow;
+ render_window = new GRenderWindow(this, *this);
render_window->hide();
+ emu_thread = new EmuThread(render_window);
profilerWidget = new ProfilerWidget(this);
addDockWidget(Qt::BottomDockWidgetArea, profilerWidget);
profilerWidget->hide();
- disasmWidget = new DisassemblerWidget(this, render_window->GetEmuThread());
+ disasmWidget = new DisassemblerWidget(this, *this);
addDockWidget(Qt::BottomDockWidgetArea, disasmWidget);
disasmWidget->hide();
@@ -139,13 +140,13 @@ GMainWindow::GMainWindow()
connect(ui.action_Hotkeys, SIGNAL(triggered()), this, SLOT(OnOpenHotkeysDialog()));
// BlockingQueuedConnection is important here, it makes sure we've finished refreshing our views before the CPU continues
- connect(&render_window->GetEmuThread(), SIGNAL(DebugModeEntered()), disasmWidget, SLOT(OnDebugModeEntered()), Qt::BlockingQueuedConnection);
- connect(&render_window->GetEmuThread(), SIGNAL(DebugModeEntered()), registersWidget, SLOT(OnDebugModeEntered()), Qt::BlockingQueuedConnection);
- connect(&render_window->GetEmuThread(), SIGNAL(DebugModeEntered()), callstackWidget, SLOT(OnDebugModeEntered()), Qt::BlockingQueuedConnection);
-
- connect(&render_window->GetEmuThread(), SIGNAL(DebugModeLeft()), disasmWidget, SLOT(OnDebugModeLeft()), Qt::BlockingQueuedConnection);
- connect(&render_window->GetEmuThread(), SIGNAL(DebugModeLeft()), registersWidget, SLOT(OnDebugModeLeft()), Qt::BlockingQueuedConnection);
- connect(&render_window->GetEmuThread(), SIGNAL(DebugModeLeft()), callstackWidget, SLOT(OnDebugModeLeft()), Qt::BlockingQueuedConnection);
+ connect(emu_thread, SIGNAL(DebugModeEntered()), disasmWidget, SLOT(OnDebugModeEntered()), Qt::BlockingQueuedConnection);
+ connect(emu_thread, SIGNAL(DebugModeEntered()), registersWidget, SLOT(OnDebugModeEntered()), Qt::BlockingQueuedConnection);
+ connect(emu_thread, SIGNAL(DebugModeEntered()), callstackWidget, SLOT(OnDebugModeEntered()), Qt::BlockingQueuedConnection);
+
+ connect(emu_thread, SIGNAL(DebugModeLeft()), disasmWidget, SLOT(OnDebugModeLeft()), Qt::BlockingQueuedConnection);
+ connect(emu_thread, SIGNAL(DebugModeLeft()), registersWidget, SLOT(OnDebugModeLeft()), Qt::BlockingQueuedConnection);
+ connect(emu_thread, SIGNAL(DebugModeLeft()), callstackWidget, SLOT(OnDebugModeLeft()), Qt::BlockingQueuedConnection);
// Setup hotkeys
RegisterHotkey("Main Window", "Load File", QKeySequence::Open);
@@ -210,8 +211,8 @@ void GMainWindow::BootGame(std::string filename)
registersWidget->OnDebugModeEntered();
callstackWidget->OnDebugModeEntered();
- render_window->GetEmuThread().SetFilename(filename);
- render_window->GetEmuThread().start();
+ emu_thread->SetFilename(filename);
+ emu_thread->start();
render_window->show();
OnStartGame();
@@ -232,7 +233,7 @@ void GMainWindow::OnMenuLoadSymbolMap() {
void GMainWindow::OnStartGame()
{
- render_window->GetEmuThread().SetCpuRunning(true);
+ emu_thread->SetCpuRunning(true);
ui.action_Start->setEnabled(false);
ui.action_Pause->setEnabled(true);
@@ -241,7 +242,7 @@ void GMainWindow::OnStartGame()
void GMainWindow::OnPauseGame()
{
- render_window->GetEmuThread().SetCpuRunning(false);
+ emu_thread->SetCpuRunning(false);
ui.action_Start->setEnabled(true);
ui.action_Pause->setEnabled(false);
@@ -250,7 +251,7 @@ void GMainWindow::OnPauseGame()
void GMainWindow::OnStopGame()
{
- render_window->GetEmuThread().SetCpuRunning(false);
+ emu_thread->SetCpuRunning(false);
// TODO: Shutdown core
ui.action_Start->setEnabled(true);
@@ -265,24 +266,22 @@ void GMainWindow::OnOpenHotkeysDialog()
}
-void GMainWindow::ToggleWindowMode()
-{
- bool enable = ui.action_Single_Window_Mode->isChecked();
- if (!enable && render_window->parent() != nullptr)
- {
- ui.horizontalLayout->removeWidget(render_window);
- render_window->setParent(nullptr);
- render_window->setVisible(true);
- render_window->RestoreGeometry();
- render_window->setFocusPolicy(Qt::NoFocus);
- }
- else if (enable && render_window->parent() == nullptr)
- {
+void GMainWindow::ToggleWindowMode() {
+ if (ui.action_Single_Window_Mode->isChecked()) {
+ // Render in the main window...
render_window->BackupGeometry();
ui.horizontalLayout->addWidget(render_window);
render_window->setVisible(true);
render_window->setFocusPolicy(Qt::ClickFocus);
render_window->setFocus();
+
+ } else {
+ // Render in a separate window...
+ ui.horizontalLayout->removeWidget(render_window);
+ render_window->setParent(nullptr);
+ render_window->setVisible(true);
+ render_window->RestoreGeometry();
+ render_window->setFocusPolicy(Qt::NoFocus);
}
}
diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h
index 9b57c5772..5b33ea962 100644
--- a/src/citra_qt/main.h
+++ b/src/citra_qt/main.h
@@ -11,6 +11,7 @@
class GImageInfo;
class GRenderWindow;
+class EmuThread;
class ProfilerWidget;
class DisassemblerWidget;
class RegistersWidget;
@@ -34,6 +35,10 @@ public:
GMainWindow();
~GMainWindow();
+ EmuThread* GetEmuThread() {
+ return emu_thread;
+ }
+
private:
void BootGame(std::string filename);
@@ -54,6 +59,7 @@ private:
Ui::MainWindow ui;
GRenderWindow* render_window;
+ EmuThread* emu_thread;
ProfilerWidget* profilerWidget;
DisassemblerWidget* disasmWidget;