mirror of
https://github.com/libretro/mgba.git
synced 2024-11-27 10:11:00 +00:00
Qt: Fix saving settings enabling camera when camera name changes (fixes #2125)
This commit is contained in:
parent
527c089f1f
commit
ab7cfb9634
1
CHANGES
1
CHANGES
@ -17,6 +17,7 @@ Other fixes:
|
|||||||
- Qt: Fix crash when switching from high-resolution OpenGL renderer to software
|
- Qt: Fix crash when switching from high-resolution OpenGL renderer to software
|
||||||
- Qt: Fix OpenGL renderer lagging behind when fast-forwarding (fixes mgba.io/i/2094)
|
- Qt: Fix OpenGL renderer lagging behind when fast-forwarding (fixes mgba.io/i/2094)
|
||||||
- Qt: Fix smudged window icon on Windows
|
- Qt: Fix smudged window icon on Windows
|
||||||
|
- Qt: Fix saving settings enabling camera when camera name changes (fixes mgba.io/i/2125)
|
||||||
Misc:
|
Misc:
|
||||||
- Core: Truncate preloading ROMs that slightly exceed max size (fixes mgba.io/i/2093)
|
- Core: Truncate preloading ROMs that slightly exceed max size (fixes mgba.io/i/2093)
|
||||||
- GBA: Default-enable VBA bug compat for Ruby and Emerald ROM hacks
|
- GBA: Default-enable VBA bug compat for Ruby and Emerald ROM hacks
|
||||||
|
@ -94,23 +94,23 @@ InputController::InputController(int playerId, QWidget* topLevel, QObject* paren
|
|||||||
InputControllerImage* image = static_cast<InputControllerImage*>(context);
|
InputControllerImage* image = static_cast<InputControllerImage*>(context);
|
||||||
image->w = w;
|
image->w = w;
|
||||||
image->h = h;
|
image->h = h;
|
||||||
|
image->p->m_cameraActive = true;
|
||||||
if (image->image.isNull()) {
|
if (image->image.isNull()) {
|
||||||
image->image.load(":/res/no-cam.png");
|
image->image.load(":/res/no-cam.png");
|
||||||
}
|
}
|
||||||
#ifdef BUILD_QT_MULTIMEDIA
|
#ifdef BUILD_QT_MULTIMEDIA
|
||||||
if (image->p->m_config->getQtOption("cameraDriver").toInt() == static_cast<int>(CameraDriver::QT_MULTIMEDIA)) {
|
QByteArray camera = image->p->m_config->getQtOption("camera").toByteArray();
|
||||||
QByteArray camera = image->p->m_config->getQtOption("camera").toByteArray();
|
if (!camera.isNull()) {
|
||||||
if (!camera.isNull()) {
|
image->p->m_cameraDevice = camera;
|
||||||
QMetaObject::invokeMethod(image->p, "setCamera", Q_ARG(QByteArray, camera));
|
|
||||||
}
|
|
||||||
QMetaObject::invokeMethod(image->p, "setupCam");
|
|
||||||
}
|
}
|
||||||
|
QMetaObject::invokeMethod(image->p, "setupCam");
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
m_image.stopRequestImage = [](mImageSource* context) {
|
m_image.stopRequestImage = [](mImageSource* context) {
|
||||||
InputControllerImage* image = static_cast<InputControllerImage*>(context);
|
InputControllerImage* image = static_cast<InputControllerImage*>(context);
|
||||||
#ifdef BUILD_QT_MULTIMEDIA
|
#ifdef BUILD_QT_MULTIMEDIA
|
||||||
|
image->p->m_cameraActive = false;
|
||||||
QMetaObject::invokeMethod(image->p, "teardownCam");
|
QMetaObject::invokeMethod(image->p, "teardownCam");
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@ -766,10 +766,18 @@ void InputController::setLuminanceValue(uint8_t value) {
|
|||||||
|
|
||||||
void InputController::setupCam() {
|
void InputController::setupCam() {
|
||||||
#ifdef BUILD_QT_MULTIMEDIA
|
#ifdef BUILD_QT_MULTIMEDIA
|
||||||
|
if (m_config->getQtOption("cameraDriver").toInt() != static_cast<int>(CameraDriver::QT_MULTIMEDIA)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!m_camera) {
|
if (!m_camera) {
|
||||||
m_camera = std::make_unique<QCamera>();
|
m_camera = std::make_unique<QCamera>(m_cameraDevice);
|
||||||
connect(m_camera.get(), &QCamera::statusChanged, this, &InputController::prepareCamSettings, Qt::QueuedConnection);
|
connect(m_camera.get(), &QCamera::statusChanged, this, &InputController::prepareCamSettings, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
if (m_camera->status() == QCamera::UnavailableStatus) {
|
||||||
|
m_camera.reset();
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_camera->setCaptureMode(QCamera::CaptureVideo);
|
m_camera->setCaptureMode(QCamera::CaptureVideo);
|
||||||
m_camera->setViewfinder(&m_videoDumper);
|
m_camera->setViewfinder(&m_videoDumper);
|
||||||
m_camera->load();
|
m_camera->load();
|
||||||
@ -820,20 +828,22 @@ void InputController::prepareCamSettings(QCamera::Status status) {
|
|||||||
void InputController::teardownCam() {
|
void InputController::teardownCam() {
|
||||||
#ifdef BUILD_QT_MULTIMEDIA
|
#ifdef BUILD_QT_MULTIMEDIA
|
||||||
if (m_camera) {
|
if (m_camera) {
|
||||||
m_camera->stop();
|
m_camera->unload();
|
||||||
|
m_camera.reset();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputController::setCamera(const QByteArray& name) {
|
void InputController::setCamera(const QByteArray& name) {
|
||||||
#ifdef BUILD_QT_MULTIMEDIA
|
#ifdef BUILD_QT_MULTIMEDIA
|
||||||
bool needsRestart = false;
|
if (m_cameraDevice == name) {
|
||||||
if (m_camera) {
|
return;
|
||||||
needsRestart = m_camera->state() == QCamera::ActiveState;
|
|
||||||
}
|
}
|
||||||
m_camera = std::make_unique<QCamera>(name);
|
m_cameraDevice = name;
|
||||||
connect(m_camera.get(), &QCamera::statusChanged, this, &InputController::prepareCamSettings, Qt::QueuedConnection);
|
if (m_camera && m_camera->state() == QCamera::ActiveState) {
|
||||||
if (needsRestart) {
|
teardownCam();
|
||||||
|
}
|
||||||
|
if (m_cameraActive) {
|
||||||
setupCam();
|
setupCam();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -158,6 +158,8 @@ private:
|
|||||||
} m_image;
|
} m_image;
|
||||||
|
|
||||||
#ifdef BUILD_QT_MULTIMEDIA
|
#ifdef BUILD_QT_MULTIMEDIA
|
||||||
|
bool m_cameraActive = false;
|
||||||
|
QByteArray m_cameraDevice;
|
||||||
std::unique_ptr<QCamera> m_camera;
|
std::unique_ptr<QCamera> m_camera;
|
||||||
VideoDumper m_videoDumper;
|
VideoDumper m_videoDumper;
|
||||||
#endif
|
#endif
|
||||||
|
@ -503,9 +503,12 @@ void SettingsView::updateConfig() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QVariant camera = m_ui.camera->itemData(m_ui.camera->currentIndex());
|
QVariant camera = m_ui.camera->itemData(m_ui.camera->currentIndex());
|
||||||
if (camera != m_controller->getQtOption("camera")) {
|
QVariant oldCamera = m_controller->getQtOption("camera");
|
||||||
|
if (camera != oldCamera) {
|
||||||
m_controller->setQtOption("camera", camera);
|
m_controller->setQtOption("camera", camera);
|
||||||
emit cameraChanged(camera.toByteArray());
|
if (!oldCamera.isNull()) {
|
||||||
|
emit cameraChanged(camera.toByteArray());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QLocale language = m_ui.languages->itemData(m_ui.languages->currentIndex()).toLocale();
|
QLocale language = m_ui.languages->itemData(m_ui.languages->currentIndex()).toLocale();
|
||||||
|
Loading…
Reference in New Issue
Block a user