mirror of
				https://github.com/dolphin-emu/dolphin.git
				synced 2025-10-25 09:29:43 +00:00 
			
		
		
		
	SPDX standardizes how source code conveys its copyright and licensing information. See https://spdx.github.io/spdx-spec/1-rationale/ . SPDX tags are adopted in many large projects, including things like the Linux kernel.
		
			
				
	
	
		
			46 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| // Copyright 2019 Dolphin Emulator Project
 | |
| // SPDX-License-Identifier: GPL-2.0-or-later
 | |
| 
 | |
| #include "DolphinQt/TAS/TASCheckBox.h"
 | |
| 
 | |
| #include <QMouseEvent>
 | |
| 
 | |
| #include "Core/Movie.h"
 | |
| #include "DolphinQt/TAS/TASInputWindow.h"
 | |
| 
 | |
| TASCheckBox::TASCheckBox(const QString& text, TASInputWindow* parent)
 | |
|     : QCheckBox(text, parent), m_parent(parent)
 | |
| {
 | |
|   setTristate(true);
 | |
| }
 | |
| 
 | |
| bool TASCheckBox::GetValue() const
 | |
| {
 | |
|   if (checkState() == 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();
 | |
| }
 | |
| 
 | |
| 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();
 | |
|   setCheckState(Qt::PartiallyChecked);
 | |
| }
 |