summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt2/Config/Mapping/MappingBool.cpp
blob: 363a41e4bab0b94a0573057bedfdcb495fa68d7b (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
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

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

#include "DolphinQt2/Config/Mapping/MappingWidget.h"
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"

MappingBool::MappingBool(MappingWidget* widget, ControllerEmu::BooleanSetting* setting)
    : QCheckBox(QString::fromStdString(setting->m_ui_name)), m_parent(widget), m_setting(setting)
{
  setChecked(setting->GetValue());
  Connect();
}

void MappingBool::Connect()
{
  connect(this, &QCheckBox::stateChanged, this, [this](int value) {
    m_setting->SetValue(value);
    Update();
  });
}

void MappingBool::Clear()
{
  setChecked(false);
  Update();
}

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