summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/Config/Mapping/MappingBool.cpp
blob: b944b976c966c6e5cd5c87fb0371dafbce085269 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include "DolphinQt/Config/Mapping/MappingBool.h"

#include "DolphinQt/Config/Mapping/MappingWidget.h"

#include "InputCommon/ControllerEmu/ControllerEmu.h"
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"

MappingBool::MappingBool(MappingWidget* widget, ControllerEmu::BooleanSetting* setting)
    : QCheckBox(tr(setting->m_ui_name.c_str())), m_parent(widget), m_setting(setting)
{
  Update();
  Connect();
}

void MappingBool::Connect()
{
  connect(this, &QCheckBox::stateChanged, this, [this](int value) {
    m_setting->SetValue(value);
    m_parent->SaveSettings();
    m_parent->GetController()->UpdateReferences(g_controller_interface);
  });
}

void MappingBool::Clear()
{
  m_setting->SetValue(false);
  m_parent->SaveSettings();
  Update();
}

void MappingBool::Update()
{
  setChecked(m_setting->GetValue());
}