summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/TAS/TASCheckBox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Core/DolphinQt/TAS/TASCheckBox.cpp')
-rw-r--r--Source/Core/DolphinQt/TAS/TASCheckBox.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/Source/Core/DolphinQt/TAS/TASCheckBox.cpp b/Source/Core/DolphinQt/TAS/TASCheckBox.cpp
index 29a7171f47..32d1b3b0b0 100644
--- a/Source/Core/DolphinQt/TAS/TASCheckBox.cpp
+++ b/Source/Core/DolphinQt/TAS/TASCheckBox.cpp
@@ -6,23 +6,34 @@
#include <QMouseEvent>
#include "Core/Movie.h"
+#include "DolphinQt/QtUtils/QueueOnObject.h"
#include "DolphinQt/TAS/TASInputWindow.h"
TASCheckBox::TASCheckBox(const QString& text, TASInputWindow* parent)
: QCheckBox(text, parent), m_parent(parent)
{
setTristate(true);
+
+ connect(this, &TASCheckBox::stateChanged, this, &TASCheckBox::OnUIValueChanged);
}
bool TASCheckBox::GetValue() const
{
- if (checkState() == Qt::PartiallyChecked)
+ Qt::CheckState check_state = static_cast<Qt::CheckState>(m_state.GetValue());
+
+ if (check_state == Qt::PartiallyChecked)
{
const u64 frames_elapsed = Movie::GetCurrentFrame() - m_frame_turbo_started;
return static_cast<int>(frames_elapsed % m_turbo_total_frames) < m_turbo_press_frames;
}
- return isChecked();
+ return check_state != Qt::Unchecked;
+}
+
+void TASCheckBox::OnControllerValueChanged(bool new_value)
+{
+ if (m_state.OnControllerValueChanged(new_value ? Qt::Checked : Qt::Unchecked))
+ QueueOnObject(this, &TASCheckBox::ApplyControllerValueChange);
}
void TASCheckBox::mousePressEvent(QMouseEvent* event)
@@ -44,3 +55,14 @@ void TASCheckBox::mousePressEvent(QMouseEvent* event)
m_turbo_total_frames = m_turbo_press_frames + m_parent->GetTurboReleaseFrames();
setCheckState(Qt::PartiallyChecked);
}
+
+void TASCheckBox::OnUIValueChanged(int new_value)
+{
+ m_state.OnUIValueChanged(static_cast<u16>(new_value));
+}
+
+void TASCheckBox::ApplyControllerValueChange()
+{
+ const QSignalBlocker blocker(this);
+ setCheckState(static_cast<Qt::CheckState>(m_state.ApplyControllerValueChange()));
+}