
#include "regwidget.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QDebug>
RegWidget::RegWidget(QWidget * parent ):QWidget(parent)
{
    init();
    initLay();
    initConnect();

}
RegWidget::~RegWidget( )
{

}
void  RegWidget::init()
{
    //注册说明：请与我公司联系获取注册码，联系电话：0372-7775-555
    m_labRegDes.setText(tr("Registration Instructions: Please contact our company to \n"
                           "obtain the registration code, contact phone: 0372-7775-555"));
    //安装序列号
    m_labInstallSerialNum.setText(tr("serial number"));
    //安装注册码
    m_labInstallRegNum.setText(tr("registration code"));
    //使用单位
    m_labCompany.setText(tr("Company"));
    //联系电话
    m_labTelephoneNum.setText(tr("TelephoneNum"));
    //注册确认
    m_btnOk.setText(tr("Registration confirmation"));
    //试用
    m_btnCancel.setText(tr("Free Trial"));
}
void  RegWidget::initLay()
{


     QHBoxLayout * layHDes = new QHBoxLayout;
     QHBoxLayout * layHOkCancel = new QHBoxLayout;
     QGridLayout * gridlayReg = new QGridLayout;


     layHDes->addStretch();
     layHDes->addWidget(&m_labRegDes);
     layHDes->addStretch();

     layHOkCancel->addStretch();
     layHOkCancel->addWidget(&m_btnOk);
     layHOkCancel->addWidget(&m_btnCancel);
     layHOkCancel->addStretch();

     int col = 0;
     int row = 0;
     gridlayReg->addWidget(&m_labInstallSerialNum,row,col);
     gridlayReg->addWidget(&m_editInstallSerialNum,row,++col);
     row ++;
     col = 0;
     gridlayReg->addWidget(&m_labInstallRegNum,row,col);
     gridlayReg->addWidget(&m_editInstallRegNum,row,++col);
     row ++;
     col = 0;
     gridlayReg->addWidget(&m_labCompany,row,col);
     gridlayReg->addWidget(&m_editCompany,row,++col);
     row ++;
     col = 0;
     gridlayReg->addWidget(&m_labTelephoneNum,row,col);
     gridlayReg->addWidget(&m_editTelephoneNum,row,++col);

     QVBoxLayout  * vlay  =new QVBoxLayout(this);
     vlay->addStretch();
     vlay->addLayout(layHDes);
     vlay->addLayout(gridlayReg);
     vlay->addLayout(layHOkCancel);
       vlay->setContentsMargins(30,1,30,1);
       vlay->setSpacing(1);
       vlay->addStretch();
     setLayout(vlay);
}
 bool  RegWidget::initConnect()
{
    bool bCon = true;
    bCon = connect(&m_btnOk,SIGNAL(clicked(bool)),this,SLOT(slotRegOk()));
    if(!bCon)
    {
        qDebug()<<"connect failed"<<endl;
        return bCon;
    }

    bCon = connect(&m_btnCancel,SIGNAL(clicked(bool)),this,SLOT(slotTrial()));
    if(!bCon)
    {
        qDebug()<<"connect failed"<<endl;
        return bCon;
    }

    return bCon;
}
 void RegWidget::slotRegOk()
 {

 }
 void RegWidget::slotTrial()
 {

 }
