summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/Config/ConfigControls/ConfigRadio.cpp
blob: eba9de283c78b0fcb6ef9f6c3fe455bcf2bd729b (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
// Copyright 2018 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#include "DolphinQt/Config/ConfigControls/ConfigRadio.h"

ConfigRadioInt::ConfigRadioInt(const QString& label, const Config::Info<int>& setting, int value,
                               Config::Layer* layer)
    : ConfigControl(label, setting.GetLocation(), layer), m_setting(setting), m_value(value)
{
  setChecked(ReadValue(setting) == value);

  connect(this, &QRadioButton::toggled, this, &ConfigRadioInt::Update);
}

void ConfigRadioInt::Update()
{
  if (isChecked())
  {
    SaveValue(m_setting, m_value);

    emit OnSelected(m_value);
  }
  else
  {
    emit OnDeselected(m_value);
  }
}

void ConfigRadioInt::OnConfigChanged()
{
  setChecked(ReadValue(m_setting) == m_value);
}