all repos — mgba @ 943b805306a362a0c20bbe6d7d4ee660cc75f036

mGBA Game Boy Advance Emulator

Qt: Sync light sensor window with current state
Jeffrey Pfau jeffrey@endrift.com
Fri, 13 Mar 2015 00:07:59 -0700
commit

943b805306a362a0c20bbe6d7d4ee660cc75f036

parent

2c5d11539a2f7cd8672fc6272a63363cd36c9016

M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -489,6 +489,7 @@ m_luxLevel = i;

break; } } + emit luminanceValueChanged(m_luxValue); } void GameController::setLuminanceLevel(int level) {
M src/platform/qt/GameController.hsrc/platform/qt/GameController.h

@@ -79,6 +79,8 @@ void gameCrashed(const QString& errorMessage);

void gameFailed(); void stateLoaded(GBAThread*); + void luminanceValueChanged(int); + void postLog(int level, const QString& log); public slots:

@@ -109,6 +111,7 @@ void clearAVStream();

void reloadAudioDriver(); void setLuminanceValue(uint8_t value); + uint8_t luminanceValue() const { return m_luxValue; } void setLuminanceLevel(int level); void increaseLuminanceLevel() { setLuminanceLevel(m_luxLevel + 1); } void decreaseLuminanceLevel() { setLuminanceLevel(m_luxLevel - 1); }
M src/platform/qt/SensorView.cppsrc/platform/qt/SensorView.cpp

@@ -31,12 +31,17 @@ });

connect(m_ui.timeNow, &QPushButton::clicked, [controller, this] () { m_ui.time->setDateTime(QDateTime::currentDateTime()); }); + + connect(m_controller, SIGNAL(luminanceValueChanged(int)), this, SLOT(luminanceValueChanged(int))); } void SensorView::setLuminanceValue(int value) { - bool oldState; value = std::max(0, std::min(value, 255)); + m_controller->setLuminanceValue(value); +} +void SensorView::luminanceValueChanged(int value) { + bool oldState; oldState = m_ui.lightSpin->blockSignals(true); m_ui.lightSpin->setValue(value); m_ui.lightSpin->blockSignals(oldState);

@@ -44,6 +49,4 @@

oldState = m_ui.lightSlide->blockSignals(true); m_ui.lightSlide->setValue(value); m_ui.lightSlide->blockSignals(oldState); - - m_controller->setLuminanceValue(value); }
M src/platform/qt/SensorView.hsrc/platform/qt/SensorView.h

@@ -23,6 +23,7 @@ SensorView(GameController* controller, QWidget* parent = nullptr);

private slots: void setLuminanceValue(int); + void luminanceValueChanged(int); private: Ui::SensorView m_ui;