Qt: Sync light sensor window with current state
Jeffrey Pfau jeffrey@endrift.com
Fri, 13 Mar 2015 00:07:59 -0700
4 files changed,
11 insertions(+),
3 deletions(-)
M
src/platform/qt/GameController.cpp
→
src/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.h
→
src/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.cpp
→
src/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.h
→
src/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;