mirror of https://github.com/mgba-emu/mgba.git
Qt: Dolphin cleanup
This commit is contained in:
parent
8ad2e89cfc
commit
512bdf9c60
|
@ -5,6 +5,8 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include "DolphinConnector.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "CoreController.h"
|
||||
#include "Window.h"
|
||||
#include "utils.h"
|
||||
|
@ -43,15 +45,26 @@ void DolphinConnector::attach() {
|
|||
}
|
||||
|
||||
convertAddress(&qaddress, &address);
|
||||
CoreController::Interrupter interrupter(m_window->controller());
|
||||
m_window->controller()->attachDolphin(address);
|
||||
m_controller = m_window->controller();
|
||||
CoreController::Interrupter interrupter(m_controller);
|
||||
m_controller->attachDolphin(address);
|
||||
connect(m_controller.get(), &CoreController::stopping, this, &DolphinConnector::detach);
|
||||
|
||||
if (!m_controller->isDolphinConnected()) {
|
||||
QMessageBox* fail = new QMessageBox(QMessageBox::Warning, tr("Couldn't Connect"),
|
||||
tr("Could not connect to Dolphin."),
|
||||
QMessageBox::Ok);
|
||||
fail->setAttribute(Qt::WA_DeleteOnClose);
|
||||
fail->show();
|
||||
}
|
||||
|
||||
updateAttached();
|
||||
}
|
||||
|
||||
void DolphinConnector::detach() {
|
||||
if (m_window->controller()) {
|
||||
m_window->controller()->detachDolphin();
|
||||
if (m_controller) {
|
||||
m_controller->detachDolphin();
|
||||
m_controller.reset();
|
||||
}
|
||||
updateAttached();
|
||||
}
|
||||
|
|
|
@ -7,8 +7,11 @@
|
|||
|
||||
#include "ui_DolphinConnector.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace QGBA {
|
||||
|
||||
class CoreController;
|
||||
class Window;
|
||||
|
||||
class DolphinConnector : public QDialog {
|
||||
|
@ -27,6 +30,7 @@ private slots:
|
|||
private:
|
||||
Ui::DolphinConnector m_ui;
|
||||
|
||||
std::shared_ptr<CoreController> m_controller;
|
||||
Window* m_window;
|
||||
};
|
||||
|
||||
|
|
|
@ -499,6 +499,18 @@ std::function<void()> Window::openControllerTView(A... arg) {
|
|||
};
|
||||
}
|
||||
|
||||
template <typename T, typename... A>
|
||||
std::function<void()> Window::openNamedTView(std::unique_ptr<T>* name, A... arg) {
|
||||
return [=]() {
|
||||
if (!*name) {
|
||||
*name = std::make_unique<T>(arg...);
|
||||
connect(this, &Window::shutdown, name->get(), &QWidget::close);
|
||||
}
|
||||
(*name)->show();
|
||||
(*name)->setFocus(Qt::PopupFocusReason);
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T, typename... A>
|
||||
std::function<void()> Window::openNamedControllerTView(std::unique_ptr<T>* name, A... arg) {
|
||||
return [=]() {
|
||||
|
@ -1196,7 +1208,7 @@ void Window::setupMenu(QMenuBar* menubar) {
|
|||
}, "file");
|
||||
|
||||
#ifdef M_CORE_GBA
|
||||
Action* dolphin = m_actions.addAction(tr("Connect to Dolphin..."), "connectDolphin", openTView<DolphinConnector>(this), "file");
|
||||
Action* dolphin = m_actions.addAction(tr("Connect to Dolphin..."), "connectDolphin", openNamedTView<DolphinConnector>(&m_dolphinView, this), "file");
|
||||
m_platformActions.insert(mPLATFORM_GBA, dolphin);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ class CoreController;
|
|||
class CoreManager;
|
||||
class DebuggerConsoleController;
|
||||
class Display;
|
||||
class DolphinConnector;
|
||||
class FrameView;
|
||||
class GDBController;
|
||||
class GIFView;
|
||||
|
@ -164,6 +165,7 @@ private:
|
|||
|
||||
template <typename T, typename... A> std::function<void()> openTView(A... arg);
|
||||
template <typename T, typename... A> std::function<void()> openControllerTView(A... arg);
|
||||
template <typename T, typename... A> std::function<void()> openNamedTView(std::unique_ptr<T>*, A... arg);
|
||||
template <typename T, typename... A> std::function<void()> openNamedControllerTView(std::unique_ptr<T>*, A... arg);
|
||||
|
||||
Action* addGameAction(const QString& visibleName, const QString& name, Action::Function action, const QString& menu = {}, const QKeySequence& = {});
|
||||
|
@ -225,6 +227,7 @@ private:
|
|||
|
||||
std::unique_ptr<OverrideView> m_overrideView;
|
||||
std::unique_ptr<SensorView> m_sensorView;
|
||||
std::unique_ptr<DolphinConnector> m_dolphinView;
|
||||
FrameView* m_frameView = nullptr;
|
||||
|
||||
#ifdef USE_FFMPEG
|
||||
|
|
Loading…
Reference in New Issue