#include "controlhdmiwidget.h"
#include "ui_controlhdmiwidget.h"

ControlHdmiWidget::ControlHdmiWidget(QWidget *parent,QList<LedCard *> *list) :
    QWidget(parent),
    ui(new Ui::ControlHdmiWidget)
{
    m_pLedlist=list;
    ui->setupUi(this);
    refreshLable();
    m_pStackedW = new QStackedWidget;
    m_pManual = new ControlHdmiManual(this,m_pLedlist);
    m_pSchedule = new ControlHdmiSchedule(this,m_pLedlist);
    m_pStackedW->addWidget(m_pManual);
    m_pStackedW->addWidget(m_pSchedule);
    ui->horizontalLayout_2->addWidget(m_pStackedW);
    init();
    connect(parent->parent()->parent(),SIGNAL(sigSelectedDeviceList(QList<LedCard *> *)),this,SLOT(onSelectedDeviceList(QList<LedCard *> *)));
    connect(parent->parent(),SIGNAL(sigChangeLanguage()),this,SLOT(refreshLable()));
}

ControlHdmiWidget::~ControlHdmiWidget()
{
    m_pStackedW->deleteLater()  ;
    m_pManual->deleteLater()  ;
    m_pSchedule->deleteLater()  ;
   delete ui;
}
void ControlHdmiWidget::refreshLable()
{
    ui->labelHdmiConfiguration->setText(tr("HDMI Configuration"));
    ui->radioButtonManual->setText(tr("Manual"));
    ui->radioButtonSchedule->setText(tr("Schedule"));
}

void ControlHdmiWidget::init()
{
    m_buttonGroup = new QButtonGroup;
    //第二个参数id可以自行定义
    m_buttonGroup->addButton(ui->radioButtonManual,0);
    m_buttonGroup->addButton(ui->radioButtonSchedule,1);
    connect(m_buttonGroup,SIGNAL(buttonClicked(int)),m_pStackedW,SLOT(setCurrentIndex(int)));
    ui->radioButtonManual->setChecked(true);
    m_pStackedW->setCurrentIndex(0);

}

