dolphin/Source/Core/DolphinQt/TAS/TASCheckBox.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.1 KiB
C++
Raw Normal View History

2019-03-31 02:49:57 +00:00
// Copyright 2019 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinQt/TAS/TASCheckBox.h"
#include <QMouseEvent>
#include "Core/Movie.h"
#include "DolphinQt/TAS/TASInputWindow.h"
2019-03-31 02:49:57 +00:00
TASCheckBox::TASCheckBox(const QString& text, TASInputWindow* parent)
: QCheckBox(text, parent), m_parent(parent)
2019-03-31 02:49:57 +00:00
{
setTristate(true);
}
bool TASCheckBox::GetValue() const
2019-03-31 02:49:57 +00:00
{
if (checkState() == Qt::PartiallyChecked)
{
const u64 frames_elapsed = Movie::GetCurrentFrame() - m_frame_turbo_started;
return frames_elapsed % m_turbo_total_frames < m_turbo_press_frames;
}
2019-03-31 02:49:57 +00:00
return isChecked();
}
void TASCheckBox::mousePressEvent(QMouseEvent* event)
{
if (event->button() != Qt::RightButton)
{
setChecked(!isChecked());
return;
}
if (checkState() == Qt::PartiallyChecked)
{
setCheckState(Qt::Unchecked);
return;
}
m_frame_turbo_started = Movie::GetCurrentFrame();
m_turbo_press_frames = m_parent->GetTurboPressFrames();
m_turbo_total_frames = m_turbo_press_frames + m_parent->GetTurboReleaseFrames();
2019-03-31 02:49:57 +00:00
setCheckState(Qt::PartiallyChecked);
}