89 lines
2.8 KiB
C++
89 lines
2.8 KiB
C++
#include "controlbrightnesswidget.h"
|
|
#include "ui_controlbrightnesswidget.h"
|
|
|
|
ControlBrightnessWidget::ControlBrightnessWidget(QWidget *parent,QList<LedCard *> *list) :
|
|
QWidget(parent),
|
|
ui(new Ui::ControlBrightnessWidget)
|
|
{
|
|
m_pLedlist=list;
|
|
ui->setupUi(this);
|
|
refreshLable();
|
|
m_pStackedW = new QStackedWidget;
|
|
m_pAuto = new ControlBrightnessAutoWidget(this,m_pLedlist);
|
|
m_pManual = new ControlBrightnessManualWidget(this,m_pLedlist);
|
|
m_pSchedule = new ControlBrightnessSchedule(this,m_pLedlist);
|
|
m_pStackedW->addWidget(m_pAuto);
|
|
m_pStackedW->addWidget(m_pManual);
|
|
m_pStackedW->addWidget(m_pSchedule);
|
|
ui->horizontalLayout_2->addWidget(m_pStackedW);
|
|
init();
|
|
// connect(parent->parent(),SIGNAL(sigSelectedDeviceList(QList<LedCard *> *)),this,SLOT(onSelectedDeviceList(QList<LedCard *> *)));
|
|
connect(parent->parent(),SIGNAL(sigChangeLanguage()),this,SLOT(refreshLable()));
|
|
connect(m_pAuto,SIGNAL(sigAuto(bool)),this,SLOT(OnGetBrightnessAutoType(bool)));
|
|
connect(m_pSchedule,SIGNAL(sigHaveSchedule(bool)),this,SLOT(OnGetBrightnessModeType(bool)));
|
|
}
|
|
|
|
ControlBrightnessWidget::~ControlBrightnessWidget()
|
|
{
|
|
m_pStackedW->deleteLater() ;
|
|
m_pAuto->deleteLater() ;
|
|
m_pManual->deleteLater() ;
|
|
m_pSchedule->deleteLater() ;
|
|
delete ui;
|
|
}
|
|
void ControlBrightnessWidget::refreshLable()
|
|
{
|
|
ui->labelBrightnessConfiguration->setText(tr("Brightness Configuration"));
|
|
ui->radioButtonAuto->setText(tr("Auto"));
|
|
ui->radioButtonManual->setText(tr("Manual"));
|
|
ui->radioButtonSchedule->setText(tr("Schedule"));
|
|
|
|
}
|
|
|
|
void ControlBrightnessWidget::init()
|
|
{
|
|
m_buttonGroup = new QButtonGroup;
|
|
//第二个参数id可以自行定义
|
|
m_buttonGroup->addButton(ui->radioButtonAuto,0);
|
|
m_buttonGroup->addButton(ui->radioButtonManual,1);
|
|
m_buttonGroup->addButton(ui->radioButtonSchedule,2);
|
|
// buttonGroup->setId(ui->radioButtonAuto, 0);
|
|
// buttonGroup->setId(ui->radioButtonManual, 1);
|
|
// buttonGroup->setId(ui->radioButtonSchedule, 2);
|
|
connect(m_buttonGroup,SIGNAL(buttonClicked(int)),m_pStackedW,SLOT(setCurrentIndex(int)));
|
|
|
|
ui->radioButtonAuto->setChecked(true);
|
|
|
|
m_pStackedW->setCurrentIndex(0);
|
|
|
|
}
|
|
void ControlBrightnessWidget::OnControlTypeSwitchIndexChanged(int index)
|
|
{
|
|
Q_UNUSED(index);
|
|
}
|
|
void ControlBrightnessWidget::OnGetBrightnessAutoType(bool b)
|
|
{
|
|
m_bAutoBrightnessFlag=b;
|
|
}
|
|
|
|
void ControlBrightnessWidget::OnGetBrightnessModeType(bool b)
|
|
{
|
|
if(b)
|
|
{
|
|
m_pStackedW->setCurrentIndex(2);
|
|
ui->radioButtonSchedule->setChecked(true);
|
|
}
|
|
else {
|
|
if(m_bAutoBrightnessFlag)
|
|
{
|
|
m_pStackedW->setCurrentIndex(0);
|
|
ui->radioButtonAuto->setChecked(true);
|
|
}
|
|
else {
|
|
m_pStackedW->setCurrentIndex(1);
|
|
ui->radioButtonManual->setChecked(true);
|
|
|
|
}
|
|
}
|
|
}
|